teodor-new-chat-ui 4.0.13 → 4.0.15

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/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(Ce,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom"],y):(Ce=typeof globalThis<"u"?globalThis:Ce||self,y(Ce.NewChatUI={},Ce.React,Ce.LucideReact,Ce.reactSlot,Ce.classVarianceAuthority,Ce.clsx,Ce.tailwindMerge,Ce.ReactDOM))})(this,function(Ce,y,ne,Cn,Kr,wp,bp,Is){"use strict";var gC=Object.defineProperty;var xC=(Ce,y,ne)=>y in Ce?gC(Ce,y,{enumerable:!0,configurable:!0,writable:!0,value:ne}):Ce[y]=ne;var xp=(Ce,y,ne)=>xC(Ce,typeof y!="symbol"?y+"":y,ne);var Ns=typeof document<"u"?document.currentScript:null;function Da(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const p=Da(y),qr=Da(Is);var As={exports:{}},lr={};/**
1
+ (function(Te,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom"],y):(Te=typeof globalThis<"u"?globalThis:Te||self,y(Te.NewChatUI={},Te.React,Te.LucideReact,Te.reactSlot,Te.classVarianceAuthority,Te.clsx,Te.tailwindMerge,Te.ReactDOM))})(this,function(Te,y,te,Cn,Kr,bp,yp,Is){"use strict";var xC=Object.defineProperty;var vC=(Te,y,te)=>y in Te?xC(Te,y,{enumerable:!0,configurable:!0,writable:!0,value:te}):Te[y]=te;var vp=(Te,y,te)=>vC(Te,typeof y!="symbol"?y+"":y,te);var Ns=typeof document<"u"?document.currentScript:null;function Da(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const p=Da(y),qr=Da(Is);var As={exports:{}},lr={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var La;function yp(){if(La)return lr;La=1;var e=y,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,c,u){var d,f={},h=null,m=null;u!==void 0&&(h=""+u),c.key!==void 0&&(h=""+c.key),c.ref!==void 0&&(m=c.ref);for(d in c)r.call(c,d)&&!s.hasOwnProperty(d)&&(f[d]=c[d]);if(a&&a.defaultProps)for(d in c=a.defaultProps,c)f[d]===void 0&&(f[d]=c[d]);return{$$typeof:t,type:a,key:h,ref:m,props:f,_owner:o.current}}return lr.Fragment=n,lr.jsx=i,lr.jsxs=i,lr}var cr={};/**
9
+ */var La;function Sp(){if(La)return lr;La=1;var e=y,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,c,u){var d,f={},h=null,m=null;u!==void 0&&(h=""+u),c.key!==void 0&&(h=""+c.key),c.ref!==void 0&&(m=c.ref);for(d in c)r.call(c,d)&&!s.hasOwnProperty(d)&&(f[d]=c[d]);if(a&&a.defaultProps)for(d in c=a.defaultProps,c)f[d]===void 0&&(f[d]=c[d]);return{$$typeof:t,type:a,key:h,ref:m,props:f,_owner:o.current}}return lr.Fragment=n,lr.jsx=i,lr.jsxs=i,lr}var cr={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,41 +14,41 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var $a;function Sp(){return $a||($a=1,process.env.NODE_ENV!=="production"&&function(){var e=y,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),m=Symbol.for("react.offscreen"),w=Symbol.iterator,v="@@iterator";function g(E){if(E===null||typeof E!="object")return null;var V=w&&E[w]||E[v];return typeof V=="function"?V:null}var x=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(E){{for(var V=arguments.length,re=new Array(V>1?V-1:0),Se=1;Se<V;Se++)re[Se-1]=arguments[Se];S("error",E,re)}}function S(E,V,re){{var Se=x.ReactDebugCurrentFrame,Ue=Se.getStackAddendum();Ue!==""&&(V+="%s",re=re.concat([Ue]));var Ke=re.map(function(De){return String(De)});Ke.unshift("Warning: "+V),Function.prototype.apply.call(console[E],console,Ke)}}var k=!1,C=!1,T=!1,I=!1,N=!1,_;_=Symbol.for("react.module.reference");function j(E){return!!(typeof E=="string"||typeof E=="function"||E===r||E===s||N||E===o||E===u||E===d||I||E===m||k||C||T||typeof E=="object"&&E!==null&&(E.$$typeof===h||E.$$typeof===f||E.$$typeof===i||E.$$typeof===a||E.$$typeof===c||E.$$typeof===_||E.getModuleId!==void 0))}function R(E,V,re){var Se=E.displayName;if(Se)return Se;var Ue=V.displayName||V.name||"";return Ue!==""?re+"("+Ue+")":re}function z(E){return E.displayName||"Context"}function H(E){if(E==null)return null;if(typeof E.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof E=="function")return E.displayName||E.name||null;if(typeof E=="string")return E;switch(E){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case u:return"Suspense";case d:return"SuspenseList"}if(typeof E=="object")switch(E.$$typeof){case a:var V=E;return z(V)+".Consumer";case i:var re=E;return z(re._context)+".Provider";case c:return R(E,E.render,"ForwardRef");case f:var Se=E.displayName||null;return Se!==null?Se:H(E.type)||"Memo";case h:{var Ue=E,Ke=Ue._payload,De=Ue._init;try{return H(De(Ke))}catch{return null}}}return null}var O=Object.assign,W=0,K,G,$,A,D,U,J;function Q(){}Q.__reactDisabledLog=!0;function ce(){{if(W===0){K=console.log,G=console.info,$=console.warn,A=console.error,D=console.group,U=console.groupCollapsed,J=console.groupEnd;var E={configurable:!0,enumerable:!0,value:Q,writable:!0};Object.defineProperties(console,{info:E,log:E,warn:E,error:E,group:E,groupCollapsed:E,groupEnd:E})}W++}}function we(){{if(W--,W===0){var E={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:O({},E,{value:K}),info:O({},E,{value:G}),warn:O({},E,{value:$}),error:O({},E,{value:A}),group:O({},E,{value:D}),groupCollapsed:O({},E,{value:U}),groupEnd:O({},E,{value:J})})}W<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ke=x.ReactCurrentDispatcher,q;function M(E,V,re){{if(q===void 0)try{throw Error()}catch(Ue){var Se=Ue.stack.trim().match(/\n( *(at )?)/);q=Se&&Se[1]||""}return`
18
- `+q+E}}var X=!1,ee;{var L=typeof WeakMap=="function"?WeakMap:Map;ee=new L}function F(E,V){if(!E||X)return"";{var re=ee.get(E);if(re!==void 0)return re}var Se;X=!0;var Ue=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Ke;Ke=ke.current,ke.current=null,ce();try{if(V){var De=function(){throw Error()};if(Object.defineProperty(De.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(De,[])}catch(yt){Se=yt}Reflect.construct(E,[],De)}else{try{De.call()}catch(yt){Se=yt}E.call(De.prototype)}}else{try{throw Error()}catch(yt){Se=yt}E()}}catch(yt){if(yt&&Se&&typeof yt.stack=="string"){for(var Pe=yt.stack.split(`
19
- `),xt=Se.stack.split(`
20
- `),rt=Pe.length-1,st=xt.length-1;rt>=1&&st>=0&&Pe[rt]!==xt[st];)st--;for(;rt>=1&&st>=0;rt--,st--)if(Pe[rt]!==xt[st]){if(rt!==1||st!==1)do if(rt--,st--,st<0||Pe[rt]!==xt[st]){var Lt=`
21
- `+Pe[rt].replace(" at new "," at ");return E.displayName&&Lt.includes("<anonymous>")&&(Lt=Lt.replace("<anonymous>",E.displayName)),typeof E=="function"&&ee.set(E,Lt),Lt}while(rt>=1&&st>=0);break}}}finally{X=!1,ke.current=Ke,we(),Error.prepareStackTrace=Ue}var ar=E?E.displayName||E.name:"",Hn=ar?M(ar):"";return typeof E=="function"&&ee.set(E,Hn),Hn}function me(E,V,re){return F(E,!1)}function Re(E){var V=E.prototype;return!!(V&&V.isReactComponent)}function xe(E,V,re){if(E==null)return"";if(typeof E=="function")return F(E,Re(E));if(typeof E=="string")return M(E);switch(E){case u:return M("Suspense");case d:return M("SuspenseList")}if(typeof E=="object")switch(E.$$typeof){case c:return me(E.render);case f:return xe(E.type,V,re);case h:{var Se=E,Ue=Se._payload,Ke=Se._init;try{return xe(Ke(Ue),V,re)}catch{}}}return""}var _e=Object.prototype.hasOwnProperty,Be={},qe=x.ReactDebugCurrentFrame;function $e(E){if(E){var V=E._owner,re=xe(E.type,E._source,V?V.type:null);qe.setExtraStackFrame(re)}else qe.setExtraStackFrame(null)}function nt(E,V,re,Se,Ue){{var Ke=Function.call.bind(_e);for(var De in E)if(Ke(E,De)){var Pe=void 0;try{if(typeof E[De]!="function"){var xt=Error((Se||"React class")+": "+re+" type `"+De+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof E[De]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw xt.name="Invariant Violation",xt}Pe=E[De](V,De,Se,re,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(rt){Pe=rt}Pe&&!(Pe instanceof Error)&&($e(Ue),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Se||"React class",re,De,typeof Pe),$e(null)),Pe instanceof Error&&!(Pe.message in Be)&&(Be[Pe.message]=!0,$e(Ue),b("Failed %s type: %s",re,Pe.message),$e(null))}}}var at=Array.isArray;function ie(E){return at(E)}function te(E){{var V=typeof Symbol=="function"&&Symbol.toStringTag,re=V&&E[Symbol.toStringTag]||E.constructor.name||"Object";return re}}function pe(E){try{return de(E),!1}catch{return!0}}function de(E){return""+E}function Ne(E){if(pe(E))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",te(E)),de(E)}var Fe=x.ReactCurrentOwner,Xe={key:!0,ref:!0,__self:!0,__source:!0},Ze,lt;function Dt(E){if(_e.call(E,"ref")){var V=Object.getOwnPropertyDescriptor(E,"ref").get;if(V&&V.isReactWarning)return!1}return E.ref!==void 0}function ir(E){if(_e.call(E,"key")){var V=Object.getOwnPropertyDescriptor(E,"key").get;if(V&&V.isReactWarning)return!1}return E.key!==void 0}function _a(E,V){typeof E.ref=="string"&&Fe.current}function ja(E,V){{var re=function(){Ze||(Ze=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",V))};re.isReactWarning=!0,Object.defineProperty(E,"key",{get:re,configurable:!0})}}function ys(E,V){{var re=function(){lt||(lt=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",V))};re.isReactWarning=!0,Object.defineProperty(E,"ref",{get:re,configurable:!0})}}var Br=function(E,V,re,Se,Ue,Ke,De){var Pe={$$typeof:t,type:E,key:V,ref:re,props:De,_owner:Ke};return Pe._store={},Object.defineProperty(Pe._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Pe,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Se}),Object.defineProperty(Pe,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Ue}),Object.freeze&&(Object.freeze(Pe.props),Object.freeze(Pe)),Pe};function Ra(E,V,re,Se,Ue){{var Ke,De={},Pe=null,xt=null;re!==void 0&&(Ne(re),Pe=""+re),ir(V)&&(Ne(V.key),Pe=""+V.key),Dt(V)&&(xt=V.ref,_a(V,Ue));for(Ke in V)_e.call(V,Ke)&&!Xe.hasOwnProperty(Ke)&&(De[Ke]=V[Ke]);if(E&&E.defaultProps){var rt=E.defaultProps;for(Ke in rt)De[Ke]===void 0&&(De[Ke]=rt[Ke])}if(Pe||xt){var st=typeof E=="function"?E.displayName||E.name||"Unknown":E;Pe&&ja(De,st),xt&&ys(De,st)}return Br(E,Pe,xt,Ue,Se,Fe.current,De)}}var Hr=x.ReactCurrentOwner,Ss=x.ReactDebugCurrentFrame;function Sn(E){if(E){var V=E._owner,re=xe(E.type,E._source,V?V.type:null);Ss.setExtraStackFrame(re)}else Ss.setExtraStackFrame(null)}var Ur;Ur=!1;function Wr(E){return typeof E=="object"&&E!==null&&E.$$typeof===t}function Cs(){{if(Hr.current){var E=H(Hr.current.type);if(E)return`
17
+ */var $a;function Cp(){return $a||($a=1,process.env.NODE_ENV!=="production"&&function(){var e=y,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),m=Symbol.for("react.offscreen"),w=Symbol.iterator,v="@@iterator";function g(E){if(E===null||typeof E!="object")return null;var U=w&&E[w]||E[v];return typeof U=="function"?U:null}var x=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(E){{for(var U=arguments.length,ne=new Array(U>1?U-1:0),Ce=1;Ce<U;Ce++)ne[Ce-1]=arguments[Ce];S("error",E,ne)}}function S(E,U,ne){{var Ce=x.ReactDebugCurrentFrame,Ue=Ce.getStackAddendum();Ue!==""&&(U+="%s",ne=ne.concat([Ue]));var Ge=ne.map(function($e){return String($e)});Ge.unshift("Warning: "+U),Function.prototype.apply.call(console[E],console,Ge)}}var k=!1,C=!1,T=!1,I=!1,N=!1,_;_=Symbol.for("react.module.reference");function j(E){return!!(typeof E=="string"||typeof E=="function"||E===r||E===s||N||E===o||E===u||E===d||I||E===m||k||C||T||typeof E=="object"&&E!==null&&(E.$$typeof===h||E.$$typeof===f||E.$$typeof===i||E.$$typeof===a||E.$$typeof===c||E.$$typeof===_||E.getModuleId!==void 0))}function R(E,U,ne){var Ce=E.displayName;if(Ce)return Ce;var Ue=U.displayName||U.name||"";return Ue!==""?ne+"("+Ue+")":ne}function $(E){return E.displayName||"Context"}function z(E){if(E==null)return null;if(typeof E.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof E=="function")return E.displayName||E.name||null;if(typeof E=="string")return E;switch(E){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case u:return"Suspense";case d:return"SuspenseList"}if(typeof E=="object")switch(E.$$typeof){case a:var U=E;return $(U)+".Consumer";case i:var ne=E;return $(ne._context)+".Provider";case c:return R(E,E.render,"ForwardRef");case f:var Ce=E.displayName||null;return Ce!==null?Ce:z(E.type)||"Memo";case h:{var Ue=E,Ge=Ue._payload,$e=Ue._init;try{return z($e(Ge))}catch{return null}}}return null}var O=Object.assign,W=0,B,q,L,A,D,H,X;function Q(){}Q.__reactDisabledLog=!0;function ue(){{if(W===0){B=console.log,q=console.info,L=console.warn,A=console.error,D=console.group,H=console.groupCollapsed,X=console.groupEnd;var E={configurable:!0,enumerable:!0,value:Q,writable:!0};Object.defineProperties(console,{info:E,log:E,warn:E,error:E,group:E,groupCollapsed:E,groupEnd:E})}W++}}function we(){{if(W--,W===0){var E={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:O({},E,{value:B}),info:O({},E,{value:q}),warn:O({},E,{value:L}),error:O({},E,{value:A}),group:O({},E,{value:D}),groupCollapsed:O({},E,{value:H}),groupEnd:O({},E,{value:X})})}W<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Ie=x.ReactCurrentDispatcher,K;function M(E,U,ne){{if(K===void 0)try{throw Error()}catch(Ue){var Ce=Ue.stack.trim().match(/\n( *(at )?)/);K=Ce&&Ce[1]||""}return`
18
+ `+K+E}}var Y=!1,ee;{var de=typeof WeakMap=="function"?WeakMap:Map;ee=new de}function ce(E,U){if(!E||Y)return"";{var ne=ee.get(E);if(ne!==void 0)return ne}var Ce;Y=!0;var Ue=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Ge;Ge=Ie.current,Ie.current=null,ue();try{if(U){var $e=function(){throw Error()};if(Object.defineProperty($e.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct($e,[])}catch(yt){Ce=yt}Reflect.construct(E,[],$e)}else{try{$e.call()}catch(yt){Ce=yt}E.call($e.prototype)}}else{try{throw Error()}catch(yt){Ce=yt}E()}}catch(yt){if(yt&&Ce&&typeof yt.stack=="string"){for(var Me=yt.stack.split(`
19
+ `),xt=Ce.stack.split(`
20
+ `),rt=Me.length-1,it=xt.length-1;rt>=1&&it>=0&&Me[rt]!==xt[it];)it--;for(;rt>=1&&it>=0;rt--,it--)if(Me[rt]!==xt[it]){if(rt!==1||it!==1)do if(rt--,it--,it<0||Me[rt]!==xt[it]){var Lt=`
21
+ `+Me[rt].replace(" at new "," at ");return E.displayName&&Lt.includes("<anonymous>")&&(Lt=Lt.replace("<anonymous>",E.displayName)),typeof E=="function"&&ee.set(E,Lt),Lt}while(rt>=1&&it>=0);break}}}finally{Y=!1,Ie.current=Ge,we(),Error.prepareStackTrace=Ue}var ar=E?E.displayName||E.name:"",Hn=ar?M(ar):"";return typeof E=="function"&&ee.set(E,Hn),Hn}function ze(E,U,ne){return ce(E,!1)}function Ye(E){var U=E.prototype;return!!(U&&U.isReactComponent)}function V(E,U,ne){if(E==null)return"";if(typeof E=="function")return ce(E,Ye(E));if(typeof E=="string")return M(E);switch(E){case u:return M("Suspense");case d:return M("SuspenseList")}if(typeof E=="object")switch(E.$$typeof){case c:return ze(E.render);case f:return V(E.type,U,ne);case h:{var Ce=E,Ue=Ce._payload,Ge=Ce._init;try{return V(Ge(Ue),U,ne)}catch{}}}return""}var J=Object.prototype.hasOwnProperty,be={},Oe=x.ReactDebugCurrentFrame;function _e(E){if(E){var U=E._owner,ne=V(E.type,E._source,U?U.type:null);Oe.setExtraStackFrame(ne)}else Oe.setExtraStackFrame(null)}function et(E,U,ne,Ce,Ue){{var Ge=Function.call.bind(J);for(var $e in E)if(Ge(E,$e)){var Me=void 0;try{if(typeof E[$e]!="function"){var xt=Error((Ce||"React class")+": "+ne+" type `"+$e+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof E[$e]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw xt.name="Invariant Violation",xt}Me=E[$e](U,$e,Ce,ne,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(rt){Me=rt}Me&&!(Me instanceof Error)&&(_e(Ue),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Ce||"React class",ne,$e,typeof Me),_e(null)),Me instanceof Error&&!(Me.message in be)&&(be[Me.message]=!0,_e(Ue),b("Failed %s type: %s",ne,Me.message),_e(null))}}}var st=Array.isArray;function ie(E){return st(E)}function ae(E){{var U=typeof Symbol=="function"&&Symbol.toStringTag,ne=U&&E[Symbol.toStringTag]||E.constructor.name||"Object";return ne}}function me(E){try{return ge(E),!1}catch{return!0}}function ge(E){return""+E}function ke(E){if(me(E))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ae(E)),ge(E)}var je=x.ReactCurrentOwner,Ke={key:!0,ref:!0,__self:!0,__source:!0},qe,lt;function Dt(E){if(J.call(E,"ref")){var U=Object.getOwnPropertyDescriptor(E,"ref").get;if(U&&U.isReactWarning)return!1}return E.ref!==void 0}function ir(E){if(J.call(E,"key")){var U=Object.getOwnPropertyDescriptor(E,"key").get;if(U&&U.isReactWarning)return!1}return E.key!==void 0}function _a(E,U){typeof E.ref=="string"&&je.current}function ja(E,U){{var ne=function(){qe||(qe=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",U))};ne.isReactWarning=!0,Object.defineProperty(E,"key",{get:ne,configurable:!0})}}function ys(E,U){{var ne=function(){lt||(lt=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",U))};ne.isReactWarning=!0,Object.defineProperty(E,"ref",{get:ne,configurable:!0})}}var Br=function(E,U,ne,Ce,Ue,Ge,$e){var Me={$$typeof:t,type:E,key:U,ref:ne,props:$e,_owner:Ge};return Me._store={},Object.defineProperty(Me._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Me,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Ce}),Object.defineProperty(Me,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Ue}),Object.freeze&&(Object.freeze(Me.props),Object.freeze(Me)),Me};function Ra(E,U,ne,Ce,Ue){{var Ge,$e={},Me=null,xt=null;ne!==void 0&&(ke(ne),Me=""+ne),ir(U)&&(ke(U.key),Me=""+U.key),Dt(U)&&(xt=U.ref,_a(U,Ue));for(Ge in U)J.call(U,Ge)&&!Ke.hasOwnProperty(Ge)&&($e[Ge]=U[Ge]);if(E&&E.defaultProps){var rt=E.defaultProps;for(Ge in rt)$e[Ge]===void 0&&($e[Ge]=rt[Ge])}if(Me||xt){var it=typeof E=="function"?E.displayName||E.name||"Unknown":E;Me&&ja($e,it),xt&&ys($e,it)}return Br(E,Me,xt,Ue,Ce,je.current,$e)}}var Hr=x.ReactCurrentOwner,Ss=x.ReactDebugCurrentFrame;function Sn(E){if(E){var U=E._owner,ne=V(E.type,E._source,U?U.type:null);Ss.setExtraStackFrame(ne)}else Ss.setExtraStackFrame(null)}var Ur;Ur=!1;function Wr(E){return typeof E=="object"&&E!==null&&E.$$typeof===t}function Cs(){{if(Hr.current){var E=z(Hr.current.type);if(E)return`
22
22
 
23
- Check the render method of \``+E+"`."}return""}}function Pa(E){return""}var Ts={};function Oa(E){{var V=Cs();if(!V){var re=typeof E=="string"?E:E.displayName||E.name;re&&(V=`
23
+ Check the render method of \``+E+"`."}return""}}function Pa(E){return""}var Ts={};function Oa(E){{var U=Cs();if(!U){var ne=typeof E=="string"?E:E.displayName||E.name;ne&&(U=`
24
24
 
25
- Check the top-level render call using <`+re+">.")}return V}}function le(E,V){{if(!E._store||E._store.validated||E.key!=null)return;E._store.validated=!0;var re=Oa(V);if(Ts[re])return;Ts[re]=!0;var Se="";E&&E._owner&&E._owner!==Hr.current&&(Se=" It was passed a child from "+H(E._owner.type)+"."),Sn(E),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',re,Se),Sn(null)}}function ge(E,V){{if(typeof E!="object")return;if(ie(E))for(var re=0;re<E.length;re++){var Se=E[re];Wr(Se)&&le(Se,V)}else if(Wr(E))E._store&&(E._store.validated=!0);else if(E){var Ue=g(E);if(typeof Ue=="function"&&Ue!==E.entries)for(var Ke=Ue.call(E),De;!(De=Ke.next()).done;)Wr(De.value)&&le(De.value,V)}}}function Me(E){{var V=E.type;if(V==null||typeof V=="string")return;var re;if(typeof V=="function")re=V.propTypes;else if(typeof V=="object"&&(V.$$typeof===c||V.$$typeof===f))re=V.propTypes;else return;if(re){var Se=H(V);nt(re,E.props,"prop",Se,E)}else if(V.PropTypes!==void 0&&!Ur){Ur=!0;var Ue=H(V);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ue||"Unknown")}typeof V.getDefaultProps=="function"&&!V.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Qe(E){{for(var V=Object.keys(E.props),re=0;re<V.length;re++){var Se=V[re];if(Se!=="children"&&Se!=="key"){Sn(E),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Se),Sn(null);break}}E.ref!==null&&(Sn(E),b("Invalid attribute `ref` supplied to `React.Fragment`."),Sn(null))}}var At={};function rn(E,V,re,Se,Ue,Ke){{var De=j(E);if(!De){var Pe="";(E===void 0||typeof E=="object"&&E!==null&&Object.keys(E).length===0)&&(Pe+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var xt=Pa();xt?Pe+=xt:Pe+=Cs();var rt;E===null?rt="null":ie(E)?rt="array":E!==void 0&&E.$$typeof===t?(rt="<"+(H(E.type)||"Unknown")+" />",Pe=" Did you accidentally export a JSX literal instead of a component?"):rt=typeof E,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",rt,Pe)}var st=Ra(E,V,re,Ue,Ke);if(st==null)return st;if(De){var Lt=V.children;if(Lt!==void 0)if(Se)if(ie(Lt)){for(var ar=0;ar<Lt.length;ar++)ge(Lt[ar],E);Object.freeze&&Object.freeze(Lt)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ge(Lt,E)}if(_e.call(V,"key")){var Hn=H(E),yt=Object.keys(V).filter(function(mC){return mC!=="key"}),Ma=yt.length>0?"{key: someKey, "+yt.join(": ..., ")+": ...}":"{key: someKey}";if(!At[Hn+Ma]){var pC=yt.length>0?"{"+yt.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+ne+">.")}return U}}function le(E,U){{if(!E._store||E._store.validated||E.key!=null)return;E._store.validated=!0;var ne=Oa(U);if(Ts[ne])return;Ts[ne]=!0;var Ce="";E&&E._owner&&E._owner!==Hr.current&&(Ce=" It was passed a child from "+z(E._owner.type)+"."),Sn(E),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',ne,Ce),Sn(null)}}function xe(E,U){{if(typeof E!="object")return;if(ie(E))for(var ne=0;ne<E.length;ne++){var Ce=E[ne];Wr(Ce)&&le(Ce,U)}else if(Wr(E))E._store&&(E._store.validated=!0);else if(E){var Ue=g(E);if(typeof Ue=="function"&&Ue!==E.entries)for(var Ge=Ue.call(E),$e;!($e=Ge.next()).done;)Wr($e.value)&&le($e.value,U)}}}function Le(E){{var U=E.type;if(U==null||typeof U=="string")return;var ne;if(typeof U=="function")ne=U.propTypes;else if(typeof U=="object"&&(U.$$typeof===c||U.$$typeof===f))ne=U.propTypes;else return;if(ne){var Ce=z(U);et(ne,E.props,"prop",Ce,E)}else if(U.PropTypes!==void 0&&!Ur){Ur=!0;var Ue=z(U);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ue||"Unknown")}typeof U.getDefaultProps=="function"&&!U.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Qe(E){{for(var U=Object.keys(E.props),ne=0;ne<U.length;ne++){var Ce=U[ne];if(Ce!=="children"&&Ce!=="key"){Sn(E),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ce),Sn(null);break}}E.ref!==null&&(Sn(E),b("Invalid attribute `ref` supplied to `React.Fragment`."),Sn(null))}}var At={};function rn(E,U,ne,Ce,Ue,Ge){{var $e=j(E);if(!$e){var Me="";(E===void 0||typeof E=="object"&&E!==null&&Object.keys(E).length===0)&&(Me+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var xt=Pa();xt?Me+=xt:Me+=Cs();var rt;E===null?rt="null":ie(E)?rt="array":E!==void 0&&E.$$typeof===t?(rt="<"+(z(E.type)||"Unknown")+" />",Me=" Did you accidentally export a JSX literal instead of a component?"):rt=typeof E,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",rt,Me)}var it=Ra(E,U,ne,Ue,Ge);if(it==null)return it;if($e){var Lt=U.children;if(Lt!==void 0)if(Ce)if(ie(Lt)){for(var ar=0;ar<Lt.length;ar++)xe(Lt[ar],E);Object.freeze&&Object.freeze(Lt)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else xe(Lt,E)}if(J.call(U,"key")){var Hn=z(E),yt=Object.keys(U).filter(function(gC){return gC!=="key"}),Ma=yt.length>0?"{key: someKey, "+yt.join(": ..., ")+": ...}":"{key: someKey}";if(!At[Hn+Ma]){var mC=yt.length>0?"{"+yt.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
26
26
  let props = %s;
27
27
  <%s {...props} />
28
28
  React keys must be passed directly to JSX without using spread:
29
29
  let props = %s;
30
- <%s key={someKey} {...props} />`,Ma,Hn,pC,Hn),At[Hn+Ma]=!0}}return E===r?Qe(st):Me(st),st}}function Vr(E,V,re){return rn(E,V,re,!0)}function Es(E,V,re){return rn(E,V,re,!1)}var ks=Es,ln=Vr;cr.Fragment=r,cr.jsx=ks,cr.jsxs=ln}()),cr}process.env.NODE_ENV==="production"?As.exports=yp():As.exports=Sp();var l=As.exports;function Fa(e,t){return function(){return e.apply(t,arguments)}}const{toString:Cp}=Object.prototype,{getPrototypeOf:_s}=Object,{iterator:Gr,toStringTag:za}=Symbol,Yr=(e=>t=>{const n=Cp.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),$t=e=>(e=e.toLowerCase(),t=>Yr(t)===e),Xr=e=>t=>typeof t===e,{isArray:Un}=Array,Wn=Xr("undefined");function ur(e){return e!==null&&!Wn(e)&&e.constructor!==null&&!Wn(e.constructor)&&vt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ba=$t("ArrayBuffer");function Tp(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ba(e.buffer),t}const Ep=Xr("string"),vt=Xr("function"),Ha=Xr("number"),dr=e=>e!==null&&typeof e=="object",kp=e=>e===!0||e===!1,Jr=e=>{if(Yr(e)!=="object")return!1;const t=_s(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(za in e)&&!(Gr in e)},Ip=e=>{if(!dr(e)||ur(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Np=$t("Date"),Ap=$t("File"),_p=$t("Blob"),jp=$t("FileList"),Rp=e=>dr(e)&&vt(e.pipe),Pp=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||vt(e.append)&&((t=Yr(e))==="formdata"||t==="object"&&vt(e.toString)&&e.toString()==="[object FormData]"))},Op=$t("URLSearchParams"),[Mp,Dp,Lp,$p]=["ReadableStream","Request","Response","Headers"].map($t),Fp=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function fr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Un(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(ur(e))return;const s=n?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length;let a;for(r=0;r<i;r++)a=s[r],t.call(null,e[a],a,e)}}function Ua(e,t){if(ur(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Tn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Wa=e=>!Wn(e)&&e!==Tn;function js(){const{caseless:e,skipUndefined:t}=Wa(this)&&this||{},n={},r=(o,s)=>{const i=e&&Ua(n,s)||s;Jr(n[i])&&Jr(o)?n[i]=js(n[i],o):Jr(o)?n[i]=js({},o):Un(o)?n[i]=o.slice():(!t||!Wn(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&fr(arguments[o],r);return n}const zp=(e,t,n,{allOwnKeys:r}={})=>(fr(t,(o,s)=>{n&&vt(o)?e[s]=Fa(o,n):e[s]=o},{allOwnKeys:r}),e),Bp=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Hp=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Up=(e,t,n,r)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!r||r(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=n!==!1&&_s(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Wp=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Vp=e=>{if(!e)return null;if(Un(e))return e;let t=e.length;if(!Ha(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Kp=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&_s(Uint8Array)),qp=(e,t)=>{const r=(e&&e[Gr]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Gp=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Yp=$t("HTMLFormElement"),Xp=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Va=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Jp=$t("RegExp"),Ka=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};fr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Zp=e=>{Ka(e,(t,n)=>{if(vt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(vt(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Qp=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return Un(e)?r(e):r(String(e).split(t)),n},em=()=>{},tm=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function nm(e){return!!(e&&vt(e.append)&&e[za]==="FormData"&&e[Gr])}const rm=e=>{const t=new Array(10),n=(r,o)=>{if(dr(r)){if(t.indexOf(r)>=0)return;if(ur(r))return r;if(!("toJSON"in r)){t[o]=r;const s=Un(r)?[]:{};return fr(r,(i,a)=>{const c=n(i,o+1);!Wn(c)&&(s[a]=c)}),t[o]=void 0,s}}return r};return n(e,0)},om=$t("AsyncFunction"),sm=e=>e&&(dr(e)||vt(e))&&vt(e.then)&&vt(e.catch),qa=((e,t)=>e?setImmediate:t?((n,r)=>(Tn.addEventListener("message",({source:o,data:s})=>{o===Tn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Tn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",vt(Tn.postMessage)),im=typeof queueMicrotask<"u"?queueMicrotask.bind(Tn):typeof process<"u"&&process.nextTick||qa,P={isArray:Un,isArrayBuffer:Ba,isBuffer:ur,isFormData:Pp,isArrayBufferView:Tp,isString:Ep,isNumber:Ha,isBoolean:kp,isObject:dr,isPlainObject:Jr,isEmptyObject:Ip,isReadableStream:Mp,isRequest:Dp,isResponse:Lp,isHeaders:$p,isUndefined:Wn,isDate:Np,isFile:Ap,isBlob:_p,isRegExp:Jp,isFunction:vt,isStream:Rp,isURLSearchParams:Op,isTypedArray:Kp,isFileList:jp,forEach:fr,merge:js,extend:zp,trim:Fp,stripBOM:Bp,inherits:Hp,toFlatObject:Up,kindOf:Yr,kindOfTest:$t,endsWith:Wp,toArray:Vp,forEachEntry:qp,matchAll:Gp,isHTMLForm:Yp,hasOwnProperty:Va,hasOwnProp:Va,reduceDescriptors:Ka,freezeMethods:Zp,toObjectSet:Qp,toCamelCase:Xp,noop:em,toFiniteNumber:tm,findKey:Ua,global:Tn,isContextDefined:Wa,isSpecCompliantForm:nm,toJSONObject:rm,isAsyncFn:om,isThenable:sm,setImmediate:qa,asap:im,isIterable:e=>e!=null&&vt(e[Gr])};function Ee(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}P.inherits(Ee,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:P.toJSONObject(this.config),code:this.code,status:this.status}}});const Ga=Ee.prototype,Ya={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Ya[e]={value:e}}),Object.defineProperties(Ee,Ya),Object.defineProperty(Ga,"isAxiosError",{value:!0}),Ee.from=(e,t,n,r,o,s)=>{const i=Object.create(Ga);P.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const a=e&&e.message?e.message:"Error",c=t==null&&e?e.code:t;return Ee.call(i,a,c,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const am=null;function Rs(e){return P.isPlainObject(e)||P.isArray(e)}function Xa(e){return P.endsWith(e,"[]")?e.slice(0,-2):e}function Ja(e,t,n){return e?e.concat(t).map(function(o,s){return o=Xa(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function lm(e){return P.isArray(e)&&!e.some(Rs)}const cm=P.toFlatObject(P,{},null,function(t){return/^is[A-Z]/.test(t)});function Zr(e,t,n){if(!P.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=P.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,g){return!P.isUndefined(g[v])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&P.isSpecCompliantForm(t);if(!P.isFunction(o))throw new TypeError("visitor must be a function");function u(w){if(w===null)return"";if(P.isDate(w))return w.toISOString();if(P.isBoolean(w))return w.toString();if(!c&&P.isBlob(w))throw new Ee("Blob is not supported. Use a Buffer instead.");return P.isArrayBuffer(w)||P.isTypedArray(w)?c&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function d(w,v,g){let x=w;if(w&&!g&&typeof w=="object"){if(P.endsWith(v,"{}"))v=r?v:v.slice(0,-2),w=JSON.stringify(w);else if(P.isArray(w)&&lm(w)||(P.isFileList(w)||P.endsWith(v,"[]"))&&(x=P.toArray(w)))return v=Xa(v),x.forEach(function(S,k){!(P.isUndefined(S)||S===null)&&t.append(i===!0?Ja([v],k,s):i===null?v:v+"[]",u(S))}),!1}return Rs(w)?!0:(t.append(Ja(g,v,s),u(w)),!1)}const f=[],h=Object.assign(cm,{defaultVisitor:d,convertValue:u,isVisitable:Rs});function m(w,v){if(!P.isUndefined(w)){if(f.indexOf(w)!==-1)throw Error("Circular reference detected in "+v.join("."));f.push(w),P.forEach(w,function(x,b){(!(P.isUndefined(x)||x===null)&&o.call(t,x,P.isString(b)?b.trim():b,v,h))===!0&&m(x,v?v.concat(b):[b])}),f.pop()}}if(!P.isObject(e))throw new TypeError("data must be an object");return m(e),t}function Za(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ps(e,t){this._pairs=[],e&&Zr(e,this,t)}const Qa=Ps.prototype;Qa.append=function(t,n){this._pairs.push([t,n])},Qa.toString=function(t){const n=t?function(r){return t.call(this,r,Za)}:Za;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function um(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function el(e,t,n){if(!t)return e;const r=n&&n.encode||um;P.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=P.isURLSearchParams(t)?t.toString():new Ps(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class tl{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){P.forEach(this.handlers,function(r){r!==null&&t(r)})}}const nl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},dm={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ps,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Os=typeof window<"u"&&typeof document<"u",Ms=typeof navigator=="object"&&navigator||void 0,fm=Os&&(!Ms||["ReactNative","NativeScript","NS"].indexOf(Ms.product)<0),hm=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",pm=Os&&window.location.href||"http://localhost",dt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Os,hasStandardBrowserEnv:fm,hasStandardBrowserWebWorkerEnv:hm,navigator:Ms,origin:pm},Symbol.toStringTag,{value:"Module"})),...dm};function mm(e,t){return Zr(e,new dt.classes.URLSearchParams,{visitor:function(n,r,o,s){return dt.isNode&&P.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function gm(e){return P.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function xm(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}function rl(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),c=s>=n.length;return i=!i&&P.isArray(o)?o.length:i,c?(P.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!P.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&P.isArray(o[i])&&(o[i]=xm(o[i])),!a)}if(P.isFormData(e)&&P.isFunction(e.entries)){const n={};return P.forEachEntry(e,(r,o)=>{t(gm(r),o,n,0)}),n}return null}function vm(e,t,n){if(P.isString(e))try{return(t||JSON.parse)(e),P.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const hr={transitional:nl,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=P.isObject(t);if(s&&P.isHTMLForm(t)&&(t=new FormData(t)),P.isFormData(t))return o?JSON.stringify(rl(t)):t;if(P.isArrayBuffer(t)||P.isBuffer(t)||P.isStream(t)||P.isFile(t)||P.isBlob(t)||P.isReadableStream(t))return t;if(P.isArrayBufferView(t))return t.buffer;if(P.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return mm(t,this.formSerializer).toString();if((a=P.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return Zr(a?{"files[]":t}:t,c&&new c,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),vm(t)):t}],transformResponse:[function(t){const n=this.transitional||hr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(P.isResponse(t)||P.isReadableStream(t))return t;if(t&&P.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Ee.from(a,Ee.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:dt.classes.FormData,Blob:dt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};P.forEach(["delete","get","head","post","put","patch"],e=>{hr.headers[e]={}});const wm=P.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),bm=e=>{const t={};let n,r,o;return e&&e.split(`
31
- `).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&wm[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},ol=Symbol("internals");function pr(e){return e&&String(e).trim().toLowerCase()}function Qr(e){return e===!1||e==null?e:P.isArray(e)?e.map(Qr):String(e)}function ym(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const Sm=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ds(e,t,n,r,o){if(P.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!P.isString(t)){if(P.isString(r))return t.indexOf(r)!==-1;if(P.isRegExp(r))return r.test(t)}}function Cm(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Tm(e,t){const n=P.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,i){return this[r].call(this,t,o,s,i)},configurable:!0})})}let wt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,c,u){const d=pr(c);if(!d)throw new Error("header name must be a non-empty string");const f=P.findKey(o,d);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||c]=Qr(a))}const i=(a,c)=>P.forEach(a,(u,d)=>s(u,d,c));if(P.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(P.isString(t)&&(t=t.trim())&&!Sm(t))i(bm(t),n);else if(P.isObject(t)&&P.isIterable(t)){let a={},c,u;for(const d of t){if(!P.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(c=a[u])?P.isArray(c)?[...c,d[1]]:[c,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=pr(t),t){const r=P.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return ym(o);if(P.isFunction(n))return n.call(this,o,r);if(P.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=pr(t),t){const r=P.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Ds(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=pr(i),i){const a=P.findKey(r,i);a&&(!n||Ds(r,r[a],a,n))&&(delete r[a],o=!0)}}return P.isArray(t)?t.forEach(s):s(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const s=n[r];(!t||Ds(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return P.forEach(this,(o,s)=>{const i=P.findKey(r,s);if(i){n[i]=Qr(o),delete n[s];return}const a=t?Cm(s):String(s).trim();a!==s&&delete n[s],n[a]=Qr(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return P.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&P.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
32
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[ol]=this[ol]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=pr(i);r[a]||(Tm(o,i),r[a]=!0)}return P.isArray(t)?t.forEach(s):s(t),this}};wt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),P.reduceDescriptors(wt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),P.freezeMethods(wt);function Ls(e,t){const n=this||hr,r=t||n,o=wt.from(r.headers);let s=r.data;return P.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function sl(e){return!!(e&&e.__CANCEL__)}function Vn(e,t,n){Ee.call(this,e??"canceled",Ee.ERR_CANCELED,t,n),this.name="CanceledError"}P.inherits(Vn,Ee,{__CANCEL__:!0});function il(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Ee("Request failed with status code "+n.status,[Ee.ERR_BAD_REQUEST,Ee.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Em(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function km(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(c){const u=Date.now(),d=r[s];i||(i=u),n[o]=c,r[o]=u;let f=s,h=0;for(;f!==o;)h+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const m=d&&u-d;return m?Math.round(h*1e3/m):void 0}}function Im(e,t){let n=0,r=1e3/t,o,s;const i=(u,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...u)};return[(...u)=>{const d=Date.now(),f=d-n;f>=r?i(u,d):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const eo=(e,t,n=3)=>{let r=0;const o=km(50,250);return Im(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,c=i-r,u=o(c),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:c,rate:u||void 0,estimated:u&&a&&d?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},al=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},ll=e=>(...t)=>P.asap(()=>e(...t)),Nm=dt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,dt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(dt.origin),dt.navigator&&/(msie|trident)/i.test(dt.navigator.userAgent)):()=>!0,Am=dt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];P.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),P.isString(r)&&i.push("path="+r),P.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function _m(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function jm(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function cl(e,t,n){let r=!_m(t);return e&&(r||n==!1)?jm(e,t):t}const ul=e=>e instanceof wt?{...e}:e;function En(e,t){t=t||{};const n={};function r(u,d,f,h){return P.isPlainObject(u)&&P.isPlainObject(d)?P.merge.call({caseless:h},u,d):P.isPlainObject(d)?P.merge({},d):P.isArray(d)?d.slice():d}function o(u,d,f,h){if(P.isUndefined(d)){if(!P.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!P.isUndefined(d))return r(void 0,d)}function i(u,d){if(P.isUndefined(d)){if(!P.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function a(u,d,f){if(f in t)return r(u,d);if(f in e)return r(void 0,u)}const c={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(u,d,f)=>o(ul(u),ul(d),f,!0)};return P.forEach(Object.keys({...e,...t}),function(d){const f=c[d]||o,h=f(e[d],t[d],d);P.isUndefined(h)&&f!==a||(n[d]=h)}),n}const dl=e=>{const t=En({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=wt.from(i),t.url=el(cl(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),P.isFormData(n)){if(dt.hasStandardBrowserEnv||dt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(P.isFunction(n.getHeaders)){const c=n.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([d,f])=>{u.includes(d.toLowerCase())&&i.set(d,f)})}}if(dt.hasStandardBrowserEnv&&(r&&P.isFunction(r)&&(r=r(t)),r||r!==!1&&Nm(t.url))){const c=o&&s&&Am.read(s);c&&i.set(o,c)}return t},Rm=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=dl(e);let s=o.data;const i=wt.from(o.headers).normalize();let{responseType:a,onUploadProgress:c,onDownloadProgress:u}=o,d,f,h,m,w;function v(){m&&m(),w&&w(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function x(){if(!g)return;const S=wt.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:S,config:e,request:g};il(function(I){n(I),v()},function(I){r(I),v()},C),g=null}"onloadend"in g?g.onloadend=x:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(x)},g.onabort=function(){g&&(r(new Ee("Request aborted",Ee.ECONNABORTED,e,g)),g=null)},g.onerror=function(k){const C=k&&k.message?k.message:"Network Error",T=new Ee(C,Ee.ERR_NETWORK,e,g);T.event=k||null,r(T),g=null},g.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||nl;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Ee(k,C.clarifyTimeoutError?Ee.ETIMEDOUT:Ee.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&P.forEach(i.toJSON(),function(k,C){g.setRequestHeader(C,k)}),P.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,w]=eo(u,!0),g.addEventListener("progress",h)),c&&g.upload&&([f,m]=eo(c),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",m)),(o.cancelToken||o.signal)&&(d=S=>{g&&(r(!S||S.type?new Vn(null,e,g):S),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=Em(o.url);if(b&&dt.protocols.indexOf(b)===-1){r(new Ee("Unsupported protocol "+b+":",Ee.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Pm=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(u){if(!o){o=!0,a();const d=u instanceof Error?u:this.reason;r.abort(d instanceof Ee?d:new Vn(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Ee(`timeout ${t} of ms exceeded`,Ee.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:c}=r;return c.unsubscribe=()=>P.asap(a),c}},Om=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},Mm=async function*(e,t){for await(const n of Dm(e))yield*Om(n,t)},Dm=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},fl=(e,t,n,r)=>{const o=Mm(e,t);let s=0,i,a=c=>{i||(i=!0,r&&r(c))};return new ReadableStream({async pull(c){try{const{done:u,value:d}=await o.next();if(u){a(),c.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}c.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(c){return a(c),o.return()}},{highWaterMark:2})},hl=64*1024,{isFunction:to}=P,Lm=(({Request:e,Response:t})=>({Request:e,Response:t}))(P.global),{ReadableStream:pl,TextEncoder:ml}=P.global,gl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},$m=e=>{e=P.merge.call({skipUndefined:!0},Lm,e);const{fetch:t,Request:n,Response:r}=e,o=t?to(t):typeof fetch=="function",s=to(n),i=to(r);if(!o)return!1;const a=o&&to(pl),c=o&&(typeof ml=="function"?(w=>v=>w.encode(v))(new ml):async w=>new Uint8Array(await new n(w).arrayBuffer())),u=s&&a&&gl(()=>{let w=!1;const v=new n(dt.origin,{body:new pl,method:"POST",get duplex(){return w=!0,"half"}}).headers.has("Content-Type");return w&&!v}),d=i&&a&&gl(()=>P.isReadableStream(new r("").body)),f={stream:d&&(w=>w.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(w=>{!f[w]&&(f[w]=(v,g)=>{let x=v&&v[w];if(x)return x.call(v);throw new Ee(`Response type '${w}' is not supported`,Ee.ERR_NOT_SUPPORT,g)})});const h=async w=>{if(w==null)return 0;if(P.isBlob(w))return w.size;if(P.isSpecCompliantForm(w))return(await new n(dt.origin,{method:"POST",body:w}).arrayBuffer()).byteLength;if(P.isArrayBufferView(w)||P.isArrayBuffer(w))return w.byteLength;if(P.isURLSearchParams(w)&&(w=w+""),P.isString(w))return(await c(w)).byteLength},m=async(w,v)=>{const g=P.toFiniteNumber(w.getContentLength());return g??h(v)};return async w=>{let{url:v,method:g,data:x,signal:b,cancelToken:S,timeout:k,onDownloadProgress:C,onUploadProgress:T,responseType:I,headers:N,withCredentials:_="same-origin",fetchOptions:j}=dl(w),R=t||fetch;I=I?(I+"").toLowerCase():"text";let z=Pm([b,S&&S.toAbortSignal()],k),H=null;const O=z&&z.unsubscribe&&(()=>{z.unsubscribe()});let W;try{if(T&&u&&g!=="get"&&g!=="head"&&(W=await m(N,x))!==0){let U=new n(v,{method:"POST",body:x,duplex:"half"}),J;if(P.isFormData(x)&&(J=U.headers.get("content-type"))&&N.setContentType(J),U.body){const[Q,ce]=al(W,eo(ll(T)));x=fl(U.body,hl,Q,ce)}}P.isString(_)||(_=_?"include":"omit");const K=s&&"credentials"in n.prototype,G={...j,signal:z,method:g.toUpperCase(),headers:N.normalize().toJSON(),body:x,duplex:"half",credentials:K?_:void 0};H=s&&new n(v,G);let $=await(s?R(H,j):R(v,G));const A=d&&(I==="stream"||I==="response");if(d&&(C||A&&O)){const U={};["status","statusText","headers"].forEach(we=>{U[we]=$[we]});const J=P.toFiniteNumber($.headers.get("content-length")),[Q,ce]=C&&al(J,eo(ll(C),!0))||[];$=new r(fl($.body,hl,Q,()=>{ce&&ce(),O&&O()}),U)}I=I||"text";let D=await f[P.findKey(f,I)||"text"]($,w);return!A&&O&&O(),await new Promise((U,J)=>{il(U,J,{data:D,headers:wt.from($.headers),status:$.status,statusText:$.statusText,config:w,request:H})})}catch(K){throw O&&O(),K&&K.name==="TypeError"&&/Load failed|fetch/i.test(K.message)?Object.assign(new Ee("Network Error",Ee.ERR_NETWORK,w,H),{cause:K.cause||K}):Ee.from(K,K&&K.code,w,H)}}},Fm=new Map,xl=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,c,u,d=Fm;for(;a--;)c=s[a],u=d.get(c),u===void 0&&d.set(c,u=a?new Map:$m(t)),d=u;return u};xl();const $s={http:am,xhr:Rm,fetch:{get:xl}};P.forEach($s,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const vl=e=>`- ${e}`,zm=e=>P.isFunction(e)||e===null||e===!1,wl={getAdapter:(e,t)=>{e=P.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){r=e[i];let a;if(o=r,!zm(r)&&(o=$s[(a=String(r)).toLowerCase()],o===void 0))throw new Ee(`Unknown adapter '${a}'`);if(o&&(P.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
30
+ <%s key={someKey} {...props} />`,Ma,Hn,mC,Hn),At[Hn+Ma]=!0}}return E===r?Qe(it):Le(it),it}}function Vr(E,U,ne){return rn(E,U,ne,!0)}function Es(E,U,ne){return rn(E,U,ne,!1)}var ks=Es,ln=Vr;cr.Fragment=r,cr.jsx=ks,cr.jsxs=ln}()),cr}process.env.NODE_ENV==="production"?As.exports=Sp():As.exports=Cp();var l=As.exports;function Fa(e,t){return function(){return e.apply(t,arguments)}}const{toString:Tp}=Object.prototype,{getPrototypeOf:_s}=Object,{iterator:Gr,toStringTag:za}=Symbol,Yr=(e=>t=>{const n=Tp.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),$t=e=>(e=e.toLowerCase(),t=>Yr(t)===e),Xr=e=>t=>typeof t===e,{isArray:Un}=Array,Wn=Xr("undefined");function ur(e){return e!==null&&!Wn(e)&&e.constructor!==null&&!Wn(e.constructor)&&vt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ba=$t("ArrayBuffer");function Ep(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ba(e.buffer),t}const kp=Xr("string"),vt=Xr("function"),Ha=Xr("number"),dr=e=>e!==null&&typeof e=="object",Ip=e=>e===!0||e===!1,Jr=e=>{if(Yr(e)!=="object")return!1;const t=_s(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(za in e)&&!(Gr in e)},Np=e=>{if(!dr(e)||ur(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Ap=$t("Date"),_p=$t("File"),jp=$t("Blob"),Rp=$t("FileList"),Pp=e=>dr(e)&&vt(e.pipe),Op=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||vt(e.append)&&((t=Yr(e))==="formdata"||t==="object"&&vt(e.toString)&&e.toString()==="[object FormData]"))},Mp=$t("URLSearchParams"),[Dp,Lp,$p,Fp]=["ReadableStream","Request","Response","Headers"].map($t),zp=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function fr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Un(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(ur(e))return;const s=n?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length;let a;for(r=0;r<i;r++)a=s[r],t.call(null,e[a],a,e)}}function Ua(e,t){if(ur(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Tn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Wa=e=>!Wn(e)&&e!==Tn;function js(){const{caseless:e,skipUndefined:t}=Wa(this)&&this||{},n={},r=(o,s)=>{const i=e&&Ua(n,s)||s;Jr(n[i])&&Jr(o)?n[i]=js(n[i],o):Jr(o)?n[i]=js({},o):Un(o)?n[i]=o.slice():(!t||!Wn(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&fr(arguments[o],r);return n}const Bp=(e,t,n,{allOwnKeys:r}={})=>(fr(t,(o,s)=>{n&&vt(o)?e[s]=Fa(o,n):e[s]=o},{allOwnKeys:r}),e),Hp=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Up=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Wp=(e,t,n,r)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!r||r(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=n!==!1&&_s(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Vp=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Kp=e=>{if(!e)return null;if(Un(e))return e;let t=e.length;if(!Ha(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},qp=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&_s(Uint8Array)),Gp=(e,t)=>{const r=(e&&e[Gr]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Yp=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Xp=$t("HTMLFormElement"),Jp=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Va=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Zp=$t("RegExp"),Ka=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};fr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Qp=e=>{Ka(e,(t,n)=>{if(vt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(vt(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},em=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return Un(e)?r(e):r(String(e).split(t)),n},tm=()=>{},nm=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function rm(e){return!!(e&&vt(e.append)&&e[za]==="FormData"&&e[Gr])}const om=e=>{const t=new Array(10),n=(r,o)=>{if(dr(r)){if(t.indexOf(r)>=0)return;if(ur(r))return r;if(!("toJSON"in r)){t[o]=r;const s=Un(r)?[]:{};return fr(r,(i,a)=>{const c=n(i,o+1);!Wn(c)&&(s[a]=c)}),t[o]=void 0,s}}return r};return n(e,0)},sm=$t("AsyncFunction"),im=e=>e&&(dr(e)||vt(e))&&vt(e.then)&&vt(e.catch),qa=((e,t)=>e?setImmediate:t?((n,r)=>(Tn.addEventListener("message",({source:o,data:s})=>{o===Tn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Tn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",vt(Tn.postMessage)),am=typeof queueMicrotask<"u"?queueMicrotask.bind(Tn):typeof process<"u"&&process.nextTick||qa,P={isArray:Un,isArrayBuffer:Ba,isBuffer:ur,isFormData:Op,isArrayBufferView:Ep,isString:kp,isNumber:Ha,isBoolean:Ip,isObject:dr,isPlainObject:Jr,isEmptyObject:Np,isReadableStream:Dp,isRequest:Lp,isResponse:$p,isHeaders:Fp,isUndefined:Wn,isDate:Ap,isFile:_p,isBlob:jp,isRegExp:Zp,isFunction:vt,isStream:Pp,isURLSearchParams:Mp,isTypedArray:qp,isFileList:Rp,forEach:fr,merge:js,extend:Bp,trim:zp,stripBOM:Hp,inherits:Up,toFlatObject:Wp,kindOf:Yr,kindOfTest:$t,endsWith:Vp,toArray:Kp,forEachEntry:Gp,matchAll:Yp,isHTMLForm:Xp,hasOwnProperty:Va,hasOwnProp:Va,reduceDescriptors:Ka,freezeMethods:Qp,toObjectSet:em,toCamelCase:Jp,noop:tm,toFiniteNumber:nm,findKey:Ua,global:Tn,isContextDefined:Wa,isSpecCompliantForm:rm,toJSONObject:om,isAsyncFn:sm,isThenable:im,setImmediate:qa,asap:am,isIterable:e=>e!=null&&vt(e[Gr])};function Ne(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}P.inherits(Ne,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:P.toJSONObject(this.config),code:this.code,status:this.status}}});const Ga=Ne.prototype,Ya={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Ya[e]={value:e}}),Object.defineProperties(Ne,Ya),Object.defineProperty(Ga,"isAxiosError",{value:!0}),Ne.from=(e,t,n,r,o,s)=>{const i=Object.create(Ga);P.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const a=e&&e.message?e.message:"Error",c=t==null&&e?e.code:t;return Ne.call(i,a,c,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const lm=null;function Rs(e){return P.isPlainObject(e)||P.isArray(e)}function Xa(e){return P.endsWith(e,"[]")?e.slice(0,-2):e}function Ja(e,t,n){return e?e.concat(t).map(function(o,s){return o=Xa(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function cm(e){return P.isArray(e)&&!e.some(Rs)}const um=P.toFlatObject(P,{},null,function(t){return/^is[A-Z]/.test(t)});function Zr(e,t,n){if(!P.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=P.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,g){return!P.isUndefined(g[v])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&P.isSpecCompliantForm(t);if(!P.isFunction(o))throw new TypeError("visitor must be a function");function u(w){if(w===null)return"";if(P.isDate(w))return w.toISOString();if(P.isBoolean(w))return w.toString();if(!c&&P.isBlob(w))throw new Ne("Blob is not supported. Use a Buffer instead.");return P.isArrayBuffer(w)||P.isTypedArray(w)?c&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function d(w,v,g){let x=w;if(w&&!g&&typeof w=="object"){if(P.endsWith(v,"{}"))v=r?v:v.slice(0,-2),w=JSON.stringify(w);else if(P.isArray(w)&&cm(w)||(P.isFileList(w)||P.endsWith(v,"[]"))&&(x=P.toArray(w)))return v=Xa(v),x.forEach(function(S,k){!(P.isUndefined(S)||S===null)&&t.append(i===!0?Ja([v],k,s):i===null?v:v+"[]",u(S))}),!1}return Rs(w)?!0:(t.append(Ja(g,v,s),u(w)),!1)}const f=[],h=Object.assign(um,{defaultVisitor:d,convertValue:u,isVisitable:Rs});function m(w,v){if(!P.isUndefined(w)){if(f.indexOf(w)!==-1)throw Error("Circular reference detected in "+v.join("."));f.push(w),P.forEach(w,function(x,b){(!(P.isUndefined(x)||x===null)&&o.call(t,x,P.isString(b)?b.trim():b,v,h))===!0&&m(x,v?v.concat(b):[b])}),f.pop()}}if(!P.isObject(e))throw new TypeError("data must be an object");return m(e),t}function Za(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ps(e,t){this._pairs=[],e&&Zr(e,this,t)}const Qa=Ps.prototype;Qa.append=function(t,n){this._pairs.push([t,n])},Qa.toString=function(t){const n=t?function(r){return t.call(this,r,Za)}:Za;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function dm(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function el(e,t,n){if(!t)return e;const r=n&&n.encode||dm;P.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=P.isURLSearchParams(t)?t.toString():new Ps(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class tl{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){P.forEach(this.handlers,function(r){r!==null&&t(r)})}}const nl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},fm={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ps,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Os=typeof window<"u"&&typeof document<"u",Ms=typeof navigator=="object"&&navigator||void 0,hm=Os&&(!Ms||["ReactNative","NativeScript","NS"].indexOf(Ms.product)<0),pm=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",mm=Os&&window.location.href||"http://localhost",dt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Os,hasStandardBrowserEnv:hm,hasStandardBrowserWebWorkerEnv:pm,navigator:Ms,origin:mm},Symbol.toStringTag,{value:"Module"})),...fm};function gm(e,t){return Zr(e,new dt.classes.URLSearchParams,{visitor:function(n,r,o,s){return dt.isNode&&P.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function xm(e){return P.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function vm(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}function rl(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),c=s>=n.length;return i=!i&&P.isArray(o)?o.length:i,c?(P.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!P.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&P.isArray(o[i])&&(o[i]=vm(o[i])),!a)}if(P.isFormData(e)&&P.isFunction(e.entries)){const n={};return P.forEachEntry(e,(r,o)=>{t(xm(r),o,n,0)}),n}return null}function wm(e,t,n){if(P.isString(e))try{return(t||JSON.parse)(e),P.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const hr={transitional:nl,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=P.isObject(t);if(s&&P.isHTMLForm(t)&&(t=new FormData(t)),P.isFormData(t))return o?JSON.stringify(rl(t)):t;if(P.isArrayBuffer(t)||P.isBuffer(t)||P.isStream(t)||P.isFile(t)||P.isBlob(t)||P.isReadableStream(t))return t;if(P.isArrayBufferView(t))return t.buffer;if(P.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return gm(t,this.formSerializer).toString();if((a=P.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return Zr(a?{"files[]":t}:t,c&&new c,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),wm(t)):t}],transformResponse:[function(t){const n=this.transitional||hr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(P.isResponse(t)||P.isReadableStream(t))return t;if(t&&P.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Ne.from(a,Ne.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:dt.classes.FormData,Blob:dt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};P.forEach(["delete","get","head","post","put","patch"],e=>{hr.headers[e]={}});const bm=P.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),ym=e=>{const t={};let n,r,o;return e&&e.split(`
31
+ `).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&bm[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},ol=Symbol("internals");function pr(e){return e&&String(e).trim().toLowerCase()}function Qr(e){return e===!1||e==null?e:P.isArray(e)?e.map(Qr):String(e)}function Sm(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const Cm=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ds(e,t,n,r,o){if(P.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!P.isString(t)){if(P.isString(r))return t.indexOf(r)!==-1;if(P.isRegExp(r))return r.test(t)}}function Tm(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Em(e,t){const n=P.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,i){return this[r].call(this,t,o,s,i)},configurable:!0})})}let wt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,c,u){const d=pr(c);if(!d)throw new Error("header name must be a non-empty string");const f=P.findKey(o,d);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||c]=Qr(a))}const i=(a,c)=>P.forEach(a,(u,d)=>s(u,d,c));if(P.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(P.isString(t)&&(t=t.trim())&&!Cm(t))i(ym(t),n);else if(P.isObject(t)&&P.isIterable(t)){let a={},c,u;for(const d of t){if(!P.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(c=a[u])?P.isArray(c)?[...c,d[1]]:[c,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=pr(t),t){const r=P.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Sm(o);if(P.isFunction(n))return n.call(this,o,r);if(P.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=pr(t),t){const r=P.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Ds(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=pr(i),i){const a=P.findKey(r,i);a&&(!n||Ds(r,r[a],a,n))&&(delete r[a],o=!0)}}return P.isArray(t)?t.forEach(s):s(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const s=n[r];(!t||Ds(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return P.forEach(this,(o,s)=>{const i=P.findKey(r,s);if(i){n[i]=Qr(o),delete n[s];return}const a=t?Tm(s):String(s).trim();a!==s&&delete n[s],n[a]=Qr(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return P.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&P.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
32
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[ol]=this[ol]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=pr(i);r[a]||(Em(o,i),r[a]=!0)}return P.isArray(t)?t.forEach(s):s(t),this}};wt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),P.reduceDescriptors(wt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),P.freezeMethods(wt);function Ls(e,t){const n=this||hr,r=t||n,o=wt.from(r.headers);let s=r.data;return P.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function sl(e){return!!(e&&e.__CANCEL__)}function Vn(e,t,n){Ne.call(this,e??"canceled",Ne.ERR_CANCELED,t,n),this.name="CanceledError"}P.inherits(Vn,Ne,{__CANCEL__:!0});function il(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Ne("Request failed with status code "+n.status,[Ne.ERR_BAD_REQUEST,Ne.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function km(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Im(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(c){const u=Date.now(),d=r[s];i||(i=u),n[o]=c,r[o]=u;let f=s,h=0;for(;f!==o;)h+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const m=d&&u-d;return m?Math.round(h*1e3/m):void 0}}function Nm(e,t){let n=0,r=1e3/t,o,s;const i=(u,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...u)};return[(...u)=>{const d=Date.now(),f=d-n;f>=r?i(u,d):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const eo=(e,t,n=3)=>{let r=0;const o=Im(50,250);return Nm(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,c=i-r,u=o(c),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:c,rate:u||void 0,estimated:u&&a&&d?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},al=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},ll=e=>(...t)=>P.asap(()=>e(...t)),Am=dt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,dt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(dt.origin),dt.navigator&&/(msie|trident)/i.test(dt.navigator.userAgent)):()=>!0,_m=dt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];P.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),P.isString(r)&&i.push("path="+r),P.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function jm(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Rm(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function cl(e,t,n){let r=!jm(t);return e&&(r||n==!1)?Rm(e,t):t}const ul=e=>e instanceof wt?{...e}:e;function En(e,t){t=t||{};const n={};function r(u,d,f,h){return P.isPlainObject(u)&&P.isPlainObject(d)?P.merge.call({caseless:h},u,d):P.isPlainObject(d)?P.merge({},d):P.isArray(d)?d.slice():d}function o(u,d,f,h){if(P.isUndefined(d)){if(!P.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!P.isUndefined(d))return r(void 0,d)}function i(u,d){if(P.isUndefined(d)){if(!P.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function a(u,d,f){if(f in t)return r(u,d);if(f in e)return r(void 0,u)}const c={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(u,d,f)=>o(ul(u),ul(d),f,!0)};return P.forEach(Object.keys({...e,...t}),function(d){const f=c[d]||o,h=f(e[d],t[d],d);P.isUndefined(h)&&f!==a||(n[d]=h)}),n}const dl=e=>{const t=En({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=wt.from(i),t.url=el(cl(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),P.isFormData(n)){if(dt.hasStandardBrowserEnv||dt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(P.isFunction(n.getHeaders)){const c=n.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([d,f])=>{u.includes(d.toLowerCase())&&i.set(d,f)})}}if(dt.hasStandardBrowserEnv&&(r&&P.isFunction(r)&&(r=r(t)),r||r!==!1&&Am(t.url))){const c=o&&s&&_m.read(s);c&&i.set(o,c)}return t},Pm=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=dl(e);let s=o.data;const i=wt.from(o.headers).normalize();let{responseType:a,onUploadProgress:c,onDownloadProgress:u}=o,d,f,h,m,w;function v(){m&&m(),w&&w(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function x(){if(!g)return;const S=wt.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:S,config:e,request:g};il(function(I){n(I),v()},function(I){r(I),v()},C),g=null}"onloadend"in g?g.onloadend=x:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(x)},g.onabort=function(){g&&(r(new Ne("Request aborted",Ne.ECONNABORTED,e,g)),g=null)},g.onerror=function(k){const C=k&&k.message?k.message:"Network Error",T=new Ne(C,Ne.ERR_NETWORK,e,g);T.event=k||null,r(T),g=null},g.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||nl;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Ne(k,C.clarifyTimeoutError?Ne.ETIMEDOUT:Ne.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&P.forEach(i.toJSON(),function(k,C){g.setRequestHeader(C,k)}),P.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,w]=eo(u,!0),g.addEventListener("progress",h)),c&&g.upload&&([f,m]=eo(c),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",m)),(o.cancelToken||o.signal)&&(d=S=>{g&&(r(!S||S.type?new Vn(null,e,g):S),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=km(o.url);if(b&&dt.protocols.indexOf(b)===-1){r(new Ne("Unsupported protocol "+b+":",Ne.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Om=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(u){if(!o){o=!0,a();const d=u instanceof Error?u:this.reason;r.abort(d instanceof Ne?d:new Vn(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Ne(`timeout ${t} of ms exceeded`,Ne.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:c}=r;return c.unsubscribe=()=>P.asap(a),c}},Mm=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},Dm=async function*(e,t){for await(const n of Lm(e))yield*Mm(n,t)},Lm=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},fl=(e,t,n,r)=>{const o=Dm(e,t);let s=0,i,a=c=>{i||(i=!0,r&&r(c))};return new ReadableStream({async pull(c){try{const{done:u,value:d}=await o.next();if(u){a(),c.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}c.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(c){return a(c),o.return()}},{highWaterMark:2})},hl=64*1024,{isFunction:to}=P,$m=(({Request:e,Response:t})=>({Request:e,Response:t}))(P.global),{ReadableStream:pl,TextEncoder:ml}=P.global,gl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Fm=e=>{e=P.merge.call({skipUndefined:!0},$m,e);const{fetch:t,Request:n,Response:r}=e,o=t?to(t):typeof fetch=="function",s=to(n),i=to(r);if(!o)return!1;const a=o&&to(pl),c=o&&(typeof ml=="function"?(w=>v=>w.encode(v))(new ml):async w=>new Uint8Array(await new n(w).arrayBuffer())),u=s&&a&&gl(()=>{let w=!1;const v=new n(dt.origin,{body:new pl,method:"POST",get duplex(){return w=!0,"half"}}).headers.has("Content-Type");return w&&!v}),d=i&&a&&gl(()=>P.isReadableStream(new r("").body)),f={stream:d&&(w=>w.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(w=>{!f[w]&&(f[w]=(v,g)=>{let x=v&&v[w];if(x)return x.call(v);throw new Ne(`Response type '${w}' is not supported`,Ne.ERR_NOT_SUPPORT,g)})});const h=async w=>{if(w==null)return 0;if(P.isBlob(w))return w.size;if(P.isSpecCompliantForm(w))return(await new n(dt.origin,{method:"POST",body:w}).arrayBuffer()).byteLength;if(P.isArrayBufferView(w)||P.isArrayBuffer(w))return w.byteLength;if(P.isURLSearchParams(w)&&(w=w+""),P.isString(w))return(await c(w)).byteLength},m=async(w,v)=>{const g=P.toFiniteNumber(w.getContentLength());return g??h(v)};return async w=>{let{url:v,method:g,data:x,signal:b,cancelToken:S,timeout:k,onDownloadProgress:C,onUploadProgress:T,responseType:I,headers:N,withCredentials:_="same-origin",fetchOptions:j}=dl(w),R=t||fetch;I=I?(I+"").toLowerCase():"text";let $=Om([b,S&&S.toAbortSignal()],k),z=null;const O=$&&$.unsubscribe&&(()=>{$.unsubscribe()});let W;try{if(T&&u&&g!=="get"&&g!=="head"&&(W=await m(N,x))!==0){let H=new n(v,{method:"POST",body:x,duplex:"half"}),X;if(P.isFormData(x)&&(X=H.headers.get("content-type"))&&N.setContentType(X),H.body){const[Q,ue]=al(W,eo(ll(T)));x=fl(H.body,hl,Q,ue)}}P.isString(_)||(_=_?"include":"omit");const B=s&&"credentials"in n.prototype,q={...j,signal:$,method:g.toUpperCase(),headers:N.normalize().toJSON(),body:x,duplex:"half",credentials:B?_:void 0};z=s&&new n(v,q);let L=await(s?R(z,j):R(v,q));const A=d&&(I==="stream"||I==="response");if(d&&(C||A&&O)){const H={};["status","statusText","headers"].forEach(we=>{H[we]=L[we]});const X=P.toFiniteNumber(L.headers.get("content-length")),[Q,ue]=C&&al(X,eo(ll(C),!0))||[];L=new r(fl(L.body,hl,Q,()=>{ue&&ue(),O&&O()}),H)}I=I||"text";let D=await f[P.findKey(f,I)||"text"](L,w);return!A&&O&&O(),await new Promise((H,X)=>{il(H,X,{data:D,headers:wt.from(L.headers),status:L.status,statusText:L.statusText,config:w,request:z})})}catch(B){throw O&&O(),B&&B.name==="TypeError"&&/Load failed|fetch/i.test(B.message)?Object.assign(new Ne("Network Error",Ne.ERR_NETWORK,w,z),{cause:B.cause||B}):Ne.from(B,B&&B.code,w,z)}}},zm=new Map,xl=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,c,u,d=zm;for(;a--;)c=s[a],u=d.get(c),u===void 0&&d.set(c,u=a?new Map:Fm(t)),d=u;return u};xl();const $s={http:lm,xhr:Pm,fetch:{get:xl}};P.forEach($s,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const vl=e=>`- ${e}`,Bm=e=>P.isFunction(e)||e===null||e===!1,wl={getAdapter:(e,t)=>{e=P.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){r=e[i];let a;if(o=r,!Bm(r)&&(o=$s[(a=String(r)).toLowerCase()],o===void 0))throw new Ne(`Unknown adapter '${a}'`);if(o&&(P.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
33
33
  `+i.map(vl).join(`
34
- `):" "+vl(i[0]):"as no adapter specified";throw new Ee("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:$s};function Fs(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Vn(null,e)}function bl(e){return Fs(e),e.headers=wt.from(e.headers),e.data=Ls.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),wl.getAdapter(e.adapter||hr.adapter,e)(e).then(function(r){return Fs(e),r.data=Ls.call(e,e.transformResponse,r),r.headers=wt.from(r.headers),r},function(r){return sl(r)||(Fs(e),r&&r.response&&(r.response.data=Ls.call(e,e.transformResponse,r.response),r.response.headers=wt.from(r.response.headers))),Promise.reject(r)})}const yl="1.12.2",no={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{no[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Sl={};no.transitional=function(t,n,r){function o(s,i){return"[Axios v"+yl+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Ee(o(i," has been removed"+(n?" in "+n:"")),Ee.ERR_DEPRECATED);return n&&!Sl[i]&&(Sl[i]=!0,console.warn(o(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(s,i,a):!0}},no.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Bm(e,t,n){if(typeof e!="object")throw new Ee("options must be an object",Ee.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const a=e[s],c=a===void 0||i(a,s,e);if(c!==!0)throw new Ee("option "+s+" must be "+c,Ee.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Ee("Unknown option "+s,Ee.ERR_BAD_OPTION)}}const ro={assertOptions:Bm,validators:no},Vt=ro.validators;let kn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new tl,response:new tl}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
35
- `+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=En(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&ro.assertOptions(r,{silentJSONParsing:Vt.transitional(Vt.boolean),forcedJSONParsing:Vt.transitional(Vt.boolean),clarifyTimeoutError:Vt.transitional(Vt.boolean)},!1),o!=null&&(P.isFunction(o)?n.paramsSerializer={serialize:o}:ro.assertOptions(o,{encode:Vt.function,serialize:Vt.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ro.assertOptions(n,{baseUrl:Vt.spelling("baseURL"),withXsrfToken:Vt.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&P.merge(s.common,s[n.method]);s&&P.forEach(["delete","get","head","post","put","patch","common"],w=>{delete s[w]}),n.headers=wt.concat(i,s);const a=[];let c=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(n)===!1||(c=c&&v.synchronous,a.unshift(v.fulfilled,v.rejected))});const u=[];this.interceptors.response.forEach(function(v){u.push(v.fulfilled,v.rejected)});let d,f=0,h;if(!c){const w=[bl.bind(this),void 0];for(w.unshift(...a),w.push(...u),h=w.length,d=Promise.resolve(n);f<h;)d=d.then(w[f++],w[f++]);return d}h=a.length;let m=n;for(;f<h;){const w=a[f++],v=a[f++];try{m=w(m)}catch(g){v.call(this,g);break}}try{d=bl.call(this,m)}catch(w){return Promise.reject(w)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=En(this.defaults,t);const n=cl(t.baseURL,t.url,t.allowAbsoluteUrls);return el(n,t.params,t.paramsSerializer)}};P.forEach(["delete","get","head","options"],function(t){kn.prototype[t]=function(n,r){return this.request(En(r||{},{method:t,url:n,data:(r||{}).data}))}}),P.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(En(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}kn.prototype[t]=n(),kn.prototype[t+"Form"]=n(!0)});let Hm=class vp{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new Vn(s,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new vp(function(o){t=o}),cancel:t}}};function Um(e){return function(n){return e.apply(null,n)}}function Wm(e){return P.isObject(e)&&e.isAxiosError===!0}const zs={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(zs).forEach(([e,t])=>{zs[t]=e});function Cl(e){const t=new kn(e),n=Fa(kn.prototype.request,t);return P.extend(n,kn.prototype,t,{allOwnKeys:!0}),P.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Cl(En(e,o))},n}const et=Cl(hr);et.Axios=kn,et.CanceledError=Vn,et.CancelToken=Hm,et.isCancel=sl,et.VERSION=yl,et.toFormData=Zr,et.AxiosError=Ee,et.Cancel=et.CanceledError,et.all=function(t){return Promise.all(t)},et.spread=Um,et.isAxiosError=Wm,et.mergeConfig=En,et.AxiosHeaders=wt,et.formToJSON=e=>rl(P.isHTMLForm(e)?new FormData(e):e),et.getAdapter=wl.getAdapter,et.HttpStatusCode=zs,et.default=et;const{Axios:TC,AxiosError:EC,CanceledError:kC,isCancel:IC,CancelToken:NC,VERSION:AC,all:_C,Cancel:jC,isAxiosError:RC,spread:PC,toFormData:OC,AxiosHeaders:MC,HttpStatusCode:DC,formToJSON:LC,getAdapter:$C,mergeConfig:FC}=et,Tl=typeof window<"u"?window.__API_BASE_URL__:void 0,El=Tl?Tl.replace(/\/+$/,""):void 0;let oo=null;const Bs=new Set;function kl(){return oo}function Hs(e){oo=e,Bs.forEach(t=>t(e))}function Il(e){return Bs.add(e),()=>Bs.delete(e)}const _t=et.create({...El?{baseURL:El}:{},timeout:3e4,withCredentials:!0});_t.interceptors.request.use(e=>(oo&&(e.headers.Authorization=`Bearer ${oo}`),e)),_t.interceptors.response.use(e=>e,e=>Promise.reject(e));async function St(e,t){return _t.defaults.baseURL?(await _t.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Us(e,t,n){return _t.defaults.baseURL?(await _t.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Nl(e,t,n){return _t.defaults.baseURL?(await _t.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Al(e,t){return _t.defaults.baseURL?(await _t.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Ct(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class _l{get baseUrl(){const t=_t.defaults.baseURL||"";return String(t).replace(/\/+$|^\s+|\s+$/g,"")}updateConfig(t){t.baseUrl&&(_t.defaults.baseURL=String(t.baseUrl).replace(/\/+$/g,"")),t.authToken!==void 0&&Hs(t.authToken)}getAuthToken(){return kl()}setAuthToken(t){Hs(t)}onTokenChange(t){return Il(t)}async listThreads(){const t=await St("/chat/threads"),n=Ct(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Us("/chat/threads",t?{title:t}:void 0);return Ct(r)}async updateThread(t,n){const r=await Nl(`/chat/threads/${t}`,{title:n});return Ct(r)}async deleteThread(t){const n=await Al(`/chat/threads/${t}`);return Ct(n)}async threadInfo(t){const n=await St(`/chat/threads/${t}/info`);return Ct(n)}async listAgents(){const t=await St("/chat/agents"),n=Ct(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await St(`/chat/agents/${t}`);return Ct(n)}async getAgentSchema(t){const n=await St(`/chat/agents/${t}/schema`);return Ct(n)}async getMessages(t){const n=await St(`/chat/threads/${t.threadId}/messages`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs,limit:t.limit,before_id:t.beforeId??void 0}});return Ct(n)}async getState(t){const n=await St(`/chat/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Ct(n)}async getStateHistory(t){const n=await St(`/chat/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Ct(n)}async listCheckpoints(t){const n=await St(`/chat/threads/${t}/checkpoints`,{params:{thread_id:t}});return Ct(n)}async resume(t){const n=await Us("/chat/runs/resume",{thread_id:t.threadId,value:t.value});return Ct(n)}}const cn=new _l,jl=y.createContext(null);function Vm({children:e,apiConfig:t}){const n=cn;y.useEffect(()=>{t&&n.updateConfig({baseUrl:t.baseUrl,authToken:t.apiKey})},[n,t]);const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return l.jsx(jl.Provider,{value:r,children:e})}function so(){const e=y.useContext(jl);if(!e)throw new Error("useApi must be used within ApiProvider");return e}const Rl=y.createContext(null),Pl=y.createContext(null);function Km(e,t){switch(t.type){case"STREAM_START":return{...e,isStreaming:!0,error:null,streamingAssistantId:t.assistantId??null};case"STREAM_END":return{...e,isStreaming:!1,streamingAssistantId:null};case"STREAM_ERROR":return{...e,isStreaming:!1,error:t.error};case"UPDATE_CHECKPOINT":return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:t.checkpointNs??e.lastCheckpointNs};case"UPDATE_ASSEMBLING_ID":return{...e,streamingAssistantId:t.assistantId};case"CLEAR_ERROR":return{...e,error:null};default:return e}}const qm={isStreaming:!1,error:null,streamingAssistantId:null,lastCheckpointId:null,lastCheckpointNs:null};function Gm({children:e}){const[t,n]=y.useReducer(Km,qm);return l.jsx(Pl.Provider,{value:n,children:l.jsx(Rl.Provider,{value:t,children:e})})}function Ol(){const e=y.useContext(Rl);if(!e)throw new Error("useStream must be used within StreamProvider");return e}function Ym(){const e=y.useContext(Pl);if(!e)throw new Error("useStreamDispatch must be used within StreamProvider");return e}function Xm(e,t){const n=e==null?void 0:e.checkpoints,r=Array.isArray(n)?n.slice():n?Object.values(n):[],o=i=>i&&typeof i=="object"&&i!==null&&"checkpointId"in i&&"createdAt"in i&&typeof i.checkpointId=="string"&&typeof i.createdAt=="string",s=r.filter(o).map(i=>{const a=i;return{checkpointId:a.checkpointId,checkpointNs:a.checkpointNs??"",createdAt:a.createdAt,messagesLen:a.messagesLen??0,preview:a.preview??"",role:a.role??null,parentId:a.parentId??null,editedMessageId:a.editedMessageId??null,branchLabel:a.branchLabel??null,lastMessageId:a.lastMessageId??null,hasMessages:typeof a.hasMessages=="boolean"?a.hasMessages:void 0}});return{threadId:(e==null?void 0:e.threadId)??t??null,checkpoints:s}}async function Jm(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let c=0;c<a;c++)i+=String.fromCharCode(s[c]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function Zm(e,t=[],n,r,o,s){const i=[],a=[];for(const c of t)try{const u=await Jm(c);a.push({filename:c.name,data:u,mime_type:c.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const Ml=y.createContext(null),Qm=y.createContext(null);function eg({children:e,initialThreadId:t=null,autoLoadInitial:n=!0,disableAutoRestore:r=!1,onThreadChange:o,onError:s}){const{api:i}=so(),[a,c]=y.useState([]),[u,d]=y.useState(t),[f,h]=y.useState(!1),[m,w]=y.useState(!1),[v,g]=y.useState(void 0),[x,b]=y.useState(void 0),S=y.useRef(!1),k=y.useRef([]),C=y.useRef(null),T=y.useRef(null);y.useRef(!1);const I=y.useRef(u);y.useEffect(()=>{I.current=u},[u]);const N=y.useContext(Qm),_=y.useCallback((D,U)=>new Promise((J,Q)=>{const ce=async()=>{S.current=!0;try{console.log(`[ThreadProvider] Executing operation: ${U||"unnamed"}`),await D(),J()}catch(we){console.error(`[ThreadProvider] Operation "${U}" failed:`,we),Q(we)}finally{S.current=!1;const we=k.current.shift();we&&we().catch(()=>{})}};S.current?(k.current.push(ce),console.log(`[ThreadProvider] Queued operation: ${U||"unnamed"}`)):ce().catch(we=>{Q(we)})}),[]),j=y.useCallback(async()=>{h(!0);try{const D=await i.listThreads();c(D)}catch(D){console.error("[ThreadProvider] Failed to refresh threads:",D),s==null||s(String(D))}finally{h(!1)}},[i,s]),R=y.useCallback(async D=>{const U=await i.createThread(D),J=typeof U=="string"?U:U.threadId;return await j(),d(J),J},[i,j]),z=y.useCallback(async D=>{await i.deleteThread(D),u===D&&(d(null),N==null||N.onThreadCleared()),await j()},[i,u,j,N]),H=y.useCallback(async(D,U)=>{try{await i.updateThread(D,U),c(J=>J.map(Q=>Q.threadId===D?{...Q,title:U}:Q))}catch(J){throw await j(),J}},[i,j]),O=y.useCallback(async(D,U,J,Q=!1)=>{await _(async()=>{if(T.current===D&&!Q){console.log("[ThreadProvider] Skipping load for thread:",D),T.current=null;return}if(C.current===D&&!Q){console.log("[ThreadProvider] Load already in progress for thread:",D);return}C.current=D,w(!0);try{const ce=await i.getMessages({threadId:D,checkpointId:U,checkpointNs:J});N==null||N.onThreadLoaded(D,ce),g((ce==null?void 0:ce.checkpointId)??void 0),b((ce==null?void 0:ce.checkpointNs)??void 0)}finally{C.current=null,w(!1)}},`loadThread-${D}`)},[i,_,N]),W=y.useCallback(async()=>{console.log("[ThreadProvider] 🔄 clearCurrentThread called"),await _(async()=>{u&&(T.current=u),N==null||N.onThreadCleared(),d(null),g(void 0),b(void 0);try{localStorage.removeItem("lastThreadId")}catch(D){console.warn("[ThreadProvider] Failed to clear localStorage:",D)}},"clearCurrentThread")},[u,_,N]),K=y.useCallback(async D=>{const U=await i.listCheckpoints(D);return Xm(U,D)},[i]),G=y.useCallback(async(D,U)=>{if(!u)throw new Error("No active thread");await O(u,D,U??void 0,!0)},[u,O]),$=y.useCallback(async()=>{if(!u)throw new Error("No active thread");await O(u,void 0,void 0,!0)},[u,O]);y.useEffect(()=>{if(o==null||o(u),u)try{localStorage.setItem("lastThreadId",u)}catch(D){console.warn("[ThreadProvider] Failed to persist thread ID:",D)}},[u,o]),y.useEffect(()=>{let D=!0;return(async()=>{try{if(await j(),!D)return;if(!r&&!t)try{const J=localStorage.getItem("lastThreadId");J&&(d(J),n&&await O(J))}catch(J){console.warn("[ThreadProvider] Failed to restore from localStorage:",J)}else t&&n&&await O(t)}catch(J){console.error("[ThreadProvider] Initialization failed:",J),s==null||s(String(J))}})(),()=>{D=!1}},[]);const A={threads:a,currentThreadId:u,isLoadingThreads:f,isLoadingThread:m,setCurrentThreadId:d,createThread:R,deleteThread:z,renameThread:H,refreshThreads:j,loadThread:O,clearCurrentThread:W,listCheckpoints:K,navigateToCheckpoint:G,returnToLatest:$};return l.jsx(Ml.Provider,{value:A,children:e})}function mr(){const e=y.useContext(Ml);if(!e)throw new Error("useThreads must be used within ThreadProvider");return e}function tg(e){return e.type!=="thread_info"&&e.type!=="token"}const ng={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};function rg(e,t){var n;switch(t.type){case"reset":{console.log("[MessageReducer] 🔄 RESET action received"),console.log("[MessageReducer] 📊 Before reset - messages count:",e.messages.length);const r={messages:Ws(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};return console.log("[MessageReducer] 📊 After reset - messages count:",r.messages.length),r}case"seed":{const r=Ws(t.payload.messages),o={...e,messages:r,assemblingId:null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),console.log("[MessageReducer] seed action (REPLACE mode):",{incomingCount:t.payload.messages.length,sanitizedCount:r.length,previousCount:e.messages.length,checkpointId:o.lastCheckpointId}),o}case"prepend":{const r=Ws(t.payload.messages);if(!r.length)return console.log("[MessageReducer] No incoming messages after sanitize - skipping"),e;const o=new Set(e.messages.map(i=>i.id)),s=r.filter(i=>!o.has(i.id));return console.log("[MessageReducer] After dedup:",{uniqueCount:s.length,duplicates:r.length-s.length,finalTotal:s.length+e.messages.length}),s.length?{...e,messages:[...s,...e.messages]}:(console.log("[MessageReducer] All messages were duplicates - skipping"),e)}case"user_message":{const r=t.payload.message;return e.messages.some(o=>o.id===r.id)?e:{...e,messages:[...e.messages,r]}}case"event":return Ll(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Ll(o,s),e):e}case"interrupt_response":{const{interruptId:r}=t.payload,o=e.messages.map(s=>({...s,content:s.content.filter(i=>i.type!=="interrupt")}));return{...e,messages:o,pendingInterrupt:null}}default:return e}}function Dl(e=[]){const[t,n]=y.useReducer(rg,{...ng,messages:e}),r=y.useRef([]),o=y.useRef(null),s=y.useRef(null),i=y.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=y.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),c=y.useCallback(d=>{r.current.push(d),a()},[a]);y.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const u=y.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:d=>n({type:"user_message",payload:{message:d}}),onEvent:c}),[c]);return{state:t,dispatch:n,...u}}function Ll(e,t){var n,r;if(t.type==="message_start"&&t.role==="assistant"){const o=t.id,s=lg(t.model);if(e.messages.some(c=>c.id===o))return{...e,assemblingId:o};const a={id:o,role:"assistant",name:s||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:o,messages:[...e.messages,a]}}if(t.type==="message_delta"){const o=e.assemblingId??Vs(e.messages);return o?{...e,messages:Ks(e.messages,o,t.delta)}:e}if(t.type==="message_end"){const o=e.assemblingId??Vs(e.messages);if(!o)return{...e,assemblingId:null};const s=e.messages,i=s.findIndex(a=>a.id===o&&a.role==="assistant");if(i>=0&&!((n=s[i].content)==null?void 0:n.some(u=>{var d;return(u==null?void 0:u.type)==="text"&&((d=u.text)==null?void 0:d.trim())}))){const u=[...s.slice(0,i),...s.slice(i+1)];return{...e,assemblingId:null,messages:u}}return e}if(t.type==="tool_start"){const o=t.id??t.call_id,s=t.name??t.tool??"tool";if(!o)return e;const i=`tool-${o}`,a={type:"tool_call",id:o,name:s,args:t.args};if(e.messages.find(d=>d.id===i))return{...e,toolIndex:{...e.toolIndex,[o]:i}};const u={id:i,role:"tool",name:s,createdAt:new Date().toISOString(),content:[a]};return{...e,messages:[...e.messages,u],toolIndex:{...e.toolIndex,[o]:i}}}if(t.type==="tool_end"){const o=t.id??t.call_id;if(!o)return e;const s=e.toolIndex[o]??`tool-${o}`,i={type:"tool_end",toolCallId:o,output:t.output,error:t.error},a=e.messages.find(d=>d.id===s),c={id:s,role:"tool",name:t.name??((r=e.messages.find(d=>d.id===s))==null?void 0:r.name),content:[i],createdAt:new Date().toISOString()},u=a?Ks(e.messages,s,[i]):[...e.messages,c];return{...e,messages:u,toolIndex:{...e.toolIndex,[o]:s}}}if(t.type==="checkpoint"){const o=t.checkpointNs??e.lastCheckpointNs??null,s=ag(e.messages,t.checkpointId,o);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:o,messages:s}}if(t.type==="branch"){const o=t.checkpointId??e.lastCheckpointId,s=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:o??null,lastCheckpointNs:s??null}}if(t.type==="error"){const o={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,o]}}if(t.type==="interrupt"){const o=e.assemblingId??Vs(e.messages),s={type:"interrupt",value:t.value};if(o)return{...e,assemblingId:null,messages:Ks(e.messages,o,[s]),pendingInterrupt:{id:t.id,value:t.value}};const i={id:`interrupt-${t.id}`,role:"system",createdAt:new Date().toISOString(),content:[s]};return{...e,messages:[...e.messages,i],pendingInterrupt:{id:t.id,value:t.value}}}return e}function Ws(e){return e.filter(t=>{if(t.role!=="assistant")return!0;const n=(t.content||[]).some(o=>{var s;return o&&o.type==="text"&&((s=o.text)==null?void 0:s.trim())}),r=(t.content||[]).some(o=>o&&o.type==="image_url");return!!(n||r)})}function og(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Vs(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function sg(e,t,n){const r=e.findIndex(i=>i.id===t);if(r===-1)return e;const o=e[r],s=n(o);return s===o?e:[...e.slice(0,r),s,...e.slice(r+1)]}function Ks(e,t,n){return sg(e,t,r=>({...r,content:ig(r.content,n)}))}function ig(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1];(o==null?void 0:o.type)==="text"?o.text+=r.text:n.push({type:"text",text:r.text})}else n.push(r);return n}function ag(e,t,n){for(let r=e.length-1;r>=0;r--)if(e[r].role==="assistant"){const s={...e[r],checkpointId:t,checkpointNs:n??void 0};return og(e,r,s)}return e}function lg(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const cg={MODE:"library"};function ug(){var i;const e=typeof globalThis<"u"?globalThis.process:void 0,t=typeof((i=e==null?void 0:e.env)==null?void 0:i.NODE_ENV)=="string"?e.env.NODE_ENV:void 0;if(t)return t==="production";const n=typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Ns&&Ns.tagName.toUpperCase()==="SCRIPT"&&Ns.src||new URL("index.umd.js",document.baseURI).href}<"u"?cg:void 0,r=typeof(n==null?void 0:n.MODE)=="string"?n.MODE:void 0,o=typeof(n==null?void 0:n.NODE_ENV)=="string"?n.NODE_ENV:void 0;return(r??o)==="production"}function dg(){return!ug()}function fg({onThreadInfo:e,onMessageEvent:t,onUnhandledEvent:n,onSequenceGap:r}){const o=y.useRef(null),s=y.useCallback(a=>{const c=a.seq;if(c!=null){const u=o.current;if(u!==null){if(c<=u){dg()&&console.debug("[StreamEventCoordinator] drop out-of-order seq",{prev:u,seq:c,type:a.type});return}c>u+1&&(r==null||r({from:u,to:c}))}o.current=c}if(a.type==="thread_info"){e==null||e(a);return}if(tg(a)){t(a);return}n==null||n(a)},[t,r,e,n]),i=y.useCallback(()=>{o.current=null},[]);return{handleEvent:s,reset:i}}function $l(e={}){const t=y.useMemo(()=>{const j=(e.baseUrl??"/api/chat").replace(/\/+$/,"");return j.endsWith("/chat")?j:`${j}/chat`},[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=y.useState(e.token??null),s=y.useRef(e.headers??{}),[i,a]=y.useState(!1),[c,u]=y.useState(null),[d,f]=y.useState(""),[h,m]=y.useState(null),[w,v]=y.useState(0),[g,x]=y.useState(!1),b=y.useRef(null),S=y.useRef(!0),k=y.useRef(0),C=y.useCallback(_=>{o(_)},[]),T=y.useCallback(()=>{var _;(_=b.current)==null||_.abort(),b.current=null,a(!1),x(!1)},[]),I=y.useCallback(()=>{f(""),m(null),u(null)},[]),N=y.useCallback((_,j,R)=>{b.current&&(b.current.abort(),b.current=null),a(!0),u(null),e.autoAppendAssistant!==!1&&f("");const z=new AbortController;return b.current=z,(async()=>{var O,W,K,G,$,A,D,U;const H=J=>{var Q;try{const ce=JSON.parse(JSON.stringify(J));return(Q=ce==null?void 0:ce.payload)!=null&&Q.files_info&&Array.isArray(ce.payload.files_info)&&(ce.payload.files_info=ce.payload.files_info.map(we=>({...we,data:we!=null&&we.data?`<base64 ${String(we.data).length} chars>`:we==null?void 0:we.data}))),ce}catch{return J}};try{let J={};try{if(r)J={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const _e=window.__AUTH_TOKEN__,Be=((O=window.localStorage)==null?void 0:O.getItem("authToken"))||null;let qe=null;try{const nt=(W=window.localStorage)==null?void 0:W.getItem("chat-settings");nt&&(qe=((K=JSON.parse(nt))==null?void 0:K.apiKey)||null)}catch{}const $e=_e||Be||qe||null;$e&&(J={Authorization:`Bearer ${$e}`})}}catch{}console.debug("[use-chat] POST",t+n,H(_));const Q=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...J,...s.current},body:JSON.stringify(_),signal:z.signal});if(!Q.ok||!Q.body){const xe=await Q.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",Q.status,xe==null?void 0:xe.slice(0,500)),new Error(`stream ${Q.status}${xe?": "+xe:""}`)}x(!0);const ce=Q.body.getReader(),we=new TextDecoder;let ke="",q=[],M=k.current,X=null;const ee=()=>{if(q.length){const xe=q.join("");q=[],S.current&&f(_e=>_e+xe)}X=null},L=()=>{typeof window<"u"&&X==null&&(X=requestAnimationFrame(ee))};let F=Date.now();const me=setInterval(()=>{var xe;if(Date.now()-F>2e4){const _e="Stream idle timeout";u(_e),z.abort(),(xe=R==null?void 0:R.onError)==null||xe.call(R,_e)}},5e3),Re=1024*1024;try{const xe=Q.headers.get("X-Thread-Id")||Q.headers.get("x-thread-id"),_e=Q.headers.get("X-Thread-Created")||Q.headers.get("x-thread-created"),Be=xe??null,qe=String(_e??"").toLowerCase()==="true";for((G=R==null?void 0:R.onOpen)==null||G.call(R,{threadId:Be,created:qe});;){const{value:$e,done:nt}=await ce.read();if(nt)break;ke+=we.decode($e,{stream:!0}),ke.length>Re&&(ke="",console.warn("Stream buffer reset: exceeded 1MB"));let at;for(;(at=ke.indexOf(`
34
+ `):" "+vl(i[0]):"as no adapter specified";throw new Ne("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:$s};function Fs(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Vn(null,e)}function bl(e){return Fs(e),e.headers=wt.from(e.headers),e.data=Ls.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),wl.getAdapter(e.adapter||hr.adapter,e)(e).then(function(r){return Fs(e),r.data=Ls.call(e,e.transformResponse,r),r.headers=wt.from(r.headers),r},function(r){return sl(r)||(Fs(e),r&&r.response&&(r.response.data=Ls.call(e,e.transformResponse,r.response),r.response.headers=wt.from(r.response.headers))),Promise.reject(r)})}const yl="1.12.2",no={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{no[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Sl={};no.transitional=function(t,n,r){function o(s,i){return"[Axios v"+yl+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Ne(o(i," has been removed"+(n?" in "+n:"")),Ne.ERR_DEPRECATED);return n&&!Sl[i]&&(Sl[i]=!0,console.warn(o(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(s,i,a):!0}},no.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Hm(e,t,n){if(typeof e!="object")throw new Ne("options must be an object",Ne.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const a=e[s],c=a===void 0||i(a,s,e);if(c!==!0)throw new Ne("option "+s+" must be "+c,Ne.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Ne("Unknown option "+s,Ne.ERR_BAD_OPTION)}}const ro={assertOptions:Hm,validators:no},Vt=ro.validators;let kn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new tl,response:new tl}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
35
+ `+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=En(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&ro.assertOptions(r,{silentJSONParsing:Vt.transitional(Vt.boolean),forcedJSONParsing:Vt.transitional(Vt.boolean),clarifyTimeoutError:Vt.transitional(Vt.boolean)},!1),o!=null&&(P.isFunction(o)?n.paramsSerializer={serialize:o}:ro.assertOptions(o,{encode:Vt.function,serialize:Vt.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ro.assertOptions(n,{baseUrl:Vt.spelling("baseURL"),withXsrfToken:Vt.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&P.merge(s.common,s[n.method]);s&&P.forEach(["delete","get","head","post","put","patch","common"],w=>{delete s[w]}),n.headers=wt.concat(i,s);const a=[];let c=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(n)===!1||(c=c&&v.synchronous,a.unshift(v.fulfilled,v.rejected))});const u=[];this.interceptors.response.forEach(function(v){u.push(v.fulfilled,v.rejected)});let d,f=0,h;if(!c){const w=[bl.bind(this),void 0];for(w.unshift(...a),w.push(...u),h=w.length,d=Promise.resolve(n);f<h;)d=d.then(w[f++],w[f++]);return d}h=a.length;let m=n;for(;f<h;){const w=a[f++],v=a[f++];try{m=w(m)}catch(g){v.call(this,g);break}}try{d=bl.call(this,m)}catch(w){return Promise.reject(w)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=En(this.defaults,t);const n=cl(t.baseURL,t.url,t.allowAbsoluteUrls);return el(n,t.params,t.paramsSerializer)}};P.forEach(["delete","get","head","options"],function(t){kn.prototype[t]=function(n,r){return this.request(En(r||{},{method:t,url:n,data:(r||{}).data}))}}),P.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(En(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}kn.prototype[t]=n(),kn.prototype[t+"Form"]=n(!0)});let Um=class wp{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new Vn(s,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new wp(function(o){t=o}),cancel:t}}};function Wm(e){return function(n){return e.apply(null,n)}}function Vm(e){return P.isObject(e)&&e.isAxiosError===!0}const zs={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(zs).forEach(([e,t])=>{zs[t]=e});function Cl(e){const t=new kn(e),n=Fa(kn.prototype.request,t);return P.extend(n,kn.prototype,t,{allOwnKeys:!0}),P.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Cl(En(e,o))},n}const tt=Cl(hr);tt.Axios=kn,tt.CanceledError=Vn,tt.CancelToken=Um,tt.isCancel=sl,tt.VERSION=yl,tt.toFormData=Zr,tt.AxiosError=Ne,tt.Cancel=tt.CanceledError,tt.all=function(t){return Promise.all(t)},tt.spread=Wm,tt.isAxiosError=Vm,tt.mergeConfig=En,tt.AxiosHeaders=wt,tt.formToJSON=e=>rl(P.isHTMLForm(e)?new FormData(e):e),tt.getAdapter=wl.getAdapter,tt.HttpStatusCode=zs,tt.default=tt;const{Axios:EC,AxiosError:kC,CanceledError:IC,isCancel:NC,CancelToken:AC,VERSION:_C,all:jC,Cancel:RC,isAxiosError:PC,spread:OC,toFormData:MC,AxiosHeaders:DC,HttpStatusCode:LC,formToJSON:$C,getAdapter:FC,mergeConfig:zC}=tt,Tl=typeof window<"u"?window.__API_BASE_URL__:void 0,El=Tl?Tl.replace(/\/+$/,""):void 0;let oo=null;const Bs=new Set;function kl(){return oo}function Hs(e){oo=e,Bs.forEach(t=>t(e))}function Il(e){return Bs.add(e),()=>Bs.delete(e)}const _t=tt.create({...El?{baseURL:El}:{},timeout:3e4,withCredentials:!0});_t.interceptors.request.use(e=>(oo&&(e.headers.Authorization=`Bearer ${oo}`),e)),_t.interceptors.response.use(e=>e,e=>Promise.reject(e));async function St(e,t){return _t.defaults.baseURL?(await _t.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Us(e,t,n){return _t.defaults.baseURL?(await _t.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Nl(e,t,n){return _t.defaults.baseURL?(await _t.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Al(e,t){return _t.defaults.baseURL?(await _t.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Ct(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class _l{get baseUrl(){const t=_t.defaults.baseURL||"";return String(t).replace(/\/+$|^\s+|\s+$/g,"")}updateConfig(t){t.baseUrl&&(_t.defaults.baseURL=String(t.baseUrl).replace(/\/+$/g,"")),t.authToken!==void 0&&Hs(t.authToken)}getAuthToken(){return kl()}setAuthToken(t){Hs(t)}onTokenChange(t){return Il(t)}async listThreads(){const t=await St("/chat/threads"),n=Ct(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Us("/chat/threads",t?{title:t}:void 0);return Ct(r)}async updateThread(t,n){const r=await Nl(`/chat/threads/${t}`,{title:n});return Ct(r)}async deleteThread(t){const n=await Al(`/chat/threads/${t}`);return Ct(n)}async threadInfo(t){const n=await St(`/chat/threads/${t}/info`);return Ct(n)}async listAgents(){const t=await St("/chat/agents"),n=Ct(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await St(`/chat/agents/${t}`);return Ct(n)}async getAgentSchema(t){const n=await St(`/chat/agents/${t}/schema`);return Ct(n)}async getMessages(t){const n=await St(`/chat/threads/${t.threadId}/messages`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs,limit:t.limit,before_id:t.beforeId??void 0}});return Ct(n)}async getState(t){const n=await St(`/chat/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Ct(n)}async getStateHistory(t){const n=await St(`/chat/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Ct(n)}async listCheckpoints(t){const n=await St(`/chat/threads/${t}/checkpoints`,{params:{thread_id:t}});return Ct(n)}async resume(t){const n=await Us("/chat/runs/resume",{thread_id:t.threadId,value:t.value});return Ct(n)}}const cn=new _l,jl=y.createContext(null);function Km({children:e,apiConfig:t}){const n=cn;y.useEffect(()=>{t&&n.updateConfig({baseUrl:t.baseUrl,authToken:t.apiKey})},[n,t]);const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return l.jsx(jl.Provider,{value:r,children:e})}function so(){const e=y.useContext(jl);if(!e)throw new Error("useApi must be used within ApiProvider");return e}const Rl=y.createContext(null),Pl=y.createContext(null);function qm(e,t){switch(t.type){case"STREAM_START":return{...e,isStreaming:!0,error:null,streamingAssistantId:t.assistantId??null};case"STREAM_END":return{...e,isStreaming:!1,streamingAssistantId:null};case"STREAM_ERROR":return{...e,isStreaming:!1,error:t.error};case"UPDATE_CHECKPOINT":return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:t.checkpointNs??e.lastCheckpointNs};case"UPDATE_ASSEMBLING_ID":return{...e,streamingAssistantId:t.assistantId};case"CLEAR_ERROR":return{...e,error:null};default:return e}}const Gm={isStreaming:!1,error:null,streamingAssistantId:null,lastCheckpointId:null,lastCheckpointNs:null};function Ym({children:e}){const[t,n]=y.useReducer(qm,Gm);return l.jsx(Pl.Provider,{value:n,children:l.jsx(Rl.Provider,{value:t,children:e})})}function Ol(){const e=y.useContext(Rl);if(!e)throw new Error("useStream must be used within StreamProvider");return e}function Xm(){const e=y.useContext(Pl);if(!e)throw new Error("useStreamDispatch must be used within StreamProvider");return e}function Jm(e,t){const n=e==null?void 0:e.checkpoints,r=Array.isArray(n)?n.slice():n?Object.values(n):[],o=i=>i&&typeof i=="object"&&i!==null&&"checkpointId"in i&&"createdAt"in i&&typeof i.checkpointId=="string"&&typeof i.createdAt=="string",s=r.filter(o).map(i=>{const a=i;return{checkpointId:a.checkpointId,checkpointNs:a.checkpointNs??"",createdAt:a.createdAt,messagesLen:a.messagesLen??0,preview:a.preview??"",role:a.role??null,parentId:a.parentId??null,editedMessageId:a.editedMessageId??null,branchLabel:a.branchLabel??null,lastMessageId:a.lastMessageId??null,hasMessages:typeof a.hasMessages=="boolean"?a.hasMessages:void 0}});return{threadId:(e==null?void 0:e.threadId)??t??null,checkpoints:s}}async function Zm(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let c=0;c<a;c++)i+=String.fromCharCode(s[c]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function Qm(e,t=[],n,r,o,s){const i=[],a=[];for(const c of t)try{const u=await Zm(c);a.push({filename:c.name,data:u,mime_type:c.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const Ml=y.createContext(null),Dl=y.createContext(null);function eg({children:e,initialThreadId:t=null,autoLoadInitial:n=!0,disableAutoRestore:r=!1,onThreadChange:o,onError:s}){const{api:i}=so(),[a,c]=y.useState([]),[u,d]=y.useState(t),[f,h]=y.useState(!1),[m,w]=y.useState(!1),[v,g]=y.useState(void 0),[x,b]=y.useState(void 0),S=y.useRef(!1),k=y.useRef([]),C=y.useRef(null),T=y.useRef(null);y.useRef(!1);const I=y.useRef(u);y.useEffect(()=>{I.current=u},[u]);const N=y.useContext(Dl),_=y.useCallback((D,H)=>new Promise((X,Q)=>{const ue=async()=>{S.current=!0;try{console.log(`[ThreadProvider] Executing operation: ${H||"unnamed"}`),await D(),X()}catch(we){console.error(`[ThreadProvider] Operation "${H}" failed:`,we),Q(we)}finally{S.current=!1;const we=k.current.shift();we&&we().catch(()=>{})}};S.current?(k.current.push(ue),console.log(`[ThreadProvider] Queued operation: ${H||"unnamed"}`)):ue().catch(we=>{Q(we)})}),[]),j=y.useCallback(async()=>{h(!0);try{const D=await i.listThreads();c(D)}catch(D){console.error("[ThreadProvider] Failed to refresh threads:",D),s==null||s(String(D))}finally{h(!1)}},[i,s]),R=y.useCallback(async D=>{const H=await i.createThread(D),X=typeof H=="string"?H:H.threadId;return await j(),d(X),X},[i,j]),$=y.useCallback(async D=>{await i.deleteThread(D),u===D&&(d(null),N==null||N.onThreadCleared()),await j()},[i,u,j,N]),z=y.useCallback(async(D,H)=>{try{await i.updateThread(D,H),c(X=>X.map(Q=>Q.threadId===D?{...Q,title:H}:Q))}catch(X){throw await j(),X}},[i,j]),O=y.useCallback(async(D,H,X,Q=!1)=>{await _(async()=>{if(T.current===D&&!Q){console.log("[ThreadProvider] Skipping load for thread:",D),T.current=null;return}if(C.current===D&&!Q){console.log("[ThreadProvider] Load already in progress for thread:",D);return}d(ue=>ue===D?ue:D),C.current=D,w(!0);try{const ue=await i.getMessages({threadId:D,checkpointId:H,checkpointNs:X});N==null||N.onThreadLoaded(D,ue),g((ue==null?void 0:ue.checkpointId)??void 0),b((ue==null?void 0:ue.checkpointNs)??void 0)}finally{C.current=null,w(!1)}},`loadThread-${D}`)},[i,_,N,d]),W=y.useCallback(async()=>{console.log("[ThreadProvider] 🔄 clearCurrentThread called"),await _(async()=>{u&&(T.current=u),N==null||N.onThreadCleared(),d(null),g(void 0),b(void 0);try{localStorage.removeItem("lastThreadId")}catch(D){console.warn("[ThreadProvider] Failed to clear localStorage:",D)}},"clearCurrentThread")},[u,_,N]),B=y.useCallback(async D=>{const H=await i.listCheckpoints(D);return Jm(H,D)},[i]),q=y.useCallback(async(D,H)=>{if(!u)throw new Error("No active thread");await O(u,D,H??void 0,!0)},[u,O]),L=y.useCallback(async()=>{if(!u)throw new Error("No active thread");await O(u,void 0,void 0,!0)},[u,O]);y.useEffect(()=>{if(o==null||o(u),u)try{localStorage.setItem("lastThreadId",u)}catch(D){console.warn("[ThreadProvider] Failed to persist thread ID:",D)}},[u,o]),y.useEffect(()=>{let D=!0;return(async()=>{try{if(await j(),!D)return;if(!r&&!t)try{const X=localStorage.getItem("lastThreadId");X&&(d(X),n&&await O(X))}catch(X){console.warn("[ThreadProvider] Failed to restore from localStorage:",X)}else t&&n&&await O(t)}catch(X){console.error("[ThreadProvider] Initialization failed:",X),s==null||s(String(X))}})(),()=>{D=!1}},[]);const A={threads:a,currentThreadId:u,isLoadingThreads:f,isLoadingThread:m,setCurrentThreadId:d,createThread:R,deleteThread:$,renameThread:z,refreshThreads:j,loadThread:O,clearCurrentThread:W,listCheckpoints:B,navigateToCheckpoint:q,returnToLatest:L};return l.jsx(Ml.Provider,{value:A,children:e})}function mr(){const e=y.useContext(Ml);if(!e)throw new Error("useThreads must be used within ThreadProvider");return e}function tg({children:e,onThreadLoaded:t,onThreadCleared:n,...r}){return l.jsx(Dl.Provider,{value:{onThreadLoaded:t,onThreadCleared:n},children:l.jsx(eg,{...r,children:e})})}function ng(e){return e.type!=="thread_info"&&e.type!=="token"}const rg={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};function og(e,t){var n;switch(t.type){case"reset":{console.log("[MessageReducer] 🔄 RESET action received"),console.log("[MessageReducer] 📊 Before reset - messages count:",e.messages.length);const r={messages:Ws(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};return console.log("[MessageReducer] 📊 After reset - messages count:",r.messages.length),r}case"seed":{const r=Ws(t.payload.messages),o={...e,messages:r,assemblingId:null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),console.log("[MessageReducer] seed action (REPLACE mode):",{incomingCount:t.payload.messages.length,sanitizedCount:r.length,previousCount:e.messages.length,checkpointId:o.lastCheckpointId}),o}case"prepend":{const r=Ws(t.payload.messages);if(!r.length)return console.log("[MessageReducer] No incoming messages after sanitize - skipping"),e;const o=new Set(e.messages.map(i=>i.id)),s=r.filter(i=>!o.has(i.id));return console.log("[MessageReducer] After dedup:",{uniqueCount:s.length,duplicates:r.length-s.length,finalTotal:s.length+e.messages.length}),s.length?{...e,messages:[...s,...e.messages]}:(console.log("[MessageReducer] All messages were duplicates - skipping"),e)}case"user_message":{const r=t.payload.message;return e.messages.some(o=>o.id===r.id)?e:{...e,messages:[...e.messages,r]}}case"event":return $l(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>$l(o,s),e):e}case"interrupt_response":{const{interruptId:r}=t.payload,o=e.messages.map(s=>({...s,content:s.content.filter(i=>i.type!=="interrupt")}));return{...e,messages:o,pendingInterrupt:null}}default:return e}}function Ll(e=[]){const[t,n]=y.useReducer(og,{...rg,messages:e}),r=y.useRef([]),o=y.useRef(null),s=y.useRef(null),i=y.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=y.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),c=y.useCallback(d=>{r.current.push(d),a()},[a]);y.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const u=y.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:d=>n({type:"user_message",payload:{message:d}}),onEvent:c}),[c]);return{state:t,dispatch:n,...u}}function $l(e,t){var n,r;if(t.type==="message_start"&&t.role==="assistant"){const o=t.id,s=cg(t.model);if(e.messages.some(c=>c.id===o))return{...e,assemblingId:o};const a={id:o,role:"assistant",name:s||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:o,messages:[...e.messages,a]}}if(t.type==="message_delta"){const o=e.assemblingId??Vs(e.messages);return o?{...e,messages:Ks(e.messages,o,t.delta)}:e}if(t.type==="message_end"){const o=e.assemblingId??Vs(e.messages);if(!o)return{...e,assemblingId:null};const s=e.messages,i=s.findIndex(a=>a.id===o&&a.role==="assistant");if(i>=0&&!((n=s[i].content)==null?void 0:n.some(u=>{var d;return(u==null?void 0:u.type)==="text"&&((d=u.text)==null?void 0:d.trim())}))){const u=[...s.slice(0,i),...s.slice(i+1)];return{...e,assemblingId:null,messages:u}}return e}if(t.type==="tool_start"){const o=t.id??t.call_id,s=t.name??t.tool??"tool";if(!o)return e;const i=`tool-${o}`,a={type:"tool_call",id:o,name:s,args:t.args};if(e.messages.find(d=>d.id===i))return{...e,toolIndex:{...e.toolIndex,[o]:i}};const u={id:i,role:"tool",name:s,createdAt:new Date().toISOString(),content:[a]};return{...e,messages:[...e.messages,u],toolIndex:{...e.toolIndex,[o]:i}}}if(t.type==="tool_end"){const o=t.id??t.call_id;if(!o)return e;const s=e.toolIndex[o]??`tool-${o}`,i={type:"tool_end",toolCallId:o,output:t.output,error:t.error},a=e.messages.find(d=>d.id===s),c={id:s,role:"tool",name:t.name??((r=e.messages.find(d=>d.id===s))==null?void 0:r.name),content:[i],createdAt:new Date().toISOString()},u=a?Ks(e.messages,s,[i]):[...e.messages,c];return{...e,messages:u,toolIndex:{...e.toolIndex,[o]:s}}}if(t.type==="checkpoint"){const o=t.checkpointNs??e.lastCheckpointNs??null,s=lg(e.messages,t.checkpointId,o);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:o,messages:s}}if(t.type==="branch"){const o=t.checkpointId??e.lastCheckpointId,s=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:o??null,lastCheckpointNs:s??null}}if(t.type==="error"){const o={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,o]}}if(t.type==="interrupt"){const o=e.assemblingId??Vs(e.messages),s={type:"interrupt",value:t.value};if(o)return{...e,assemblingId:null,messages:Ks(e.messages,o,[s]),pendingInterrupt:{id:t.id,value:t.value}};const i={id:`interrupt-${t.id}`,role:"system",createdAt:new Date().toISOString(),content:[s]};return{...e,messages:[...e.messages,i],pendingInterrupt:{id:t.id,value:t.value}}}return e}function Ws(e){return e.filter(t=>{if(t.role!=="assistant")return!0;const n=(t.content||[]).some(o=>{var s;return o&&o.type==="text"&&((s=o.text)==null?void 0:s.trim())}),r=(t.content||[]).some(o=>o&&o.type==="image_url");return!!(n||r)})}function sg(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Vs(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function ig(e,t,n){const r=e.findIndex(i=>i.id===t);if(r===-1)return e;const o=e[r],s=n(o);return s===o?e:[...e.slice(0,r),s,...e.slice(r+1)]}function Ks(e,t,n){return ig(e,t,r=>({...r,content:ag(r.content,n)}))}function ag(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1];(o==null?void 0:o.type)==="text"?o.text+=r.text:n.push({type:"text",text:r.text})}else n.push(r);return n}function lg(e,t,n){for(let r=e.length-1;r>=0;r--)if(e[r].role==="assistant"){const s={...e[r],checkpointId:t,checkpointNs:n??void 0};return sg(e,r,s)}return e}function cg(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const ug={MODE:"library"};function dg(){var i;const e=typeof globalThis<"u"?globalThis.process:void 0,t=typeof((i=e==null?void 0:e.env)==null?void 0:i.NODE_ENV)=="string"?e.env.NODE_ENV:void 0;if(t)return t==="production";const n=typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Ns&&Ns.tagName.toUpperCase()==="SCRIPT"&&Ns.src||new URL("index.umd.js",document.baseURI).href}<"u"?ug:void 0,r=typeof(n==null?void 0:n.MODE)=="string"?n.MODE:void 0,o=typeof(n==null?void 0:n.NODE_ENV)=="string"?n.NODE_ENV:void 0;return(r??o)==="production"}function fg(){return!dg()}function hg({onThreadInfo:e,onMessageEvent:t,onUnhandledEvent:n,onSequenceGap:r}){const o=y.useRef(null),s=y.useCallback(a=>{const c=a.seq;if(c!=null){const u=o.current;if(u!==null){if(c<=u){fg()&&console.debug("[StreamEventCoordinator] drop out-of-order seq",{prev:u,seq:c,type:a.type});return}c>u+1&&(r==null||r({from:u,to:c}))}o.current=c}if(a.type==="thread_info"){e==null||e(a);return}if(ng(a)){t(a);return}n==null||n(a)},[t,r,e,n]),i=y.useCallback(()=>{o.current=null},[]);return{handleEvent:s,reset:i}}function Fl(e={}){const t=y.useMemo(()=>{const j=(e.baseUrl??"/api/chat").replace(/\/+$/,"");return j.endsWith("/chat")?j:`${j}/chat`},[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=y.useState(e.token??null),s=y.useRef(e.headers??{}),[i,a]=y.useState(!1),[c,u]=y.useState(null),[d,f]=y.useState(""),[h,m]=y.useState(null),[w,v]=y.useState(0),[g,x]=y.useState(!1),b=y.useRef(null),S=y.useRef(!0),k=y.useRef(0),C=y.useCallback(_=>{o(_)},[]),T=y.useCallback(()=>{var _;(_=b.current)==null||_.abort(),b.current=null,a(!1),x(!1)},[]),I=y.useCallback(()=>{f(""),m(null),u(null)},[]),N=y.useCallback((_,j,R)=>{b.current&&(b.current.abort(),b.current=null),a(!0),u(null),e.autoAppendAssistant!==!1&&f("");const $=new AbortController;return b.current=$,(async()=>{var O,W,B,q,L,A,D,H;const z=X=>{var Q;try{const ue=JSON.parse(JSON.stringify(X));return(Q=ue==null?void 0:ue.payload)!=null&&Q.files_info&&Array.isArray(ue.payload.files_info)&&(ue.payload.files_info=ue.payload.files_info.map(we=>({...we,data:we!=null&&we.data?`<base64 ${String(we.data).length} chars>`:we==null?void 0:we.data}))),ue}catch{return X}};try{let X={};try{if(r)X={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const J=window.__AUTH_TOKEN__,be=((O=window.localStorage)==null?void 0:O.getItem("authToken"))||null;let Oe=null;try{const et=(W=window.localStorage)==null?void 0:W.getItem("chat-settings");et&&(Oe=((B=JSON.parse(et))==null?void 0:B.apiKey)||null)}catch{}const _e=J||be||Oe||null;_e&&(X={Authorization:`Bearer ${_e}`})}}catch{}console.debug("[use-chat] POST",t+n,z(_));const Q=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...X,...s.current},body:JSON.stringify(_),signal:$.signal});if(!Q.ok||!Q.body){const V=await Q.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",Q.status,V==null?void 0:V.slice(0,500)),new Error(`stream ${Q.status}${V?": "+V:""}`)}x(!0);const ue=Q.body.getReader(),we=new TextDecoder;let Ie="",K=[],M=k.current,Y=null;const ee=()=>{if(K.length){const V=K.join("");K=[],S.current&&f(J=>J+V)}Y=null},de=()=>{typeof window<"u"&&Y==null&&(Y=requestAnimationFrame(ee))};let ce=Date.now();const ze=setInterval(()=>{var V;if(Date.now()-ce>2e4){const J="Stream idle timeout";u(J),$.abort(),(V=R==null?void 0:R.onError)==null||V.call(R,J)}},5e3),Ye=1024*1024;try{const V=Q.headers.get("X-Thread-Id")||Q.headers.get("x-thread-id"),J=Q.headers.get("X-Thread-Created")||Q.headers.get("x-thread-created"),be=V??null,Oe=String(J??"").toLowerCase()==="true";for((q=R==null?void 0:R.onOpen)==null||q.call(R,{threadId:be,created:Oe});;){const{value:_e,done:et}=await ue.read();if(et)break;Ie+=we.decode(_e,{stream:!0}),Ie.length>Ye&&(Ie="",console.warn("Stream buffer reset: exceeded 1MB"));let st;for(;(st=Ie.indexOf(`
36
36
 
37
- `))>=0;){const ie=ke.slice(0,at);ke=ke.slice(at+2);const te=pg(ie);if(!te)continue;let pe;try{pe=JSON.parse(te)}catch{console.debug("[use-chat] malformed SSE:",te.slice(0,200));continue}const de=hg(pe)?pe.data:pe;F=Date.now();const Ne=de.seq;if(Ne!==void 0){if(Ne<=M){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:Ne,lastProcessedSeq:M,type:de.type});continue}M>0&&Ne>M+1&&(($=R==null?void 0:R.onGap)==null||$.call(R,{from:M,to:Ne})),M=Ne,k.current=Ne,v(Ne)}if(j==null||j(de),de.type==="token"&&e.autoAppendAssistant!==!1)q.push(de.content),L();else if(de.type==="message_delta"){const Fe=de.delta.filter(Xe=>Xe.type==="text").map(Xe=>Xe.text).join("");Fe&&e.autoAppendAssistant!==!1&&(q.push(Fe),L())}else X!==null&&cancelAnimationFrame(X),ee(),de.type==="checkpoint"?m(de.checkpointId):de.type==="error"&&u(de.message)}}ee()}catch(xe){if(xe.name!=="AbortError"){const _e=xe.message||String(xe);u(_e),(A=R==null?void 0:R.onError)==null||A.call(R,_e)}}finally{try{await ce.cancel()}catch{}finally{(D=ce.releaseLock)==null||D.call(ce)}X!==null&&typeof window<"u"&&window.cancelAnimationFrame(X),clearInterval(me),a(!1),x(!1),b.current=null}}catch(J){if(J.name!=="AbortError"){const Q=J.message||String(J);u(Q),(U=R==null?void 0:R.onError)==null||U.call(R,Q)}}finally{a(!1),x(!1),b.current=null}})(),{close:()=>z.abort()}},[t,n,r,e.autoAppendAssistant]);return y.useEffect(()=>()=>{var _;S.current=!1,(_=b.current)==null||_.abort()},[]),{isStreaming:i,error:c,assistantText:d,lastCheckpointId:h,lastSeq:w,connected:g,stream:N,stop:T,clear:I,setToken:C}}function hg(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function pg(e){const t=e.split(/\r?\n/),n=[];for(const r of t)if(r&&!r.startsWith(":")&&r.startsWith("data:")){const o=r.slice(5);n.push(o.startsWith(" ")?o.slice(1):o)}return n.length===0?null:n.join(`
38
- `)}const Fl=y.createContext(null);function mg({children:e,enableFileAgentRouting:t=!1,fileAgentId:n="invoice_reader"}){const{api:r,baseUrl:o}=so(),s=y.useMemo(()=>{const L=(o??"").replace(/\/+$/,"");return L?L.endsWith("/chat")?L:`${L}/chat`:"/api/chat"},[o]),{currentThreadId:i,setCurrentThreadId:a,isLoadingThread:c}=mr(),u=Ym(),{state:d,dispatch:f,seed:h,prepend:m,pushUser:w,onEvent:v,reset:g}=Dl(),[x,b]=y.useState(!1),[S,k]=y.useState(!1),[C,T]=y.useState(null),[I,N]=y.useState(void 0),[_,j]=y.useState(void 0),R=20,z=y.useRef(i);y.useEffect(()=>{z.current=i},[i]);const H=y.useRef(null),O=y.useRef(!1),W=y.useCallback(()=>{O.current=!0},[]),{isStreaming:K,error:G,stream:$,stop:A,setToken:D}=$l({baseUrl:s,token:null});y.useEffect(()=>{const L=r.getAuthToken();D(L)},[r,D]),y.useEffect(()=>{u(K?{type:"STREAM_START",assistantId:d.assemblingId??void 0}:{type:"STREAM_END"})},[K,d.assemblingId,u]),y.useEffect(()=>{u(G?{type:"STREAM_ERROR",error:G}:{type:"CLEAR_ERROR"})},[G,u]),y.useEffect(()=>{d.lastCheckpointId&&u({type:"UPDATE_CHECKPOINT",checkpointId:d.lastCheckpointId,checkpointNs:d.lastCheckpointNs??void 0})},[d.lastCheckpointId,d.lastCheckpointNs,u]),y.useEffect(()=>{u({type:"UPDATE_ASSEMBLING_ID",assistantId:d.assemblingId})},[d.assemblingId,u]);const U=y.useCallback((L,F)=>{const me=Array.isArray(L==null?void 0:L.messages)?L.messages:[];F==="replace"?(console.log("[MessagesProvider] Replacing messages, count:",me.length),h(me,{checkpointId:(L==null?void 0:L.checkpointId)??null,checkpointNs:(L==null?void 0:L.checkpointNs)??null})):F==="prepend"&&me.length&&(console.log("[MessagesProvider] Prepending messages, count:",me.length),m(me)),T((L==null?void 0:L.nextCursor)??null),b(!!(L!=null&&L.hasMore)),N(Re=>(L==null?void 0:L.checkpointId)??Re??void 0),j(Re=>(L==null?void 0:L.checkpointNs)??Re??void 0)},[h,m]),J=y.useCallback(L=>{const F=L.threadId,me=!!L.created,Re=!!L.ready;if(i!==F){const xe=!i&&d.messages.length<=1;xe&&(H.current=F),a(F),(Re||me||xe)&&W();return}(Re||me)&&W()},[i,d.messages.length,a,W]),Q=y.useCallback(({from:L,to:F})=>{const me=z.current;me&&console.warn(`[MessagesProvider] Stream sequence gap detected (${L} -> ${F}) for thread ${me}`)},[]),{handleEvent:ce,reset:we}=fg({onThreadInfo:J,onMessageEvent:v,onUnhandledEvent:L=>{console.warn(`[MessagesProvider] Unhandled stream event type: ${L.type}`,L)},onSequenceGap:Q}),ke=y.useCallback(async L=>{if(!i)throw new Error("No active thread");if(S||!x)return;const F=C;if(F){k(!0);try{const me=await r.getMessages({threadId:i,checkpointId:I,checkpointNs:_,limit:(L==null?void 0:L.limit)??R,beforeId:F});U(me,"prepend")}finally{k(!1)}}},[r,i,I,_,C,x,S,U,R]),q=y.useCallback(()=>{console.log("[MessagesProvider] Clearing messages"),g([]),b(!1),k(!1),T(null),N(void 0),j(void 0)},[g]),M=y.useCallback(async(L,F)=>{var ie;!i&&!(F!=null&&F.payloadExtras)&&console.warn("[MessagesProvider] No thread ID - message will create new thread");const me=(F==null?void 0:F.attachments)||[],{contentParts:Re,filesInfo:xe}=await Zm(r,me),_e=[...Re];L&&L.trim()&&_e.push({type:"text",text:L.trim()});const Be={id:((ie=crypto.randomUUID)==null?void 0:ie.call(crypto))||`user-${Date.now()}`,role:"user",content:_e,createdAt:new Date().toISOString(),checkpointId:(F==null?void 0:F.checkpointId)??d.lastCheckpointId??void 0,checkpointNs:(F==null?void 0:F.checkpointNs)??d.lastCheckpointNs??void 0};w(Be);const qe={...Be,content:_e},$e={...(F==null?void 0:F.payloadExtras)??{}},nt=me&&me.length>0,at={...i?{threadId:i}:{},payload:{messages:[qe],files_info:xe,...t&&nt&&n?{active_agent:n}:{},...$e},checkpointId:(F==null?void 0:F.checkpointId)??d.lastCheckpointId??void 0,checkpointNs:(F==null?void 0:F.checkpointNs)??d.lastCheckpointNs??void 0,nodeFilter:F==null?void 0:F.nodeFilter,config:F==null?void 0:F.config};we(),W(),$(at,te=>{ce(te)},{onError:te=>console.warn("[MessagesProvider] Stream error:",te),onOpen:({threadId:te,created:pe})=>{if(!i&&te){const de=d.messages.length<=1;de&&(H.current=te),a(te),(pe||de)&&W()}},onGap:Q})},[i,w,$,ce,we,Q,d.lastCheckpointId,d.lastCheckpointNs,d.messages.length,r,W,a,t,n]),X=y.useCallback(async(L,F,me)=>{const Re=z.current;if(!Re)throw new Error("No active thread to handle interrupt");try{console.log(`[MessagesProvider] Handling interrupt ${L}: ${F?"approved":"rejected"}`);const xe=F?me??!0:!1;await r.resume({threadId:Re,value:xe}),console.log(`[MessagesProvider] Interrupt ${L} handled successfully`)}catch(xe){throw console.error(`[MessagesProvider] Failed to handle interrupt ${L}:`,xe),xe}},[r]),ee={messages:d.messages,assemblingId:d.assemblingId,lastUserMessage:null,hasMoreHistory:x,isLoadingHistory:S,send:M,stop:A,loadOlderMessages:ke,clearMessages:q,handleInterrupt:X};return l.jsx(Fl.Provider,{value:ee,children:e})}function gg(e){return l.jsx(mg,{...e})}function qs(){const e=y.useContext(Fl);if(!e)throw new Error("useMessages must be used within MessagesProvider");return e}function io({children:e,apiConfig:t,initialThreadId:n=null,autoLoadInitial:r=!0,disableAutoRestore:o=!1,enableFileAgentRouting:s=!1,fileAgentId:i="invoice_reader",onError:a,onThreadChange:c}){return l.jsx(Vm,{apiConfig:t,children:l.jsx(Gm,{children:l.jsx(eg,{initialThreadId:n,autoLoadInitial:r,disableAutoRestore:o,onError:a,onThreadChange:c,children:l.jsx(gg,{enableFileAgentRouting:s,fileAgentId:i,children:e})})})})}function Z(...e){return bp.twMerge(wp.clsx(e))}const xg=Kr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Le=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Cn.Slot:"button";return l.jsx(i,{className:Z(xg({variant:t,size:n,className:e})),ref:s,...o})});Le.displayName="Button";const zl=p.forwardRef(({className:e,...t},n)=>l.jsx("textarea",{className:Z("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));zl.displayName="Textarea";function vg({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,onSend:i,onCancelEdit:a,onStop:c,className:u="",textareaClassName:d="",allowEmptySend:f=!1}){const[h,m]=y.useState(e),[w,v]=y.useTransition(),g=y.useRef(null);y.useEffect(()=>{m(e??""),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const x=y.useCallback(()=>{const N=g.current;N&&(N.style.height="auto",N.style.height=`${N.scrollHeight}px`)},[]);y.useEffect(()=>{x()},[x]);const b=y.useCallback(async N=>{N&&N.preventDefault();const _=(h??"").trim();!_&&!f||v(()=>{try{const j=i(_);j&&typeof j.then=="function"?j.then(()=>{m(""),g.current&&(g.current.style.height="auto")}).catch(()=>{}):(m(""),g.current&&(g.current.style.height="auto"))}catch{}})},[h,i,f]),S=y.useCallback(N=>{m(N.target.value),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),k=y.useCallback(N=>{N.key==="Enter"&&!N.shiftKey?(N.preventDefault(),b()):N.key==="Escape"&&t&&(N.preventDefault(),a==null||a())},[b,t,a]),I=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${d}`;return l.jsx("form",{onSubmit:N=>void b(N),className:`w-full ${u}`,children:l.jsxs("div",{className:"flex items-end gap-2",children:[l.jsx("div",{className:"flex-1",children:l.jsx(zl,{ref:g,value:h,onChange:S,onKeyDown:k,placeholder:t?"Edit your message...":n,className:I,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),l.jsx("div",{children:r?l.jsx(Le,{type:"button",onClick:()=>{c==null||c()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!c,children:l.jsx(ne.Square,{size:16})}):l.jsx(Le,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||w,children:l.jsx(ne.Send,{size:16})})})]})})}const wg=y.memo(vg),ao=0,un=1,Kn=2,Bl=4;function Hl(e){return()=>e}function bg(e){e()}function Ul(e,t){return n=>e(t(n))}function Wl(e,t){return()=>e(t)}function yg(e,t){return n=>e(t,n)}function Gs(e){return e!==void 0}function Sg(...e){return()=>{e.map(bg)}}function qn(){}function lo(e,t){return t(e),e}function Cg(e,t){return t(e)}function Ge(...e){return e}function He(e,t){return e(un,t)}function Ie(e,t){e(ao,t)}function Ys(e){e(Kn)}function tt(e){return e(Bl)}function ue(e,t){return He(e,yg(t,ao))}function Ft(e,t){const n=e(un,r=>{n(),t(r)});return n}function Vl(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Kl(e,t){return e===t}function Ye(e=Kl){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function be(e){return t=>n=>{e(n)&&t(n)}}function oe(e){return t=>Ul(t,e)}function Kt(e){return t=>()=>{t(e)}}function B(e,...t){const n=Tg(...t);return(r,o)=>{switch(r){case Kn:Ys(e);return;case un:return He(e,n(o))}}}function qt(e,t){return n=>r=>{n(t=e(t,r))}}function In(e){return t=>n=>{e>0?e--:t(n)}}function on(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Ae(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);He(s,c=>{const u=n;n=n|a,t[i]=c,u!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function Tg(...e){return t=>e.reduceRight(Cg,t)}function Eg(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case un:return s?n===s?void 0:(r(),n=s,t=He(e,s),t):(r(),qn);case Kn:r(),n=null;return}}}function Y(e){let t=e;const n=Oe();return(r,o)=>{switch(r){case ao:t=o;break;case un:{o(t);break}case Bl:return t}return n(r,o)}}function ft(e,t){return lo(Y(t),n=>ue(e,n))}function Oe(){const e=[];return(t,n)=>{switch(t){case ao:e.slice().forEach(r=>{r(n)});return;case Kn:e.splice(0,e.length);return;case un:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Tt(e){return lo(Oe(),t=>ue(e,t))}function ze(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:kg(),singleton:n}}const kg=()=>Symbol();function Ig(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(c=>n(c)));return i&&t.set(s,a),a};return n(e)}function ot(...e){const t=Oe(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);He(s,c=>{n[i]=c,r=r|a,r===o&&Ie(t,n)})}),function(s,i){switch(s){case Kn:{Ys(t);return}case un:return r===o&&i(n),He(t,i)}}}function ve(e,t=Kl){return B(e,Ye(t))}function Xs(...e){return function(t,n){switch(t){case Kn:return;case un:return Sg(...e.map(r=>He(r,n)))}}}var bt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(bt||{});const Ng={0:"debug",3:"error",1:"log",2:"warn"},Ag=()=>typeof globalThis>"u"?window:globalThis,dn=ze(()=>{const e=Y(3);return{log:Y((t,n,r=1)=>{var o;const s=(o=Ag().VIRTUOSO_LOG_LEVEL)!=null?o:tt(e);r>=s&&console[Ng[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Nn(e,t,n){return Js(e,t,n).callbackRef}function Js(e,t,n){const r=y.useRef(null);let o=i=>{};const s=y.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const c=i[0].target;c.offsetParent!==null&&e(c)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function _g(e,t,n,r,o,s,i,a,c){const u=y.useCallback(d=>{const f=jg(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const m=h.lastElementChild.dataset.viewportType==="window";let w;m&&(w=h.ownerDocument.defaultView);const v=i?a?i.scrollLeft:i.scrollTop:m?a?w.scrollX||w.document.documentElement.scrollLeft:w.scrollY||w.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:m?a?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,x=i?a?i.offsetWidth:i.offsetHeight:m?a?w.innerWidth:w.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(v,0),viewportHeight:x}),s==null||s(a?ql("column-gap",getComputedStyle(d).columnGap,o):ql("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return Js(u,n,c)}function jg(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const c=parseInt(a.dataset.index),u=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},bt.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==c-1?s.push({endIndex:c,size:d,startIndex:c}):s[s.length-1].endIndex++}return s}function ql(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,bt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Gl(e,t,n){const r=y.useRef(null),o=y.useCallback(c=>{if(!(c!=null&&c.offsetParent))return;const u=c.getBoundingClientRect(),d=u.width;let f,h;if(t){const m=t.getBoundingClientRect(),w=u.top-m.top;h=m.height-Math.max(0,w),f=w+t.scrollTop}else{const m=i.current.ownerDocument.defaultView;h=m.innerHeight-Math.max(0,u.top),f=u.top+m.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Js(o,!0,n),a=y.useCallback(()=>{o(i.current)},[o,i]);return y.useEffect(()=>{var c;if(t){t.addEventListener("scroll",a);const u=new ResizeObserver(()=>{requestAnimationFrame(a)});return u.observe(t),()=>{t.removeEventListener("scroll",a),u.unobserve(t)}}else{const u=(c=i.current)==null?void 0:c.ownerDocument.defaultView;return u==null||u.addEventListener("scroll",a),u==null||u.addEventListener("resize",a),()=>{u==null||u.removeEventListener("scroll",a),u==null||u.removeEventListener("resize",a)}}},[a,t,i]),s}const mt=ze(()=>{const e=Oe(),t=Oe(),n=Y(0),r=Oe(),o=Y(0),s=Oe(),i=Oe(),a=Y(0),c=Y(0),u=Y(0),d=Y(0),f=Oe(),h=Oe(),m=Y(!1),w=Y(!1),v=Y(!1);return ue(B(e,oe(({scrollTop:g})=>g)),t),ue(B(e,oe(({scrollHeight:g})=>g)),i),ue(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:c,footerHeight:d,headerHeight:a,horizontalDirection:w,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:m,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:v,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),gr={lvl:0};function Yl(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:c}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=c}return s.push({end:1/0,start:r,value:o}),s}function We(e){return e===gr}function xr(e,t){if(!We(e))return t===e.k?e.v:t<e.k?xr(e.l,t):xr(e.r,t)}function zt(e,t,n="k"){if(We(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=zt(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return zt(e.l,t,n)}function Et(e,t,n){return We(e)?Zl(t,n,1):t===e.k?it(e,{k:t,v:n}):t<e.k?Ql(it(e,{l:Et(e.l,t,n)})):Ql(it(e,{r:Et(e.r,t,n)}))}function Gn(){return gr}function co(e,t,n){if(We(e))return[];const r=zt(e,t)[0];return Rg(Qs(e,r,n))}function Zs(e,t){if(We(e))return gr;const{k:n,l:r,r:o}=e;if(t===n){if(We(r))return o;if(We(o))return r;{const[s,i]=Jl(r);return uo(it(e,{k:s,l:Xl(r),v:i}))}}else return t<n?uo(it(e,{l:Zs(r,t)})):uo(it(e,{r:Zs(o,t)}))}function An(e){return We(e)?[]:[...An(e.l),{k:e.k,v:e.v},...An(e.r)]}function Qs(e,t,n){if(We(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Qs(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Qs(s,t,n))),a}function uo(e){const{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(ei(t))return ec(it(e,{lvl:n-1}));if(!We(t)&&!We(t.r))return it(t.r,{l:it(t,{r:t.r.l}),lvl:n,r:it(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(ei(e))return ti(it(e,{lvl:n-1}));if(!We(r)&&!We(r.l)){const o=r.l,s=ei(o)?r.lvl-1:r.lvl;return it(o,{l:it(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:ti(it(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function it(e,t){return Zl(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function Xl(e){return We(e.r)?e.l:uo(it(e,{r:Xl(e.r)}))}function ei(e){return We(e)||e.lvl>e.r.lvl}function Jl(e){return We(e.r)?[e.k,e.v]:Jl(e.r)}function Zl(e,t,n,r=gr,o=gr){return{k:e,l:r,lvl:n,r:o,v:t}}function Ql(e){return ti(ec(e))}function ec(e){const{l:t}=e;return!We(t)&&t.lvl===e.lvl?it(t,{r:it(e,{l:t.r})}):e}function ti(e){const{lvl:t,r:n}=e;return!We(n)&&!We(n.r)&&n.lvl===t&&n.r.lvl===t?it(n,{l:it(e,{r:n.l}),lvl:t+1}):e}function Rg(e){return Yl(e,({k:t,v:n})=>({index:t,value:n}))}function tc(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function vr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const ni=ze(()=>({recalcInProgress:Y(!1)}),[],{singleton:!0});function nc(e,t,n){return e[fo(e,t,n)]}function fo(e,t,n,r=0){let o=e.length-1;for(;r<=o;){const s=Math.floor((r+o)/2),i=e[s],a=n(i,t);if(a===0)return s;if(a===-1){if(o-r<2)return s-1;o=s-1}else{if(o===r)return s;r=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function Pg(e,t,n,r){const o=fo(e,t,r),s=fo(e,n,r,o);return e.slice(o,s+1)}function fn(e,t){return Math.round(e.getBoundingClientRect()[t])}function ho(e){return!We(e.groupOffsetTree)}function ri({index:e},t){return t===e?0:t<e?-1:1}function Og(){return{groupIndices:[],groupOffsetTree:Gn(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Gn()}}function Mg(e,t){let n=We(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),We(e)){e=Et(e,0,s);continue}const a=co(e,i-1,o+1);if(a.some(Hg(r)))continue;let c=!1,u=!1;for(const{end:d,start:f,value:h}of a)c?(o>=f||s===h)&&(e=Zs(e,f)):(u=h!==s,c=!0),d>o&&o>=f&&h!==s&&(e=Et(e,o+1,h));u&&(e=Et(e,i,s))}return[e,n]}function Dg(e){return typeof e.groupIndex<"u"}function Lg({offset:e},t){return t===e?0:t<e?-1:1}function wr(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=nc(t,e,ri),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function rc(e,t){if(!ho(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function oc(e,t,n){if(Dg(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=rc(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function $g(e,t,n,r=0){return r>0&&(t=Math.max(t,nc(e,r,ri).offset)),Yl(Pg(e,t,n,Lg),Bg)}function Fg(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,bt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&We(s)&&t.length===2){const h=t[0].size,m=t[1].size;i=n.reduce((w,v)=>Et(Et(w,v,h),v+1,m),i)}else[i,a]=Mg(i,t);if(i===s)return e;const{lastIndex:c,lastOffset:u,lastSize:d,offsetTree:f}=oi(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,m)=>Et(h,m,wr(m,f,o)),Gn()),lastIndex:c,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function zg(e){return An(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function sc(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function oi(e,t,n,r){let o=e,s=0,i=0,a=0,c=0;if(t!==0){c=fo(o,t-1,ri),a=o[c].offset;const u=zt(n,t-1);s=u[0],i=u[1],o.length&&o[c].size===zt(n,t)[1]&&(c-=1),o=o.slice(0,c+1)}else o=[];for(const{start:u,value:d}of co(n,t,1/0)){const f=u-s,h=f*i+a+f*r;o.push({index:u,offset:h,size:d}),s=u,a=h,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function Bg(e){return{index:e.index,value:e}}function Hg(e){const{endIndex:t,size:n,startIndex:r}=e;return o=>o.start===r&&(o.end===t||o.end===1/0)&&o.value===n}const Ug={offsetHeight:"height",offsetWidth:"width"},Gt=ze(([{log:e},{recalcInProgress:t}])=>{const n=Oe(),r=Oe(),o=ft(r,0),s=Oe(),i=Oe(),a=Y(0),c=Y([]),u=Y(void 0),d=Y(void 0),f=Y((C,T)=>fn(C,Ug[T])),h=Y(void 0),m=Y(0),w=Og(),v=ft(B(n,Ae(c,e,m),qt(Fg,w),Ye()),w),g=ft(B(c,Ye(),qt((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),oe(({prev:C})=>C)),[]);ue(B(c,be(C=>C.length>0),Ae(v,m),oe(([C,T,I])=>{const N=C.reduce((_,j,R)=>Et(_,j,wr(j,T.offsetTree,I)||R),Gn());return{...T,groupIndices:C,groupOffsetTree:N}})),v),ue(B(r,Ae(v),be(([C,{lastIndex:T}])=>C<T),oe(([C,{lastIndex:T,lastSize:I}])=>[{endIndex:T,size:I,startIndex:C}])),n),ue(u,d);const x=ft(B(u,oe(C=>C===void 0)),!0);ue(B(d,be(C=>C!==void 0&&We(tt(v).sizeTree)),oe(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=Tt(B(n,Ae(v),qt(({sizes:C},[T,I])=>({changed:I!==C,sizes:I}),{changed:!1,sizes:w}),oe(C=>C.changed)));He(B(a,qt((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),oe(C=>C.diff)),C=>{const{groupIndices:T}=tt(v);if(C>0)Ie(t,!0),Ie(s,C+sc(C,T));else if(C<0){const I=tt(g);I.length>0&&(C-=sc(-C,I)),Ie(i,C)}}),He(B(a,Ae(e)),([C,T])=>{C<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},bt.ERROR)});const S=Tt(s);ue(B(s,Ae(v),oe(([C,T])=>{const I=T.groupIndices.length>0,N=[],_=T.lastSize;if(I){const j=xr(T.sizeTree,0);let R=0,z=0;for(;R<C;){const O=T.groupIndices[z],W=T.groupIndices.length===z+1?1/0:T.groupIndices[z+1]-O-1;N.push({endIndex:O,size:j,startIndex:O}),N.push({endIndex:O+1+W-1,size:_,startIndex:O+1}),z++,R+=W+1}const H=An(T.sizeTree);return R!==C&&H.shift(),H.reduce((O,{k:W,v:K})=>{let G=O.ranges;return O.prevSize!==0&&(G=[...O.ranges,{endIndex:W+C-1,size:O.prevSize,startIndex:O.prevIndex}]),{prevIndex:W+C,prevSize:K,ranges:G}},{prevIndex:C,prevSize:0,ranges:N}).ranges}return An(T.sizeTree).reduce((j,{k:R,v:z})=>({prevIndex:R+C,prevSize:z,ranges:[...j.ranges,{endIndex:R+C-1,size:j.prevSize,startIndex:j.prevIndex}]}),{prevIndex:0,prevSize:_,ranges:[]}).ranges})),n);const k=Tt(B(i,Ae(v,m),oe(([C,{offsetTree:T},I])=>{const N=-C;return wr(N,T,I)})));return ue(B(i,Ae(v,m),oe(([C,T,I])=>{if(T.groupIndices.length>0){if(We(T.sizeTree))return T;let N=Gn();const _=tt(g);let j=0,R=0,z=0;for(;j<-C;){z=_[R];const H=_[R+1]-z-1;R++,j+=H+1}if(N=An(T.sizeTree).reduce((H,{k:O,v:W})=>Et(H,Math.max(0,O+C),W),N),j!==-C){const H=xr(T.sizeTree,z);N=Et(N,0,H);const O=zt(T.sizeTree,-C+1)[1];N=Et(N,1,O)}return{...T,sizeTree:N,...oi(T.offsetTree,0,N,I)}}else{const N=An(T.sizeTree).reduce((_,{k:j,v:R})=>Et(_,Math.max(0,j+C),R),Gn());return{...T,sizeTree:N,...oi(T.offsetTree,0,N,I)}}})),v),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:m,groupIndices:c,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:v,statefulTotalCount:o,totalCount:r,trackItemSizes:x,unshiftWith:s}},Ge(dn,ni),{singleton:!0});function Wg(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const ic=ze(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Oe(),i=Oe(),a=Tt(B(s,oe(Wg)));return ue(B(a,oe(c=>c.totalCount)),n),ue(B(a,oe(c=>c.groupIndices)),e),ue(B(ot(o,t,r),be(([c,u])=>ho(u)),oe(([c,u,d])=>zt(u.groupOffsetTree,Math.max(c-d,0),"v")[0]),Ye(),oe(c=>[c])),i),{groupCounts:s,topItemsIndexes:i}},Ge(Gt,mt)),hn=ze(([{log:e}])=>{const t=Y(!1),n=Tt(B(t,be(r=>r),Ye()));return He(t,r=>{r&&tt(e)("props updated",{},bt.DEBUG)}),{didMount:n,propsReady:t}},Ge(dn),{singleton:!0}),Vg=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function ac(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Vg)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const br=ze(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:c,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const m=Oe(),w=Oe(),v=Y(0);let g=null,x=null,b=null;function S(){g&&(g(),g=null),b&&(b(),b=null),x&&(clearTimeout(x),x=null),Ie(c,!1)}return ue(B(m,Ae(n,f,r,v,a,i,h),Ae(e,s,o),oe(([[k,C,T,I,N,_,j,R],z,H,O])=>{const W=ac(k),{align:K,behavior:G,offset:$}=W,A=I-1,D=oc(W,C,A);let U=wr(D,C.offsetTree,z)+_;K==="end"?(U+=H+zt(C.sizeTree,D)[1]-T+O,D===A&&(U+=j)):K==="center"?U+=(H+zt(C.sizeTree,D)[1]-T+O)/2:U-=N,$&&(U+=$);const J=Q=>{S(),Q?(R("retrying to scroll to",{location:k},bt.DEBUG),Ie(m,k)):(Ie(w,!0),R("list did not change, scroll successful",{},bt.DEBUG))};if(S(),G==="smooth"){let Q=!1;b=He(t,ce=>{Q=Q||ce}),g=Ft(d,()=>{J(Q)})}else g=Ft(B(t,Kg(150)),J);return x=setTimeout(()=>{S()},1200),Ie(c,!0),R("scrolling from index to",{behavior:G,index:D,top:U},bt.DEBUG),{behavior:G,top:U}})),u),{scrollTargetReached:w,scrollToIndex:m,topListHeight:v}},Ge(Gt,mt,dn),{singleton:!0});function Kg(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function si(e,t){e==0?t():requestAnimationFrame(()=>{si(e-1,t)})}function ii(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const yr=ze(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=Y(!0),c=Y(0),u=Y(!0);return ue(B(i,Ae(c),be(([d,f])=>!!f),Kt(!1)),a),ue(B(i,Ae(c),be(([d,f])=>!!f),Kt(!1)),u),He(B(ot(t,i),Ae(a,n,e,u),be(([[,d],f,{sizeTree:h},m,w])=>d&&(!We(h)||Gs(m))&&!f&&!w),Ae(c)),([,d])=>{Ft(o,()=>{Ie(u,!0)}),si(4,()=>{Ft(r,()=>{Ie(a,!0)}),Ie(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:c,scrolledToInitialItem:a}},Ge(Gt,mt,br,hn),{singleton:!0});function lc(e,t){return Math.abs(e-t)<1.01}const Sr="up",Cr="down",qg="none",Gg={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Yg=0,Tr=ze(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=Y(!1),a=Y(!0),c=Oe(),u=Oe(),d=Y(4),f=Y(Yg),h=ft(B(Xs(B(ve(o),In(1),Kt(!0)),B(ve(o),In(1),Kt(!1),Vl(100))),Ye()),!1),m=ft(B(Xs(B(n,Kt(!0)),B(n,Kt(!1),Vl(200))),Ye()),!1);ue(B(ot(ve(o),ve(f)),oe(([b,S])=>b<=S),Ye()),a),ue(B(a,on(50)),u);const w=Tt(B(ot(r,ve(s),ve(t),ve(e),ve(d)),qt((b,[{scrollHeight:S,scrollTop:k},C,T,I,N])=>{const _=k+C-S>-N,j={scrollHeight:S,scrollTop:k,viewportHeight:C};if(_){let z,H;return k>b.state.scrollTop?(z="SCROLLED_DOWN",H=b.state.scrollTop-k):(z="SIZE_DECREASED",H=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:z,scrollTopDelta:H,state:j}}let R;return j.scrollHeight>b.state.scrollHeight?R="SIZE_INCREASED":C<b.state.viewportHeight?R="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?R="SCROLLING_UPWARDS":R="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:R,state:j}},Gg),Ye((b,S)=>b&&b.atBottom===S.atBottom))),v=ft(B(r,qt((b,{scrollHeight:S,scrollTop:k,viewportHeight:C})=>{if(lc(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const T=S-(k+C)<1;return b.scrollTop!==k&&T?{changed:!0,jump:b.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),be(b=>b.changed),oe(b=>b.jump)),0);ue(B(w,oe(b=>b.atBottom)),i),ue(B(i,on(50)),c);const g=Y(Cr);ue(B(r,oe(({scrollTop:b})=>b),Ye(),qt((b,S)=>tt(m)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?Sr:Cr,prevScrollTop:S},{direction:Cr,prevScrollTop:0}),oe(b=>b.direction)),g),ue(B(r,on(50),Kt(qg)),g);const x=Y(0);return ue(B(h,be(b=>!b),Kt(0)),x),ue(B(o,on(100),Ae(h),be(([b,S])=>!!S),qt(([b,S],[k])=>[S,k],[0,0]),oe(([b,S])=>S-b)),x),{atBottomState:w,atBottomStateChange:c,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:v,scrollDirection:g,scrollVelocity:x}},Ge(mt)),po="top",mo="bottom",cc="none";function uc(e,t,n){return typeof e=="number"?n===Sr&&t===po||n===Cr&&t===mo?e:0:n===Sr?t===po?e.main:e.reverse:t===mo?e.main:e.reverse}function dc(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const ai=ze(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Oe(),i=Y(0),a=Y(0),c=Y(0),u=ft(B(ot(ve(r),ve(o),ve(n),ve(s,vr),ve(c),ve(i),ve(t),ve(e),ve(a)),oe(([d,f,h,[m,w],v,g,x,b,S])=>{const k=d-b,C=g+x,T=Math.max(h-k,0);let I=cc;const N=dc(S,po),_=dc(S,mo);return m-=b,m+=h+x,w+=h+x,w-=b,m>d+C-N&&(I=Sr),w<d-T+f+_&&(I=Cr),I!==cc?[Math.max(k-h-uc(v,po,I)-N,0),k-T-x+f+uc(v,mo,I)+_]:null}),be(d=>d!=null),Ye(vr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:c,topListHeight:i,visibleRange:u}},Ge(mt),{singleton:!0});function Xg(e,t,n){if(ho(t)){const r=rc(e,t);return[{index:zt(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const li={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function go(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:c}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const v=e[e.length-1];d=v.offset+v.size}const f=n-i,h=a+f*c+(f-1)*r,m=u,w=h-d;return{bottom:d,firstItemIndex:s,items:hc(e,o,s),offsetBottom:w,offsetTop:u,top:m,topItems:hc(t,o,s),topListHeight:t.reduce((v,g)=>g.size+v,0),totalCount:n}}function fc(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,c=ii(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+c],index:f+c,offset:0,size:0}));return go(u,[],a,o,n,r)}function hc(e,t,n){if(e.length===0)return[];if(!ho(t))return e.map(u=>({...u,index:u.index+n,originalIndex:u.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=co(t.groupOffsetTree,r,o);let a,c=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),c=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:c,type:"group"}:d={groupIndex:c,index:u.index-(c+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const _n=ze(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:c},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:m},{recalcInProgress:w}])=>{const v=Y([]),g=Y(0),x=Oe();ue(s.topItemsIndexes,v);const b=ft(B(ot(m,w,ve(c,vr),ve(o),ve(r),ve(u),d,ve(v),ve(t),ve(n),e),be(([T,I,,N,,,,,,,_])=>{const j=_&&_.length!==N;return T&&!I&&!j}),oe(([,,[T,I],N,_,j,R,z,H,O,W])=>{const K=_,{offsetTree:G,sizeTree:$}=K,A=tt(g);if(N===0)return{...li,totalCount:N};if(T===0&&I===0)return A===0?{...li,totalCount:N}:fc(A,j,_,H,O,W||[]);if(We($))return A>0?null:go(Xg(ii(j,N),K,W),[],N,O,K,H);const D=[];if(z.length>0){const we=z[0],ke=z[z.length-1];let q=0;for(const M of co($,we,ke)){const X=M.value,ee=Math.max(M.start,we),L=Math.min(M.end,ke);for(let F=ee;F<=L;F++)D.push({data:W==null?void 0:W[F],index:F,offset:q,size:X}),q+=X}}if(!R)return go([],D,N,O,K,H);const U=z.length>0?z[z.length-1]+1:0,J=$g(G,T,I,U);if(J.length===0)return null;const Q=N-1,ce=lo([],we=>{for(const ke of J){const q=ke.value;let M=q.offset,X=ke.start;const ee=q.size;if(q.offset<T){X+=Math.floor((T-q.offset+O)/(ee+O));const F=X-ke.start;M+=F*ee+F*O}X<U&&(M+=(U-X)*ee,X=U);const L=Math.min(ke.end,Q);for(let F=X;F<=L&&!(M>=I);F++)we.push({data:W==null?void 0:W[F],index:F,offset:M,size:ee}),M+=ee+O}});return go(ce,D,N,O,K,H)}),be(T=>T!==null),Ye()),li);ue(B(e,be(Gs),oe(T=>T==null?void 0:T.length)),o),ue(B(b,oe(T=>T.topListHeight)),f),ue(f,a),ue(B(b,oe(T=>[T.top,T.bottom])),i),ue(B(b,oe(T=>T.items)),x);const S=Tt(B(b,be(({items:T})=>T.length>0),Ae(o,e),be(([{items:T},I])=>T[T.length-1].originalIndex===I-1),oe(([,T,I])=>[T-1,I]),Ye(vr),oe(([T])=>T))),k=Tt(B(b,on(200),be(({items:T,topItems:I})=>T.length>0&&T[0].originalIndex===I.length),oe(({items:T})=>T[0].index),Ye())),C=Tt(B(b,be(({items:T})=>T.length>0),oe(({items:T})=>{let I=0,N=T.length-1;for(;T[I].type==="group"&&I<N;)I++;for(;T[N].type==="group"&&N>I;)N--;return{endIndex:T[N].index,startIndex:T[I].index}}),Ye(tc)));return{endReached:S,initialItemCount:g,itemsRendered:x,listState:b,rangeChanged:C,startReached:k,topItemsIndexes:v,...h}},Ge(Gt,ic,ai,yr,br,Tr,hn,ni),{singleton:!0}),pc=ze(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Oe(),i=ft(B(ot(n,e,r,t,o),oe(([a,c,u,d,f])=>a+c+u+d+f.offsetBottom+f.bottom)),0);return ue(ve(i),s),{totalListHeight:i,totalListHeightChanged:s}},Ge(mt,_n),{singleton:!0}),Jg=ze(([{viewportHeight:e},{totalListHeight:t}])=>{const n=Y(!1),r=ft(B(ot(n,e,t),be(([o])=>o),oe(([,o,s])=>Math.max(0,o-s)),on(0),Ye()),0);return{alignToBottom:n,paddingTopAddition:r}},Ge(mt,pc),{singleton:!0}),mc=ze(()=>({context:Y(null)})),Zg=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...o},viewportBottom:s,viewportTop:i})=>t<i?{...o,align:n??"start",behavior:r}:e>s?{...o,align:n??"end",behavior:r}:null,gc=ze(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:c},{scrollToIndex:u}])=>{const d=Oe();return ue(B(d,Ae(t,c,n,s,o,r,a),Ae(e),oe(([[f,h,m,w,v,g,x,b],S])=>{const{align:k,behavior:C,calculateViewLocation:T=Zg,done:I,...N}=f,_=oc(f,h,w-1),j=wr(_,h.offsetTree,S)+v+g,R=j+zt(h.sizeTree,_)[1],z=b+g,H=b+m-x,O=T({itemBottom:R,itemTop:j,locationParams:{align:k,behavior:C,...N},viewportBottom:H,viewportTop:z});return O?I&&Ft(B(i,be(W=>!W),In(tt(i)?1:2)),I):I&&I(),O}),be(f=>f!==null)),u),{scrollIntoView:d}},Ge(Gt,mt,br,_n,dn),{singleton:!0});function xc(e){return e?e==="smooth"?"smooth":"auto":!1}const Qg=(e,t)=>typeof e=="function"?xc(e(t)):t&&xc(e),ex=ze(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:c,propsReady:u},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:m}])=>{const w=Y(!1),v=Oe();let g=null;function x(C){Ie(i,{align:"end",behavior:C,index:"LAST"})}He(B(ot(B(ve(t),In(1)),c),Ae(ve(w),s,a,f),oe(([[C,T],I,N,_,j])=>{let R=T&&_,z="auto";return R&&(z=Qg(I,N||j),R=R&&!!z),{followOutputBehavior:z,shouldFollow:R,totalCount:C}}),be(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{g&&(g(),g=null),tt(n)?requestAnimationFrame(()=>{tt(d)("following output to ",{totalCount:T},bt.DEBUG),x(C)}):g=Ft(e,()=>{tt(d)("following output to ",{totalCount:T},bt.DEBUG),x(C),g=null})});function b(C){const T=Ft(o,I=>{C&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(tt(d)("scrolling to bottom due to increased size",{},bt.DEBUG),x("auto"))});setTimeout(T,100)}He(B(ot(ve(w),t,u),be(([C,,T])=>C&&T),qt(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),be(({refreshed:C})=>C),Ae(w,t)),([,C])=>{tt(a)&&b(C!==!1)}),He(v,()=>{b(tt(w)!==!1)}),He(ot(ve(w),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&x("auto")});const S=Y(null),k=Oe();return ue(Xs(B(ve(r),oe(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),B(ve(t))),k),He(B(ot(B(k,In(1)),c),Ae(ve(S),a,f,h),oe(([[C,T],I,N,_,j])=>T&&N&&(I==null?void 0:I({context:j,totalCount:C,scrollingInProgress:_}))),be(C=>!!C),on(0)),C=>{g&&(g(),g=null),tt(n)?requestAnimationFrame(()=>{tt(d)("scrolling into view",{}),Ie(m,C)}):g=Ft(e,()=>{tt(d)("scrolling into view",{}),Ie(m,C),g=null})}),{autoscrollToBottom:v,followOutput:w,scrollIntoViewOnChange:S}},Ge(Gt,Tr,br,yr,hn,dn,mt,mc,gc)),tx=ze(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ue(B(a,Ae(s),be(([,c])=>c!==0),Ae(o,r,t,n,e),oe(([[,c],u,d,f,h,m=[]])=>fc(c,u,d,f,h,m))),i),{}),Ge(Gt,yr,_n,hn),{singleton:!0}),nx=ze(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=Y(0);return He(B(e,Ae(r),be(([,o])=>o!==0),oe(([,o])=>({top:o}))),o=>{Ft(B(n,In(1),be(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Ie(t,o)})})}),{initialScrollTop:r}},Ge(hn,mt,_n),{singleton:!0}),vc=ze(([{scrollVelocity:e}])=>{const t=Y(!1),n=Oe(),r=Y(!1);return ue(B(e,Ae(r,t,n),be(([o,s])=>!!s),oe(([o,s,i,a])=>{const{enter:c,exit:u}=s;if(i){if(u(o,a))return!1}else if(c(o,a))return!0;return i}),Ye()),t),He(B(ot(t,e,n),Ae(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},Ge(Tr),{singleton:!0}),ci=ze(([{scrollContainerState:e,scrollTo:t}])=>{const n=Oe(),r=Oe(),o=Oe(),s=Y(!1),i=Y(void 0);return ue(B(ot(n,r),oe(([{scrollHeight:a,scrollTop:c,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,c-d),viewportHeight:u}))),e),ue(B(t,Ae(r),oe(([a,{offsetTop:c}])=>({...a,top:a.top+c}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},Ge(mt)),rx=ze(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:c}])=>{const u=Oe(),d=Y(void 0),f=Y(null),h=Y(null);return ue(a,f),ue(c,h),He(B(u,Ae(t,r,i,f,h,n)),([m,w,v,g,x,b,S])=>{const k=zg(w.sizeTree);g&&x!==null&&b!==null&&(v=x.scrollTop-b.offsetTop),v-=S,m({ranges:k,scrollTop:v})}),ue(B(d,be(Gs),oe(ox)),o),ue(B(s,Ae(d),be(([,m])=>m!==void 0),Ye(),oe(([,m])=>m.ranges)),e),{getState:u,restoreStateFrom:d}},Ge(Gt,mt,yr,hn,ci));function ox(e){return{align:"start",index:0,offset:e.scrollTop}}const sx=ze(([{topItemsIndexes:e}])=>{const t=Y(0);return ue(B(t,be(n=>n>=0),oe(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},Ge(_n));function wc(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const ix=wc(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),ax=ze(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:c},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:h},{log:m},{recalcInProgress:w}])=>{const v=Tt(B(c,Ae(i),qt(([,x,b,S],[{bottom:k,items:C,offsetBottom:T,totalCount:I},N])=>{const _=k+T;let j=0;return b===I&&x.length>0&&C.length>0&&(C[0].originalIndex===0&&x[0].originalIndex===0||(j=_-S,j!==0&&(j+=N))),[j,C,I,_]},[0,[],0,0]),be(([x])=>x!==0),Ae(r,a,n,o,m,w),be(([,x,b,S,,,k])=>!k&&!S&&x!==0&&b===Sr),oe(([[x],,,,,b])=>(b("Upward scrolling compensation",{amount:x},bt.DEBUG),x))));function g(x){x>0?(Ie(t,{behavior:"auto",top:-x}),Ie(e,0)):(Ie(e,0),Ie(t,{behavior:"auto",top:-x}))}return He(B(v,Ae(e,s)),([x,b,S])=>{S&&ix()?Ie(e,b-x):g(-x)}),He(B(ot(ft(s,!1),e,w),be(([x,b,S])=>!x&&!S&&b!==0),oe(([x,b])=>b),on(1)),g),ue(B(f,oe(x=>({top:-x}))),t),He(B(u,Ae(h,d),oe(([x,{groupIndices:b,lastSize:S,sizeTree:k},C])=>{function T(I){return I*(S+C)}if(b.length===0)return T(x);{let I=0;const N=xr(k,0);let _=0,j=0;for(;_<x;){_++,I+=N;let R=b.length===j+1?1/0:b[j+1]-b[j]-1;_+R>x&&(I-=N,R=x-_+1),_+=R,I+=T(R),j++}return I}})),x=>{Ie(e,x),requestAnimationFrame(()=>{Ie(t,{top:x}),requestAnimationFrame(()=>{Ie(e,0),Ie(w,!1)})})}),{deviation:e}},Ge(mt,Tr,_n,Gt,dn,ni)),lx=ze(([e,t,n,r,o,s,i,a,c,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...c,...u,...d}),Ge(ai,tx,hn,vc,pc,nx,Jg,ci,gc,dn,mc)),bc=ze(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:c,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:m,scrolledToInitialItem:w},v,g,x,{listState:b,topItemsIndexes:S,...k},{scrollToIndex:C},T,{topItemCount:I},{groupCounts:N},_])=>(ue(k.rangeChanged,_.scrollSeekRangeChanged),ue(B(_.windowViewportRect,oe(j=>j.visibleHeight)),v.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:N,initialItemFinalLocationReached:h,initialTopMostItemIndex:m,scrolledToInitialItem:w,sizeRanges:a,topItemCount:I,topItemsIndexes:S,totalCount:d,...x,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...k,..._,...v,sizes:c,...g}),Ge(Gt,yr,mt,rx,ex,_n,br,ax,sx,ic,lx));function cx(e,t){const n={},r={};let o=0;const s=e.length;for(;o<s;)r[e[o]]=1,o+=1;for(const i in t)Object.hasOwn(r,i)||(n[i]=t[i]);return n}const xo=typeof document<"u"?y.useLayoutEffect:y.useEffect;function yc(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=y.createContext({});function c(g,x){g.propsReady&&Ie(g.propsReady,!1);for(const b of r){const S=g[t.required[b]];Ie(S,x[b])}for(const b of o)if(b in x){const S=g[t.optional[b]];Ie(S,x[b])}g.propsReady&&Ie(g.propsReady,!0)}function u(g){return s.reduce((x,b)=>(x[b]=S=>{const k=g[t.methods[b]];Ie(k,S)},x),{})}function d(g){return i.reduce((x,b)=>(x[b]=Eg(g[t.events[b]]),x),{})}const f=y.forwardRef((g,x)=>{const{children:b,...S}=g,[k]=y.useState(()=>lo(Ig(e),I=>{c(I,S)})),[C]=y.useState(Wl(d,k));xo(()=>{for(const I of i)I in S&&He(C[I],S[I]);return()=>{Object.values(C).map(Ys)}},[S,C,k]),xo(()=>{c(k,S)}),y.useImperativeHandle(x,Hl(u(k)));const T=n;return l.jsx(a.Provider,{value:k,children:n?l.jsx(T,{...cx([...r,...o,...i],S),children:b}):b})}),h=g=>{const x=y.useContext(a);return y.useCallback(b=>{Ie(x[g],b)},[x,g])},m=g=>{const x=y.useContext(a)[g],b=y.useCallback(S=>He(x,S),[x]);return y.useSyncExternalStore(b,()=>tt(x),()=>tt(x))},w=g=>{const x=y.useContext(a)[g],[b,S]=y.useState(Wl(tt,x));return xo(()=>He(x,k=>{k!==b&&S(Hl(k))}),[x,b]),b},v=y.version.startsWith("18")?m:w;return{Component:f,useEmitter:(g,x)=>{const b=y.useContext(a)[g];xo(()=>He(b,x),[x,b])},useEmitterValue:v,usePublisher:h}}const Sc=y.createContext(void 0),Cc=y.createContext(void 0),Tc=typeof document<"u"?y.useLayoutEffect:y.useEffect;function ui(e){return"self"in e}function ux(e){return"body"in e}function Ec(e,t,n,r=qn,o,s){const i=y.useRef(null),a=y.useRef(null),c=y.useRef(null),u=y.useCallback(h=>{let m,w,v;const g=h.target;if(ux(g)||ui(g)){const b=ui(g)?g:g.defaultView;v=s?b.scrollX:b.scrollY,m=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,w=s?b.innerWidth:b.innerHeight}else v=s?g.scrollLeft:g.scrollTop,m=s?g.scrollWidth:g.scrollHeight,w=s?g.offsetWidth:g.offsetHeight;const x=()=>{e({scrollHeight:m,scrollTop:Math.max(v,0),viewportHeight:w})};h.suppressFlushSync?x():Is.flushSync(x),a.current!==null&&(v===a.current||v<=0||v===m-w)&&(a.current=null,t(!0),c.current&&(clearTimeout(c.current),c.current=null))},[e,t,s]);y.useEffect(()=>{const h=o||i.current;return r(o||i.current),u({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",u,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",u)}},[i,u,n,r,o]);function d(h){const m=i.current;if(!m||(s?"offsetWidth"in m&&m.offsetWidth===0:"offsetHeight"in m&&m.offsetHeight===0))return;const w=h.behavior==="smooth";let v,g,x;ui(m)?(g=Math.max(fn(m.document.documentElement,s?"width":"height"),s?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight),v=s?m.innerWidth:m.innerHeight,x=s?window.scrollX:window.scrollY):(g=m[s?"scrollWidth":"scrollHeight"],v=fn(m,s?"width":"height"),x=m[s?"scrollLeft":"scrollTop"]);const b=g-v;if(h.top=Math.ceil(Math.max(Math.min(b,h.top),0)),lc(v,g)||h.top===x){e({scrollHeight:g,scrollTop:x,viewportHeight:v}),w&&t(!0);return}w?(a.current=h.top,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(h={behavior:h.behavior,left:h.top}),m.scrollTo(h)}function f(h){s&&(h={behavior:h.behavior,left:h.top}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const di="-webkit-sticky",kc="sticky",fi=wc(()=>{if(typeof document>"u")return kc;const e=document.createElement("div");return e.style.position=di,e.style.position===di?di:kc});function hi(e){return e}const dx=ze(()=>{const e=Y(a=>`Item ${a}`),t=Y(a=>`Group ${a}`),n=Y({}),r=Y(hi),o=Y("div"),s=Y(qn),i=(a,c=null)=>ft(B(n,oe(u=>u[a]),Ye()),c);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),fx=ze(([e,t])=>({...e,...t}),Ge(bc,dx)),hx=({height:e})=>l.jsx("div",{style:{height:e}}),px={overflowAnchor:"none",position:fi(),zIndex:1},Ic={overflowAnchor:"none"},mx={...Ic,display:"inline-block",height:"100%"},Nc=y.memo(function({showTopList:e=!1}){const t=Te("listState"),n=jt("sizeRanges"),r=Te("useWindowScroll"),o=Te("customScrollParent"),s=jt("windowScrollContainerState"),i=jt("scrollContainerState"),a=o||r?s:i,c=Te("itemContent"),u=Te("context"),d=Te("groupContent"),f=Te("trackItemSizes"),h=Te("itemSize"),m=Te("log"),w=jt("gap"),v=Te("horizontalDirection"),{callbackRef:g}=_g(n,h,f,e?qn:a,m,w,o,v,Te("skipAnimationFrameInResizeObserver")),[x,b]=y.useState(0);pi("deviation",O=>{x!==O&&b(O)});const S=Te("EmptyPlaceholder"),k=Te("ScrollSeekPlaceholder")||hx,C=Te("ListComponent"),T=Te("ItemComponent"),I=Te("GroupComponent"),N=Te("computeItemKey"),_=Te("isSeeking"),j=Te("groupIndices").length>0,R=Te("alignToBottom"),z=Te("initialItemFinalLocationReached"),H=e?{}:{boxSizing:"border-box",...v?{display:"inline-block",height:"100%",marginLeft:x!==0?x:R?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:x!==0?x:R?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...z?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?l.jsx(S,{...ht(S,u)}):l.jsx(C,{...ht(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:H,children:(e?t.topItems:t.items).map(O=>{const W=O.originalIndex,K=N(W+t.firstItemIndex,O.data,u);return _?y.createElement(k,{...ht(k,u),height:O.size,index:O.index,key:K,type:O.type||"item",...O.type==="group"?{}:{groupIndex:O.groupIndex}}):O.type==="group"?y.createElement(I,{...ht(I,u),"data-index":W,"data-item-index":O.index,"data-known-size":O.size,key:K,style:px},d(O.index,u)):y.createElement(T,{...ht(T,u),...wx(T,O.data),"data-index":W,"data-item-group-index":O.groupIndex,"data-item-index":O.index,"data-known-size":O.size,key:K,style:v?mx:Ic},j?c(O.index,O.groupIndex,O.data,u):c(O.index,O.data,u))})})}),gx={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},xx={outline:"none",overflowX:"auto",position:"relative"},vo=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),vx={position:fi(),top:0,width:"100%",zIndex:1};function ht(e,t){if(typeof e!="string")return{context:t}}function wx(e,t){return{item:typeof e=="string"?void 0:t}}const bx=y.memo(function(){const e=Te("HeaderComponent"),t=jt("headerHeight"),n=Te("HeaderFooterTag"),r=Nn(y.useMemo(()=>s=>{t(fn(s,"height"))},[t]),!0,Te("skipAnimationFrameInResizeObserver")),o=Te("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...ht(e,o)})}):null}),yx=y.memo(function(){const e=Te("FooterComponent"),t=jt("footerHeight"),n=Te("HeaderFooterTag"),r=Nn(y.useMemo(()=>s=>{t(fn(s,"height"))},[t]),!0,Te("skipAnimationFrameInResizeObserver")),o=Te("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...ht(e,o)})}):null});function Ac({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),c=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:m,scrollToCallback:w}=Ec(a,u,c,d,void 0,f);return e("scrollTo",w),e("scrollBy",h),l.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:m,style:{...f?xx:gx,...o},tabIndex:0,...i,...ht(c,s),children:r})})}function _c({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),c=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),m=y.useRef(null),w=t("scrollerRef"),{scrollByCallback:v,scrollerRef:g,scrollToCallback:x}=Ec(a,u,c,w,h);return Tc(()=>{var b;return g.current=h||((b=m.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",x),e("scrollBy",v),l.jsx(c,{ref:m,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...ht(c,s),children:r})})}const Sx=({children:e})=>{const t=y.useContext(Sc),n=jt("viewportHeight"),r=jt("fixedItemHeight"),o=Te("alignToBottom"),s=Te("horizontalDirection"),i=y.useMemo(()=>Ul(n,c=>fn(c,s?"width":"height")),[n,s]),a=Nn(i,!0,Te("skipAnimationFrameInResizeObserver"));return y.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),l.jsx("div",{"data-viewport-type":"element",ref:a,style:vo(o),children:e})},Cx=({children:e})=>{const t=y.useContext(Sc),n=jt("windowViewportRect"),r=jt("fixedItemHeight"),o=Te("customScrollParent"),s=Gl(n,o,Te("skipAnimationFrameInResizeObserver")),i=Te("alignToBottom");return y.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),l.jsx("div",{"data-viewport-type":"window",ref:s,style:vo(i),children:e})},Tx=({children:e})=>{const t=Te("TopItemListComponent")||"div",n=Te("headerHeight"),r={...vx,marginTop:`${n}px`},o=Te("context");return l.jsx(t,{style:r,...ht(t,o),children:e})},Ex=y.memo(function(e){const t=Te("useWindowScroll"),n=Te("topItemsIndexes").length>0,r=Te("customScrollParent"),o=Te("context");return l.jsxs(r||t?Nx:Ix,{...e,context:o,children:[n&&l.jsx(Tx,{children:l.jsx(Nc,{showTopList:!0})}),l.jsxs(r||t?Cx:Sx,{children:[l.jsx(bx,{}),l.jsx(Nc,{}),l.jsx(yx,{})]})]})}),{Component:kx,useEmitter:pi,useEmitterValue:Te,usePublisher:jt}=yc(fx,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},Ex),Ix=Ac({useEmitter:pi,useEmitterValue:Te,usePublisher:jt}),Nx=_c({useEmitter:pi,useEmitterValue:Te,usePublisher:jt}),Ax=kx;Ge(bc,ze(()=>{const e=Y(u=>l.jsxs("td",{children:["Item $",u]})),t=Y(null),n=Y(u=>l.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=Y(null),o=Y(null),s=Y({}),i=Y(hi),a=Y(qn),c=(u,d=null)=>ft(B(s,oe(f=>f[u]),Ye()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:c("EmptyPlaceholder"),FillerRow:c("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder"),TableBodyComponent:c("TableBody","tbody"),TableComponent:c("Table","table"),TableFooterComponent:c("TableFoot","tfoot"),TableHeadComponent:c("TableHead","thead"),TableRowComponent:c("TableRow","tr"),GroupComponent:c("Group","tr")}})),fi();const jc={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},_x={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Rc,floor:wo,max:Er,min:mi,round:Pc}=Math;function Oc(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function jx(e){return{..._x,items:e}}function bo(e,t){return e&&e.width===t.width&&e.height===t.height}function Rx(e,t){return e&&e.column===t.column&&e.row===t.row}const Px=ze(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:c,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},h,m,{didMount:w,propsReady:v},{customScrollParent:g,useWindowScroll:x,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k},C])=>{const T=Y(0),I=Y(0),N=Y(jc),_=Y({height:0,width:0}),j=Y({height:0,width:0}),R=Oe(),z=Oe(),H=Y(0),O=Y(null),W=Y({column:0,row:0}),K=Oe(),G=Oe(),$=Y(!1),A=Y(0),D=Y(!0),U=Y(!1),J=Y(!1);He(B(w,Ae(A),be(([M,X])=>!!X)),()=>{Ie(D,!1)}),He(B(ot(w,D,j,_,A,U),be(([M,X,ee,L,,F])=>M&&!X&&ee.height!==0&&L.height!==0&&!F)),([,,,,M])=>{Ie(U,!0),si(1,()=>{Ie(R,M)}),Ft(B(u),()=>{Ie(t,[0,0]),Ie(D,!0)})}),ue(B(G,be(M=>M!=null&&M.scrollTop>0),Kt(0)),I),He(B(w,Ae(G),be(([,M])=>M!=null)),([,M])=>{M&&(Ie(_,M.viewport),Ie(j,M.item),Ie(W,M.gap),M.scrollTop>0&&(Ie($,!0),Ft(B(u,In(1)),X=>{Ie($,!1)}),Ie(c,{top:M.scrollTop})))}),ue(B(_,oe(({height:M})=>M)),f),ue(B(ot(ve(_,bo),ve(j,bo),ve(W,(M,X)=>M&&M.column===X.column&&M.row===X.row),ve(u)),oe(([M,X,ee,L])=>({gap:ee,item:X,scrollTop:L,viewport:M}))),K),ue(B(ot(ve(T),r,ve(W,Rx),ve(j,bo),ve(_,bo),ve(O),ve(I),ve($),ve(D),ve(A)),be(([,,,,,,,M])=>!M),oe(([M,[X,ee],L,F,me,Re,xe,,_e,Be])=>{const{column:qe,row:$e}=L,{height:nt,width:at}=F,{width:ie}=me;if(xe===0&&(M===0||ie===0))return jc;if(at===0){const Dt=ii(Be,M),ir=Dt+Math.max(xe-1,0);return jx(Oc(Dt,ir,Re))}const te=Mc(ie,at,qe);let pe,de;_e?X===0&&ee===0&&xe>0?(pe=0,de=xe-1):(pe=te*wo((X+$e)/(nt+$e)),de=te*Rc((ee+$e)/(nt+$e))-1,de=mi(M-1,Er(de,te-1)),pe=mi(de,Er(0,pe))):(pe=0,de=-1);const Ne=Oc(pe,de,Re),{bottom:Fe,top:Xe}=Dc(me,L,F,Ne),Ze=Rc(M/te),lt=Ze*nt+(Ze-1)*$e-Fe;return{bottom:Fe,itemHeight:nt,items:Ne,itemWidth:at,offsetBottom:lt,offsetTop:Xe,top:Xe}})),N),ue(B(O,be(M=>M!==null),oe(M=>M.length)),T),ue(B(ot(_,j,N,W),be(([M,X,{items:ee}])=>ee.length>0&&X.height!==0&&M.height!==0),oe(([M,X,{items:ee},L])=>{const{bottom:F,top:me}=Dc(M,L,X,ee);return[me,F]}),Ye(vr)),t);const Q=Y(!1);ue(B(u,Ae(Q),oe(([M,X])=>X||M!==0)),Q);const ce=Tt(B(ot(N,T),be(([{items:M}])=>M.length>0),Ae(Q),be(([[M,X],ee])=>{const L=M.items[M.items.length-1].index===X-1;return(ee||M.bottom>0&&M.itemHeight>0&&M.offsetBottom===0&&M.items.length===X)&&L}),oe(([[,M]])=>M-1),Ye())),we=Tt(B(ve(N),be(({items:M})=>M.length>0&&M[0].index===0),Kt(0),Ye())),ke=Tt(B(ve(N),Ae($),be(([{items:M},X])=>M.length>0&&!X),oe(([{items:M}])=>({endIndex:M[M.length-1].index,startIndex:M[0].index})),Ye(tc),on(0)));ue(ke,m.scrollSeekRangeChanged),ue(B(R,Ae(_,j,T,W),oe(([M,X,ee,L,F])=>{const me=ac(M),{align:Re,behavior:xe,offset:_e}=me;let Be=me.index;Be==="LAST"&&(Be=L-1),Be=Er(0,Be,mi(L-1,Be));let qe=gi(X,F,ee,Be);return Re==="end"?qe=Pc(qe-X.height+ee.height):Re==="center"&&(qe=Pc(qe-X.height/2+ee.height/2)),_e&&(qe+=_e),{behavior:xe,top:qe}})),c);const q=ft(B(N,oe(M=>M.offsetBottom+M.bottom)),0);return ue(B(k,oe(M=>({height:M.visibleHeight,width:M.visibleWidth}))),_),{customScrollParent:g,data:O,deviation:H,footerHeight:o,gap:W,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:j,overscan:n,restoreStateFrom:G,scrollBy:i,scrollContainerState:a,scrollHeight:z,scrollTo:c,scrollToIndex:R,scrollTop:u,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:x,viewportDimensions:_,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k,...m,gridState:N,horizontalDirection:J,initialTopMostItemIndex:A,totalListHeight:q,...h,endReached:ce,propsReady:v,rangeChanged:ke,startReached:we,stateChanged:K,stateRestoreInProgress:$,...C}},Ge(ai,mt,Tr,vc,hn,ci,dn));function Mc(e,t,n){return Er(1,wo((e+n)/(wo(t)+n)))}function Dc(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=gi(e,t,n,r[0].index);return{bottom:gi(e,t,n,r[r.length-1].index)+o,top:s}}function gi(e,t,n,r){const o=Mc(e.width,n.width,t.column),s=wo(r/o),i=s*n.height+Er(0,s-1)*t.row;return i>0?i+t.row:i}const Ox=ze(()=>{const e=Y(f=>`Item ${f}`),t=Y({}),n=Y(null),r=Y("virtuoso-grid-item"),o=Y("virtuoso-grid-list"),s=Y(hi),i=Y("div"),a=Y(qn),c=(f,h=null)=>ft(B(t,oe(m=>m[f]),Ye()),h),u=Y(!1),d=Y(!1);return ue(ve(d),u),{components:t,computeItemKey:s,context:n,FooterComponent:c("Footer"),HeaderComponent:c("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:c("Item","div"),itemContent:e,listClassName:o,ListComponent:c("List","div"),readyStateChanged:u,reportReadyState:d,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}),Mx=ze(([e,t])=>({...e,...t}),Ge(Px,Ox)),Dx=y.memo(function(){const e=Je("gridState"),t=Je("listClassName"),n=Je("itemClassName"),r=Je("itemContent"),o=Je("computeItemKey"),s=Je("isSeeking"),i=Rt("scrollHeight"),a=Je("ItemComponent"),c=Je("ListComponent"),u=Je("ScrollSeekPlaceholder"),d=Je("context"),f=Rt("itemDimensions"),h=Rt("gap"),m=Je("log"),w=Je("stateRestoreInProgress"),v=Rt("reportReadyState"),g=Nn(y.useMemo(()=>x=>{const b=x.parentElement.parentElement.scrollHeight;i(b);const S=x.firstChild;if(S){const{height:k,width:C}=S.getBoundingClientRect();f({height:k,width:C})}h({column:$c("column-gap",getComputedStyle(x).columnGap,m),row:$c("row-gap",getComputedStyle(x).rowGap,m)})},[i,f,h,m]),!0,!1);return Tc(()=>{e.itemHeight>0&&e.itemWidth>0&&v(!0)},[e]),w?null:l.jsx(c,{className:t,ref:g,...ht(c,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(x=>{const b=o(x.index,x.data,d);return s?l.jsx(u,{...ht(u,d),height:e.itemHeight,index:x.index,width:e.itemWidth},b):y.createElement(a,{...ht(a,d),className:n,"data-index":x.index,key:b},r(x.index,x.data,d))})})}),Lx=y.memo(function(){const e=Je("HeaderComponent"),t=Rt("headerHeight"),n=Je("headerFooterTag"),r=Nn(y.useMemo(()=>s=>{t(fn(s,"height"))},[t]),!0,!1),o=Je("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...ht(e,o)})}):null}),$x=y.memo(function(){const e=Je("FooterComponent"),t=Rt("footerHeight"),n=Je("headerFooterTag"),r=Nn(y.useMemo(()=>s=>{t(fn(s,"height"))},[t]),!0,!1),o=Je("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...ht(e,o)})}):null}),Fx=({children:e})=>{const t=y.useContext(Cc),n=Rt("itemDimensions"),r=Rt("viewportDimensions"),o=Nn(y.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return y.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),l.jsx("div",{ref:o,style:vo(!1),children:e})},zx=({children:e})=>{const t=y.useContext(Cc),n=Rt("windowViewportRect"),r=Rt("itemDimensions"),o=Je("customScrollParent"),s=Gl(n,o,!1);return y.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),l.jsx("div",{ref:s,style:vo(!1),children:e})},Bx=y.memo(function({...e}){const t=Je("useWindowScroll"),n=Je("customScrollParent"),r=n||t?Ux:Hx,o=n||t?zx:Fx,s=Je("context");return l.jsx(r,{...e,...ht(r,s),children:l.jsxs(o,{children:[l.jsx(Lx,{}),l.jsx(Dx,{}),l.jsx($x,{})]})})}),{useEmitter:Lc,useEmitterValue:Je,usePublisher:Rt}=yc(Mx,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},Bx),Hx=Ac({useEmitter:Lc,useEmitterValue:Je,usePublisher:Rt}),Ux=_c({useEmitter:Lc,useEmitterValue:Je,usePublisher:Rt});function $c(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,bt.WARN),t==="normal"?0:parseInt(t??"0",10)}const Wx=Kr.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function xi({className:e,variant:t,...n}){return l.jsx("div",{className:Z(Wx({variant:t}),e),...n})}function ae(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Vx(e,t){const n=p.createContext(t),r=s=>{const{children:i,...a}=s,c=p.useMemo(()=>a,Object.values(a));return l.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function o(s){const i=p.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function Yt(e,t=[]){let n=[];function r(s,i){const a=p.createContext(i),c=n.length;n=[...n,i];const u=f=>{var x;const{scope:h,children:m,...w}=f,v=((x=h==null?void 0:h[e])==null?void 0:x[c])||a,g=p.useMemo(()=>w,Object.values(w));return l.jsx(v.Provider,{value:g,children:m})};u.displayName=s+"Provider";function d(f,h){var v;const m=((v=h==null?void 0:h[e])==null?void 0:v[c])||a,w=p.useContext(m);if(w)return w;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>p.createContext(i));return function(a){const c=(a==null?void 0:a[e])||s;return p.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,Kx(o,...t)]}function Kx(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:c,scopeName:u})=>{const f=c(s)[`__scope${u}`];return{...a,...f}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var ct=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},qx=p[" useInsertionEffect ".trim().toString()]||ct;function jn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Gx({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:o;{const d=p.useRef(e!==void 0);p.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const u=p.useCallback(d=>{var f;if(a){const h=Yx(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[c,u]}function Gx({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),s=p.useRef(t);return qx(()=>{s.current=t},[t]),p.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Yx(e){return typeof e=="function"}function Fc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function vi(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Fc(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():Fc(e[o],null)}}}}function je(...e){return p.useCallback(vi(...e),e)}var Xx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ye=Xx.reduce((e,t)=>{const n=Cn.createSlot(`Primitive.${t}`),r=p.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(c,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function zc(e,t){e&&qr.flushSync(()=>e.dispatchEvent(t))}function Jx(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var kt=e=>{const{present:t,children:n}=e,r=Zx(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),s=je(r.ref,Qx(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:s}):null};kt.displayName="Presence";function Zx(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),s=p.useRef("none"),i=e?"mounted":"unmounted",[a,c]=Jx(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const u=yo(r.current);s.current=a==="mounted"?u:"none"},[a]),ct(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,m=yo(u);e?c("MOUNT"):m==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(d&&h!==m?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),ct(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=m=>{const v=yo(r.current).includes(CSS.escape(m.animationName));if(m.target===t&&v&&(c("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},h=m=>{m.target===t&&(s.current=yo(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:p.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function yo(e){return(e==null?void 0:e.animationName)||"none"}function Qx(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ev=p[" useId ".trim().toString()]||(()=>{}),tv=0;function Xt(e){const[t,n]=p.useState(ev());return ct(()=>{n(r=>r??String(tv++))},[e]),e||(t?`radix-${t}`:"")}var So="Collapsible",[nv,BC]=Yt(So),[rv,wi]=nv(So),Bc=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[c,u]=jn({prop:r,defaultProp:o??!1,onChange:i,caller:So});return l.jsx(rv,{scope:n,disabled:s,contentId:Xt(),open:c,onOpenToggle:p.useCallback(()=>u(d=>!d),[u]),children:l.jsx(ye.div,{"data-state":yi(c),"data-disabled":s?"":void 0,...a,ref:t})})});Bc.displayName=So;var Hc="CollapsibleTrigger",Uc=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=wi(Hc,n);return l.jsx(ye.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":yi(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:ae(e.onClick,o.onOpenToggle)})});Uc.displayName=Hc;var bi="CollapsibleContent",ov=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=wi(bi,e.__scopeCollapsible);return l.jsx(kt,{present:n||o.open,children:({present:s})=>l.jsx(sv,{...r,ref:t,present:s})})});ov.displayName=bi;var sv=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=wi(bi,n),[a,c]=p.useState(r),u=p.useRef(null),d=je(t,u),f=p.useRef(0),h=f.current,m=p.useRef(0),w=m.current,v=i.open||a,g=p.useRef(v),x=p.useRef(void 0);return p.useEffect(()=>{const b=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(b)},[]),ct(()=>{const b=u.current;if(b){x.current=x.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const S=b.getBoundingClientRect();f.current=S.height,m.current=S.width,g.current||(b.style.transitionDuration=x.current.transitionDuration,b.style.animationName=x.current.animationName),c(r)}},[i.open,r]),l.jsx(ye.div,{"data-state":yi(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!v,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":w?`${w}px`:void 0,...e.style},children:v&&o})});function yi(e){return e?"open":"closed"}var iv=Bc;const Wc=iv,Vc=Uc,kr=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:Z("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));kr.displayName="Card";const Ir=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:Z("flex flex-col space-y-1.5 p-6",e),...t}));Ir.displayName="CardHeader";const Nr=p.forwardRef(({className:e,...t},n)=>l.jsx("h3",{ref:n,className:Z("text-2xl font-semibold leading-none tracking-tight",e),...t}));Nr.displayName="CardTitle";const Kc=p.forwardRef(({className:e,...t},n)=>l.jsx("p",{ref:n,className:Z("text-sm text-muted-foreground",e),...t}));Kc.displayName="CardDescription";const Co=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:Z("p-6 pt-0",e),...t}));Co.displayName="CardContent";const qc=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:Z("flex items-center p-6 pt-0",e),...t}));qc.displayName="CardFooter";function Gc(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let Rn=Gc();function av(e){Rn=e}const Yc=/[&<>"']/,lv=new RegExp(Yc.source,"g"),Xc=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,cv=new RegExp(Xc.source,"g"),uv={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Jc=e=>uv[e];function pt(e,t){if(t){if(Yc.test(e))return e.replace(lv,Jc)}else if(Xc.test(e))return e.replace(cv,Jc);return e}const dv=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Zc(e){return e.replace(dv,(t,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const fv=/(^|[^\[])\^/g;function Ve(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(fv,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const hv=/[^\w:]/g,pv=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Qc(e,t,n){if(e){let r;try{r=decodeURIComponent(Zc(n)).replace(hv,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!pv.test(n)&&(n=vv(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const To={},mv=/^[^:]+:\/*[^/]*$/,gv=/^([^:]+:)[\s\S]*$/,xv=/^([^:]+:\/*[^/]*)[\s\S]*$/;function vv(e,t){To[" "+e]||(mv.test(e)?To[" "+e]=e+"/":To[" "+e]=ko(e,"/",!0)),e=To[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(gv,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(xv,"$1")+t:e+t}const Eo={exec:function(){}};function eu(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let c=!1,u=i;for(;--u>=0&&a[u]==="\\";)c=!c;return c?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function ko(e,t,n){const r=e.length;if(r===0)return"";let o=0;for(;o<r;){const s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function wv(e,t){if(e.indexOf(t[1])===-1)return-1;const n=e.length;let r=0,o=0;for(;o<n;o++)if(e[o]==="\\")o++;else if(e[o]===t[0])r++;else if(e[o]===t[1]&&(r--,r<0))return o;return-1}function bv(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function tu(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function nu(e,t,n,r){const o=t.href,s=t.title?pt(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:pt(i)}}function yv(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
37
+ `))>=0;){const ie=Ie.slice(0,st);Ie=Ie.slice(st+2);const ae=mg(ie);if(!ae)continue;let me;try{me=JSON.parse(ae)}catch{console.debug("[use-chat] malformed SSE:",ae.slice(0,200));continue}const ge=pg(me)?me.data:me;ce=Date.now();const ke=ge.seq;if(ke!==void 0){if(ke<=M){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:ke,lastProcessedSeq:M,type:ge.type});continue}M>0&&ke>M+1&&((L=R==null?void 0:R.onGap)==null||L.call(R,{from:M,to:ke})),M=ke,k.current=ke,v(ke)}if(j==null||j(ge),ge.type==="token"&&e.autoAppendAssistant!==!1)K.push(ge.content),de();else if(ge.type==="message_delta"){const je=ge.delta.filter(Ke=>Ke.type==="text").map(Ke=>Ke.text).join("");je&&e.autoAppendAssistant!==!1&&(K.push(je),de())}else Y!==null&&cancelAnimationFrame(Y),ee(),ge.type==="checkpoint"?m(ge.checkpointId):ge.type==="error"&&u(ge.message)}}ee()}catch(V){if(V.name!=="AbortError"){const J=V.message||String(V);u(J),(A=R==null?void 0:R.onError)==null||A.call(R,J)}}finally{try{await ue.cancel()}catch{}finally{(D=ue.releaseLock)==null||D.call(ue)}Y!==null&&typeof window<"u"&&window.cancelAnimationFrame(Y),clearInterval(ze),a(!1),x(!1),b.current=null}}catch(X){if(X.name!=="AbortError"){const Q=X.message||String(X);u(Q),(H=R==null?void 0:R.onError)==null||H.call(R,Q)}}finally{a(!1),x(!1),b.current=null}})(),{close:()=>$.abort()}},[t,n,r,e.autoAppendAssistant]);return y.useEffect(()=>()=>{var _;S.current=!1,(_=b.current)==null||_.abort()},[]),{isStreaming:i,error:c,assistantText:d,lastCheckpointId:h,lastSeq:w,connected:g,stream:N,stop:T,clear:I,setToken:C}}function pg(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function mg(e){const t=e.split(/\r?\n/),n=[];for(const r of t)if(r&&!r.startsWith(":")&&r.startsWith("data:")){const o=r.slice(5);n.push(o.startsWith(" ")?o.slice(1):o)}return n.length===0?null:n.join(`
38
+ `)}const zl=y.createContext(null);function gg({children:e,enableFileAgentRouting:t=!1,fileAgentId:n="invoice_reader",onRegisterThreadCallbacks:r}){const{api:o,baseUrl:s}=so(),i=y.useMemo(()=>{const V=(s??"").replace(/\/+$/,"");return V?V.endsWith("/chat")?V:`${V}/chat`:"/api/chat"},[s]),{currentThreadId:a,setCurrentThreadId:c,isLoadingThread:u}=mr(),d=Xm(),{state:f,dispatch:h,seed:m,prepend:w,pushUser:v,onEvent:g,reset:x}=Ll(),[b,S]=y.useState(!1),[k,C]=y.useState(!1),[T,I]=y.useState(null),[N,_]=y.useState(void 0),[j,R]=y.useState(void 0),$=20,z=y.useRef(a);y.useEffect(()=>{z.current=a},[a]);const O=y.useRef(null),W=y.useRef(!1),B=y.useCallback(()=>{W.current=!0},[]),{isStreaming:q,error:L,stream:A,stop:D,setToken:H}=Fl({baseUrl:i,token:null});y.useEffect(()=>{const V=o.getAuthToken();H(V)},[o,H]),y.useEffect(()=>{d(q?{type:"STREAM_START",assistantId:f.assemblingId??void 0}:{type:"STREAM_END"})},[q,f.assemblingId,d]),y.useEffect(()=>{d(L?{type:"STREAM_ERROR",error:L}:{type:"CLEAR_ERROR"})},[L,d]),y.useEffect(()=>{f.lastCheckpointId&&d({type:"UPDATE_CHECKPOINT",checkpointId:f.lastCheckpointId,checkpointNs:f.lastCheckpointNs??void 0})},[f.lastCheckpointId,f.lastCheckpointNs,d]),y.useEffect(()=>{d({type:"UPDATE_ASSEMBLING_ID",assistantId:f.assemblingId})},[f.assemblingId,d]);const X=y.useCallback((V,J)=>{const be=Array.isArray(V==null?void 0:V.messages)?V.messages:[];J==="replace"?(console.log("[MessagesProvider] Replacing messages, count:",be.length),m(be,{checkpointId:(V==null?void 0:V.checkpointId)??null,checkpointNs:(V==null?void 0:V.checkpointNs)??null})):J==="prepend"&&be.length&&(console.log("[MessagesProvider] Prepending messages, count:",be.length),w(be)),I((V==null?void 0:V.nextCursor)??null),S(!!(V!=null&&V.hasMore)),_(Oe=>(V==null?void 0:V.checkpointId)??Oe??void 0),R(Oe=>(V==null?void 0:V.checkpointNs)??Oe??void 0)},[m,w]),Q=y.useCallback(V=>{const J=V.threadId,be=!!V.created,Oe=!!V.ready;if(a!==J){const _e=!a&&f.messages.length<=1;_e&&(O.current=J),c(J),(Oe||be||_e)&&B();return}(Oe||be)&&B()},[a,f.messages.length,c,B]),ue=y.useCallback(({from:V,to:J})=>{const be=z.current;be&&console.warn(`[MessagesProvider] Stream sequence gap detected (${V} -> ${J}) for thread ${be}`)},[]),{handleEvent:we,reset:Ie}=hg({onThreadInfo:Q,onMessageEvent:g,onUnhandledEvent:V=>{console.warn(`[MessagesProvider] Unhandled stream event type: ${V.type}`,V)},onSequenceGap:ue}),K=y.useCallback(async V=>{if(!a)throw new Error("No active thread");if(k||!b)return;const J=T;if(J){C(!0);try{const be=await o.getMessages({threadId:a,checkpointId:N,checkpointNs:j,limit:(V==null?void 0:V.limit)??$,beforeId:J});X(be,"prepend")}finally{C(!1)}}},[o,a,N,j,T,b,k,X,$]),M=y.useCallback(()=>{console.log("[MessagesProvider] Clearing messages"),x([]),S(!1),C(!1),I(null),_(void 0),R(void 0)},[x]),Y=y.useCallback((V,J)=>{console.log("[MessagesProvider] Handling thread load for",V),W.current=!1,X(J,"replace")},[X]),ee=y.useCallback(()=>{console.log("[MessagesProvider] Handling thread clear"),W.current=!1,M()},[M]),de=y.useMemo(()=>({onThreadLoaded:Y,onThreadCleared:ee}),[Y,ee]);y.useEffect(()=>{if(r)return r(de),()=>{r({onThreadLoaded:()=>{},onThreadCleared:()=>{}})}},[r,de]);const ce=y.useCallback(async(V,J)=>{var ke;!a&&!(J!=null&&J.payloadExtras)&&console.warn("[MessagesProvider] No thread ID - message will create new thread");const be=(J==null?void 0:J.attachments)||[],{contentParts:Oe,filesInfo:_e}=await Qm(o,be),et=[...Oe];V&&V.trim()&&et.push({type:"text",text:V.trim()});const st={id:((ke=crypto.randomUUID)==null?void 0:ke.call(crypto))||`user-${Date.now()}`,role:"user",content:et,createdAt:new Date().toISOString(),checkpointId:(J==null?void 0:J.checkpointId)??f.lastCheckpointId??void 0,checkpointNs:(J==null?void 0:J.checkpointNs)??f.lastCheckpointNs??void 0};v(st);const ie={...st,content:et},ae={...(J==null?void 0:J.payloadExtras)??{}},me=be&&be.length>0,ge={...a?{threadId:a}:{},payload:{messages:[ie],files_info:_e,...t&&me&&n?{active_agent:n}:{},...ae},checkpointId:(J==null?void 0:J.checkpointId)??f.lastCheckpointId??void 0,checkpointNs:(J==null?void 0:J.checkpointNs)??f.lastCheckpointNs??void 0,nodeFilter:J==null?void 0:J.nodeFilter,config:J==null?void 0:J.config};Ie(),B(),A(ge,je=>{we(je)},{onError:je=>console.warn("[MessagesProvider] Stream error:",je),onOpen:({threadId:je,created:Ke})=>{if(!a&&je){const qe=f.messages.length<=1;qe&&(O.current=je),c(je),(Ke||qe)&&B()}},onGap:ue})},[a,v,A,we,Ie,ue,f.lastCheckpointId,f.lastCheckpointNs,f.messages.length,o,B,c,t,n]),ze=y.useCallback(async(V,J,be)=>{const Oe=z.current;if(!Oe)throw new Error("No active thread to handle interrupt");try{console.log(`[MessagesProvider] Handling interrupt ${V}: ${J?"approved":"rejected"}`);const _e=J?be??!0:!1;await o.resume({threadId:Oe,value:_e}),console.log(`[MessagesProvider] Interrupt ${V} handled successfully`)}catch(_e){throw console.error(`[MessagesProvider] Failed to handle interrupt ${V}:`,_e),_e}},[o]),Ye={messages:f.messages,assemblingId:f.assemblingId,lastUserMessage:null,hasMoreHistory:b,isLoadingHistory:k,send:ce,stop:D,loadOlderMessages:K,clearMessages:M,handleInterrupt:ze};return l.jsx(zl.Provider,{value:Ye,children:e})}function xg(e){return l.jsx(gg,{...e})}function qs(){const e=y.useContext(zl);if(!e)throw new Error("useMessages must be used within MessagesProvider");return e}function io({children:e,apiConfig:t,initialThreadId:n=null,autoLoadInitial:r=!0,disableAutoRestore:o=!1,enableFileAgentRouting:s=!1,fileAgentId:i="invoice_reader",onError:a,onThreadChange:c}){const u=y.useRef({onThreadLoaded:()=>{},onThreadCleared:()=>{}}),d=y.useCallback(m=>{u.current=m},[]),f=y.useCallback((m,w)=>{u.current.onThreadLoaded(m,w)},[]),h=y.useCallback(()=>{u.current.onThreadCleared()},[]);return l.jsx(Km,{apiConfig:t,children:l.jsx(Ym,{children:l.jsx(tg,{initialThreadId:n,autoLoadInitial:r,disableAutoRestore:o,onError:a,onThreadChange:c,onThreadLoaded:f,onThreadCleared:h,children:l.jsx(xg,{enableFileAgentRouting:s,fileAgentId:i,onRegisterThreadCallbacks:d,children:e})})})})}function Z(...e){return yp.twMerge(bp.clsx(e))}const vg=Kr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Fe=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Cn.Slot:"button";return l.jsx(i,{className:Z(vg({variant:t,size:n,className:e})),ref:s,...o})});Fe.displayName="Button";const Bl=p.forwardRef(({className:e,...t},n)=>l.jsx("textarea",{className:Z("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Bl.displayName="Textarea";function wg({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,onSend:i,onCancelEdit:a,onStop:c,className:u="",textareaClassName:d="",allowEmptySend:f=!1}){const[h,m]=y.useState(e),[w,v]=y.useTransition(),g=y.useRef(null);y.useEffect(()=>{m(e??""),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const x=y.useCallback(()=>{const N=g.current;N&&(N.style.height="auto",N.style.height=`${N.scrollHeight}px`)},[]);y.useEffect(()=>{x()},[x]);const b=y.useCallback(async N=>{N&&N.preventDefault();const _=(h??"").trim();!_&&!f||v(()=>{try{const j=i(_);j&&typeof j.then=="function"?j.then(()=>{m(""),g.current&&(g.current.style.height="auto")}).catch(()=>{}):(m(""),g.current&&(g.current.style.height="auto"))}catch{}})},[h,i,f]),S=y.useCallback(N=>{m(N.target.value),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),k=y.useCallback(N=>{N.key==="Enter"&&!N.shiftKey?(N.preventDefault(),b()):N.key==="Escape"&&t&&(N.preventDefault(),a==null||a())},[b,t,a]),I=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${d}`;return l.jsx("form",{onSubmit:N=>void b(N),className:`w-full ${u}`,children:l.jsxs("div",{className:"flex items-end gap-2",children:[l.jsx("div",{className:"flex-1",children:l.jsx(Bl,{ref:g,value:h,onChange:S,onKeyDown:k,placeholder:t?"Edit your message...":n,className:I,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),l.jsx("div",{children:r?l.jsx(Fe,{type:"button",onClick:()=>{c==null||c()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!c,children:l.jsx(te.Square,{size:16})}):l.jsx(Fe,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||w,children:l.jsx(te.Send,{size:16})})})]})})}const bg=y.memo(wg),ao=0,un=1,Kn=2,Hl=4;function Ul(e){return()=>e}function yg(e){e()}function Wl(e,t){return n=>e(t(n))}function Vl(e,t){return()=>e(t)}function Sg(e,t){return n=>e(t,n)}function Gs(e){return e!==void 0}function Cg(...e){return()=>{e.map(yg)}}function qn(){}function lo(e,t){return t(e),e}function Tg(e,t){return t(e)}function Xe(...e){return e}function He(e,t){return e(un,t)}function Ae(e,t){e(ao,t)}function Ys(e){e(Kn)}function nt(e){return e(Hl)}function fe(e,t){return He(e,Sg(t,ao))}function Ft(e,t){const n=e(un,r=>{n(),t(r)});return n}function Kl(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function ql(e,t){return e===t}function Je(e=ql){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function ye(e){return t=>n=>{e(n)&&t(n)}}function re(e){return t=>Wl(t,e)}function Kt(e){return t=>()=>{t(e)}}function F(e,...t){const n=Eg(...t);return(r,o)=>{switch(r){case Kn:Ys(e);return;case un:return He(e,n(o))}}}function qt(e,t){return n=>r=>{n(t=e(t,r))}}function In(e){return t=>n=>{e>0?e--:t(n)}}function on(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Re(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);He(s,c=>{const u=n;n=n|a,t[i]=c,u!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function Eg(...e){return t=>e.reduceRight(Tg,t)}function kg(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case un:return s?n===s?void 0:(r(),n=s,t=He(e,s),t):(r(),qn);case Kn:r(),n=null;return}}}function G(e){let t=e;const n=De();return(r,o)=>{switch(r){case ao:t=o;break;case un:{o(t);break}case Hl:return t}return n(r,o)}}function ft(e,t){return lo(G(t),n=>fe(e,n))}function De(){const e=[];return(t,n)=>{switch(t){case ao:e.slice().forEach(r=>{r(n)});return;case Kn:e.splice(0,e.length);return;case un:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Tt(e){return lo(De(),t=>fe(e,t))}function Be(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Ig(),singleton:n}}const Ig=()=>Symbol();function Ng(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(c=>n(c)));return i&&t.set(s,a),a};return n(e)}function ot(...e){const t=De(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);He(s,c=>{n[i]=c,r=r|a,r===o&&Ae(t,n)})}),function(s,i){switch(s){case Kn:{Ys(t);return}case un:return r===o&&i(n),He(t,i)}}}function ve(e,t=ql){return F(e,Je(t))}function Xs(...e){return function(t,n){switch(t){case Kn:return;case un:return Cg(...e.map(r=>He(r,n)))}}}var bt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(bt||{});const Ag={0:"debug",3:"error",1:"log",2:"warn"},_g=()=>typeof globalThis>"u"?window:globalThis,dn=Be(()=>{const e=G(3);return{log:G((t,n,r=1)=>{var o;const s=(o=_g().VIRTUOSO_LOG_LEVEL)!=null?o:nt(e);r>=s&&console[Ag[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Nn(e,t,n){return Js(e,t,n).callbackRef}function Js(e,t,n){const r=y.useRef(null);let o=i=>{};const s=y.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const c=i[0].target;c.offsetParent!==null&&e(c)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function jg(e,t,n,r,o,s,i,a,c){const u=y.useCallback(d=>{const f=Rg(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const m=h.lastElementChild.dataset.viewportType==="window";let w;m&&(w=h.ownerDocument.defaultView);const v=i?a?i.scrollLeft:i.scrollTop:m?a?w.scrollX||w.document.documentElement.scrollLeft:w.scrollY||w.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:m?a?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,x=i?a?i.offsetWidth:i.offsetHeight:m?a?w.innerWidth:w.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(v,0),viewportHeight:x}),s==null||s(a?Gl("column-gap",getComputedStyle(d).columnGap,o):Gl("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return Js(u,n,c)}function Rg(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const c=parseInt(a.dataset.index),u=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},bt.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==c-1?s.push({endIndex:c,size:d,startIndex:c}):s[s.length-1].endIndex++}return s}function Gl(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,bt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Yl(e,t,n){const r=y.useRef(null),o=y.useCallback(c=>{if(!(c!=null&&c.offsetParent))return;const u=c.getBoundingClientRect(),d=u.width;let f,h;if(t){const m=t.getBoundingClientRect(),w=u.top-m.top;h=m.height-Math.max(0,w),f=w+t.scrollTop}else{const m=i.current.ownerDocument.defaultView;h=m.innerHeight-Math.max(0,u.top),f=u.top+m.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Js(o,!0,n),a=y.useCallback(()=>{o(i.current)},[o,i]);return y.useEffect(()=>{var c;if(t){t.addEventListener("scroll",a);const u=new ResizeObserver(()=>{requestAnimationFrame(a)});return u.observe(t),()=>{t.removeEventListener("scroll",a),u.unobserve(t)}}else{const u=(c=i.current)==null?void 0:c.ownerDocument.defaultView;return u==null||u.addEventListener("scroll",a),u==null||u.addEventListener("resize",a),()=>{u==null||u.removeEventListener("scroll",a),u==null||u.removeEventListener("resize",a)}}},[a,t,i]),s}const mt=Be(()=>{const e=De(),t=De(),n=G(0),r=De(),o=G(0),s=De(),i=De(),a=G(0),c=G(0),u=G(0),d=G(0),f=De(),h=De(),m=G(!1),w=G(!1),v=G(!1);return fe(F(e,re(({scrollTop:g})=>g)),t),fe(F(e,re(({scrollHeight:g})=>g)),i),fe(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:c,footerHeight:d,headerHeight:a,horizontalDirection:w,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:m,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:v,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),gr={lvl:0};function Xl(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:c}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=c}return s.push({end:1/0,start:r,value:o}),s}function We(e){return e===gr}function xr(e,t){if(!We(e))return t===e.k?e.v:t<e.k?xr(e.l,t):xr(e.r,t)}function zt(e,t,n="k"){if(We(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=zt(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return zt(e.l,t,n)}function Et(e,t,n){return We(e)?Ql(t,n,1):t===e.k?at(e,{k:t,v:n}):t<e.k?ec(at(e,{l:Et(e.l,t,n)})):ec(at(e,{r:Et(e.r,t,n)}))}function Gn(){return gr}function co(e,t,n){if(We(e))return[];const r=zt(e,t)[0];return Pg(Qs(e,r,n))}function Zs(e,t){if(We(e))return gr;const{k:n,l:r,r:o}=e;if(t===n){if(We(r))return o;if(We(o))return r;{const[s,i]=Zl(r);return uo(at(e,{k:s,l:Jl(r),v:i}))}}else return t<n?uo(at(e,{l:Zs(r,t)})):uo(at(e,{r:Zs(o,t)}))}function An(e){return We(e)?[]:[...An(e.l),{k:e.k,v:e.v},...An(e.r)]}function Qs(e,t,n){if(We(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Qs(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Qs(s,t,n))),a}function uo(e){const{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(ei(t))return tc(at(e,{lvl:n-1}));if(!We(t)&&!We(t.r))return at(t.r,{l:at(t,{r:t.r.l}),lvl:n,r:at(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(ei(e))return ti(at(e,{lvl:n-1}));if(!We(r)&&!We(r.l)){const o=r.l,s=ei(o)?r.lvl-1:r.lvl;return at(o,{l:at(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:ti(at(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function at(e,t){return Ql(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function Jl(e){return We(e.r)?e.l:uo(at(e,{r:Jl(e.r)}))}function ei(e){return We(e)||e.lvl>e.r.lvl}function Zl(e){return We(e.r)?[e.k,e.v]:Zl(e.r)}function Ql(e,t,n,r=gr,o=gr){return{k:e,l:r,lvl:n,r:o,v:t}}function ec(e){return ti(tc(e))}function tc(e){const{l:t}=e;return!We(t)&&t.lvl===e.lvl?at(t,{r:at(e,{l:t.r})}):e}function ti(e){const{lvl:t,r:n}=e;return!We(n)&&!We(n.r)&&n.lvl===t&&n.r.lvl===t?at(n,{l:at(e,{r:n.l}),lvl:t+1}):e}function Pg(e){return Xl(e,({k:t,v:n})=>({index:t,value:n}))}function nc(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function vr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const ni=Be(()=>({recalcInProgress:G(!1)}),[],{singleton:!0});function rc(e,t,n){return e[fo(e,t,n)]}function fo(e,t,n,r=0){let o=e.length-1;for(;r<=o;){const s=Math.floor((r+o)/2),i=e[s],a=n(i,t);if(a===0)return s;if(a===-1){if(o-r<2)return s-1;o=s-1}else{if(o===r)return s;r=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function Og(e,t,n,r){const o=fo(e,t,r),s=fo(e,n,r,o);return e.slice(o,s+1)}function fn(e,t){return Math.round(e.getBoundingClientRect()[t])}function ho(e){return!We(e.groupOffsetTree)}function ri({index:e},t){return t===e?0:t<e?-1:1}function Mg(){return{groupIndices:[],groupOffsetTree:Gn(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Gn()}}function Dg(e,t){let n=We(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),We(e)){e=Et(e,0,s);continue}const a=co(e,i-1,o+1);if(a.some(Ug(r)))continue;let c=!1,u=!1;for(const{end:d,start:f,value:h}of a)c?(o>=f||s===h)&&(e=Zs(e,f)):(u=h!==s,c=!0),d>o&&o>=f&&h!==s&&(e=Et(e,o+1,h));u&&(e=Et(e,i,s))}return[e,n]}function Lg(e){return typeof e.groupIndex<"u"}function $g({offset:e},t){return t===e?0:t<e?-1:1}function wr(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=rc(t,e,ri),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function oc(e,t){if(!ho(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function sc(e,t,n){if(Lg(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=oc(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function Fg(e,t,n,r=0){return r>0&&(t=Math.max(t,rc(e,r,ri).offset)),Xl(Og(e,t,n,$g),Hg)}function zg(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,bt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&We(s)&&t.length===2){const h=t[0].size,m=t[1].size;i=n.reduce((w,v)=>Et(Et(w,v,h),v+1,m),i)}else[i,a]=Dg(i,t);if(i===s)return e;const{lastIndex:c,lastOffset:u,lastSize:d,offsetTree:f}=oi(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,m)=>Et(h,m,wr(m,f,o)),Gn()),lastIndex:c,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function Bg(e){return An(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function ic(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function oi(e,t,n,r){let o=e,s=0,i=0,a=0,c=0;if(t!==0){c=fo(o,t-1,ri),a=o[c].offset;const u=zt(n,t-1);s=u[0],i=u[1],o.length&&o[c].size===zt(n,t)[1]&&(c-=1),o=o.slice(0,c+1)}else o=[];for(const{start:u,value:d}of co(n,t,1/0)){const f=u-s,h=f*i+a+f*r;o.push({index:u,offset:h,size:d}),s=u,a=h,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function Hg(e){return{index:e.index,value:e}}function Ug(e){const{endIndex:t,size:n,startIndex:r}=e;return o=>o.start===r&&(o.end===t||o.end===1/0)&&o.value===n}const Wg={offsetHeight:"height",offsetWidth:"width"},Gt=Be(([{log:e},{recalcInProgress:t}])=>{const n=De(),r=De(),o=ft(r,0),s=De(),i=De(),a=G(0),c=G([]),u=G(void 0),d=G(void 0),f=G((C,T)=>fn(C,Wg[T])),h=G(void 0),m=G(0),w=Mg(),v=ft(F(n,Re(c,e,m),qt(zg,w),Je()),w),g=ft(F(c,Je(),qt((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),re(({prev:C})=>C)),[]);fe(F(c,ye(C=>C.length>0),Re(v,m),re(([C,T,I])=>{const N=C.reduce((_,j,R)=>Et(_,j,wr(j,T.offsetTree,I)||R),Gn());return{...T,groupIndices:C,groupOffsetTree:N}})),v),fe(F(r,Re(v),ye(([C,{lastIndex:T}])=>C<T),re(([C,{lastIndex:T,lastSize:I}])=>[{endIndex:T,size:I,startIndex:C}])),n),fe(u,d);const x=ft(F(u,re(C=>C===void 0)),!0);fe(F(d,ye(C=>C!==void 0&&We(nt(v).sizeTree)),re(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=Tt(F(n,Re(v),qt(({sizes:C},[T,I])=>({changed:I!==C,sizes:I}),{changed:!1,sizes:w}),re(C=>C.changed)));He(F(a,qt((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),re(C=>C.diff)),C=>{const{groupIndices:T}=nt(v);if(C>0)Ae(t,!0),Ae(s,C+ic(C,T));else if(C<0){const I=nt(g);I.length>0&&(C-=ic(-C,I)),Ae(i,C)}}),He(F(a,Re(e)),([C,T])=>{C<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},bt.ERROR)});const S=Tt(s);fe(F(s,Re(v),re(([C,T])=>{const I=T.groupIndices.length>0,N=[],_=T.lastSize;if(I){const j=xr(T.sizeTree,0);let R=0,$=0;for(;R<C;){const O=T.groupIndices[$],W=T.groupIndices.length===$+1?1/0:T.groupIndices[$+1]-O-1;N.push({endIndex:O,size:j,startIndex:O}),N.push({endIndex:O+1+W-1,size:_,startIndex:O+1}),$++,R+=W+1}const z=An(T.sizeTree);return R!==C&&z.shift(),z.reduce((O,{k:W,v:B})=>{let q=O.ranges;return O.prevSize!==0&&(q=[...O.ranges,{endIndex:W+C-1,size:O.prevSize,startIndex:O.prevIndex}]),{prevIndex:W+C,prevSize:B,ranges:q}},{prevIndex:C,prevSize:0,ranges:N}).ranges}return An(T.sizeTree).reduce((j,{k:R,v:$})=>({prevIndex:R+C,prevSize:$,ranges:[...j.ranges,{endIndex:R+C-1,size:j.prevSize,startIndex:j.prevIndex}]}),{prevIndex:0,prevSize:_,ranges:[]}).ranges})),n);const k=Tt(F(i,Re(v,m),re(([C,{offsetTree:T},I])=>{const N=-C;return wr(N,T,I)})));return fe(F(i,Re(v,m),re(([C,T,I])=>{if(T.groupIndices.length>0){if(We(T.sizeTree))return T;let N=Gn();const _=nt(g);let j=0,R=0,$=0;for(;j<-C;){$=_[R];const z=_[R+1]-$-1;R++,j+=z+1}if(N=An(T.sizeTree).reduce((z,{k:O,v:W})=>Et(z,Math.max(0,O+C),W),N),j!==-C){const z=xr(T.sizeTree,$);N=Et(N,0,z);const O=zt(T.sizeTree,-C+1)[1];N=Et(N,1,O)}return{...T,sizeTree:N,...oi(T.offsetTree,0,N,I)}}else{const N=An(T.sizeTree).reduce((_,{k:j,v:R})=>Et(_,Math.max(0,j+C),R),Gn());return{...T,sizeTree:N,...oi(T.offsetTree,0,N,I)}}})),v),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:m,groupIndices:c,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:v,statefulTotalCount:o,totalCount:r,trackItemSizes:x,unshiftWith:s}},Xe(dn,ni),{singleton:!0});function Vg(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const ac=Be(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=De(),i=De(),a=Tt(F(s,re(Vg)));return fe(F(a,re(c=>c.totalCount)),n),fe(F(a,re(c=>c.groupIndices)),e),fe(F(ot(o,t,r),ye(([c,u])=>ho(u)),re(([c,u,d])=>zt(u.groupOffsetTree,Math.max(c-d,0),"v")[0]),Je(),re(c=>[c])),i),{groupCounts:s,topItemsIndexes:i}},Xe(Gt,mt)),hn=Be(([{log:e}])=>{const t=G(!1),n=Tt(F(t,ye(r=>r),Je()));return He(t,r=>{r&&nt(e)("props updated",{},bt.DEBUG)}),{didMount:n,propsReady:t}},Xe(dn),{singleton:!0}),Kg=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function lc(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Kg)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const br=Be(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:c,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const m=De(),w=De(),v=G(0);let g=null,x=null,b=null;function S(){g&&(g(),g=null),b&&(b(),b=null),x&&(clearTimeout(x),x=null),Ae(c,!1)}return fe(F(m,Re(n,f,r,v,a,i,h),Re(e,s,o),re(([[k,C,T,I,N,_,j,R],$,z,O])=>{const W=lc(k),{align:B,behavior:q,offset:L}=W,A=I-1,D=sc(W,C,A);let H=wr(D,C.offsetTree,$)+_;B==="end"?(H+=z+zt(C.sizeTree,D)[1]-T+O,D===A&&(H+=j)):B==="center"?H+=(z+zt(C.sizeTree,D)[1]-T+O)/2:H-=N,L&&(H+=L);const X=Q=>{S(),Q?(R("retrying to scroll to",{location:k},bt.DEBUG),Ae(m,k)):(Ae(w,!0),R("list did not change, scroll successful",{},bt.DEBUG))};if(S(),q==="smooth"){let Q=!1;b=He(t,ue=>{Q=Q||ue}),g=Ft(d,()=>{X(Q)})}else g=Ft(F(t,qg(150)),X);return x=setTimeout(()=>{S()},1200),Ae(c,!0),R("scrolling from index to",{behavior:q,index:D,top:H},bt.DEBUG),{behavior:q,top:H}})),u),{scrollTargetReached:w,scrollToIndex:m,topListHeight:v}},Xe(Gt,mt,dn),{singleton:!0});function qg(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function si(e,t){e==0?t():requestAnimationFrame(()=>{si(e-1,t)})}function ii(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const yr=Be(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=G(!0),c=G(0),u=G(!0);return fe(F(i,Re(c),ye(([d,f])=>!!f),Kt(!1)),a),fe(F(i,Re(c),ye(([d,f])=>!!f),Kt(!1)),u),He(F(ot(t,i),Re(a,n,e,u),ye(([[,d],f,{sizeTree:h},m,w])=>d&&(!We(h)||Gs(m))&&!f&&!w),Re(c)),([,d])=>{Ft(o,()=>{Ae(u,!0)}),si(4,()=>{Ft(r,()=>{Ae(a,!0)}),Ae(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:c,scrolledToInitialItem:a}},Xe(Gt,mt,br,hn),{singleton:!0});function cc(e,t){return Math.abs(e-t)<1.01}const Sr="up",Cr="down",Gg="none",Yg={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Xg=0,Tr=Be(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=G(!1),a=G(!0),c=De(),u=De(),d=G(4),f=G(Xg),h=ft(F(Xs(F(ve(o),In(1),Kt(!0)),F(ve(o),In(1),Kt(!1),Kl(100))),Je()),!1),m=ft(F(Xs(F(n,Kt(!0)),F(n,Kt(!1),Kl(200))),Je()),!1);fe(F(ot(ve(o),ve(f)),re(([b,S])=>b<=S),Je()),a),fe(F(a,on(50)),u);const w=Tt(F(ot(r,ve(s),ve(t),ve(e),ve(d)),qt((b,[{scrollHeight:S,scrollTop:k},C,T,I,N])=>{const _=k+C-S>-N,j={scrollHeight:S,scrollTop:k,viewportHeight:C};if(_){let $,z;return k>b.state.scrollTop?($="SCROLLED_DOWN",z=b.state.scrollTop-k):($="SIZE_DECREASED",z=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:$,scrollTopDelta:z,state:j}}let R;return j.scrollHeight>b.state.scrollHeight?R="SIZE_INCREASED":C<b.state.viewportHeight?R="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?R="SCROLLING_UPWARDS":R="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:R,state:j}},Yg),Je((b,S)=>b&&b.atBottom===S.atBottom))),v=ft(F(r,qt((b,{scrollHeight:S,scrollTop:k,viewportHeight:C})=>{if(cc(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const T=S-(k+C)<1;return b.scrollTop!==k&&T?{changed:!0,jump:b.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ye(b=>b.changed),re(b=>b.jump)),0);fe(F(w,re(b=>b.atBottom)),i),fe(F(i,on(50)),c);const g=G(Cr);fe(F(r,re(({scrollTop:b})=>b),Je(),qt((b,S)=>nt(m)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?Sr:Cr,prevScrollTop:S},{direction:Cr,prevScrollTop:0}),re(b=>b.direction)),g),fe(F(r,on(50),Kt(Gg)),g);const x=G(0);return fe(F(h,ye(b=>!b),Kt(0)),x),fe(F(o,on(100),Re(h),ye(([b,S])=>!!S),qt(([b,S],[k])=>[S,k],[0,0]),re(([b,S])=>S-b)),x),{atBottomState:w,atBottomStateChange:c,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:v,scrollDirection:g,scrollVelocity:x}},Xe(mt)),po="top",mo="bottom",uc="none";function dc(e,t,n){return typeof e=="number"?n===Sr&&t===po||n===Cr&&t===mo?e:0:n===Sr?t===po?e.main:e.reverse:t===mo?e.main:e.reverse}function fc(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const ai=Be(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=De(),i=G(0),a=G(0),c=G(0),u=ft(F(ot(ve(r),ve(o),ve(n),ve(s,vr),ve(c),ve(i),ve(t),ve(e),ve(a)),re(([d,f,h,[m,w],v,g,x,b,S])=>{const k=d-b,C=g+x,T=Math.max(h-k,0);let I=uc;const N=fc(S,po),_=fc(S,mo);return m-=b,m+=h+x,w+=h+x,w-=b,m>d+C-N&&(I=Sr),w<d-T+f+_&&(I=Cr),I!==uc?[Math.max(k-h-dc(v,po,I)-N,0),k-T-x+f+dc(v,mo,I)+_]:null}),ye(d=>d!=null),Je(vr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:c,topListHeight:i,visibleRange:u}},Xe(mt),{singleton:!0});function Jg(e,t,n){if(ho(t)){const r=oc(e,t);return[{index:zt(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const li={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function go(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:c}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const v=e[e.length-1];d=v.offset+v.size}const f=n-i,h=a+f*c+(f-1)*r,m=u,w=h-d;return{bottom:d,firstItemIndex:s,items:pc(e,o,s),offsetBottom:w,offsetTop:u,top:m,topItems:pc(t,o,s),topListHeight:t.reduce((v,g)=>g.size+v,0),totalCount:n}}function hc(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,c=ii(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+c],index:f+c,offset:0,size:0}));return go(u,[],a,o,n,r)}function pc(e,t,n){if(e.length===0)return[];if(!ho(t))return e.map(u=>({...u,index:u.index+n,originalIndex:u.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=co(t.groupOffsetTree,r,o);let a,c=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),c=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:c,type:"group"}:d={groupIndex:c,index:u.index-(c+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const _n=Be(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:c},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:m},{recalcInProgress:w}])=>{const v=G([]),g=G(0),x=De();fe(s.topItemsIndexes,v);const b=ft(F(ot(m,w,ve(c,vr),ve(o),ve(r),ve(u),d,ve(v),ve(t),ve(n),e),ye(([T,I,,N,,,,,,,_])=>{const j=_&&_.length!==N;return T&&!I&&!j}),re(([,,[T,I],N,_,j,R,$,z,O,W])=>{const B=_,{offsetTree:q,sizeTree:L}=B,A=nt(g);if(N===0)return{...li,totalCount:N};if(T===0&&I===0)return A===0?{...li,totalCount:N}:hc(A,j,_,z,O,W||[]);if(We(L))return A>0?null:go(Jg(ii(j,N),B,W),[],N,O,B,z);const D=[];if($.length>0){const we=$[0],Ie=$[$.length-1];let K=0;for(const M of co(L,we,Ie)){const Y=M.value,ee=Math.max(M.start,we),de=Math.min(M.end,Ie);for(let ce=ee;ce<=de;ce++)D.push({data:W==null?void 0:W[ce],index:ce,offset:K,size:Y}),K+=Y}}if(!R)return go([],D,N,O,B,z);const H=$.length>0?$[$.length-1]+1:0,X=Fg(q,T,I,H);if(X.length===0)return null;const Q=N-1,ue=lo([],we=>{for(const Ie of X){const K=Ie.value;let M=K.offset,Y=Ie.start;const ee=K.size;if(K.offset<T){Y+=Math.floor((T-K.offset+O)/(ee+O));const ce=Y-Ie.start;M+=ce*ee+ce*O}Y<H&&(M+=(H-Y)*ee,Y=H);const de=Math.min(Ie.end,Q);for(let ce=Y;ce<=de&&!(M>=I);ce++)we.push({data:W==null?void 0:W[ce],index:ce,offset:M,size:ee}),M+=ee+O}});return go(ue,D,N,O,B,z)}),ye(T=>T!==null),Je()),li);fe(F(e,ye(Gs),re(T=>T==null?void 0:T.length)),o),fe(F(b,re(T=>T.topListHeight)),f),fe(f,a),fe(F(b,re(T=>[T.top,T.bottom])),i),fe(F(b,re(T=>T.items)),x);const S=Tt(F(b,ye(({items:T})=>T.length>0),Re(o,e),ye(([{items:T},I])=>T[T.length-1].originalIndex===I-1),re(([,T,I])=>[T-1,I]),Je(vr),re(([T])=>T))),k=Tt(F(b,on(200),ye(({items:T,topItems:I})=>T.length>0&&T[0].originalIndex===I.length),re(({items:T})=>T[0].index),Je())),C=Tt(F(b,ye(({items:T})=>T.length>0),re(({items:T})=>{let I=0,N=T.length-1;for(;T[I].type==="group"&&I<N;)I++;for(;T[N].type==="group"&&N>I;)N--;return{endIndex:T[N].index,startIndex:T[I].index}}),Je(nc)));return{endReached:S,initialItemCount:g,itemsRendered:x,listState:b,rangeChanged:C,startReached:k,topItemsIndexes:v,...h}},Xe(Gt,ac,ai,yr,br,Tr,hn,ni),{singleton:!0}),mc=Be(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=De(),i=ft(F(ot(n,e,r,t,o),re(([a,c,u,d,f])=>a+c+u+d+f.offsetBottom+f.bottom)),0);return fe(ve(i),s),{totalListHeight:i,totalListHeightChanged:s}},Xe(mt,_n),{singleton:!0}),Zg=Be(([{viewportHeight:e},{totalListHeight:t}])=>{const n=G(!1),r=ft(F(ot(n,e,t),ye(([o])=>o),re(([,o,s])=>Math.max(0,o-s)),on(0),Je()),0);return{alignToBottom:n,paddingTopAddition:r}},Xe(mt,mc),{singleton:!0}),gc=Be(()=>({context:G(null)})),Qg=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...o},viewportBottom:s,viewportTop:i})=>t<i?{...o,align:n??"start",behavior:r}:e>s?{...o,align:n??"end",behavior:r}:null,xc=Be(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:c},{scrollToIndex:u}])=>{const d=De();return fe(F(d,Re(t,c,n,s,o,r,a),Re(e),re(([[f,h,m,w,v,g,x,b],S])=>{const{align:k,behavior:C,calculateViewLocation:T=Qg,done:I,...N}=f,_=sc(f,h,w-1),j=wr(_,h.offsetTree,S)+v+g,R=j+zt(h.sizeTree,_)[1],$=b+g,z=b+m-x,O=T({itemBottom:R,itemTop:j,locationParams:{align:k,behavior:C,...N},viewportBottom:z,viewportTop:$});return O?I&&Ft(F(i,ye(W=>!W),In(nt(i)?1:2)),I):I&&I(),O}),ye(f=>f!==null)),u),{scrollIntoView:d}},Xe(Gt,mt,br,_n,dn),{singleton:!0});function vc(e){return e?e==="smooth"?"smooth":"auto":!1}const ex=(e,t)=>typeof e=="function"?vc(e(t)):t&&vc(e),tx=Be(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:c,propsReady:u},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:m}])=>{const w=G(!1),v=De();let g=null;function x(C){Ae(i,{align:"end",behavior:C,index:"LAST"})}He(F(ot(F(ve(t),In(1)),c),Re(ve(w),s,a,f),re(([[C,T],I,N,_,j])=>{let R=T&&_,$="auto";return R&&($=ex(I,N||j),R=R&&!!$),{followOutputBehavior:$,shouldFollow:R,totalCount:C}}),ye(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{g&&(g(),g=null),nt(n)?requestAnimationFrame(()=>{nt(d)("following output to ",{totalCount:T},bt.DEBUG),x(C)}):g=Ft(e,()=>{nt(d)("following output to ",{totalCount:T},bt.DEBUG),x(C),g=null})});function b(C){const T=Ft(o,I=>{C&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(nt(d)("scrolling to bottom due to increased size",{},bt.DEBUG),x("auto"))});setTimeout(T,100)}He(F(ot(ve(w),t,u),ye(([C,,T])=>C&&T),qt(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),ye(({refreshed:C})=>C),Re(w,t)),([,C])=>{nt(a)&&b(C!==!1)}),He(v,()=>{b(nt(w)!==!1)}),He(ot(ve(w),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&x("auto")});const S=G(null),k=De();return fe(Xs(F(ve(r),re(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),F(ve(t))),k),He(F(ot(F(k,In(1)),c),Re(ve(S),a,f,h),re(([[C,T],I,N,_,j])=>T&&N&&(I==null?void 0:I({context:j,totalCount:C,scrollingInProgress:_}))),ye(C=>!!C),on(0)),C=>{g&&(g(),g=null),nt(n)?requestAnimationFrame(()=>{nt(d)("scrolling into view",{}),Ae(m,C)}):g=Ft(e,()=>{nt(d)("scrolling into view",{}),Ae(m,C),g=null})}),{autoscrollToBottom:v,followOutput:w,scrollIntoViewOnChange:S}},Xe(Gt,Tr,br,yr,hn,dn,mt,gc,xc)),nx=Be(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(fe(F(a,Re(s),ye(([,c])=>c!==0),Re(o,r,t,n,e),re(([[,c],u,d,f,h,m=[]])=>hc(c,u,d,f,h,m))),i),{}),Xe(Gt,yr,_n,hn),{singleton:!0}),rx=Be(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=G(0);return He(F(e,Re(r),ye(([,o])=>o!==0),re(([,o])=>({top:o}))),o=>{Ft(F(n,In(1),ye(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Ae(t,o)})})}),{initialScrollTop:r}},Xe(hn,mt,_n),{singleton:!0}),wc=Be(([{scrollVelocity:e}])=>{const t=G(!1),n=De(),r=G(!1);return fe(F(e,Re(r,t,n),ye(([o,s])=>!!s),re(([o,s,i,a])=>{const{enter:c,exit:u}=s;if(i){if(u(o,a))return!1}else if(c(o,a))return!0;return i}),Je()),t),He(F(ot(t,e,n),Re(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},Xe(Tr),{singleton:!0}),ci=Be(([{scrollContainerState:e,scrollTo:t}])=>{const n=De(),r=De(),o=De(),s=G(!1),i=G(void 0);return fe(F(ot(n,r),re(([{scrollHeight:a,scrollTop:c,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,c-d),viewportHeight:u}))),e),fe(F(t,Re(r),re(([a,{offsetTop:c}])=>({...a,top:a.top+c}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},Xe(mt)),ox=Be(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:c}])=>{const u=De(),d=G(void 0),f=G(null),h=G(null);return fe(a,f),fe(c,h),He(F(u,Re(t,r,i,f,h,n)),([m,w,v,g,x,b,S])=>{const k=Bg(w.sizeTree);g&&x!==null&&b!==null&&(v=x.scrollTop-b.offsetTop),v-=S,m({ranges:k,scrollTop:v})}),fe(F(d,ye(Gs),re(sx)),o),fe(F(s,Re(d),ye(([,m])=>m!==void 0),Je(),re(([,m])=>m.ranges)),e),{getState:u,restoreStateFrom:d}},Xe(Gt,mt,yr,hn,ci));function sx(e){return{align:"start",index:0,offset:e.scrollTop}}const ix=Be(([{topItemsIndexes:e}])=>{const t=G(0);return fe(F(t,ye(n=>n>=0),re(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},Xe(_n));function bc(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const ax=bc(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),lx=Be(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:c},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:h},{log:m},{recalcInProgress:w}])=>{const v=Tt(F(c,Re(i),qt(([,x,b,S],[{bottom:k,items:C,offsetBottom:T,totalCount:I},N])=>{const _=k+T;let j=0;return b===I&&x.length>0&&C.length>0&&(C[0].originalIndex===0&&x[0].originalIndex===0||(j=_-S,j!==0&&(j+=N))),[j,C,I,_]},[0,[],0,0]),ye(([x])=>x!==0),Re(r,a,n,o,m,w),ye(([,x,b,S,,,k])=>!k&&!S&&x!==0&&b===Sr),re(([[x],,,,,b])=>(b("Upward scrolling compensation",{amount:x},bt.DEBUG),x))));function g(x){x>0?(Ae(t,{behavior:"auto",top:-x}),Ae(e,0)):(Ae(e,0),Ae(t,{behavior:"auto",top:-x}))}return He(F(v,Re(e,s)),([x,b,S])=>{S&&ax()?Ae(e,b-x):g(-x)}),He(F(ot(ft(s,!1),e,w),ye(([x,b,S])=>!x&&!S&&b!==0),re(([x,b])=>b),on(1)),g),fe(F(f,re(x=>({top:-x}))),t),He(F(u,Re(h,d),re(([x,{groupIndices:b,lastSize:S,sizeTree:k},C])=>{function T(I){return I*(S+C)}if(b.length===0)return T(x);{let I=0;const N=xr(k,0);let _=0,j=0;for(;_<x;){_++,I+=N;let R=b.length===j+1?1/0:b[j+1]-b[j]-1;_+R>x&&(I-=N,R=x-_+1),_+=R,I+=T(R),j++}return I}})),x=>{Ae(e,x),requestAnimationFrame(()=>{Ae(t,{top:x}),requestAnimationFrame(()=>{Ae(e,0),Ae(w,!1)})})}),{deviation:e}},Xe(mt,Tr,_n,Gt,dn,ni)),cx=Be(([e,t,n,r,o,s,i,a,c,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...c,...u,...d}),Xe(ai,nx,hn,wc,mc,rx,Zg,ci,xc,dn,gc)),yc=Be(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:c,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:m,scrolledToInitialItem:w},v,g,x,{listState:b,topItemsIndexes:S,...k},{scrollToIndex:C},T,{topItemCount:I},{groupCounts:N},_])=>(fe(k.rangeChanged,_.scrollSeekRangeChanged),fe(F(_.windowViewportRect,re(j=>j.visibleHeight)),v.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:N,initialItemFinalLocationReached:h,initialTopMostItemIndex:m,scrolledToInitialItem:w,sizeRanges:a,topItemCount:I,topItemsIndexes:S,totalCount:d,...x,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...k,..._,...v,sizes:c,...g}),Xe(Gt,yr,mt,ox,tx,_n,br,lx,ix,ac,cx));function ux(e,t){const n={},r={};let o=0;const s=e.length;for(;o<s;)r[e[o]]=1,o+=1;for(const i in t)Object.hasOwn(r,i)||(n[i]=t[i]);return n}const xo=typeof document<"u"?y.useLayoutEffect:y.useEffect;function Sc(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=y.createContext({});function c(g,x){g.propsReady&&Ae(g.propsReady,!1);for(const b of r){const S=g[t.required[b]];Ae(S,x[b])}for(const b of o)if(b in x){const S=g[t.optional[b]];Ae(S,x[b])}g.propsReady&&Ae(g.propsReady,!0)}function u(g){return s.reduce((x,b)=>(x[b]=S=>{const k=g[t.methods[b]];Ae(k,S)},x),{})}function d(g){return i.reduce((x,b)=>(x[b]=kg(g[t.events[b]]),x),{})}const f=y.forwardRef((g,x)=>{const{children:b,...S}=g,[k]=y.useState(()=>lo(Ng(e),I=>{c(I,S)})),[C]=y.useState(Vl(d,k));xo(()=>{for(const I of i)I in S&&He(C[I],S[I]);return()=>{Object.values(C).map(Ys)}},[S,C,k]),xo(()=>{c(k,S)}),y.useImperativeHandle(x,Ul(u(k)));const T=n;return l.jsx(a.Provider,{value:k,children:n?l.jsx(T,{...ux([...r,...o,...i],S),children:b}):b})}),h=g=>{const x=y.useContext(a);return y.useCallback(b=>{Ae(x[g],b)},[x,g])},m=g=>{const x=y.useContext(a)[g],b=y.useCallback(S=>He(x,S),[x]);return y.useSyncExternalStore(b,()=>nt(x),()=>nt(x))},w=g=>{const x=y.useContext(a)[g],[b,S]=y.useState(Vl(nt,x));return xo(()=>He(x,k=>{k!==b&&S(Ul(k))}),[x,b]),b},v=y.version.startsWith("18")?m:w;return{Component:f,useEmitter:(g,x)=>{const b=y.useContext(a)[g];xo(()=>He(b,x),[x,b])},useEmitterValue:v,usePublisher:h}}const Cc=y.createContext(void 0),Tc=y.createContext(void 0),Ec=typeof document<"u"?y.useLayoutEffect:y.useEffect;function ui(e){return"self"in e}function dx(e){return"body"in e}function kc(e,t,n,r=qn,o,s){const i=y.useRef(null),a=y.useRef(null),c=y.useRef(null),u=y.useCallback(h=>{let m,w,v;const g=h.target;if(dx(g)||ui(g)){const b=ui(g)?g:g.defaultView;v=s?b.scrollX:b.scrollY,m=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,w=s?b.innerWidth:b.innerHeight}else v=s?g.scrollLeft:g.scrollTop,m=s?g.scrollWidth:g.scrollHeight,w=s?g.offsetWidth:g.offsetHeight;const x=()=>{e({scrollHeight:m,scrollTop:Math.max(v,0),viewportHeight:w})};h.suppressFlushSync?x():Is.flushSync(x),a.current!==null&&(v===a.current||v<=0||v===m-w)&&(a.current=null,t(!0),c.current&&(clearTimeout(c.current),c.current=null))},[e,t,s]);y.useEffect(()=>{const h=o||i.current;return r(o||i.current),u({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",u,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",u)}},[i,u,n,r,o]);function d(h){const m=i.current;if(!m||(s?"offsetWidth"in m&&m.offsetWidth===0:"offsetHeight"in m&&m.offsetHeight===0))return;const w=h.behavior==="smooth";let v,g,x;ui(m)?(g=Math.max(fn(m.document.documentElement,s?"width":"height"),s?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight),v=s?m.innerWidth:m.innerHeight,x=s?window.scrollX:window.scrollY):(g=m[s?"scrollWidth":"scrollHeight"],v=fn(m,s?"width":"height"),x=m[s?"scrollLeft":"scrollTop"]);const b=g-v;if(h.top=Math.ceil(Math.max(Math.min(b,h.top),0)),cc(v,g)||h.top===x){e({scrollHeight:g,scrollTop:x,viewportHeight:v}),w&&t(!0);return}w?(a.current=h.top,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(h={behavior:h.behavior,left:h.top}),m.scrollTo(h)}function f(h){s&&(h={behavior:h.behavior,left:h.top}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const di="-webkit-sticky",Ic="sticky",fi=bc(()=>{if(typeof document>"u")return Ic;const e=document.createElement("div");return e.style.position=di,e.style.position===di?di:Ic});function hi(e){return e}const fx=Be(()=>{const e=G(a=>`Item ${a}`),t=G(a=>`Group ${a}`),n=G({}),r=G(hi),o=G("div"),s=G(qn),i=(a,c=null)=>ft(F(n,re(u=>u[a]),Je()),c);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),hx=Be(([e,t])=>({...e,...t}),Xe(yc,fx)),px=({height:e})=>l.jsx("div",{style:{height:e}}),mx={overflowAnchor:"none",position:fi(),zIndex:1},Nc={overflowAnchor:"none"},gx={...Nc,display:"inline-block",height:"100%"},Ac=y.memo(function({showTopList:e=!1}){const t=Ee("listState"),n=jt("sizeRanges"),r=Ee("useWindowScroll"),o=Ee("customScrollParent"),s=jt("windowScrollContainerState"),i=jt("scrollContainerState"),a=o||r?s:i,c=Ee("itemContent"),u=Ee("context"),d=Ee("groupContent"),f=Ee("trackItemSizes"),h=Ee("itemSize"),m=Ee("log"),w=jt("gap"),v=Ee("horizontalDirection"),{callbackRef:g}=jg(n,h,f,e?qn:a,m,w,o,v,Ee("skipAnimationFrameInResizeObserver")),[x,b]=y.useState(0);pi("deviation",O=>{x!==O&&b(O)});const S=Ee("EmptyPlaceholder"),k=Ee("ScrollSeekPlaceholder")||px,C=Ee("ListComponent"),T=Ee("ItemComponent"),I=Ee("GroupComponent"),N=Ee("computeItemKey"),_=Ee("isSeeking"),j=Ee("groupIndices").length>0,R=Ee("alignToBottom"),$=Ee("initialItemFinalLocationReached"),z=e?{}:{boxSizing:"border-box",...v?{display:"inline-block",height:"100%",marginLeft:x!==0?x:R?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:x!==0?x:R?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...$?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?l.jsx(S,{...ht(S,u)}):l.jsx(C,{...ht(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:z,children:(e?t.topItems:t.items).map(O=>{const W=O.originalIndex,B=N(W+t.firstItemIndex,O.data,u);return _?y.createElement(k,{...ht(k,u),height:O.size,index:O.index,key:B,type:O.type||"item",...O.type==="group"?{}:{groupIndex:O.groupIndex}}):O.type==="group"?y.createElement(I,{...ht(I,u),"data-index":W,"data-item-index":O.index,"data-known-size":O.size,key:B,style:mx},d(O.index,u)):y.createElement(T,{...ht(T,u),...bx(T,O.data),"data-index":W,"data-item-group-index":O.groupIndex,"data-item-index":O.index,"data-known-size":O.size,key:B,style:v?gx:Nc},j?c(O.index,O.groupIndex,O.data,u):c(O.index,O.data,u))})})}),xx={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},vx={outline:"none",overflowX:"auto",position:"relative"},vo=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),wx={position:fi(),top:0,width:"100%",zIndex:1};function ht(e,t){if(typeof e!="string")return{context:t}}function bx(e,t){return{item:typeof e=="string"?void 0:t}}const yx=y.memo(function(){const e=Ee("HeaderComponent"),t=jt("headerHeight"),n=Ee("HeaderFooterTag"),r=Nn(y.useMemo(()=>s=>{t(fn(s,"height"))},[t]),!0,Ee("skipAnimationFrameInResizeObserver")),o=Ee("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...ht(e,o)})}):null}),Sx=y.memo(function(){const e=Ee("FooterComponent"),t=jt("footerHeight"),n=Ee("HeaderFooterTag"),r=Nn(y.useMemo(()=>s=>{t(fn(s,"height"))},[t]),!0,Ee("skipAnimationFrameInResizeObserver")),o=Ee("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...ht(e,o)})}):null});function _c({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),c=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:m,scrollToCallback:w}=kc(a,u,c,d,void 0,f);return e("scrollTo",w),e("scrollBy",h),l.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:m,style:{...f?vx:xx,...o},tabIndex:0,...i,...ht(c,s),children:r})})}function jc({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),c=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),m=y.useRef(null),w=t("scrollerRef"),{scrollByCallback:v,scrollerRef:g,scrollToCallback:x}=kc(a,u,c,w,h);return Ec(()=>{var b;return g.current=h||((b=m.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",x),e("scrollBy",v),l.jsx(c,{ref:m,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...ht(c,s),children:r})})}const Cx=({children:e})=>{const t=y.useContext(Cc),n=jt("viewportHeight"),r=jt("fixedItemHeight"),o=Ee("alignToBottom"),s=Ee("horizontalDirection"),i=y.useMemo(()=>Wl(n,c=>fn(c,s?"width":"height")),[n,s]),a=Nn(i,!0,Ee("skipAnimationFrameInResizeObserver"));return y.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),l.jsx("div",{"data-viewport-type":"element",ref:a,style:vo(o),children:e})},Tx=({children:e})=>{const t=y.useContext(Cc),n=jt("windowViewportRect"),r=jt("fixedItemHeight"),o=Ee("customScrollParent"),s=Yl(n,o,Ee("skipAnimationFrameInResizeObserver")),i=Ee("alignToBottom");return y.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),l.jsx("div",{"data-viewport-type":"window",ref:s,style:vo(i),children:e})},Ex=({children:e})=>{const t=Ee("TopItemListComponent")||"div",n=Ee("headerHeight"),r={...wx,marginTop:`${n}px`},o=Ee("context");return l.jsx(t,{style:r,...ht(t,o),children:e})},kx=y.memo(function(e){const t=Ee("useWindowScroll"),n=Ee("topItemsIndexes").length>0,r=Ee("customScrollParent"),o=Ee("context");return l.jsxs(r||t?Ax:Nx,{...e,context:o,children:[n&&l.jsx(Ex,{children:l.jsx(Ac,{showTopList:!0})}),l.jsxs(r||t?Tx:Cx,{children:[l.jsx(yx,{}),l.jsx(Ac,{}),l.jsx(Sx,{})]})]})}),{Component:Ix,useEmitter:pi,useEmitterValue:Ee,usePublisher:jt}=Sc(hx,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},kx),Nx=_c({useEmitter:pi,useEmitterValue:Ee,usePublisher:jt}),Ax=jc({useEmitter:pi,useEmitterValue:Ee,usePublisher:jt}),_x=Ix;Xe(yc,Be(()=>{const e=G(u=>l.jsxs("td",{children:["Item $",u]})),t=G(null),n=G(u=>l.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=G(null),o=G(null),s=G({}),i=G(hi),a=G(qn),c=(u,d=null)=>ft(F(s,re(f=>f[u]),Je()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:c("EmptyPlaceholder"),FillerRow:c("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder"),TableBodyComponent:c("TableBody","tbody"),TableComponent:c("Table","table"),TableFooterComponent:c("TableFoot","tfoot"),TableHeadComponent:c("TableHead","thead"),TableRowComponent:c("TableRow","tr"),GroupComponent:c("Group","tr")}})),fi();const Rc={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},jx={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Pc,floor:wo,max:Er,min:mi,round:Oc}=Math;function Mc(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function Rx(e){return{...jx,items:e}}function bo(e,t){return e&&e.width===t.width&&e.height===t.height}function Px(e,t){return e&&e.column===t.column&&e.row===t.row}const Ox=Be(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:c,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},h,m,{didMount:w,propsReady:v},{customScrollParent:g,useWindowScroll:x,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k},C])=>{const T=G(0),I=G(0),N=G(Rc),_=G({height:0,width:0}),j=G({height:0,width:0}),R=De(),$=De(),z=G(0),O=G(null),W=G({column:0,row:0}),B=De(),q=De(),L=G(!1),A=G(0),D=G(!0),H=G(!1),X=G(!1);He(F(w,Re(A),ye(([M,Y])=>!!Y)),()=>{Ae(D,!1)}),He(F(ot(w,D,j,_,A,H),ye(([M,Y,ee,de,,ce])=>M&&!Y&&ee.height!==0&&de.height!==0&&!ce)),([,,,,M])=>{Ae(H,!0),si(1,()=>{Ae(R,M)}),Ft(F(u),()=>{Ae(t,[0,0]),Ae(D,!0)})}),fe(F(q,ye(M=>M!=null&&M.scrollTop>0),Kt(0)),I),He(F(w,Re(q),ye(([,M])=>M!=null)),([,M])=>{M&&(Ae(_,M.viewport),Ae(j,M.item),Ae(W,M.gap),M.scrollTop>0&&(Ae(L,!0),Ft(F(u,In(1)),Y=>{Ae(L,!1)}),Ae(c,{top:M.scrollTop})))}),fe(F(_,re(({height:M})=>M)),f),fe(F(ot(ve(_,bo),ve(j,bo),ve(W,(M,Y)=>M&&M.column===Y.column&&M.row===Y.row),ve(u)),re(([M,Y,ee,de])=>({gap:ee,item:Y,scrollTop:de,viewport:M}))),B),fe(F(ot(ve(T),r,ve(W,Px),ve(j,bo),ve(_,bo),ve(O),ve(I),ve(L),ve(D),ve(A)),ye(([,,,,,,,M])=>!M),re(([M,[Y,ee],de,ce,ze,Ye,V,,J,be])=>{const{column:Oe,row:_e}=de,{height:et,width:st}=ce,{width:ie}=ze;if(V===0&&(M===0||ie===0))return Rc;if(st===0){const Dt=ii(be,M),ir=Dt+Math.max(V-1,0);return Rx(Mc(Dt,ir,Ye))}const ae=Dc(ie,st,Oe);let me,ge;J?Y===0&&ee===0&&V>0?(me=0,ge=V-1):(me=ae*wo((Y+_e)/(et+_e)),ge=ae*Pc((ee+_e)/(et+_e))-1,ge=mi(M-1,Er(ge,ae-1)),me=mi(ge,Er(0,me))):(me=0,ge=-1);const ke=Mc(me,ge,Ye),{bottom:je,top:Ke}=Lc(ze,de,ce,ke),qe=Pc(M/ae),lt=qe*et+(qe-1)*_e-je;return{bottom:je,itemHeight:et,items:ke,itemWidth:st,offsetBottom:lt,offsetTop:Ke,top:Ke}})),N),fe(F(O,ye(M=>M!==null),re(M=>M.length)),T),fe(F(ot(_,j,N,W),ye(([M,Y,{items:ee}])=>ee.length>0&&Y.height!==0&&M.height!==0),re(([M,Y,{items:ee},de])=>{const{bottom:ce,top:ze}=Lc(M,de,Y,ee);return[ze,ce]}),Je(vr)),t);const Q=G(!1);fe(F(u,Re(Q),re(([M,Y])=>Y||M!==0)),Q);const ue=Tt(F(ot(N,T),ye(([{items:M}])=>M.length>0),Re(Q),ye(([[M,Y],ee])=>{const de=M.items[M.items.length-1].index===Y-1;return(ee||M.bottom>0&&M.itemHeight>0&&M.offsetBottom===0&&M.items.length===Y)&&de}),re(([[,M]])=>M-1),Je())),we=Tt(F(ve(N),ye(({items:M})=>M.length>0&&M[0].index===0),Kt(0),Je())),Ie=Tt(F(ve(N),Re(L),ye(([{items:M},Y])=>M.length>0&&!Y),re(([{items:M}])=>({endIndex:M[M.length-1].index,startIndex:M[0].index})),Je(nc),on(0)));fe(Ie,m.scrollSeekRangeChanged),fe(F(R,Re(_,j,T,W),re(([M,Y,ee,de,ce])=>{const ze=lc(M),{align:Ye,behavior:V,offset:J}=ze;let be=ze.index;be==="LAST"&&(be=de-1),be=Er(0,be,mi(de-1,be));let Oe=gi(Y,ce,ee,be);return Ye==="end"?Oe=Oc(Oe-Y.height+ee.height):Ye==="center"&&(Oe=Oc(Oe-Y.height/2+ee.height/2)),J&&(Oe+=J),{behavior:V,top:Oe}})),c);const K=ft(F(N,re(M=>M.offsetBottom+M.bottom)),0);return fe(F(k,re(M=>({height:M.visibleHeight,width:M.visibleWidth}))),_),{customScrollParent:g,data:O,deviation:z,footerHeight:o,gap:W,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:j,overscan:n,restoreStateFrom:q,scrollBy:i,scrollContainerState:a,scrollHeight:$,scrollTo:c,scrollToIndex:R,scrollTop:u,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:x,viewportDimensions:_,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k,...m,gridState:N,horizontalDirection:X,initialTopMostItemIndex:A,totalListHeight:K,...h,endReached:ue,propsReady:v,rangeChanged:Ie,startReached:we,stateChanged:B,stateRestoreInProgress:L,...C}},Xe(ai,mt,Tr,wc,hn,ci,dn));function Dc(e,t,n){return Er(1,wo((e+n)/(wo(t)+n)))}function Lc(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=gi(e,t,n,r[0].index);return{bottom:gi(e,t,n,r[r.length-1].index)+o,top:s}}function gi(e,t,n,r){const o=Dc(e.width,n.width,t.column),s=wo(r/o),i=s*n.height+Er(0,s-1)*t.row;return i>0?i+t.row:i}const Mx=Be(()=>{const e=G(f=>`Item ${f}`),t=G({}),n=G(null),r=G("virtuoso-grid-item"),o=G("virtuoso-grid-list"),s=G(hi),i=G("div"),a=G(qn),c=(f,h=null)=>ft(F(t,re(m=>m[f]),Je()),h),u=G(!1),d=G(!1);return fe(ve(d),u),{components:t,computeItemKey:s,context:n,FooterComponent:c("Footer"),HeaderComponent:c("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:c("Item","div"),itemContent:e,listClassName:o,ListComponent:c("List","div"),readyStateChanged:u,reportReadyState:d,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}),Dx=Be(([e,t])=>({...e,...t}),Xe(Ox,Mx)),Lx=y.memo(function(){const e=Ze("gridState"),t=Ze("listClassName"),n=Ze("itemClassName"),r=Ze("itemContent"),o=Ze("computeItemKey"),s=Ze("isSeeking"),i=Rt("scrollHeight"),a=Ze("ItemComponent"),c=Ze("ListComponent"),u=Ze("ScrollSeekPlaceholder"),d=Ze("context"),f=Rt("itemDimensions"),h=Rt("gap"),m=Ze("log"),w=Ze("stateRestoreInProgress"),v=Rt("reportReadyState"),g=Nn(y.useMemo(()=>x=>{const b=x.parentElement.parentElement.scrollHeight;i(b);const S=x.firstChild;if(S){const{height:k,width:C}=S.getBoundingClientRect();f({height:k,width:C})}h({column:Fc("column-gap",getComputedStyle(x).columnGap,m),row:Fc("row-gap",getComputedStyle(x).rowGap,m)})},[i,f,h,m]),!0,!1);return Ec(()=>{e.itemHeight>0&&e.itemWidth>0&&v(!0)},[e]),w?null:l.jsx(c,{className:t,ref:g,...ht(c,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(x=>{const b=o(x.index,x.data,d);return s?l.jsx(u,{...ht(u,d),height:e.itemHeight,index:x.index,width:e.itemWidth},b):y.createElement(a,{...ht(a,d),className:n,"data-index":x.index,key:b},r(x.index,x.data,d))})})}),$x=y.memo(function(){const e=Ze("HeaderComponent"),t=Rt("headerHeight"),n=Ze("headerFooterTag"),r=Nn(y.useMemo(()=>s=>{t(fn(s,"height"))},[t]),!0,!1),o=Ze("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...ht(e,o)})}):null}),Fx=y.memo(function(){const e=Ze("FooterComponent"),t=Rt("footerHeight"),n=Ze("headerFooterTag"),r=Nn(y.useMemo(()=>s=>{t(fn(s,"height"))},[t]),!0,!1),o=Ze("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...ht(e,o)})}):null}),zx=({children:e})=>{const t=y.useContext(Tc),n=Rt("itemDimensions"),r=Rt("viewportDimensions"),o=Nn(y.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return y.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),l.jsx("div",{ref:o,style:vo(!1),children:e})},Bx=({children:e})=>{const t=y.useContext(Tc),n=Rt("windowViewportRect"),r=Rt("itemDimensions"),o=Ze("customScrollParent"),s=Yl(n,o,!1);return y.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),l.jsx("div",{ref:s,style:vo(!1),children:e})},Hx=y.memo(function({...e}){const t=Ze("useWindowScroll"),n=Ze("customScrollParent"),r=n||t?Wx:Ux,o=n||t?Bx:zx,s=Ze("context");return l.jsx(r,{...e,...ht(r,s),children:l.jsxs(o,{children:[l.jsx($x,{}),l.jsx(Lx,{}),l.jsx(Fx,{})]})})}),{useEmitter:$c,useEmitterValue:Ze,usePublisher:Rt}=Sc(Dx,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},Hx),Ux=_c({useEmitter:$c,useEmitterValue:Ze,usePublisher:Rt}),Wx=jc({useEmitter:$c,useEmitterValue:Ze,usePublisher:Rt});function Fc(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,bt.WARN),t==="normal"?0:parseInt(t??"0",10)}const Vx=Kr.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function xi({className:e,variant:t,...n}){return l.jsx("div",{className:Z(Vx({variant:t}),e),...n})}function se(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Kx(e,t){const n=p.createContext(t),r=s=>{const{children:i,...a}=s,c=p.useMemo(()=>a,Object.values(a));return l.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function o(s){const i=p.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function Yt(e,t=[]){let n=[];function r(s,i){const a=p.createContext(i),c=n.length;n=[...n,i];const u=f=>{var x;const{scope:h,children:m,...w}=f,v=((x=h==null?void 0:h[e])==null?void 0:x[c])||a,g=p.useMemo(()=>w,Object.values(w));return l.jsx(v.Provider,{value:g,children:m})};u.displayName=s+"Provider";function d(f,h){var v;const m=((v=h==null?void 0:h[e])==null?void 0:v[c])||a,w=p.useContext(m);if(w)return w;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>p.createContext(i));return function(a){const c=(a==null?void 0:a[e])||s;return p.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,qx(o,...t)]}function qx(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:c,scopeName:u})=>{const f=c(s)[`__scope${u}`];return{...a,...f}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var ct=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},Gx=p[" useInsertionEffect ".trim().toString()]||ct;function jn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Yx({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:o;{const d=p.useRef(e!==void 0);p.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const u=p.useCallback(d=>{var f;if(a){const h=Xx(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[c,u]}function Yx({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),s=p.useRef(t);return Gx(()=>{s.current=t},[t]),p.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Xx(e){return typeof e=="function"}function zc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function vi(...e){return t=>{let n=!1;const r=e.map(o=>{const s=zc(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():zc(e[o],null)}}}}function Pe(...e){return p.useCallback(vi(...e),e)}var Jx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Se=Jx.reduce((e,t)=>{const n=Cn.createSlot(`Primitive.${t}`),r=p.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(c,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Bc(e,t){e&&qr.flushSync(()=>e.dispatchEvent(t))}function Zx(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var kt=e=>{const{present:t,children:n}=e,r=Qx(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),s=Pe(r.ref,ev(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:s}):null};kt.displayName="Presence";function Qx(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),s=p.useRef("none"),i=e?"mounted":"unmounted",[a,c]=Zx(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const u=yo(r.current);s.current=a==="mounted"?u:"none"},[a]),ct(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,m=yo(u);e?c("MOUNT"):m==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(d&&h!==m?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),ct(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=m=>{const v=yo(r.current).includes(CSS.escape(m.animationName));if(m.target===t&&v&&(c("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},h=m=>{m.target===t&&(s.current=yo(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:p.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function yo(e){return(e==null?void 0:e.animationName)||"none"}function ev(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var tv=p[" useId ".trim().toString()]||(()=>{}),nv=0;function Xt(e){const[t,n]=p.useState(tv());return ct(()=>{n(r=>r??String(nv++))},[e]),e||(t?`radix-${t}`:"")}var So="Collapsible",[rv,HC]=Yt(So),[ov,wi]=rv(So),Hc=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[c,u]=jn({prop:r,defaultProp:o??!1,onChange:i,caller:So});return l.jsx(ov,{scope:n,disabled:s,contentId:Xt(),open:c,onOpenToggle:p.useCallback(()=>u(d=>!d),[u]),children:l.jsx(Se.div,{"data-state":yi(c),"data-disabled":s?"":void 0,...a,ref:t})})});Hc.displayName=So;var Uc="CollapsibleTrigger",Wc=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=wi(Uc,n);return l.jsx(Se.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":yi(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:se(e.onClick,o.onOpenToggle)})});Wc.displayName=Uc;var bi="CollapsibleContent",sv=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=wi(bi,e.__scopeCollapsible);return l.jsx(kt,{present:n||o.open,children:({present:s})=>l.jsx(iv,{...r,ref:t,present:s})})});sv.displayName=bi;var iv=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=wi(bi,n),[a,c]=p.useState(r),u=p.useRef(null),d=Pe(t,u),f=p.useRef(0),h=f.current,m=p.useRef(0),w=m.current,v=i.open||a,g=p.useRef(v),x=p.useRef(void 0);return p.useEffect(()=>{const b=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(b)},[]),ct(()=>{const b=u.current;if(b){x.current=x.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const S=b.getBoundingClientRect();f.current=S.height,m.current=S.width,g.current||(b.style.transitionDuration=x.current.transitionDuration,b.style.animationName=x.current.animationName),c(r)}},[i.open,r]),l.jsx(Se.div,{"data-state":yi(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!v,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":w?`${w}px`:void 0,...e.style},children:v&&o})});function yi(e){return e?"open":"closed"}var av=Hc;const Vc=av,Kc=Wc,kr=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:Z("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));kr.displayName="Card";const Ir=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:Z("flex flex-col space-y-1.5 p-6",e),...t}));Ir.displayName="CardHeader";const Nr=p.forwardRef(({className:e,...t},n)=>l.jsx("h3",{ref:n,className:Z("text-2xl font-semibold leading-none tracking-tight",e),...t}));Nr.displayName="CardTitle";const qc=p.forwardRef(({className:e,...t},n)=>l.jsx("p",{ref:n,className:Z("text-sm text-muted-foreground",e),...t}));qc.displayName="CardDescription";const Co=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:Z("p-6 pt-0",e),...t}));Co.displayName="CardContent";const Gc=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:Z("flex items-center p-6 pt-0",e),...t}));Gc.displayName="CardFooter";function Yc(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let Rn=Yc();function lv(e){Rn=e}const Xc=/[&<>"']/,cv=new RegExp(Xc.source,"g"),Jc=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,uv=new RegExp(Jc.source,"g"),dv={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Zc=e=>dv[e];function pt(e,t){if(t){if(Xc.test(e))return e.replace(cv,Zc)}else if(Jc.test(e))return e.replace(uv,Zc);return e}const fv=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Qc(e){return e.replace(fv,(t,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const hv=/(^|[^\[])\^/g;function Ve(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(hv,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const pv=/[^\w:]/g,mv=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function eu(e,t,n){if(e){let r;try{r=decodeURIComponent(Qc(n)).replace(pv,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!mv.test(n)&&(n=wv(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const To={},gv=/^[^:]+:\/*[^/]*$/,xv=/^([^:]+:)[\s\S]*$/,vv=/^([^:]+:\/*[^/]*)[\s\S]*$/;function wv(e,t){To[" "+e]||(gv.test(e)?To[" "+e]=e+"/":To[" "+e]=ko(e,"/",!0)),e=To[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(xv,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(vv,"$1")+t:e+t}const Eo={exec:function(){}};function tu(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let c=!1,u=i;for(;--u>=0&&a[u]==="\\";)c=!c;return c?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function ko(e,t,n){const r=e.length;if(r===0)return"";let o=0;for(;o<r;){const s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function bv(e,t){if(e.indexOf(t[1])===-1)return-1;const n=e.length;let r=0,o=0;for(;o<n;o++)if(e[o]==="\\")o++;else if(e[o]===t[0])r++;else if(e[o]===t[1]&&(r--,r<0))return o;return-1}function yv(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function nu(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function ru(e,t,n,r){const o=t.href,s=t.title?pt(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:pt(i)}}function Sv(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
39
39
  `).map(o=>{const s=o.match(/^\s+/);if(s===null)return o;const[i]=s;return i.length>=r.length?o.slice(r.length):o}).join(`
40
40
  `)}class Si{constructor(t){this.options=t||Rn}space(t){const n=this.rules.block.newline.exec(t);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(t){const n=this.rules.block.code.exec(t);if(n){const r=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:ko(r,`
41
- `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=yv(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:o}}}heading(t){const n=this.rules.block.heading.exec(t);if(n){let r=n[2].trim();if(/#$/.test(r)){const o=ko(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,c,u,d,f,h,m,w,v=n[1].trim();const g=v.length>1,x={type:"list",raw:"",ordered:g,start:g?+v.slice(0,-1):"",loose:!1,items:[]};v=g?`\\d{1,9}\\${v.slice(-1)}`:`\\${v}`,this.options.pedantic&&(v=g?v:"[*+-]");const b=new RegExp(`^( {0,3}${v})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(w=!1,!(!(n=b.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
41
+ `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=Sv(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:o}}}heading(t){const n=this.rules.block.heading.exec(t);if(n){let r=n[2].trim();if(/#$/.test(r)){const o=ko(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,c,u,d,f,h,m,w,v=n[1].trim();const g=v.length>1,x={type:"list",raw:"",ordered:g,start:g?+v.slice(0,-1):"",loose:!1,items:[]};v=g?`\\d{1,9}\\${v.slice(-1)}`:`\\${v}`,this.options.pedantic&&(v=g?v:"[*+-]");const b=new RegExp(`^( {0,3}${v})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(w=!1,!(!(n=b.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
42
42
  `,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),f=t.split(`
43
43
  `,1)[0],this.options.pedantic?(i=2,m=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,m=d.slice(i),i+=n[1].length),c=!1,!d&&/^ *$/.test(f)&&(r+=f+`
44
44
  `,t=t.substring(f.length+1),w=!0),!w){const k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),C=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),I=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(h=t.split(`
45
45
  `,1)[0],f=h,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(T.test(f)||I.test(f)||k.test(f)||C.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())m+=`
46
46
  `+f.slice(i);else{if(c||d.search(/[^ ]/)>=4||T.test(d)||I.test(d)||C.test(d))break;m+=`
47
47
  `+f}!c&&!f.trim()&&(c=!0),r+=h+`
48
- `,t=t.substring(h.length+1),d=f.slice(i)}}x.loose||(u?x.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(m),o&&(s=o[0]!=="[ ] ",m=m.replace(/^\[[ xX]\] +/,""))),x.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:m}),x.raw+=r}x.items[x.items.length-1].raw=r.trimRight(),x.items[x.items.length-1].text=m.trimRight(),x.raw=x.raw.trimRight();const S=x.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,x.items[a].tokens=this.lexer.blockTokens(x.items[a].text,[]),!x.loose){const k=x.items[a].tokens.filter(T=>T.type==="space"),C=k.length>0&&k.some(T=>/\n.*\n/.test(T.raw));x.loose=C}if(x.loose)for(a=0;a<S;a++)x.items[a].loose=!0;return x}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):pt(n[0]);r.type="paragraph",r.text=o,r.tokens=this.lexer.inline(o)}return r}}def(t){const n=this.rules.block.def.exec(t);if(n){const r=n[1].toLowerCase().replace(/\s+/g," "),o=n[2]?n[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline._escapes,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:o,title:s}}}table(t){const n=this.rules.block.table.exec(t);if(n){const r={type:"table",header:eu(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
49
- `):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,c;for(s=0;s<o;s++)/^ *-+: *$/.test(r.align[s])?r.align[s]="right":/^ *:-+: *$/.test(r.align[s])?r.align[s]="center":/^ *:-+ *$/.test(r.align[s])?r.align[s]="left":r.align[s]=null;for(o=r.rows.length,s=0;s<o;s++)r.rows[s]=eu(r.rows[s],r.header.length).map(u=>({text:u}));for(o=r.header.length,i=0;i<o;i++)r.header[i].tokens=this.lexer.inline(r.header[i].text);for(o=r.rows.length,i=0;i<o;i++)for(c=r.rows[i],a=0;a<c.length;a++)c[a].tokens=this.lexer.inline(c[a].text);return r}}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const r=n[1].charAt(n[1].length-1)===`
50
- `?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:r,tokens:this.lexer.inline(r)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:pt(n[1])}}tag(t){const n=this.rules.inline.tag.exec(t);if(n)return!this.lexer.state.inLink&&/^<a /i.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):pt(n[0]):n[0]}}link(t){const n=this.rules.inline.link.exec(t);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const i=ko(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=wv(n[2],"()");if(i>-1){const c=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,c).trim(),n[3]=""}}let o=n[2],s="";if(this.options.pedantic){const i=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(o);i&&(o=i[1],s=i[3])}else s=n[3]?n[3].slice(1,-1):"";return o=o.trim(),/^</.test(o)&&(this.options.pedantic&&!/>$/.test(r)?o=o.slice(1):o=o.slice(1,-1)),nu(n,{href:o&&o.replace(this.rules.inline._escapes,"$1"),title:s&&s.replace(this.rules.inline._escapes,"$1")},n[0],this.lexer)}}reflink(t,n){let r;if((r=this.rules.inline.reflink.exec(t))||(r=this.rules.inline.nolink.exec(t))){let o=(r[2]||r[1]).replace(/\s+/g," ");if(o=n[o.toLowerCase()],!o){const s=r[0].charAt(0);return{type:"text",raw:s,text:s}}return nu(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,c,u=i,d=0;const f=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*t.length+i);(o=f.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(c=a.length,o[3]||o[4]){u+=c;continue}else if((o[5]||o[6])&&i%3&&!((i+c)%3)){d+=c;continue}if(u-=c,u>0)continue;c=Math.min(c,c+u+d);const h=t.slice(0,i+o.index+(o[0].length-a.length)+c);if(Math.min(i,c)%2){const w=h.slice(1,-1);return{type:"em",raw:h,text:w,tokens:this.lexer.inlineTokens(w)}}const m=h.slice(2,-2);return{type:"strong",raw:h,text:m,tokens:this.lexer.inlineTokens(m)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=pt(r,!0),{type:"codespan",raw:n[0],text:r}}}br(t){const n=this.rules.inline.br.exec(t);if(n)return{type:"br",raw:n[0]}}del(t){const n=this.rules.inline.del.exec(t);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(t,n){const r=this.rules.inline.autolink.exec(t);if(r){let o,s;return r[2]==="@"?(o=pt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=pt(r[1]),s=o),{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}url(t,n){let r;if(r=this.rules.inline.url.exec(t)){let o,s;if(r[2]==="@")o=pt(this.options.mangle?n(r[0]):r[0]),s="mailto:"+o;else{let i;do i=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0];while(i!==r[0]);o=pt(r[0]),r[1]==="www."?s="http://"+r[0]:s=r[0]}return{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}inlineText(t,n){const r=this.rules.inline.text.exec(t);if(r){let o;return this.lexer.state.inRawBlock?o=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):pt(r[0]):r[0]:o=pt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const fe={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:Eo,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};fe._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,fe._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,fe.def=Ve(fe.def).replace("label",fe._label).replace("title",fe._title).getRegex(),fe.bullet=/(?:[*+-]|\d{1,9}[.)])/,fe.listItemStart=Ve(/^( *)(bull) */).replace("bull",fe.bullet).getRegex(),fe.list=Ve(fe.list).replace(/bull/g,fe.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+fe.def.source+")").getRegex(),fe._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",fe._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,fe.html=Ve(fe.html,"i").replace("comment",fe._comment).replace("tag",fe._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),fe.paragraph=Ve(fe._paragraph).replace("hr",fe.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",fe._tag).getRegex(),fe.blockquote=Ve(fe.blockquote).replace("paragraph",fe.paragraph).getRegex(),fe.normal={...fe},fe.gfm={...fe.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},fe.gfm.table=Ve(fe.gfm.table).replace("hr",fe.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",fe._tag).getRegex(),fe.gfm.paragraph=Ve(fe._paragraph).replace("hr",fe.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",fe.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",fe._tag).getRegex(),fe.pedantic={...fe.normal,html:Ve(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",fe._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Eo,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ve(fe.normal._paragraph).replace("hr",fe.hr).replace("heading",` *#{1,6} *[^
51
- ]`).replace("lheading",fe.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const se={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Eo,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:Eo,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};se._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",se.punctuation=Ve(se.punctuation).replace(/punctuation/g,se._punctuation).getRegex(),se.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,se.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,se._comment=Ve(fe._comment).replace("(?:-->|$)","-->").getRegex(),se.emStrong.lDelim=Ve(se.emStrong.lDelim).replace(/punct/g,se._punctuation).getRegex(),se.emStrong.rDelimAst=Ve(se.emStrong.rDelimAst,"g").replace(/punct/g,se._punctuation).getRegex(),se.emStrong.rDelimUnd=Ve(se.emStrong.rDelimUnd,"g").replace(/punct/g,se._punctuation).getRegex(),se._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,se._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,se._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,se.autolink=Ve(se.autolink).replace("scheme",se._scheme).replace("email",se._email).getRegex(),se._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,se.tag=Ve(se.tag).replace("comment",se._comment).replace("attribute",se._attribute).getRegex(),se._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,se._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,se._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,se.link=Ve(se.link).replace("label",se._label).replace("href",se._href).replace("title",se._title).getRegex(),se.reflink=Ve(se.reflink).replace("label",se._label).replace("ref",fe._label).getRegex(),se.nolink=Ve(se.nolink).replace("ref",fe._label).getRegex(),se.reflinkSearch=Ve(se.reflinkSearch,"g").replace("reflink",se.reflink).replace("nolink",se.nolink).getRegex(),se.normal={...se},se.pedantic={...se.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:Ve(/^!?\[(label)\]\((.*?)\)/).replace("label",se._label).getRegex(),reflink:Ve(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",se._label).getRegex()},se.gfm={...se.normal,escape:Ve(se.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},se.gfm.url=Ve(se.gfm.url,"i").replace("email",se.gfm._extended_email).getRegex(),se.breaks={...se.gfm,br:Ve(se.br).replace("{2,}","*").getRegex(),text:Ve(se.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function Sv(e){return e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")}function ru(e){let t="",n,r;const o=e.length;for(n=0;n<o;n++)r=e.charCodeAt(n),Math.random()>.5&&(r="x"+r.toString(16)),t+="&#"+r+";";return t}class pn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Rn,this.options.tokenizer=this.options.tokenizer||new Si,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:fe.normal,inline:se.normal};this.options.pedantic?(n.block=fe.pedantic,n.inline=se.pedantic):this.options.gfm&&(n.block=fe.gfm,this.options.breaks?n.inline=se.breaks:n.inline=se.gfm),this.tokenizer.rules=n}static get rules(){return{block:fe,inline:se}}static lex(t,n){return new pn(n).lex(t)}static lexInline(t,n){return new pn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
48
+ `,t=t.substring(h.length+1),d=f.slice(i)}}x.loose||(u?x.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(m),o&&(s=o[0]!=="[ ] ",m=m.replace(/^\[[ xX]\] +/,""))),x.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:m}),x.raw+=r}x.items[x.items.length-1].raw=r.trimRight(),x.items[x.items.length-1].text=m.trimRight(),x.raw=x.raw.trimRight();const S=x.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,x.items[a].tokens=this.lexer.blockTokens(x.items[a].text,[]),!x.loose){const k=x.items[a].tokens.filter(T=>T.type==="space"),C=k.length>0&&k.some(T=>/\n.*\n/.test(T.raw));x.loose=C}if(x.loose)for(a=0;a<S;a++)x.items[a].loose=!0;return x}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):pt(n[0]);r.type="paragraph",r.text=o,r.tokens=this.lexer.inline(o)}return r}}def(t){const n=this.rules.block.def.exec(t);if(n){const r=n[1].toLowerCase().replace(/\s+/g," "),o=n[2]?n[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline._escapes,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:o,title:s}}}table(t){const n=this.rules.block.table.exec(t);if(n){const r={type:"table",header:tu(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
49
+ `):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,c;for(s=0;s<o;s++)/^ *-+: *$/.test(r.align[s])?r.align[s]="right":/^ *:-+: *$/.test(r.align[s])?r.align[s]="center":/^ *:-+ *$/.test(r.align[s])?r.align[s]="left":r.align[s]=null;for(o=r.rows.length,s=0;s<o;s++)r.rows[s]=tu(r.rows[s],r.header.length).map(u=>({text:u}));for(o=r.header.length,i=0;i<o;i++)r.header[i].tokens=this.lexer.inline(r.header[i].text);for(o=r.rows.length,i=0;i<o;i++)for(c=r.rows[i],a=0;a<c.length;a++)c[a].tokens=this.lexer.inline(c[a].text);return r}}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const r=n[1].charAt(n[1].length-1)===`
50
+ `?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:r,tokens:this.lexer.inline(r)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:pt(n[1])}}tag(t){const n=this.rules.inline.tag.exec(t);if(n)return!this.lexer.state.inLink&&/^<a /i.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):pt(n[0]):n[0]}}link(t){const n=this.rules.inline.link.exec(t);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const i=ko(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=bv(n[2],"()");if(i>-1){const c=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,c).trim(),n[3]=""}}let o=n[2],s="";if(this.options.pedantic){const i=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(o);i&&(o=i[1],s=i[3])}else s=n[3]?n[3].slice(1,-1):"";return o=o.trim(),/^</.test(o)&&(this.options.pedantic&&!/>$/.test(r)?o=o.slice(1):o=o.slice(1,-1)),ru(n,{href:o&&o.replace(this.rules.inline._escapes,"$1"),title:s&&s.replace(this.rules.inline._escapes,"$1")},n[0],this.lexer)}}reflink(t,n){let r;if((r=this.rules.inline.reflink.exec(t))||(r=this.rules.inline.nolink.exec(t))){let o=(r[2]||r[1]).replace(/\s+/g," ");if(o=n[o.toLowerCase()],!o){const s=r[0].charAt(0);return{type:"text",raw:s,text:s}}return ru(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,c,u=i,d=0;const f=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*t.length+i);(o=f.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(c=a.length,o[3]||o[4]){u+=c;continue}else if((o[5]||o[6])&&i%3&&!((i+c)%3)){d+=c;continue}if(u-=c,u>0)continue;c=Math.min(c,c+u+d);const h=t.slice(0,i+o.index+(o[0].length-a.length)+c);if(Math.min(i,c)%2){const w=h.slice(1,-1);return{type:"em",raw:h,text:w,tokens:this.lexer.inlineTokens(w)}}const m=h.slice(2,-2);return{type:"strong",raw:h,text:m,tokens:this.lexer.inlineTokens(m)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=pt(r,!0),{type:"codespan",raw:n[0],text:r}}}br(t){const n=this.rules.inline.br.exec(t);if(n)return{type:"br",raw:n[0]}}del(t){const n=this.rules.inline.del.exec(t);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(t,n){const r=this.rules.inline.autolink.exec(t);if(r){let o,s;return r[2]==="@"?(o=pt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=pt(r[1]),s=o),{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}url(t,n){let r;if(r=this.rules.inline.url.exec(t)){let o,s;if(r[2]==="@")o=pt(this.options.mangle?n(r[0]):r[0]),s="mailto:"+o;else{let i;do i=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0];while(i!==r[0]);o=pt(r[0]),r[1]==="www."?s="http://"+r[0]:s=r[0]}return{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}inlineText(t,n){const r=this.rules.inline.text.exec(t);if(r){let o;return this.lexer.state.inRawBlock?o=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):pt(r[0]):r[0]:o=pt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const he={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:Eo,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};he._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,he._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,he.def=Ve(he.def).replace("label",he._label).replace("title",he._title).getRegex(),he.bullet=/(?:[*+-]|\d{1,9}[.)])/,he.listItemStart=Ve(/^( *)(bull) */).replace("bull",he.bullet).getRegex(),he.list=Ve(he.list).replace(/bull/g,he.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+he.def.source+")").getRegex(),he._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",he._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,he.html=Ve(he.html,"i").replace("comment",he._comment).replace("tag",he._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),he.paragraph=Ve(he._paragraph).replace("hr",he.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",he._tag).getRegex(),he.blockquote=Ve(he.blockquote).replace("paragraph",he.paragraph).getRegex(),he.normal={...he},he.gfm={...he.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},he.gfm.table=Ve(he.gfm.table).replace("hr",he.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",he._tag).getRegex(),he.gfm.paragraph=Ve(he._paragraph).replace("hr",he.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",he.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",he._tag).getRegex(),he.pedantic={...he.normal,html:Ve(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",he._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Eo,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ve(he.normal._paragraph).replace("hr",he.hr).replace("heading",` *#{1,6} *[^
51
+ ]`).replace("lheading",he.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const oe={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Eo,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:Eo,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};oe._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",oe.punctuation=Ve(oe.punctuation).replace(/punctuation/g,oe._punctuation).getRegex(),oe.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,oe.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,oe._comment=Ve(he._comment).replace("(?:-->|$)","-->").getRegex(),oe.emStrong.lDelim=Ve(oe.emStrong.lDelim).replace(/punct/g,oe._punctuation).getRegex(),oe.emStrong.rDelimAst=Ve(oe.emStrong.rDelimAst,"g").replace(/punct/g,oe._punctuation).getRegex(),oe.emStrong.rDelimUnd=Ve(oe.emStrong.rDelimUnd,"g").replace(/punct/g,oe._punctuation).getRegex(),oe._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,oe._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,oe._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,oe.autolink=Ve(oe.autolink).replace("scheme",oe._scheme).replace("email",oe._email).getRegex(),oe._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,oe.tag=Ve(oe.tag).replace("comment",oe._comment).replace("attribute",oe._attribute).getRegex(),oe._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,oe._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,oe._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,oe.link=Ve(oe.link).replace("label",oe._label).replace("href",oe._href).replace("title",oe._title).getRegex(),oe.reflink=Ve(oe.reflink).replace("label",oe._label).replace("ref",he._label).getRegex(),oe.nolink=Ve(oe.nolink).replace("ref",he._label).getRegex(),oe.reflinkSearch=Ve(oe.reflinkSearch,"g").replace("reflink",oe.reflink).replace("nolink",oe.nolink).getRegex(),oe.normal={...oe},oe.pedantic={...oe.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:Ve(/^!?\[(label)\]\((.*?)\)/).replace("label",oe._label).getRegex(),reflink:Ve(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",oe._label).getRegex()},oe.gfm={...oe.normal,escape:Ve(oe.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},oe.gfm.url=Ve(oe.gfm.url,"i").replace("email",oe.gfm._extended_email).getRegex(),oe.breaks={...oe.gfm,br:Ve(oe.br).replace("{2,}","*").getRegex(),text:Ve(oe.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function Cv(e){return e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")}function ou(e){let t="",n,r;const o=e.length;for(n=0;n<o;n++)r=e.charCodeAt(n),Math.random()>.5&&(r="x"+r.toString(16)),t+="&#"+r+";";return t}class pn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Rn,this.options.tokenizer=this.options.tokenizer||new Si,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:he.normal,inline:oe.normal};this.options.pedantic?(n.block=he.pedantic,n.inline=oe.pedantic):this.options.gfm&&(n.block=he.gfm,this.options.breaks?n.inline=oe.breaks:n.inline=oe.gfm),this.tokenizer.rules=n}static get rules(){return{block:he,inline:oe}}static lex(t,n){return new pn(n).lex(t)}static lexInline(t,n){return new pn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
52
52
  `),this.blockTokens(t,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(t,n=[]){this.options.pedantic?t=t.replace(/\t/g," ").replace(/^ +$/gm,""):t=t.replace(/^( *)(\t+)/gm,(a,c,u)=>c+" ".repeat(u.length));let r,o,s,i;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(r=a.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=`
53
53
  `:n.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&(o.type==="paragraph"||o.type==="text")?(o.raw+=`
54
54
  `+r.raw,o.text+=`
@@ -58,7 +58,7 @@ React keys must be passed directly to JSX without using spread:
58
58
  `+r.raw,o.text+=`
59
59
  `+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r),i=s.length!==t.length,t=t.substring(r.raw.length);continue}if(r=this.tokenizer.text(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&o.type==="text"?(o.raw+=`
60
60
  `+r.raw,o.text+=`
61
- `+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,c,u;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+tu("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)i=i.slice(0,a.index)+"["+tu("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.escapedEmSt.exec(i))!=null;)i=i.slice(0,a.index+a[0].length-2)+"++"+i.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;t;)if(c||(u=""),c=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(t,i,u)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(t,ru)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,ru))){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const f=t.slice(1);let h;this.options.extensions.startInline.forEach(function(m){h=m.call({lexer:this},f),typeof h=="number"&&h>=0&&(d=Math.min(d,h))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,Sv)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(u=r.raw.slice(-1)),c=!0,o=n[n.length-1],o&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(t){const d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return n}}class Ci{constructor(t){this.options=t||Rn}code(t,n,r){const o=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(t,o);s!=null&&s!==t&&(r=!0,t=s)}return t=t.replace(/\n$/,"")+`
61
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,c,u;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+nu("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)i=i.slice(0,a.index)+"["+nu("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.escapedEmSt.exec(i))!=null;)i=i.slice(0,a.index+a[0].length-2)+"++"+i.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;t;)if(c||(u=""),c=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(t,i,u)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(t,ou)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,ou))){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const f=t.slice(1);let h;this.options.extensions.startInline.forEach(function(m){h=m.call({lexer:this},f),typeof h=="number"&&h>=0&&(d=Math.min(d,h))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,Cv)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(u=r.raw.slice(-1)),c=!0,o=n[n.length-1],o&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(t){const d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return n}}class Ci{constructor(t){this.options=t||Rn}code(t,n,r){const o=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(t,o);s!=null&&s!==t&&(r=!0,t=s)}return t=t.replace(/\n$/,"")+`
62
62
  `,o?'<pre><code class="'+this.options.langPrefix+pt(o)+'">'+(r?t:pt(t,!0))+`</code></pre>
63
63
  `:"<pre><code>"+(r?t:pt(t,!0))+`</code></pre>
64
64
  `}blockquote(t){return`<blockquote>
@@ -78,10 +78,10 @@ ${t}</blockquote>
78
78
  `}tablerow(t){return`<tr>
79
79
  ${t}</tr>
80
80
  `}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
81
- `}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=Qc(this.options.sanitize,this.options.baseUrl,t),t===null)return r;let o='<a href="'+t+'"';return n&&(o+=' title="'+n+'"'),o+=">"+r+"</a>",o}image(t,n,r){if(t=Qc(this.options.sanitize,this.options.baseUrl,t),t===null)return r;let o=`<img src="${t}" alt="${r}"`;return n&&(o+=` title="${n}"`),o+=this.options.xhtml?"/>":">",o}text(t){return t}}class ou{strong(t){return t}em(t){return t}codespan(t){return t}del(t){return t}html(t){return t}text(t){return t}link(t,n,r){return""+r}image(t,n,r){return""+r}br(){return""}}class su{constructor(){this.seen={}}serialize(t){return t.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(t,n){let r=t,o=0;if(this.seen.hasOwnProperty(r)){o=this.seen[t];do o++,r=t+"-"+o;while(this.seen.hasOwnProperty(r))}return n||(this.seen[t]=o,this.seen[r]=0),r}slug(t,n={}){const r=this.serialize(t);return this.getNextSafeSlug(r,n.dryrun)}}class mn{constructor(t){this.options=t||Rn,this.options.renderer=this.options.renderer||new Ci,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new ou,this.slugger=new su}static parse(t,n){return new mn(n).parse(t)}static parseInline(t,n){return new mn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,c,u,d,f,h,m,w,v,g,x,b,S,k,C,T;const I=t.length;for(o=0;o<I;o++){if(m=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[m.type]&&(T=this.options.extensions.renderers[m.type].call({parser:this},m),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(m.type))){r+=T||"";continue}switch(m.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(m.tokens),m.depth,Zc(this.parseInline(m.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(m.text,m.lang,m.escaped);continue}case"table":{for(f="",d="",a=m.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(m.header[s].tokens),{header:!0,align:m.align[s]});for(f+=this.renderer.tablerow(d),h="",a=m.rows.length,s=0;s<a;s++){for(u=m.rows[s],d="",c=u.length,i=0;i<c;i++)d+=this.renderer.tablecell(this.parseInline(u[i].tokens),{header:!1,align:m.align[i]});h+=this.renderer.tablerow(d)}r+=this.renderer.table(f,h);continue}case"blockquote":{h=this.parse(m.tokens),r+=this.renderer.blockquote(h);continue}case"list":{for(w=m.ordered,v=m.start,g=m.loose,a=m.items.length,h="",s=0;s<a;s++)b=m.items[s],S=b.checked,k=b.task,x="",b.task&&(C=this.renderer.checkbox(S),g?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=C+" "+b.tokens[0].text,b.tokens[0].tokens&&b.tokens[0].tokens.length>0&&b.tokens[0].tokens[0].type==="text"&&(b.tokens[0].tokens[0].text=C+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:C}):x+=C),x+=this.parse(b.tokens,g),h+=this.renderer.listitem(x,k,S);r+=this.renderer.list(h,w,v);continue}case"html":{r+=this.renderer.html(m.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(m.tokens));continue}case"text":{for(h=m.tokens?this.parseInline(m.tokens):m.text;o+1<I&&t[o+1].type==="text";)m=t[++o],h+=`
82
- `+(m.tokens?this.parseInline(m.tokens):m.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const N='Token with "'+m.type+'" type was not found.';if(this.options.silent){console.error(N);return}else throw new Error(N)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const c='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(c);return}else throw new Error(c)}}}return r}}class Io{constructor(t){this.options=t||Rn}preprocess(t){return t}postprocess(t){return t}}xp(Io,"passThroughHooks",new Set(["preprocess","postprocess"]));function Cv(e,t,n){return r=>{if(r.message+=`
83
- Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+pt(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function iu(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...he.defaults,...s};const i=Cv(r.silent,r.async,o);if(typeof n>"u"||n===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(bv(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let c;try{r.hooks&&(n=r.hooks.preprocess(n)),c=e(n,r)}catch(f){return i(f)}const u=function(f){let h;if(!f)try{r.walkTokens&&he.walkTokens(c,r.walkTokens),h=t(c,r),r.hooks&&(h=r.hooks.postprocess(h))}catch(m){f=m}return r.highlight=a,f?i(f):o(null,h)};if(!a||a.length<3||(delete r.highlight,!c.length))return u();let d=0;he.walkTokens(c,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(h,m){if(h)return u(h);m!=null&&m!==f.text&&(f.text=m,f.escaped=!0),d--,d===0&&u()})},0))}),d===0&&u();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(he.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&he.walkTokens(a,r.walkTokens);let c=t(a,r);return r.hooks&&(c=r.hooks.postprocess(c)),c}catch(a){return i(a)}}}function he(e,t,n){return iu(pn.lex,mn.parse)(e,t,n)}he.options=he.setOptions=function(e){return he.defaults={...he.defaults,...e},av(he.defaults),he},he.getDefaults=Gc,he.defaults=Rn,he.use=function(...e){const t=he.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=he.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=he.defaults.renderer||new Ci;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let c=n.renderer[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.renderer=o}if(n.tokenizer){const o=he.defaults.tokenizer||new Si;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let c=n.tokenizer[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.tokenizer=o}if(n.hooks){const o=he.defaults.hooks||new Io;for(const s in n.hooks){const i=o[s];Io.passThroughHooks.has(s)?o[s]=a=>{if(he.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(u=>i.call(o,u));const c=n.hooks[s].call(o,a);return i.call(o,c)}:o[s]=(...a)=>{let c=n.hooks[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.hooks=o}if(n.walkTokens){const o=he.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}he.setOptions(r)})},he.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(he,r)),r.type){case"table":{for(const o of r.header)n=n.concat(he.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(he.walkTokens(s.tokens,t));break}case"list":{n=n.concat(he.walkTokens(r.items,t));break}default:he.defaults.extensions&&he.defaults.extensions.childTokens&&he.defaults.extensions.childTokens[r.type]?he.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(he.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(he.walkTokens(r.tokens,t)))}return n},he.parseInline=iu(pn.lexInline,mn.parseInline),he.Parser=mn,he.parser=mn.parse,he.Renderer=Ci,he.TextRenderer=ou,he.Lexer=pn,he.lexer=pn.lex,he.Tokenizer=Si,he.Slugger=su,he.Hooks=Io,he.parse=he,he.options,he.setOptions,he.use,he.walkTokens,he.parseInline,mn.parse,pn.lex;function Ti({content:e,className:t="",allowHtml:n=!1}){const r=y.useMemo(()=>{try{if(!n){const o=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return he.parse(o)}return he.parse(e)}catch(o){return console.error("[MarkdownContent] parse error",o),`<pre>Error rendering markdown: ${String(o)}</pre>`}},[e,n]);return l.jsx("div",{className:Z("markdown prose max-w-none break-words dark:prose-invert",t),dangerouslySetInnerHTML:{__html:r}})}async function au(e,t){return await St(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function lu(e,t){return await(await au(`/chat/files/${e}/view`,t)).text()}async function Tv(e,t){const n=await au(`/chat/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await St(`/chat/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Ev(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await St("/chat/files",{params:r})}const kv=1,Iv=1e6;let Ei=0;function Nv(){return Ei=(Ei+1)%Number.MAX_SAFE_INTEGER,Ei.toString()}const ki=new Map,cu=e=>{if(ki.has(e))return;const t=setTimeout(()=>{ki.delete(e),Ar({type:"REMOVE_TOAST",toastId:e})},Iv);ki.set(e,t)},Av=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,kv)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?cu(n):e.toasts.forEach(r=>{cu(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},No=[];let Ao={toasts:[]};function Ar(e){Ao=Av(Ao,e),No.forEach(t=>{t(Ao)})}function _v({...e}){const t=Nv(),n=o=>Ar({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Ar({type:"DISMISS_TOAST",toastId:t});return Ar({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Ii(){const[e,t]=p.useState(Ao);return p.useEffect(()=>(No.push(t),()=>{const n=No.indexOf(t);n>-1&&No.splice(n,1)}),[e]),{...e,toast:_v,dismiss:n=>Ar({type:"DISMISS_TOAST",toastId:n})}}function ut(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function jv(e,t=globalThis==null?void 0:globalThis.document){const n=ut(e);p.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Rv="DismissableLayer",Ni="dismissableLayer.update",Pv="dismissableLayer.pointerDownOutside",Ov="dismissableLayer.focusOutside",uu,du=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),_o=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...c}=e,u=p.useContext(du),[d,f]=p.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=p.useState({}),w=je(t,I=>f(I)),v=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=v.indexOf(g),b=d?v.indexOf(d):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,k=b>=x,C=Lv(I=>{const N=I.target,_=[...u.branches].some(j=>j.contains(N));!k||_||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},h),T=$v(I=>{const N=I.target;[...u.branches].some(j=>j.contains(N))||(s==null||s(I),i==null||i(I),I.defaultPrevented||a==null||a())},h);return jv(I=>{b===u.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},h),p.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(uu=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),fu(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=uu)}},[d,h,n,u]),p.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),fu())},[d,u]),p.useEffect(()=>{const I=()=>m({});return document.addEventListener(Ni,I),()=>document.removeEventListener(Ni,I)},[]),l.jsx(ye.div,{...c,ref:w,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:ae(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ae(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ae(e.onPointerDownCapture,C.onPointerDownCapture)})});_o.displayName=Rv;var Mv="DismissableLayerBranch",Dv=p.forwardRef((e,t)=>{const n=p.useContext(du),r=p.useRef(null),o=je(t,r);return p.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),l.jsx(ye.div,{...e,ref:o})});Dv.displayName=Mv;function Lv(e,t=globalThis==null?void 0:globalThis.document){const n=ut(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let c=function(){hu(Pv,n,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function $v(e,t=globalThis==null?void 0:globalThis.document){const n=ut(e),r=p.useRef(!1);return p.useEffect(()=>{const o=s=>{s.target&&!r.current&&hu(Ov,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function fu(){const e=new CustomEvent(Ni);document.dispatchEvent(e)}function hu(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?zc(o,s):o.dispatchEvent(s)}var Ai="focusScope.autoFocusOnMount",_i="focusScope.autoFocusOnUnmount",pu={bubbles:!1,cancelable:!0},Fv="FocusScope",jo=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,c]=p.useState(null),u=ut(o),d=ut(s),f=p.useRef(null),h=je(t,v=>c(v)),m=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let v=function(S){if(m.paused||!a)return;const k=S.target;a.contains(k)?f.current=k:gn(f.current,{select:!0})},g=function(S){if(m.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||gn(f.current,{select:!0}))},x=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&gn(a)};document.addEventListener("focusin",v),document.addEventListener("focusout",g);const b=new MutationObserver(x);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",g),b.disconnect()}}},[r,a,m.paused]),p.useEffect(()=>{if(a){xu.add(m);const v=document.activeElement;if(!a.contains(v)){const x=new CustomEvent(Ai,pu);a.addEventListener(Ai,u),a.dispatchEvent(x),x.defaultPrevented||(zv(Vv(mu(a)),{select:!0}),document.activeElement===v&&gn(a))}return()=>{a.removeEventListener(Ai,u),setTimeout(()=>{const x=new CustomEvent(_i,pu);a.addEventListener(_i,d),a.dispatchEvent(x),x.defaultPrevented||gn(v??document.body,{select:!0}),a.removeEventListener(_i,d),xu.remove(m)},0)}}},[a,u,d,m]);const w=p.useCallback(v=>{if(!n&&!r||m.paused)return;const g=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,x=document.activeElement;if(g&&x){const b=v.currentTarget,[S,k]=Bv(b);S&&k?!v.shiftKey&&x===k?(v.preventDefault(),n&&gn(S,{select:!0})):v.shiftKey&&x===S&&(v.preventDefault(),n&&gn(k,{select:!0})):x===b&&v.preventDefault()}},[n,r,m.paused]);return l.jsx(ye.div,{tabIndex:-1,...i,ref:h,onKeyDown:w})});jo.displayName=Fv;function zv(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(gn(r,{select:t}),document.activeElement!==n)return}function Bv(e){const t=mu(e),n=gu(t,e),r=gu(t.reverse(),e);return[n,r]}function mu(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function gu(e,t){for(const n of e)if(!Hv(n,{upTo:t}))return n}function Hv(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Uv(e){return e instanceof HTMLInputElement&&"select"in e}function gn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Uv(e)&&t&&e.select()}}var xu=Wv();function Wv(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=vu(e,t),e.unshift(t)},remove(t){var n;e=vu(e,t),(n=e[0])==null||n.resume()}}}function vu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Vv(e){return e.filter(t=>t.tagName!=="A")}var Kv="Portal",Ro=p.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=p.useState(!1);ct(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Is.createPortal(l.jsx(ye.div,{...r,ref:t}),i):null});Ro.displayName=Kv;var ji=0;function Ri(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??wu()),document.body.insertAdjacentElement("beforeend",e[1]??wu()),ji++,()=>{ji===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),ji--}},[])}function wu(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Jt=function(){return Jt=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Jt.apply(this,arguments)};function bu(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function qv(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var Po="right-scroll-bar-position",Oo="width-before-scroll-bar",Gv="with-scroll-bars-hidden",Yv="--removed-body-scroll-bar-size";function Pi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Xv(e,t){var n=y.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Jv=typeof window<"u"?p.useLayoutEffect:p.useEffect,yu=new WeakMap;function Zv(e,t){var n=Xv(null,function(r){return e.forEach(function(o){return Pi(o,r)})});return Jv(function(){var r=yu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Pi(a,null)}),s.forEach(function(a){o.has(a)||Pi(a,i)})}yu.set(n,e)},[e]),n}function Qv(e){return e}function ew(e,t){t===void 0&&(t=Qv);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var c=function(){var d=i;i=[],d.forEach(s)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return o}function tw(e){e===void 0&&(e={});var t=ew(null);return t.options=Jt({async:!0,ssr:!1},e),t}var Su=function(e){var t=e.sideCar,n=bu(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return p.createElement(r,Jt({},n))};Su.isSideCarExport=!0;function nw(e,t){return e.useMedium(t),Su}var Cu=tw(),Oi=function(){},Mo=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:Oi,onWheelCapture:Oi,onTouchMoveCapture:Oi}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,c=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,m=e.noRelative,w=e.noIsolation,v=e.inert,g=e.allowPinchZoom,x=e.as,b=x===void 0?"div":x,S=e.gapMode,k=bu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,T=Zv([n,t]),I=Jt(Jt({},k),o);return p.createElement(p.Fragment,null,d&&p.createElement(C,{sideCar:Cu,removeScrollBar:u,shards:f,noRelative:m,noIsolation:w,inert:v,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:S}),i?p.cloneElement(p.Children.only(a),Jt(Jt({},I),{ref:T})):p.createElement(b,Jt({},I,{className:c,ref:T}),a))});Mo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Mo.classNames={fullWidth:Oo,zeroRight:Po};var rw=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function ow(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=rw();return t&&e.setAttribute("nonce",t),e}function sw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function iw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var aw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=ow())&&(sw(t,n),iw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},lw=function(){var e=aw();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Tu=function(){var e=lw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},cw={left:0,top:0,right:0,gap:0},Mi=function(e){return parseInt(e||"",10)||0},uw=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Mi(n),Mi(r),Mi(o)]},dw=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return cw;var t=uw(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},fw=Tu(),Yn="data-scroll-locked",hw=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
84
- .`.concat(Gv,` {
81
+ `}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=eu(this.options.sanitize,this.options.baseUrl,t),t===null)return r;let o='<a href="'+t+'"';return n&&(o+=' title="'+n+'"'),o+=">"+r+"</a>",o}image(t,n,r){if(t=eu(this.options.sanitize,this.options.baseUrl,t),t===null)return r;let o=`<img src="${t}" alt="${r}"`;return n&&(o+=` title="${n}"`),o+=this.options.xhtml?"/>":">",o}text(t){return t}}class su{strong(t){return t}em(t){return t}codespan(t){return t}del(t){return t}html(t){return t}text(t){return t}link(t,n,r){return""+r}image(t,n,r){return""+r}br(){return""}}class iu{constructor(){this.seen={}}serialize(t){return t.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(t,n){let r=t,o=0;if(this.seen.hasOwnProperty(r)){o=this.seen[t];do o++,r=t+"-"+o;while(this.seen.hasOwnProperty(r))}return n||(this.seen[t]=o,this.seen[r]=0),r}slug(t,n={}){const r=this.serialize(t);return this.getNextSafeSlug(r,n.dryrun)}}class mn{constructor(t){this.options=t||Rn,this.options.renderer=this.options.renderer||new Ci,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new su,this.slugger=new iu}static parse(t,n){return new mn(n).parse(t)}static parseInline(t,n){return new mn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,c,u,d,f,h,m,w,v,g,x,b,S,k,C,T;const I=t.length;for(o=0;o<I;o++){if(m=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[m.type]&&(T=this.options.extensions.renderers[m.type].call({parser:this},m),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(m.type))){r+=T||"";continue}switch(m.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(m.tokens),m.depth,Qc(this.parseInline(m.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(m.text,m.lang,m.escaped);continue}case"table":{for(f="",d="",a=m.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(m.header[s].tokens),{header:!0,align:m.align[s]});for(f+=this.renderer.tablerow(d),h="",a=m.rows.length,s=0;s<a;s++){for(u=m.rows[s],d="",c=u.length,i=0;i<c;i++)d+=this.renderer.tablecell(this.parseInline(u[i].tokens),{header:!1,align:m.align[i]});h+=this.renderer.tablerow(d)}r+=this.renderer.table(f,h);continue}case"blockquote":{h=this.parse(m.tokens),r+=this.renderer.blockquote(h);continue}case"list":{for(w=m.ordered,v=m.start,g=m.loose,a=m.items.length,h="",s=0;s<a;s++)b=m.items[s],S=b.checked,k=b.task,x="",b.task&&(C=this.renderer.checkbox(S),g?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=C+" "+b.tokens[0].text,b.tokens[0].tokens&&b.tokens[0].tokens.length>0&&b.tokens[0].tokens[0].type==="text"&&(b.tokens[0].tokens[0].text=C+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:C}):x+=C),x+=this.parse(b.tokens,g),h+=this.renderer.listitem(x,k,S);r+=this.renderer.list(h,w,v);continue}case"html":{r+=this.renderer.html(m.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(m.tokens));continue}case"text":{for(h=m.tokens?this.parseInline(m.tokens):m.text;o+1<I&&t[o+1].type==="text";)m=t[++o],h+=`
82
+ `+(m.tokens?this.parseInline(m.tokens):m.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const N='Token with "'+m.type+'" type was not found.';if(this.options.silent){console.error(N);return}else throw new Error(N)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const c='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(c);return}else throw new Error(c)}}}return r}}class Io{constructor(t){this.options=t||Rn}preprocess(t){return t}postprocess(t){return t}}vp(Io,"passThroughHooks",new Set(["preprocess","postprocess"]));function Tv(e,t,n){return r=>{if(r.message+=`
83
+ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+pt(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function au(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...pe.defaults,...s};const i=Tv(r.silent,r.async,o);if(typeof n>"u"||n===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(yv(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let c;try{r.hooks&&(n=r.hooks.preprocess(n)),c=e(n,r)}catch(f){return i(f)}const u=function(f){let h;if(!f)try{r.walkTokens&&pe.walkTokens(c,r.walkTokens),h=t(c,r),r.hooks&&(h=r.hooks.postprocess(h))}catch(m){f=m}return r.highlight=a,f?i(f):o(null,h)};if(!a||a.length<3||(delete r.highlight,!c.length))return u();let d=0;pe.walkTokens(c,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(h,m){if(h)return u(h);m!=null&&m!==f.text&&(f.text=m,f.escaped=!0),d--,d===0&&u()})},0))}),d===0&&u();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(pe.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&pe.walkTokens(a,r.walkTokens);let c=t(a,r);return r.hooks&&(c=r.hooks.postprocess(c)),c}catch(a){return i(a)}}}function pe(e,t,n){return au(pn.lex,mn.parse)(e,t,n)}pe.options=pe.setOptions=function(e){return pe.defaults={...pe.defaults,...e},lv(pe.defaults),pe},pe.getDefaults=Yc,pe.defaults=Rn,pe.use=function(...e){const t=pe.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=pe.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=pe.defaults.renderer||new Ci;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let c=n.renderer[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.renderer=o}if(n.tokenizer){const o=pe.defaults.tokenizer||new Si;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let c=n.tokenizer[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.tokenizer=o}if(n.hooks){const o=pe.defaults.hooks||new Io;for(const s in n.hooks){const i=o[s];Io.passThroughHooks.has(s)?o[s]=a=>{if(pe.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(u=>i.call(o,u));const c=n.hooks[s].call(o,a);return i.call(o,c)}:o[s]=(...a)=>{let c=n.hooks[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.hooks=o}if(n.walkTokens){const o=pe.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}pe.setOptions(r)})},pe.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(pe,r)),r.type){case"table":{for(const o of r.header)n=n.concat(pe.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(pe.walkTokens(s.tokens,t));break}case"list":{n=n.concat(pe.walkTokens(r.items,t));break}default:pe.defaults.extensions&&pe.defaults.extensions.childTokens&&pe.defaults.extensions.childTokens[r.type]?pe.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(pe.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(pe.walkTokens(r.tokens,t)))}return n},pe.parseInline=au(pn.lexInline,mn.parseInline),pe.Parser=mn,pe.parser=mn.parse,pe.Renderer=Ci,pe.TextRenderer=su,pe.Lexer=pn,pe.lexer=pn.lex,pe.Tokenizer=Si,pe.Slugger=iu,pe.Hooks=Io,pe.parse=pe,pe.options,pe.setOptions,pe.use,pe.walkTokens,pe.parseInline,mn.parse,pn.lex;function Ti({content:e,className:t="",allowHtml:n=!1}){const r=y.useMemo(()=>{try{if(!n){const o=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return pe.parse(o)}return pe.parse(e)}catch(o){return console.error("[MarkdownContent] parse error",o),`<pre>Error rendering markdown: ${String(o)}</pre>`}},[e,n]);return l.jsx("div",{className:Z("markdown prose max-w-none break-words dark:prose-invert",t),dangerouslySetInnerHTML:{__html:r}})}async function lu(e,t){return await St(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function cu(e,t){return await(await lu(`/chat/files/${e}/view`,t)).text()}async function Ev(e,t){const n=await lu(`/chat/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await St(`/chat/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function kv(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await St("/chat/files",{params:r})}const Iv=1,Nv=1e6;let Ei=0;function Av(){return Ei=(Ei+1)%Number.MAX_SAFE_INTEGER,Ei.toString()}const ki=new Map,uu=e=>{if(ki.has(e))return;const t=setTimeout(()=>{ki.delete(e),Ar({type:"REMOVE_TOAST",toastId:e})},Nv);ki.set(e,t)},_v=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Iv)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?uu(n):e.toasts.forEach(r=>{uu(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},No=[];let Ao={toasts:[]};function Ar(e){Ao=_v(Ao,e),No.forEach(t=>{t(Ao)})}function jv({...e}){const t=Av(),n=o=>Ar({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Ar({type:"DISMISS_TOAST",toastId:t});return Ar({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Ii(){const[e,t]=p.useState(Ao);return p.useEffect(()=>(No.push(t),()=>{const n=No.indexOf(t);n>-1&&No.splice(n,1)}),[e]),{...e,toast:jv,dismiss:n=>Ar({type:"DISMISS_TOAST",toastId:n})}}function ut(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Rv(e,t=globalThis==null?void 0:globalThis.document){const n=ut(e);p.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Pv="DismissableLayer",Ni="dismissableLayer.update",Ov="dismissableLayer.pointerDownOutside",Mv="dismissableLayer.focusOutside",du,fu=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),_o=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...c}=e,u=p.useContext(fu),[d,f]=p.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=p.useState({}),w=Pe(t,I=>f(I)),v=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=v.indexOf(g),b=d?v.indexOf(d):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,k=b>=x,C=$v(I=>{const N=I.target,_=[...u.branches].some(j=>j.contains(N));!k||_||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},h),T=Fv(I=>{const N=I.target;[...u.branches].some(j=>j.contains(N))||(s==null||s(I),i==null||i(I),I.defaultPrevented||a==null||a())},h);return Rv(I=>{b===u.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},h),p.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(du=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),hu(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=du)}},[d,h,n,u]),p.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),hu())},[d,u]),p.useEffect(()=>{const I=()=>m({});return document.addEventListener(Ni,I),()=>document.removeEventListener(Ni,I)},[]),l.jsx(Se.div,{...c,ref:w,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:se(e.onFocusCapture,T.onFocusCapture),onBlurCapture:se(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:se(e.onPointerDownCapture,C.onPointerDownCapture)})});_o.displayName=Pv;var Dv="DismissableLayerBranch",Lv=p.forwardRef((e,t)=>{const n=p.useContext(fu),r=p.useRef(null),o=Pe(t,r);return p.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),l.jsx(Se.div,{...e,ref:o})});Lv.displayName=Dv;function $v(e,t=globalThis==null?void 0:globalThis.document){const n=ut(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let c=function(){pu(Ov,n,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Fv(e,t=globalThis==null?void 0:globalThis.document){const n=ut(e),r=p.useRef(!1);return p.useEffect(()=>{const o=s=>{s.target&&!r.current&&pu(Mv,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function hu(){const e=new CustomEvent(Ni);document.dispatchEvent(e)}function pu(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Bc(o,s):o.dispatchEvent(s)}var Ai="focusScope.autoFocusOnMount",_i="focusScope.autoFocusOnUnmount",mu={bubbles:!1,cancelable:!0},zv="FocusScope",jo=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,c]=p.useState(null),u=ut(o),d=ut(s),f=p.useRef(null),h=Pe(t,v=>c(v)),m=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let v=function(S){if(m.paused||!a)return;const k=S.target;a.contains(k)?f.current=k:gn(f.current,{select:!0})},g=function(S){if(m.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||gn(f.current,{select:!0}))},x=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&gn(a)};document.addEventListener("focusin",v),document.addEventListener("focusout",g);const b=new MutationObserver(x);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",g),b.disconnect()}}},[r,a,m.paused]),p.useEffect(()=>{if(a){vu.add(m);const v=document.activeElement;if(!a.contains(v)){const x=new CustomEvent(Ai,mu);a.addEventListener(Ai,u),a.dispatchEvent(x),x.defaultPrevented||(Bv(Kv(gu(a)),{select:!0}),document.activeElement===v&&gn(a))}return()=>{a.removeEventListener(Ai,u),setTimeout(()=>{const x=new CustomEvent(_i,mu);a.addEventListener(_i,d),a.dispatchEvent(x),x.defaultPrevented||gn(v??document.body,{select:!0}),a.removeEventListener(_i,d),vu.remove(m)},0)}}},[a,u,d,m]);const w=p.useCallback(v=>{if(!n&&!r||m.paused)return;const g=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,x=document.activeElement;if(g&&x){const b=v.currentTarget,[S,k]=Hv(b);S&&k?!v.shiftKey&&x===k?(v.preventDefault(),n&&gn(S,{select:!0})):v.shiftKey&&x===S&&(v.preventDefault(),n&&gn(k,{select:!0})):x===b&&v.preventDefault()}},[n,r,m.paused]);return l.jsx(Se.div,{tabIndex:-1,...i,ref:h,onKeyDown:w})});jo.displayName=zv;function Bv(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(gn(r,{select:t}),document.activeElement!==n)return}function Hv(e){const t=gu(e),n=xu(t,e),r=xu(t.reverse(),e);return[n,r]}function gu(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function xu(e,t){for(const n of e)if(!Uv(n,{upTo:t}))return n}function Uv(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Wv(e){return e instanceof HTMLInputElement&&"select"in e}function gn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Wv(e)&&t&&e.select()}}var vu=Vv();function Vv(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=wu(e,t),e.unshift(t)},remove(t){var n;e=wu(e,t),(n=e[0])==null||n.resume()}}}function wu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Kv(e){return e.filter(t=>t.tagName!=="A")}var qv="Portal",Ro=p.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=p.useState(!1);ct(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Is.createPortal(l.jsx(Se.div,{...r,ref:t}),i):null});Ro.displayName=qv;var ji=0;function Ri(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??bu()),document.body.insertAdjacentElement("beforeend",e[1]??bu()),ji++,()=>{ji===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),ji--}},[])}function bu(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Jt=function(){return Jt=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Jt.apply(this,arguments)};function yu(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function Gv(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var Po="right-scroll-bar-position",Oo="width-before-scroll-bar",Yv="with-scroll-bars-hidden",Xv="--removed-body-scroll-bar-size";function Pi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Jv(e,t){var n=y.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Zv=typeof window<"u"?p.useLayoutEffect:p.useEffect,Su=new WeakMap;function Qv(e,t){var n=Jv(null,function(r){return e.forEach(function(o){return Pi(o,r)})});return Zv(function(){var r=Su.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Pi(a,null)}),s.forEach(function(a){o.has(a)||Pi(a,i)})}Su.set(n,e)},[e]),n}function ew(e){return e}function tw(e,t){t===void 0&&(t=ew);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var c=function(){var d=i;i=[],d.forEach(s)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return o}function nw(e){e===void 0&&(e={});var t=tw(null);return t.options=Jt({async:!0,ssr:!1},e),t}var Cu=function(e){var t=e.sideCar,n=yu(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return p.createElement(r,Jt({},n))};Cu.isSideCarExport=!0;function rw(e,t){return e.useMedium(t),Cu}var Tu=nw(),Oi=function(){},Mo=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:Oi,onWheelCapture:Oi,onTouchMoveCapture:Oi}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,c=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,m=e.noRelative,w=e.noIsolation,v=e.inert,g=e.allowPinchZoom,x=e.as,b=x===void 0?"div":x,S=e.gapMode,k=yu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,T=Qv([n,t]),I=Jt(Jt({},k),o);return p.createElement(p.Fragment,null,d&&p.createElement(C,{sideCar:Tu,removeScrollBar:u,shards:f,noRelative:m,noIsolation:w,inert:v,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:S}),i?p.cloneElement(p.Children.only(a),Jt(Jt({},I),{ref:T})):p.createElement(b,Jt({},I,{className:c,ref:T}),a))});Mo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Mo.classNames={fullWidth:Oo,zeroRight:Po};var ow=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function sw(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=ow();return t&&e.setAttribute("nonce",t),e}function iw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function aw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var lw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=sw())&&(iw(t,n),aw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},cw=function(){var e=lw();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Eu=function(){var e=cw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},uw={left:0,top:0,right:0,gap:0},Mi=function(e){return parseInt(e||"",10)||0},dw=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Mi(n),Mi(r),Mi(o)]},fw=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return uw;var t=dw(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},hw=Eu(),Yn="data-scroll-locked",pw=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
84
+ .`.concat(Yv,` {
85
85
  overflow: hidden `).concat(r,`;
86
86
  padding-right: `).concat(a,"px ").concat(r,`;
87
87
  }
@@ -115,20 +115,20 @@ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An err
115
115
  }
116
116
 
117
117
  body[`).concat(Yn,`] {
118
- `).concat(Yv,": ").concat(a,`px;
118
+ `).concat(Xv,": ").concat(a,`px;
119
119
  }
120
- `)},Eu=function(){var e=parseInt(document.body.getAttribute(Yn)||"0",10);return isFinite(e)?e:0},pw=function(){p.useEffect(function(){return document.body.setAttribute(Yn,(Eu()+1).toString()),function(){var e=Eu()-1;e<=0?document.body.removeAttribute(Yn):document.body.setAttribute(Yn,e.toString())}},[])},mw=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;pw();var s=p.useMemo(function(){return dw(o)},[o]);return p.createElement(fw,{styles:hw(s,!t,o,n?"":"!important")})},Di=!1;if(typeof window<"u")try{var Do=Object.defineProperty({},"passive",{get:function(){return Di=!0,!0}});window.addEventListener("test",Do,Do),window.removeEventListener("test",Do,Do)}catch{Di=!1}var Xn=Di?{passive:!1}:!1,gw=function(e){return e.tagName==="TEXTAREA"},ku=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!gw(e)&&n[t]==="visible")},xw=function(e){return ku(e,"overflowY")},vw=function(e){return ku(e,"overflowX")},Iu=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Nu(e,r);if(o){var s=Au(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},ww=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},bw=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Nu=function(e,t){return e==="v"?xw(t):vw(t)},Au=function(e,t){return e==="v"?ww(t):bw(t)},yw=function(e,t){return e==="h"&&t==="rtl"?-1:1},Sw=function(e,t,n,r,o){var s=yw(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,c=t.contains(a),u=!1,d=i>0,f=0,h=0;do{if(!a)break;var m=Au(e,a),w=m[0],v=m[1],g=m[2],x=v-g-s*w;(w||x)&&Nu(e,a)&&(f+=x,h+=w);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!c&&a!==document.body||c&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},Lo=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},_u=function(e){return[e.deltaX,e.deltaY]},ju=function(e){return e&&"current"in e?e.current:e},Cw=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Tw=function(e){return`
120
+ `)},ku=function(){var e=parseInt(document.body.getAttribute(Yn)||"0",10);return isFinite(e)?e:0},mw=function(){p.useEffect(function(){return document.body.setAttribute(Yn,(ku()+1).toString()),function(){var e=ku()-1;e<=0?document.body.removeAttribute(Yn):document.body.setAttribute(Yn,e.toString())}},[])},gw=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;mw();var s=p.useMemo(function(){return fw(o)},[o]);return p.createElement(hw,{styles:pw(s,!t,o,n?"":"!important")})},Di=!1;if(typeof window<"u")try{var Do=Object.defineProperty({},"passive",{get:function(){return Di=!0,!0}});window.addEventListener("test",Do,Do),window.removeEventListener("test",Do,Do)}catch{Di=!1}var Xn=Di?{passive:!1}:!1,xw=function(e){return e.tagName==="TEXTAREA"},Iu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!xw(e)&&n[t]==="visible")},vw=function(e){return Iu(e,"overflowY")},ww=function(e){return Iu(e,"overflowX")},Nu=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Au(e,r);if(o){var s=_u(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},bw=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},yw=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Au=function(e,t){return e==="v"?vw(t):ww(t)},_u=function(e,t){return e==="v"?bw(t):yw(t)},Sw=function(e,t){return e==="h"&&t==="rtl"?-1:1},Cw=function(e,t,n,r,o){var s=Sw(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,c=t.contains(a),u=!1,d=i>0,f=0,h=0;do{if(!a)break;var m=_u(e,a),w=m[0],v=m[1],g=m[2],x=v-g-s*w;(w||x)&&Au(e,a)&&(f+=x,h+=w);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!c&&a!==document.body||c&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},Lo=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},ju=function(e){return[e.deltaX,e.deltaY]},Ru=function(e){return e&&"current"in e?e.current:e},Tw=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Ew=function(e){return`
121
121
  .block-interactivity-`.concat(e,` {pointer-events: none;}
122
122
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
123
- `)},Ew=0,Jn=[];function kw(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),o=p.useState(Ew++)[0],s=p.useState(Tu)[0],i=p.useRef(e);p.useEffect(function(){i.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var v=qv([e.lockRef.current],(e.shards||[]).map(ju),!0).filter(Boolean);return v.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),v.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=p.useCallback(function(v,g){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!i.current.allowPinchZoom;var x=Lo(v),b=n.current,S="deltaX"in v?v.deltaX:b[0]-x[0],k="deltaY"in v?v.deltaY:b[1]-x[1],C,T=v.target,I=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in v&&I==="h"&&T.type==="range")return!1;var N=Iu(I,T);if(!N)return!0;if(N?C=I:(C=I==="v"?"h":"v",N=Iu(I,T)),!N)return!1;if(!r.current&&"changedTouches"in v&&(S||k)&&(r.current=C),!C)return!0;var _=r.current||C;return Sw(_,g,v,_==="h"?S:k)},[]),c=p.useCallback(function(v){var g=v;if(!(!Jn.length||Jn[Jn.length-1]!==s)){var x="deltaY"in g?_u(g):Lo(g),b=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&Cw(C.delta,x)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(ju).filter(Boolean).filter(function(C){return C.contains(g.target)}),k=S.length>0?a(g,S[0]):!i.current.noIsolation;k&&g.cancelable&&g.preventDefault()}}},[]),u=p.useCallback(function(v,g,x,b){var S={name:v,delta:g,target:x,should:b,shadowParent:Iw(x)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=p.useCallback(function(v){n.current=Lo(v),r.current=void 0},[]),f=p.useCallback(function(v){u(v.type,_u(v),v.target,a(v,e.lockRef.current))},[]),h=p.useCallback(function(v){u(v.type,Lo(v),v.target,a(v,e.lockRef.current))},[]);p.useEffect(function(){return Jn.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",c,Xn),document.addEventListener("touchmove",c,Xn),document.addEventListener("touchstart",d,Xn),function(){Jn=Jn.filter(function(v){return v!==s}),document.removeEventListener("wheel",c,Xn),document.removeEventListener("touchmove",c,Xn),document.removeEventListener("touchstart",d,Xn)}},[]);var m=e.removeScrollBar,w=e.inert;return p.createElement(p.Fragment,null,w?p.createElement(s,{styles:Tw(o)}):null,m?p.createElement(mw,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Iw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Nw=nw(Cu,kw);var $o=p.forwardRef(function(e,t){return p.createElement(Mo,Jt({},e,{ref:t,sideCar:Nw}))});$o.classNames=Mo.classNames;var Aw=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Zn=new WeakMap,Fo=new WeakMap,zo={},Li=0,Ru=function(e){return e&&(e.host||Ru(e.parentNode))},_w=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Ru(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},jw=function(e,t,n,r){var o=_w(t,Array.isArray(e)?e:[e]);zo[n]||(zo[n]=new WeakMap);var s=zo[n],i=[],a=new Set,c=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var d=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))d(h);else try{var m=h.getAttribute(r),w=m!==null&&m!=="false",v=(Zn.get(h)||0)+1,g=(s.get(h)||0)+1;Zn.set(h,v),s.set(h,g),i.push(h),v===1&&w&&Fo.set(h,!0),g===1&&h.setAttribute(n,"true"),w||h.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",h,x)}})};return d(t),a.clear(),Li++,function(){i.forEach(function(f){var h=Zn.get(f)-1,m=s.get(f)-1;Zn.set(f,h),s.set(f,m),h||(Fo.has(f)||f.removeAttribute(r),Fo.delete(f)),m||f.removeAttribute(n)}),Li--,Li||(Zn=new WeakMap,Zn=new WeakMap,Fo=new WeakMap,zo={})}},$i=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Aw(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),jw(r,o,n,"aria-hidden")):function(){return null}},Bo="Dialog",[Pu,HC]=Yt(Bo),[Rw,Bt]=Pu(Bo),Ou=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=p.useRef(null),c=p.useRef(null),[u,d]=jn({prop:r,defaultProp:o??!1,onChange:s,caller:Bo});return l.jsx(Rw,{scope:t,triggerRef:a,contentRef:c,contentId:Xt(),titleId:Xt(),descriptionId:Xt(),open:u,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Ou.displayName=Bo;var Mu="DialogTrigger",Du=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Bt(Mu,n),s=je(t,o.triggerRef);return l.jsx(ye.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Bi(o.open),...r,ref:s,onClick:ae(e.onClick,o.onOpenToggle)})});Du.displayName=Mu;var Fi="DialogPortal",[Pw,Lu]=Pu(Fi,{forceMount:void 0}),$u=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=Bt(Fi,t);return l.jsx(Pw,{scope:t,forceMount:n,children:p.Children.map(r,i=>l.jsx(kt,{present:n||s.open,children:l.jsx(Ro,{asChild:!0,container:o,children:i})}))})};$u.displayName=Fi;var Ho="DialogOverlay",Fu=p.forwardRef((e,t)=>{const n=Lu(Ho,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Bt(Ho,e.__scopeDialog);return s.modal?l.jsx(kt,{present:r||s.open,children:l.jsx(Mw,{...o,ref:t})}):null});Fu.displayName=Ho;var Ow=Cn.createSlot("DialogOverlay.RemoveScroll"),Mw=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Bt(Ho,n);return l.jsx($o,{as:Ow,allowPinchZoom:!0,shards:[o.contentRef],children:l.jsx(ye.div,{"data-state":Bi(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Pn="DialogContent",zu=p.forwardRef((e,t)=>{const n=Lu(Pn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Bt(Pn,e.__scopeDialog);return l.jsx(kt,{present:r||s.open,children:s.modal?l.jsx(Dw,{...o,ref:t}):l.jsx(Lw,{...o,ref:t})})});zu.displayName=Pn;var Dw=p.forwardRef((e,t)=>{const n=Bt(Pn,e.__scopeDialog),r=p.useRef(null),o=je(t,n.contentRef,r);return p.useEffect(()=>{const s=r.current;if(s)return $i(s)},[]),l.jsx(Bu,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ae(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ae(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault())})}),Lw=p.forwardRef((e,t)=>{const n=Bt(Pn,e.__scopeDialog),r=p.useRef(!1),o=p.useRef(!1);return l.jsx(Bu,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var c,u;(c=e.onInteractOutside)==null||c.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((u=n.triggerRef.current)==null?void 0:u.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Bu=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=Bt(Pn,n),c=p.useRef(null),u=je(t,c);return Ri(),l.jsxs(l.Fragment,{children:[l.jsx(jo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:l.jsx(_o,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Bi(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),l.jsxs(l.Fragment,{children:[l.jsx($w,{titleId:a.titleId}),l.jsx(zw,{contentRef:c,descriptionId:a.descriptionId})]})]})}),zi="DialogTitle",Hu=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Bt(zi,n);return l.jsx(ye.h2,{id:o.titleId,...r,ref:t})});Hu.displayName=zi;var Uu="DialogDescription",Wu=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Bt(Uu,n);return l.jsx(ye.p,{id:o.descriptionId,...r,ref:t})});Wu.displayName=Uu;var Vu="DialogClose",Ku=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Bt(Vu,n);return l.jsx(ye.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,()=>o.onOpenChange(!1))})});Ku.displayName=Vu;function Bi(e){return e?"open":"closed"}var qu="DialogTitleWarning",[UC,Gu]=Vx(qu,{contentName:Pn,titleName:zi,docsSlug:"dialog"}),$w=({titleId:e})=>{const t=Gu(qu),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
123
+ `)},kw=0,Jn=[];function Iw(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),o=p.useState(kw++)[0],s=p.useState(Eu)[0],i=p.useRef(e);p.useEffect(function(){i.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var v=Gv([e.lockRef.current],(e.shards||[]).map(Ru),!0).filter(Boolean);return v.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),v.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=p.useCallback(function(v,g){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!i.current.allowPinchZoom;var x=Lo(v),b=n.current,S="deltaX"in v?v.deltaX:b[0]-x[0],k="deltaY"in v?v.deltaY:b[1]-x[1],C,T=v.target,I=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in v&&I==="h"&&T.type==="range")return!1;var N=Nu(I,T);if(!N)return!0;if(N?C=I:(C=I==="v"?"h":"v",N=Nu(I,T)),!N)return!1;if(!r.current&&"changedTouches"in v&&(S||k)&&(r.current=C),!C)return!0;var _=r.current||C;return Cw(_,g,v,_==="h"?S:k)},[]),c=p.useCallback(function(v){var g=v;if(!(!Jn.length||Jn[Jn.length-1]!==s)){var x="deltaY"in g?ju(g):Lo(g),b=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&Tw(C.delta,x)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Ru).filter(Boolean).filter(function(C){return C.contains(g.target)}),k=S.length>0?a(g,S[0]):!i.current.noIsolation;k&&g.cancelable&&g.preventDefault()}}},[]),u=p.useCallback(function(v,g,x,b){var S={name:v,delta:g,target:x,should:b,shadowParent:Nw(x)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=p.useCallback(function(v){n.current=Lo(v),r.current=void 0},[]),f=p.useCallback(function(v){u(v.type,ju(v),v.target,a(v,e.lockRef.current))},[]),h=p.useCallback(function(v){u(v.type,Lo(v),v.target,a(v,e.lockRef.current))},[]);p.useEffect(function(){return Jn.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",c,Xn),document.addEventListener("touchmove",c,Xn),document.addEventListener("touchstart",d,Xn),function(){Jn=Jn.filter(function(v){return v!==s}),document.removeEventListener("wheel",c,Xn),document.removeEventListener("touchmove",c,Xn),document.removeEventListener("touchstart",d,Xn)}},[]);var m=e.removeScrollBar,w=e.inert;return p.createElement(p.Fragment,null,w?p.createElement(s,{styles:Ew(o)}):null,m?p.createElement(gw,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Nw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Aw=rw(Tu,Iw);var $o=p.forwardRef(function(e,t){return p.createElement(Mo,Jt({},e,{ref:t,sideCar:Aw}))});$o.classNames=Mo.classNames;var _w=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Zn=new WeakMap,Fo=new WeakMap,zo={},Li=0,Pu=function(e){return e&&(e.host||Pu(e.parentNode))},jw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Pu(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Rw=function(e,t,n,r){var o=jw(t,Array.isArray(e)?e:[e]);zo[n]||(zo[n]=new WeakMap);var s=zo[n],i=[],a=new Set,c=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var d=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))d(h);else try{var m=h.getAttribute(r),w=m!==null&&m!=="false",v=(Zn.get(h)||0)+1,g=(s.get(h)||0)+1;Zn.set(h,v),s.set(h,g),i.push(h),v===1&&w&&Fo.set(h,!0),g===1&&h.setAttribute(n,"true"),w||h.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",h,x)}})};return d(t),a.clear(),Li++,function(){i.forEach(function(f){var h=Zn.get(f)-1,m=s.get(f)-1;Zn.set(f,h),s.set(f,m),h||(Fo.has(f)||f.removeAttribute(r),Fo.delete(f)),m||f.removeAttribute(n)}),Li--,Li||(Zn=new WeakMap,Zn=new WeakMap,Fo=new WeakMap,zo={})}},$i=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=_w(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Rw(r,o,n,"aria-hidden")):function(){return null}},Bo="Dialog",[Ou,UC]=Yt(Bo),[Pw,Bt]=Ou(Bo),Mu=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=p.useRef(null),c=p.useRef(null),[u,d]=jn({prop:r,defaultProp:o??!1,onChange:s,caller:Bo});return l.jsx(Pw,{scope:t,triggerRef:a,contentRef:c,contentId:Xt(),titleId:Xt(),descriptionId:Xt(),open:u,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Mu.displayName=Bo;var Du="DialogTrigger",Lu=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Bt(Du,n),s=Pe(t,o.triggerRef);return l.jsx(Se.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Bi(o.open),...r,ref:s,onClick:se(e.onClick,o.onOpenToggle)})});Lu.displayName=Du;var Fi="DialogPortal",[Ow,$u]=Ou(Fi,{forceMount:void 0}),Fu=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=Bt(Fi,t);return l.jsx(Ow,{scope:t,forceMount:n,children:p.Children.map(r,i=>l.jsx(kt,{present:n||s.open,children:l.jsx(Ro,{asChild:!0,container:o,children:i})}))})};Fu.displayName=Fi;var Ho="DialogOverlay",zu=p.forwardRef((e,t)=>{const n=$u(Ho,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Bt(Ho,e.__scopeDialog);return s.modal?l.jsx(kt,{present:r||s.open,children:l.jsx(Dw,{...o,ref:t})}):null});zu.displayName=Ho;var Mw=Cn.createSlot("DialogOverlay.RemoveScroll"),Dw=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Bt(Ho,n);return l.jsx($o,{as:Mw,allowPinchZoom:!0,shards:[o.contentRef],children:l.jsx(Se.div,{"data-state":Bi(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Pn="DialogContent",Bu=p.forwardRef((e,t)=>{const n=$u(Pn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Bt(Pn,e.__scopeDialog);return l.jsx(kt,{present:r||s.open,children:s.modal?l.jsx(Lw,{...o,ref:t}):l.jsx($w,{...o,ref:t})})});Bu.displayName=Pn;var Lw=p.forwardRef((e,t)=>{const n=Bt(Pn,e.__scopeDialog),r=p.useRef(null),o=Pe(t,n.contentRef,r);return p.useEffect(()=>{const s=r.current;if(s)return $i(s)},[]),l.jsx(Hu,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:se(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:se(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:se(e.onFocusOutside,s=>s.preventDefault())})}),$w=p.forwardRef((e,t)=>{const n=Bt(Pn,e.__scopeDialog),r=p.useRef(!1),o=p.useRef(!1);return l.jsx(Hu,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var c,u;(c=e.onInteractOutside)==null||c.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((u=n.triggerRef.current)==null?void 0:u.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Hu=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=Bt(Pn,n),c=p.useRef(null),u=Pe(t,c);return Ri(),l.jsxs(l.Fragment,{children:[l.jsx(jo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:l.jsx(_o,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Bi(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),l.jsxs(l.Fragment,{children:[l.jsx(Fw,{titleId:a.titleId}),l.jsx(Bw,{contentRef:c,descriptionId:a.descriptionId})]})]})}),zi="DialogTitle",Uu=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Bt(zi,n);return l.jsx(Se.h2,{id:o.titleId,...r,ref:t})});Uu.displayName=zi;var Wu="DialogDescription",Vu=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Bt(Wu,n);return l.jsx(Se.p,{id:o.descriptionId,...r,ref:t})});Vu.displayName=Wu;var Ku="DialogClose",qu=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Bt(Ku,n);return l.jsx(Se.button,{type:"button",...r,ref:t,onClick:se(e.onClick,()=>o.onOpenChange(!1))})});qu.displayName=Ku;function Bi(e){return e?"open":"closed"}var Gu="DialogTitleWarning",[WC,Yu]=Kx(Gu,{contentName:Pn,titleName:zi,docsSlug:"dialog"}),Fw=({titleId:e})=>{const t=Yu(Gu),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
124
124
 
125
125
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
126
126
 
127
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return p.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Fw="DialogDescriptionWarning",zw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Gu(Fw).contentName}}.`;return p.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Yu=Ou,Bw=Du,Xu=$u,Uo=Fu,Wo=zu,On=Hu,Vo=Wu,Ju=Ku;const Hw=Yu,Uw=Xu,Zu=p.forwardRef(({className:e,...t},n)=>l.jsx(Uo,{ref:n,className:Z("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Zu.displayName=Uo.displayName;const Qu=p.forwardRef(({className:e,children:t,...n},r)=>{const o=p.useMemo(()=>{let s=!1;function i(a){p.Children.forEach(a,c=>{if(s||!p.isValidElement(c))return;const u=c.type;if(u===On||(u==null?void 0:u.displayName)===On.displayName||(u==null?void 0:u.name)==="DialogTitle"){s=!0;return}c.props&&c.props.children&&i(c.props.children)})}return i(t),s},[t]);return l.jsxs(Uw,{children:[l.jsx(Zu,{}),l.jsxs(Wo,{ref:r,className:Z("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&l.jsx(On,{className:"sr-only",children:"Dialog"}),t,l.jsxs(Ju,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[l.jsx(ne.X,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Qu.displayName=Wo.displayName;const ed=({className:e,...t})=>l.jsx("div",{className:Z("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});ed.displayName="DialogHeader";const td=p.forwardRef(({className:e,...t},n)=>l.jsx(On,{ref:n,className:Z("text-lg font-semibold leading-none tracking-tight",e),...t}));td.displayName=On.displayName;const Ww=p.forwardRef(({className:e,...t},n)=>l.jsx(Vo,{ref:n,className:Z("text-sm text-muted-foreground",e),...t}));Ww.displayName=Vo.displayName;function Vw({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=y.useState(!1),[a,c]=y.useState(null),[u,d]=y.useState(null),{toast:f}=Ii(),h=y.useCallback(async()=>{if(n){i(!0),d(null),c(null);try{const x=await lu(n);c(x)}catch(x){console.error("Failed to load file:",x),d(x instanceof Error?x.message:"Failed to load file")}finally{i(!1)}}},[n]);y.useEffect(()=>{e&&n&&h()},[e,n,h]);const m=async()=>{if(n)try{await Tv(n),f({title:"Download started",description:`Downloading ${r}`})}catch(x){console.error("Failed to download file:",x),f({title:"Download failed",description:String(x),variant:"destructive"})}},w=async()=>{if(n)try{const x=await lu(n),b=new Blob([x],{type:o}),S=URL.createObjectURL(b);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(x){console.error("Failed to open file externally:",x),f({title:"Failed to open file",description:String(x),variant:"destructive"})}},v=()=>s?l.jsxs("div",{className:"flex items-center justify-center py-12",children:[l.jsx(ne.Loader,{className:"h-8 w-8 animate-spin mr-3"}),l.jsx("span",{children:"Loading file..."})]}):u?l.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[l.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),l.jsx("p",{className:"text-red-600 mb-4",children:u}),l.jsx(Le,{onClick:h,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?l.jsx("div",{className:"flex justify-center",children:l.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?l.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:l.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?l.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:l.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):l.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[l.jsx(ne.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),l.jsx("p",{className:"text-lg font-medium mb-2",children:r}),l.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),g=()=>o.startsWith("image/")?l.jsx(ne.Image,{className:"h-5 w-5"}):l.jsx(ne.FileText,{className:"h-5 w-5"});return l.jsx(Hw,{open:e,onOpenChange:t,children:l.jsxs(Qu,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[l.jsx(ed,{children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[g(),l.jsxs("div",{children:[l.jsx(td,{className:"text-left",children:r}),l.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Le,{variant:"outline",size:"sm",onClick:w,className:"flex items-center gap-2",children:[l.jsx(ne.ExternalLink,{className:"h-4 w-4"}),"External"]}),l.jsxs(Le,{variant:"outline",size:"sm",onClick:m,className:"flex items-center gap-2",children:[l.jsx(ne.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),l.jsx("div",{className:"flex-1 overflow-hidden",children:v()})]})})}function nd(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function rd(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function _r(e){if(typeof e=="string")return e.length>2e3?e.slice(0,2e3)+"... [truncated]":e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(_r).filter(r=>r!==void 0);return n.length?n:void 0}if(rd(e))return;const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=_r(r);o!==void 0&&(t[n]=o)}}return Object.keys(t).length?t:void 0}return e}function Hi(e){if(typeof e=="string")return e;if(rd(e))return"";try{const t=_r(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function od(e){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){if(e.desirability||e.feasibility||e.viability||e.other)return{desirability:Array.isArray(e.desirability)?e.desirability:[],feasibility:Array.isArray(e.feasibility)?e.feasibility:[],viability:Array.isArray(e.viability)?e.viability:[],other:Array.isArray(e.other)?e.other:[]};if(e.output&&typeof e.output!="object")e=e.output;else if(e.output&&typeof e.output=="object")return od(e.output)}const t=String(e),n={desirability:[],feasibility:[],viability:[],other:[]};let r=t;const o=Math.min(...["desirability=","feasibility=","viability=","other="].map(i=>{const a=r.toLowerCase().indexOf(i);return a===-1?Number.MAX_SAFE_INTEGER:a}));o!==Number.MAX_SAFE_INTEGER&&(r=r.slice(o));for(const i of Object.keys(n)){const c=new RegExp(i+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(r);if(!c)continue;const u=c[1],d=/Issue\(([\s\S]*?)\)(?:,|$)/g;let f=null;for(;(f=d.exec(u))!==null;){const h=f[1],m=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(h),w=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(h),v=m?m[2].trim():"",g=w?w[2].trim():"";n[i].push({title:v,description:g})}}return Object.values(n).some(i=>i.length>0)?n:null}const Ko="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words",Mn=1e5;function Kw(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function qw(e){const t=e.find(r=>r.type==="tool_call"),n=e.find(r=>r.type==="tool_end");return{name:t==null?void 0:t.name,toolCallId:(n==null?void 0:n.toolCallId)??(t==null?void 0:t.id)}}function Gw(e){const t=e.filter(r=>r.type==="tool_call");return e.filter(r=>r.type==="tool_end").map(r=>{var o;return{name:(o=t.find(s=>s.id===r.toolCallId))==null?void 0:o.name,toolCallId:r.toolCallId,output:r.output}})}function Yw(e){const t=(r,o=Mn)=>{try{const s=_r(r),i=typeof s=="string"?s:JSON.stringify(s??"");return i.length<=o?i:i.slice(0,o)+`
128
- … [truncated ${i.length-o} chars]`}catch{return""}},n=e.filter(r=>r.type==="tool_end");if(n.length)try{return n.length===1?t(n[0].output):t(n.map(r=>({toolCallId:r.toolCallId,output:r.output})))}catch{}return t(e)}function Xw(e){const t=e.find(r=>r.type==="tool_end");if(!t)return null;const n=t.output;return typeof n=="string"?n:null}function Jw(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function sd(e){const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(r=>{switch(r.type){case"text":return`t:${r.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"tool_end":return"end";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function Zw({className:e}){const[t,n]=y.useState(0);return y.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),l.jsxs("span",{"aria-live":"polite",className:Z("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const id=y.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:c="desktop",truncateToolMessages:u=!0,toolMessagePreviewLength:d=200,truncateUserMessages:f=!0,userMessagePreviewLength:h=200,customStyles:m={},onEdit:w,onRegenerate:v,onCancelEdit:g,onCopy:x}){const[b,S]=y.useState(!1),[k,C]=y.useState("collapsed"),[T,I]=y.useState(!1),{currentThreadId:N}=mr(),{handleInterrupt:_}=qs(),{toast:j}=Ii(),[R,z]=y.useState({}),[H,O]=y.useState(!1),[W,K]=y.useState(null),G=c==="phone"||c==="half-screen",$=t.role,A=$==="tool",D=!(r&&$!=="user"),U=y.useMemo(()=>{switch($){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[$]),J=y.useMemo(()=>Kw(t.content),[t.content]),Q=y.useMemo(()=>qw(t.content),[t.content]),ce=y.useMemo(()=>t.content.filter(ie=>ie.type==="image_url"),[t.content]),we=y.useMemo(()=>t.content.filter(ie=>ie.type==="file"),[t.content]),ke=y.useMemo(()=>t.content.filter(ie=>ie.type==="interrupt"),[t.content]),q=y.useMemo(()=>Yw(t.content),[t.content]);y.useMemo(()=>Xw(t.content),[t.content]);const M=y.useMemo(()=>q.length<=Mn?q:`${q.slice(0,Mn)}
129
- … [truncated ${q.length-Mn} chars]`,[q]),X=y.useCallback(async(ie="all")=>{const pe=ie==="visible"&&A?M:A?q:J;async function de(Ne){try{await navigator.clipboard.writeText(Ne)}catch{try{const Fe=document.createElement("textarea");Fe.value=Ne,Fe.setAttribute("readonly",""),Fe.style.position="absolute",Fe.style.left="-9999px",document.body.appendChild(Fe),Fe.select(),document.execCommand("copy"),document.body.removeChild(Fe)}catch(Fe){throw console.error("Failed to copy:",Fe),Fe}}}try{await de(pe),S(!0),setTimeout(()=>S(!1),2e3),x==null||x(pe)}catch(Ne){console.error("Failed to copy:",Ne)}},[A,q,J,M,x]),ee=y.useCallback(()=>{if(!w)return;const ie=A?q:J;w(t.id,ie)},[w,t.id,A,q,J]),L=y.useCallback(()=>{v==null||v(n)},[v,n]),F=y.useCallback(async(ie,te,pe)=>{if(!D){ie.preventDefault();return}if(R[pe]){ie.preventDefault();return}try{const de=String(te.url??""),Ne=de.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(Ne){ie.preventDefault();const Fe=Ne[1],Xe=te.name||`file_${Fe}`,Ze=te.mimeType||"application/octet-stream";K({id:Fe,name:Xe,mimeType:Ze}),O(!0);return}if(de.startsWith("data:")){ie.preventDefault(),z(Ze=>({...Ze,[pe]:!0}));const Fe=`${te.name}_${te.size}_${Date.now()}`,Xe=j({title:"Fetching file...",description:"",open:!0});try{const Ze=await Ev(N??void 0);if(!Ze||!Array.isArray(Ze))throw new Error("Invalid file list response");const lt=Ze.find(Dt=>!Dt||typeof Dt!="object"||!((Dt.filename??"")===(te.name??""))?!1:typeof te.size=="number"&&typeof Dt.size=="number"?Dt.size===te.size:!0);if(!(lt!=null&&lt.id))throw new Error(`File "${te.name}" is not yet available on the server`);if(!lt.id||!lt.filename)throw new Error("Invalid file data received from server");K({id:lt.id,name:te.name||lt.filename||`file_${lt.id}`,mimeType:te.mimeType||lt.mime_type||"application/octet-stream"}),O(!0),Xe.update({id:Xe.id,title:"Success",description:`Opened ${te.name}`,open:!0})}catch(Ze){console.error("Failed to fetch server file:",Ze);const lt=Ze instanceof Error?Ze.message:"Unknown error occurred";Xe.update({id:Xe.id,title:"Failed",description:lt}),j({title:"Failed to fetch file",description:lt,open:!0})}finally{z(Ze=>({...Ze,[pe]:!1}))}}}catch(de){console.error("File click error:",de),z(Ne=>({...Ne,[pe]:!1}))}},[D,R,j,N]),me=y.useCallback(()=>{const te=Z(G?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",U);switch($){case"user":return l.jsx(ne.User,{className:te});case"assistant":return l.jsx(ne.Bot,{className:te});case"tool":return l.jsx(ne.Wrench,{className:te});default:return l.jsx(ne.Bot,{className:te})}},[G,U,$]),Re=y.useCallback(()=>{const ie="group relative mb-4 flex w-full";switch($){case"user":return Z(ie,"justify-end");case"assistant":case"tool":case"system":return Z(ie,"justify-start");default:return ie}},[$]),xe=y.useCallback(()=>{const ie=Z("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",G&&"px-3 py-2 text-sm");switch($){case"user":return Z(ie,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return Z(ie,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return Z(ie,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return Z(ie,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return Z(ie,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[G,$]),_e=y.useCallback(async ie=>{try{const te=ie.id||`interrupt-${Date.now()}`;await _(te,!0)}catch(te){console.error("Failed to approve interrupt:",te)}},[_]),Be=y.useCallback(async ie=>{try{const te=ie.id||`interrupt-${Date.now()}`;await _(te,!1)}catch(te){console.error("Failed to reject interrupt:",te)}},[_]),qe=y.useCallback(({part:ie,i:te})=>{if(ie.type==="text"){const pe=ie.text??"",de=pe.trim(),Ne=nd(de);return Ne&&$!=="tool"?l.jsx(Qw,{data:Ne},te):$==="user"&&f&&de.length>h?l.jsxs(Wc,{open:T,onOpenChange:I,children:[l.jsx("div",{className:Z("text-sm text-[hsl(var(--chat-bubble-user-text))]",G&&"text-xs"),children:T?l.jsx(Ti,{content:de,allowHtml:!1}):l.jsxs("pre",{className:Z("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",G&&"text-xs"),children:[de.substring(0,h),"..."]})}),l.jsx(Vc,{asChild:!0,children:l.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:T?l.jsxs(l.Fragment,{children:[l.jsx(ne.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):l.jsxs(l.Fragment,{children:[l.jsx(ne.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",de.length-h," chars)"]})})})]},te):l.jsx(Ti,{content:pe,allowHtml:!1},te)}if(ie.type==="image_url"){const pe=ie;return l.jsx("div",{className:"my-2",children:l.jsx("img",{src:pe.url,alt:pe.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},te)}if(ie.type==="file"){const pe=ie,de=pe.name||"file";return l.jsxs("a",{href:pe.url,onClick:Ne=>F(Ne,pe,te),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
130
- dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[R[te]?l.jsx(ne.Loader,{className:"h-4 w-4 animate-spin"}):null,l.jsxs("span",{className:"truncate max-w-[180px]",children:[de,R[te]?" (processing)":""]})]},te)}return ie.type==="interrupt"?l.jsx(tb,{interruptPart:ie,onApprove:_e,onReject:Be},te):null},[F,R,_e,Be,$,f,h,T,G]),$e=y.useCallback(()=>l.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[l.jsx(ne.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),l.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),nt=y.useCallback(()=>{if(!(J.trim().length>0||ce.length>0||we.length>0||ke.length>0)&&!r)return $e();if(t.model==="reflection"){const te=J.trim(),pe=nd(te);if(pe&&typeof pe=="object")return l.jsx(nb,{data:pe})}if(A&&Q.name==="get_issues"){const te=t.content.find(Ne=>Ne.type==="tool_end"),pe=(te==null?void 0:te.output)??q,de=od(pe);if(de)return l.jsx(rb,{issues:de})}if(A){const te=Gw(t.content);if(te.length>0)return l.jsx("div",{className:"space-y-2",children:te.map((pe,de)=>{const Ne=typeof pe.output=="string"?pe.output:Hi(pe.output),Fe=Ne.length>Mn?`${Ne.slice(0,Mn)}
131
- … [truncated ${Ne.length-Mn} chars]`:Ne,Xe=k==="expanded";return l.jsxs(Wc,{open:Xe,onOpenChange:Ze=>C(Ze?"expanded":"preview"),children:[l.jsx("div",{className:"flex items-center gap-2 text-xs",children:l.jsx(xi,{variant:"outline",children:(pe.name??"tool")+(pe.toolCallId?` • ${pe.toolCallId.slice(0,8)}`:"")})}),l.jsx("div",{className:"font-mono text-sm mt-1",children:l.jsx("pre",{className:"whitespace-pre-wrap break-words",children:Xe?Fe:Fe.slice(0,d)+(Fe.length>d?"...":"")})}),l.jsx(Vc,{asChild:!0,children:l.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:Xe?l.jsxs(l.Fragment,{children:[" ",l.jsx(ne.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):l.jsxs(l.Fragment,{children:[l.jsx(ne.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},pe.toolCallId??de)})})}if(!A){const te=l.jsx("div",{className:"space-y-2",children:t.content.map((pe,de)=>l.jsx(qe,{part:pe,i:de},de))});return r?l.jsxs("div",{"aria-busy":"true",role:"status",children:[te,l.jsx(Zw,{className:U})]}):te}},[J,ce.length,we.length,r,t.model,A,Q.name,q,k,u,$e,U]),at=y.useMemo(()=>Jw(t),[t]);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:Z(Re(),m.container),children:l.jsxs("div",{className:Z(xe(),m.content),children:[(i||a||A)&&l.jsxs("div",{className:Z("flex items-center justify-between mb-2 pb-2 border-b border-current/10",G&&"mb-1 pb-1",U,m.header),children:[l.jsxs("div",{className:"flex items-center gap-2",children:[me(),a&&at&&l.jsx("span",{className:Z("font-medium",G?"text-xs":"text-sm"),children:at}),A&&Q.name&&l.jsxs(xi,{variant:"outline",className:Z("text-xs flex items-center gap-1 cursor-pointer",U,"border border-current/40",G&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":k!=="collapsed",onKeyDown:ie=>{(ie.key==="Enter"||ie.key===" ")&&(ie.preventDefault(),C(te=>te==="collapsed"?"preview":"collapsed"))},onClick:()=>C(ie=>ie==="collapsed"?"preview":"collapsed"),children:[l.jsx("span",{children:Q.name}),l.jsx("span",{className:"inline-flex items-center",children:k!=="collapsed"?l.jsx(ne.ChevronUp,{className:"h-3 w-3"}):l.jsx(ne.ChevronDown,{className:"h-3 w-3"})})]}),A&&!Q.name&&l.jsx(Le,{variant:"ghost",size:"sm",className:Z("h-6 px-1",U,"hover:bg-foreground/10"),onClick:()=>C(ie=>ie==="collapsed"?"preview":"collapsed"),children:l.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",k!=="collapsed"?l.jsx(ne.ChevronUp,{className:"h-3 w-3"}):l.jsx(ne.ChevronDown,{className:"h-3 w-3"})]})})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.createdAt&&l.jsx("time",{className:Z("text-xs opacity-60",U,G&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&l.jsxs("div",{className:Z("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",m.actions),children:[l.jsxs("div",{className:"relative",children:[l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>X(A?"visible":"all"),className:Z("h-6 w-6 p-0 hover:bg-foreground/10",U,G&&"h-5 w-5"),"aria-label":A?"Copy visible":"Copy message",title:A?"Copy visible portion":"Copy message",children:l.jsx(ne.Copy,{className:Z(b?"text-success":U,G?"h-3 w-3":"h-4 w-4")})}),A&&l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>X("all"),className:Z("h-6 px-1 text-xs hover:bg-foreground/10",U),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),$==="user"&&w&&l.jsx(Le,{variant:"ghost",size:"sm",onClick:ee,className:Z("h-6 w-6 p-0 hover:bg-foreground/10",U,G&&"h-5 w-5"),"aria-label":"Edit message",children:l.jsx(ne.Edit,{className:Z(U,G?"h-3 w-3":"h-4 w-4")})}),$==="assistant"&&v&&l.jsx(Le,{variant:"ghost",size:"sm",onClick:L,className:Z("h-6 w-6 p-0 hover:bg-foreground/10",U,G&&"h-5 w-5"),"aria-label":"Regenerate response",children:l.jsx(ne.RotateCcw,{className:Z(U,G?"h-3 w-3":"h-4 w-4")})})]})]})]}),l.jsx("div",{className:"relative",children:nt()}),A&&k==="expanded"&&(Q.toolCallId||Q.name)&&l.jsxs("div",{className:Z("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",G&&"text-xs"),children:[Q.name&&l.jsxs("div",{children:["Function: ",Q.name]}),Q.toolCallId&&l.jsxs("div",{children:["Call ID: ",Q.toolCallId]})]}),!(i||a||A)&&s&&!o&&l.jsxs("div",{className:Z("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",m.actions),children:[l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>X(),className:Z("h-6 w-6 p-0 hover:bg-background/50 text-current",G&&"h-5 w-5"),children:l.jsx(ne.Copy,{className:Z(b?"text-success":"text-current",G?"h-3 w-3":"h-4 w-4")})}),$==="user"&&w&&l.jsx(Le,{variant:"ghost",size:"sm",onClick:ee,className:Z("h-6 w-6 p-0 hover:bg-background/50 text-current",G&&"h-5 w-5"),children:l.jsx(ne.Edit,{className:Z("text-current",G?"h-3 w-3":"h-4 w-4")})}),$==="assistant"&&v&&l.jsx(Le,{variant:"ghost",size:"sm",onClick:L,className:Z("h-6 w-6 p-0 hover:bg-background/50 text-current",G&&"h-5 w-5"),children:l.jsx(ne.RotateCcw,{className:Z("text-current",G?"h-3 w-3":"h-4 w-4")})})]})]})}),W&&l.jsx(Vw,{isOpen:H,onClose:()=>{O(!1),K(null)},fileId:W.id,fileName:W.name,mimeType:W.mimeType})]})},(e,t)=>{var i,a,c,u,d,f,h,m;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&sd(e.message)===sd(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(w=>e[w]===t[w]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((c=e.customStyles)==null?void 0:c.content)===((u=t.customStyles)==null?void 0:u.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((h=e.customStyles)==null?void 0:h.header)===((m=t.customStyles)==null?void 0:m.header);return o&&s});function Qw({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?l.jsx("div",{className:Ko,children:l.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>l.jsx("li",{children:String(n)},r))})}):l.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Hi(e)});if(e&&typeof e=="object"){const t=Array.isArray(e.distilled_facts)?e.distilled_facts:null,n=Array.isArray(e.follow_up_queries)?e.follow_up_queries:null,r=typeof e.is_sufficient=="boolean"?e.is_sufficient:void 0;if(t||n||typeof r=="boolean")return l.jsxs("div",{className:Ko,children:[typeof r=="boolean"&&l.jsxs("p",{children:[l.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&l.jsxs("div",{children:[l.jsx("p",{children:l.jsx("strong",{children:"Follow-up queries:"})}),l.jsx("ul",{className:"list-disc pl-5",children:n.map((s,i)=>l.jsx("li",{children:String(s)},i))})]}),t&&t.length>0&&l.jsxs("div",{children:[l.jsx("p",{children:l.jsx("strong",{children:"Facts:"})}),l.jsx("ul",{className:"list-disc pl-5",children:t.map((s,i)=>l.jsx("li",{children:String(s)},i))})]})]});const o=Object.entries(e);return l.jsx("div",{className:Ko,children:l.jsx("dl",{className:"mt-0",children:o.map(([s,i])=>l.jsxs("div",{className:"mb-1",children:[l.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),l.jsx("dd",{className:"inline",children:eb(i)})]},s))})})}return l.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Hi(e)})}function eb(e){if(e==null)return String(e);const t=typeof e;if(t==="string"||t==="number"||t==="boolean")return String(e);if(Array.isArray(e)&&e.every(r=>r===null||["string","number","boolean"].includes(typeof r)))return e.join(", ");try{return l.jsx("code",{className:"text-xs",children:JSON.stringify(_r(e))})}catch{return String(e)}}function tb({interruptPart:e,onApprove:t,onReject:n}){const r=e.title??"Approve the result?";return l.jsxs(kr,{className:"border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10",children:[l.jsxs(Ir,{className:"pb-3",children:[l.jsx(Nr,{className:"text-blue-900 dark:text-blue-100 text-base",children:r}),l.jsx(Kc,{className:"text-blue-700 dark:text-blue-300",children:"Please approve or reject this action to continue."})]}),l.jsx(qc,{className:"pt-0",children:l.jsxs("div",{className:"flex gap-2 ml-auto",children:[l.jsx(Le,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",children:"Reject"}),l.jsx(Le,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",children:"Approve"})]})})]})}function nb({data:e}){return l.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>l.jsxs("div",{className:"flex",children:[l.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),l.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>l.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function rb({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return l.jsx("div",{className:Ko,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:l.jsxs("div",{className:"mb-4",children:[l.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),l.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>l.jsxs("li",{children:[l.jsx("div",{className:"font-medium",children:o.title}),l.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const ad=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Ui=y.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:c,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:m,followNewMessages:w=!0,isNavigatingCheckpoint:v=!1,onScrollAway:g,onAtBottom:x},b)=>{const S=y.useRef(null),k=y.useRef(null),C=y.useRef(!1),[T,I]=y.useState(!0),N=y.useCallback(R=>{I(R),g&&g(!R),x&&x(R)},[g,x]),_=y.useMemo(()=>{if(a)return async()=>{if(!C.current){C.current=!0;try{await a()}finally{C.current=!1}}}},[a]),j=y.useMemo(()=>!w||v?!1:T?"auto":!1,[T,w,v]);return e.length===0?l.jsx("div",{className:f,style:h,children:l.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:m||"No messages yet. Start a conversation!"})}):l.jsx("div",{className:f,style:h,children:l.jsx(Ax,{ref:R=>{S.current=R},scrollerRef:R=>{k.current=R instanceof HTMLDivElement?R:null},data:e,followOutput:j,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{_&&_()},atBottomStateChange:N,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(R,z)=>ad(z,R),itemContent:(R,z)=>{const H=ad(z,R);return l.jsx("div",{className:"mb-4 last:mb-0","data-message-id":H,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:l.jsx(id,{message:z,messageIndex:R,isStreamingMessage:t&&n===z.id,streamingDebounceMs:r,isEditing:i===z.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:c,onRegenerate:()=>u(R),onCancelEdit:d})})}})})});Ui.displayName="MessageList";const qo=1e4;function ob(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
127
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return p.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},zw="DialogDescriptionWarning",Bw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Yu(zw).contentName}}.`;return p.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Xu=Mu,Hw=Lu,Ju=Fu,Uo=zu,Wo=Bu,On=Uu,Vo=Vu,Zu=qu;const Uw=Xu,Ww=Ju,Qu=p.forwardRef(({className:e,...t},n)=>l.jsx(Uo,{ref:n,className:Z("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Qu.displayName=Uo.displayName;const ed=p.forwardRef(({className:e,children:t,...n},r)=>{const o=p.useMemo(()=>{let s=!1;function i(a){p.Children.forEach(a,c=>{if(s||!p.isValidElement(c))return;const u=c.type;if(u===On||(u==null?void 0:u.displayName)===On.displayName||(u==null?void 0:u.name)==="DialogTitle"){s=!0;return}c.props&&c.props.children&&i(c.props.children)})}return i(t),s},[t]);return l.jsxs(Ww,{children:[l.jsx(Qu,{}),l.jsxs(Wo,{ref:r,className:Z("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&l.jsx(On,{className:"sr-only",children:"Dialog"}),t,l.jsxs(Zu,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[l.jsx(te.X,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});ed.displayName=Wo.displayName;const td=({className:e,...t})=>l.jsx("div",{className:Z("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});td.displayName="DialogHeader";const nd=p.forwardRef(({className:e,...t},n)=>l.jsx(On,{ref:n,className:Z("text-lg font-semibold leading-none tracking-tight",e),...t}));nd.displayName=On.displayName;const Vw=p.forwardRef(({className:e,...t},n)=>l.jsx(Vo,{ref:n,className:Z("text-sm text-muted-foreground",e),...t}));Vw.displayName=Vo.displayName;function Kw({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=y.useState(!1),[a,c]=y.useState(null),[u,d]=y.useState(null),{toast:f}=Ii(),h=y.useCallback(async()=>{if(n){i(!0),d(null),c(null);try{const x=await cu(n);c(x)}catch(x){console.error("Failed to load file:",x),d(x instanceof Error?x.message:"Failed to load file")}finally{i(!1)}}},[n]);y.useEffect(()=>{e&&n&&h()},[e,n,h]);const m=async()=>{if(n)try{await Ev(n),f({title:"Download started",description:`Downloading ${r}`})}catch(x){console.error("Failed to download file:",x),f({title:"Download failed",description:String(x),variant:"destructive"})}},w=async()=>{if(n)try{const x=await cu(n),b=new Blob([x],{type:o}),S=URL.createObjectURL(b);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(x){console.error("Failed to open file externally:",x),f({title:"Failed to open file",description:String(x),variant:"destructive"})}},v=()=>s?l.jsxs("div",{className:"flex items-center justify-center py-12",children:[l.jsx(te.Loader,{className:"h-8 w-8 animate-spin mr-3"}),l.jsx("span",{children:"Loading file..."})]}):u?l.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[l.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),l.jsx("p",{className:"text-red-600 mb-4",children:u}),l.jsx(Fe,{onClick:h,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?l.jsx("div",{className:"flex justify-center",children:l.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?l.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:l.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?l.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:l.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):l.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[l.jsx(te.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),l.jsx("p",{className:"text-lg font-medium mb-2",children:r}),l.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),g=()=>o.startsWith("image/")?l.jsx(te.Image,{className:"h-5 w-5"}):l.jsx(te.FileText,{className:"h-5 w-5"});return l.jsx(Uw,{open:e,onOpenChange:t,children:l.jsxs(ed,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[l.jsx(td,{children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[g(),l.jsxs("div",{children:[l.jsx(nd,{className:"text-left",children:r}),l.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Fe,{variant:"outline",size:"sm",onClick:w,className:"flex items-center gap-2",children:[l.jsx(te.ExternalLink,{className:"h-4 w-4"}),"External"]}),l.jsxs(Fe,{variant:"outline",size:"sm",onClick:m,className:"flex items-center gap-2",children:[l.jsx(te.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),l.jsx("div",{className:"flex-1 overflow-hidden",children:v()})]})})}function rd(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function od(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function _r(e){if(typeof e=="string")return e.length>2e3?e.slice(0,2e3)+"... [truncated]":e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(_r).filter(r=>r!==void 0);return n.length?n:void 0}if(od(e))return;const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=_r(r);o!==void 0&&(t[n]=o)}}return Object.keys(t).length?t:void 0}return e}function Hi(e){if(typeof e=="string")return e;if(od(e))return"";try{const t=_r(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function sd(e){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){if(e.desirability||e.feasibility||e.viability||e.other)return{desirability:Array.isArray(e.desirability)?e.desirability:[],feasibility:Array.isArray(e.feasibility)?e.feasibility:[],viability:Array.isArray(e.viability)?e.viability:[],other:Array.isArray(e.other)?e.other:[]};if(e.output&&typeof e.output!="object")e=e.output;else if(e.output&&typeof e.output=="object")return sd(e.output)}const t=String(e),n={desirability:[],feasibility:[],viability:[],other:[]};let r=t;const o=Math.min(...["desirability=","feasibility=","viability=","other="].map(i=>{const a=r.toLowerCase().indexOf(i);return a===-1?Number.MAX_SAFE_INTEGER:a}));o!==Number.MAX_SAFE_INTEGER&&(r=r.slice(o));for(const i of Object.keys(n)){const c=new RegExp(i+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(r);if(!c)continue;const u=c[1],d=/Issue\(([\s\S]*?)\)(?:,|$)/g;let f=null;for(;(f=d.exec(u))!==null;){const h=f[1],m=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(h),w=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(h),v=m?m[2].trim():"",g=w?w[2].trim():"";n[i].push({title:v,description:g})}}return Object.values(n).some(i=>i.length>0)?n:null}const Ko="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words",Mn=1e5;function qw(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Gw(e){const t=e.find(r=>r.type==="tool_call"),n=e.find(r=>r.type==="tool_end");return{name:t==null?void 0:t.name,toolCallId:(n==null?void 0:n.toolCallId)??(t==null?void 0:t.id)}}function Yw(e){const t=e.filter(r=>r.type==="tool_call");return e.filter(r=>r.type==="tool_end").map(r=>{var o;return{name:(o=t.find(s=>s.id===r.toolCallId))==null?void 0:o.name,toolCallId:r.toolCallId,output:r.output}})}function Xw(e){const t=(r,o=Mn)=>{try{const s=_r(r),i=typeof s=="string"?s:JSON.stringify(s??"");return i.length<=o?i:i.slice(0,o)+`
128
+ … [truncated ${i.length-o} chars]`}catch{return""}},n=e.filter(r=>r.type==="tool_end");if(n.length)try{return n.length===1?t(n[0].output):t(n.map(r=>({toolCallId:r.toolCallId,output:r.output})))}catch{}return t(e)}function Jw(e){const t=e.find(r=>r.type==="tool_end");if(!t)return null;const n=t.output;return typeof n=="string"?n:null}function Zw(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function id(e){const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(r=>{switch(r.type){case"text":return`t:${r.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"tool_end":return"end";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function Qw({className:e}){const[t,n]=y.useState(0);return y.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),l.jsxs("span",{"aria-live":"polite",className:Z("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const ad=y.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:c="desktop",truncateToolMessages:u=!0,toolMessagePreviewLength:d=200,truncateUserMessages:f=!0,userMessagePreviewLength:h=200,customStyles:m={},onEdit:w,onRegenerate:v,onCancelEdit:g,onCopy:x}){const[b,S]=y.useState(!1),[k,C]=y.useState("collapsed"),[T,I]=y.useState(!1),{currentThreadId:N}=mr(),{handleInterrupt:_}=qs(),{toast:j}=Ii(),[R,$]=y.useState({}),[z,O]=y.useState(!1),[W,B]=y.useState(null),q=c==="phone"||c==="half-screen",L=t.role,A=L==="tool",D=!(r&&L!=="user"),H=y.useMemo(()=>{switch(L){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[L]),X=y.useMemo(()=>qw(t.content),[t.content]),Q=y.useMemo(()=>Gw(t.content),[t.content]),ue=y.useMemo(()=>t.content.filter(ie=>ie.type==="image_url"),[t.content]),we=y.useMemo(()=>t.content.filter(ie=>ie.type==="file"),[t.content]),Ie=y.useMemo(()=>t.content.filter(ie=>ie.type==="interrupt"),[t.content]),K=y.useMemo(()=>Xw(t.content),[t.content]);y.useMemo(()=>Jw(t.content),[t.content]);const M=y.useMemo(()=>K.length<=Mn?K:`${K.slice(0,Mn)}
129
+ … [truncated ${K.length-Mn} chars]`,[K]),Y=y.useCallback(async(ie="all")=>{const me=ie==="visible"&&A?M:A?K:X;async function ge(ke){try{await navigator.clipboard.writeText(ke)}catch{try{const je=document.createElement("textarea");je.value=ke,je.setAttribute("readonly",""),je.style.position="absolute",je.style.left="-9999px",document.body.appendChild(je),je.select(),document.execCommand("copy"),document.body.removeChild(je)}catch(je){throw console.error("Failed to copy:",je),je}}}try{await ge(me),S(!0),setTimeout(()=>S(!1),2e3),x==null||x(me)}catch(ke){console.error("Failed to copy:",ke)}},[A,K,X,M,x]),ee=y.useCallback(()=>{if(!w)return;const ie=A?K:X;w(t.id,ie)},[w,t.id,A,K,X]),de=y.useCallback(()=>{v==null||v(n)},[v,n]),ce=y.useCallback(async(ie,ae,me)=>{if(!D){ie.preventDefault();return}if(R[me]){ie.preventDefault();return}try{const ge=String(ae.url??""),ke=ge.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(ke){ie.preventDefault();const je=ke[1],Ke=ae.name||`file_${je}`,qe=ae.mimeType||"application/octet-stream";B({id:je,name:Ke,mimeType:qe}),O(!0);return}if(ge.startsWith("data:")){ie.preventDefault(),$(qe=>({...qe,[me]:!0}));const je=`${ae.name}_${ae.size}_${Date.now()}`,Ke=j({title:"Fetching file...",description:"",open:!0});try{const qe=await kv(N??void 0);if(!qe||!Array.isArray(qe))throw new Error("Invalid file list response");const lt=qe.find(Dt=>!Dt||typeof Dt!="object"||!((Dt.filename??"")===(ae.name??""))?!1:typeof ae.size=="number"&&typeof Dt.size=="number"?Dt.size===ae.size:!0);if(!(lt!=null&&lt.id))throw new Error(`File "${ae.name}" is not yet available on the server`);if(!lt.id||!lt.filename)throw new Error("Invalid file data received from server");B({id:lt.id,name:ae.name||lt.filename||`file_${lt.id}`,mimeType:ae.mimeType||lt.mime_type||"application/octet-stream"}),O(!0),Ke.update({id:Ke.id,title:"Success",description:`Opened ${ae.name}`,open:!0})}catch(qe){console.error("Failed to fetch server file:",qe);const lt=qe instanceof Error?qe.message:"Unknown error occurred";Ke.update({id:Ke.id,title:"Failed",description:lt}),j({title:"Failed to fetch file",description:lt,open:!0})}finally{$(qe=>({...qe,[me]:!1}))}}}catch(ge){console.error("File click error:",ge),$(ke=>({...ke,[me]:!1}))}},[D,R,j,N]),ze=y.useCallback(()=>{const ae=Z(q?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",H);switch(L){case"user":return l.jsx(te.User,{className:ae});case"assistant":return l.jsx(te.Bot,{className:ae});case"tool":return l.jsx(te.Wrench,{className:ae});default:return l.jsx(te.Bot,{className:ae})}},[q,H,L]),Ye=y.useCallback(()=>{const ie="group relative mb-4 flex w-full";switch(L){case"user":return Z(ie,"justify-end");case"assistant":case"tool":case"system":return Z(ie,"justify-start");default:return ie}},[L]),V=y.useCallback(()=>{const ie=Z("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",q&&"px-3 py-2 text-sm");switch(L){case"user":return Z(ie,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return Z(ie,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return Z(ie,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return Z(ie,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return Z(ie,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[q,L]),J=y.useCallback(async ie=>{try{const ae=ie.id||`interrupt-${Date.now()}`;await _(ae,!0)}catch(ae){console.error("Failed to approve interrupt:",ae)}},[_]),be=y.useCallback(async ie=>{try{const ae=ie.id||`interrupt-${Date.now()}`;await _(ae,!1)}catch(ae){console.error("Failed to reject interrupt:",ae)}},[_]),Oe=y.useCallback(({part:ie,i:ae})=>{if(ie.type==="text"){const me=ie.text??"",ge=me.trim(),ke=rd(ge);return ke&&L!=="tool"?l.jsx(eb,{data:ke},ae):L==="user"&&f&&ge.length>h?l.jsxs(Vc,{open:T,onOpenChange:I,children:[l.jsx("div",{className:Z("text-sm text-[hsl(var(--chat-bubble-user-text))]",q&&"text-xs"),children:T?l.jsx(Ti,{content:ge,allowHtml:!1}):l.jsxs("pre",{className:Z("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",q&&"text-xs"),children:[ge.substring(0,h),"..."]})}),l.jsx(Kc,{asChild:!0,children:l.jsx(Fe,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:T?l.jsxs(l.Fragment,{children:[l.jsx(te.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):l.jsxs(l.Fragment,{children:[l.jsx(te.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",ge.length-h," chars)"]})})})]},ae):l.jsx(Ti,{content:me,allowHtml:!1},ae)}if(ie.type==="image_url"){const me=ie;return l.jsx("div",{className:"my-2",children:l.jsx("img",{src:me.url,alt:me.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},ae)}if(ie.type==="file"){const me=ie,ge=me.name||"file";return l.jsxs("a",{href:me.url,onClick:ke=>ce(ke,me,ae),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
130
+ dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[R[ae]?l.jsx(te.Loader,{className:"h-4 w-4 animate-spin"}):null,l.jsxs("span",{className:"truncate max-w-[180px]",children:[ge,R[ae]?" (processing)":""]})]},ae)}return ie.type==="interrupt"?l.jsx(nb,{interruptPart:ie,onApprove:J,onReject:be},ae):null},[ce,R,J,be,L,f,h,T,q]),_e=y.useCallback(()=>l.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[l.jsx(te.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),l.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),et=y.useCallback(()=>{if(!(X.trim().length>0||ue.length>0||we.length>0||Ie.length>0)&&!r)return _e();if(t.model==="reflection"){const ae=X.trim(),me=rd(ae);if(me&&typeof me=="object")return l.jsx(rb,{data:me})}if(A&&Q.name==="get_issues"){const ae=t.content.find(ke=>ke.type==="tool_end"),me=(ae==null?void 0:ae.output)??K,ge=sd(me);if(ge)return l.jsx(ob,{issues:ge})}if(A){const ae=Yw(t.content);if(ae.length>0)return l.jsx("div",{className:"space-y-2",children:ae.map((me,ge)=>{const ke=typeof me.output=="string"?me.output:Hi(me.output),je=ke.length>Mn?`${ke.slice(0,Mn)}
131
+ … [truncated ${ke.length-Mn} chars]`:ke,Ke=k==="expanded";return l.jsxs(Vc,{open:Ke,onOpenChange:qe=>C(qe?"expanded":"preview"),children:[l.jsx("div",{className:"flex items-center gap-2 text-xs",children:l.jsx(xi,{variant:"outline",children:(me.name??"tool")+(me.toolCallId?` • ${me.toolCallId.slice(0,8)}`:"")})}),l.jsx("div",{className:"font-mono text-sm mt-1",children:l.jsx("pre",{className:"whitespace-pre-wrap break-words",children:Ke?je:je.slice(0,d)+(je.length>d?"...":"")})}),l.jsx(Kc,{asChild:!0,children:l.jsx(Fe,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:Ke?l.jsxs(l.Fragment,{children:[" ",l.jsx(te.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):l.jsxs(l.Fragment,{children:[l.jsx(te.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},me.toolCallId??ge)})})}if(!A){const ae=l.jsx("div",{className:"space-y-2",children:t.content.map((me,ge)=>l.jsx(Oe,{part:me,i:ge},ge))});return r?l.jsxs("div",{"aria-busy":"true",role:"status",children:[ae,l.jsx(Qw,{className:H})]}):ae}},[X,ue.length,we.length,r,t.model,A,Q.name,K,k,u,_e,H]),st=y.useMemo(()=>Zw(t),[t]);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:Z(Ye(),m.container),children:l.jsxs("div",{className:Z(V(),m.content),children:[(i||a||A)&&l.jsxs("div",{className:Z("flex items-center justify-between mb-2 pb-2 border-b border-current/10",q&&"mb-1 pb-1",H,m.header),children:[l.jsxs("div",{className:"flex items-center gap-2",children:[ze(),a&&st&&l.jsx("span",{className:Z("font-medium",q?"text-xs":"text-sm"),children:st}),A&&Q.name&&l.jsxs(xi,{variant:"outline",className:Z("text-xs flex items-center gap-1 cursor-pointer",H,"border border-current/40",q&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":k!=="collapsed",onKeyDown:ie=>{(ie.key==="Enter"||ie.key===" ")&&(ie.preventDefault(),C(ae=>ae==="collapsed"?"preview":"collapsed"))},onClick:()=>C(ie=>ie==="collapsed"?"preview":"collapsed"),children:[l.jsx("span",{children:Q.name}),l.jsx("span",{className:"inline-flex items-center",children:k!=="collapsed"?l.jsx(te.ChevronUp,{className:"h-3 w-3"}):l.jsx(te.ChevronDown,{className:"h-3 w-3"})})]}),A&&!Q.name&&l.jsx(Fe,{variant:"ghost",size:"sm",className:Z("h-6 px-1",H,"hover:bg-foreground/10"),onClick:()=>C(ie=>ie==="collapsed"?"preview":"collapsed"),children:l.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",k!=="collapsed"?l.jsx(te.ChevronUp,{className:"h-3 w-3"}):l.jsx(te.ChevronDown,{className:"h-3 w-3"})]})})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.createdAt&&l.jsx("time",{className:Z("text-xs opacity-60",H,q&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&l.jsxs("div",{className:Z("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",m.actions),children:[l.jsxs("div",{className:"relative",children:[l.jsx(Fe,{variant:"ghost",size:"sm",onClick:()=>Y(A?"visible":"all"),className:Z("h-6 w-6 p-0 hover:bg-foreground/10",H,q&&"h-5 w-5"),"aria-label":A?"Copy visible":"Copy message",title:A?"Copy visible portion":"Copy message",children:l.jsx(te.Copy,{className:Z(b?"text-success":H,q?"h-3 w-3":"h-4 w-4")})}),A&&l.jsx(Fe,{variant:"ghost",size:"sm",onClick:()=>Y("all"),className:Z("h-6 px-1 text-xs hover:bg-foreground/10",H),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),L==="user"&&w&&l.jsx(Fe,{variant:"ghost",size:"sm",onClick:ee,className:Z("h-6 w-6 p-0 hover:bg-foreground/10",H,q&&"h-5 w-5"),"aria-label":"Edit message",children:l.jsx(te.Edit,{className:Z(H,q?"h-3 w-3":"h-4 w-4")})}),L==="assistant"&&v&&l.jsx(Fe,{variant:"ghost",size:"sm",onClick:de,className:Z("h-6 w-6 p-0 hover:bg-foreground/10",H,q&&"h-5 w-5"),"aria-label":"Regenerate response",children:l.jsx(te.RotateCcw,{className:Z(H,q?"h-3 w-3":"h-4 w-4")})})]})]})]}),l.jsx("div",{className:"relative",children:et()}),A&&k==="expanded"&&(Q.toolCallId||Q.name)&&l.jsxs("div",{className:Z("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",q&&"text-xs"),children:[Q.name&&l.jsxs("div",{children:["Function: ",Q.name]}),Q.toolCallId&&l.jsxs("div",{children:["Call ID: ",Q.toolCallId]})]}),!(i||a||A)&&s&&!o&&l.jsxs("div",{className:Z("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",m.actions),children:[l.jsx(Fe,{variant:"ghost",size:"sm",onClick:()=>Y(),className:Z("h-6 w-6 p-0 hover:bg-background/50 text-current",q&&"h-5 w-5"),children:l.jsx(te.Copy,{className:Z(b?"text-success":"text-current",q?"h-3 w-3":"h-4 w-4")})}),L==="user"&&w&&l.jsx(Fe,{variant:"ghost",size:"sm",onClick:ee,className:Z("h-6 w-6 p-0 hover:bg-background/50 text-current",q&&"h-5 w-5"),children:l.jsx(te.Edit,{className:Z("text-current",q?"h-3 w-3":"h-4 w-4")})}),L==="assistant"&&v&&l.jsx(Fe,{variant:"ghost",size:"sm",onClick:de,className:Z("h-6 w-6 p-0 hover:bg-background/50 text-current",q&&"h-5 w-5"),children:l.jsx(te.RotateCcw,{className:Z("text-current",q?"h-3 w-3":"h-4 w-4")})})]})]})}),W&&l.jsx(Kw,{isOpen:z,onClose:()=>{O(!1),B(null)},fileId:W.id,fileName:W.name,mimeType:W.mimeType})]})},(e,t)=>{var i,a,c,u,d,f,h,m;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&id(e.message)===id(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(w=>e[w]===t[w]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((c=e.customStyles)==null?void 0:c.content)===((u=t.customStyles)==null?void 0:u.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((h=e.customStyles)==null?void 0:h.header)===((m=t.customStyles)==null?void 0:m.header);return o&&s});function eb({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?l.jsx("div",{className:Ko,children:l.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>l.jsx("li",{children:String(n)},r))})}):l.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Hi(e)});if(e&&typeof e=="object"){const t=Array.isArray(e.distilled_facts)?e.distilled_facts:null,n=Array.isArray(e.follow_up_queries)?e.follow_up_queries:null,r=typeof e.is_sufficient=="boolean"?e.is_sufficient:void 0;if(t||n||typeof r=="boolean")return l.jsxs("div",{className:Ko,children:[typeof r=="boolean"&&l.jsxs("p",{children:[l.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&l.jsxs("div",{children:[l.jsx("p",{children:l.jsx("strong",{children:"Follow-up queries:"})}),l.jsx("ul",{className:"list-disc pl-5",children:n.map((s,i)=>l.jsx("li",{children:String(s)},i))})]}),t&&t.length>0&&l.jsxs("div",{children:[l.jsx("p",{children:l.jsx("strong",{children:"Facts:"})}),l.jsx("ul",{className:"list-disc pl-5",children:t.map((s,i)=>l.jsx("li",{children:String(s)},i))})]})]});const o=Object.entries(e);return l.jsx("div",{className:Ko,children:l.jsx("dl",{className:"mt-0",children:o.map(([s,i])=>l.jsxs("div",{className:"mb-1",children:[l.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),l.jsx("dd",{className:"inline",children:tb(i)})]},s))})})}return l.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Hi(e)})}function tb(e){if(e==null)return String(e);const t=typeof e;if(t==="string"||t==="number"||t==="boolean")return String(e);if(Array.isArray(e)&&e.every(r=>r===null||["string","number","boolean"].includes(typeof r)))return e.join(", ");try{return l.jsx("code",{className:"text-xs",children:JSON.stringify(_r(e))})}catch{return String(e)}}function nb({interruptPart:e,onApprove:t,onReject:n}){const r=e.title??"Approve the result?";return l.jsxs(kr,{className:"border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10",children:[l.jsxs(Ir,{className:"pb-3",children:[l.jsx(Nr,{className:"text-blue-900 dark:text-blue-100 text-base",children:r}),l.jsx(qc,{className:"text-blue-700 dark:text-blue-300",children:"Please approve or reject this action to continue."})]}),l.jsx(Gc,{className:"pt-0",children:l.jsxs("div",{className:"flex gap-2 ml-auto",children:[l.jsx(Fe,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",children:"Reject"}),l.jsx(Fe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",children:"Approve"})]})})]})}function rb({data:e}){return l.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>l.jsxs("div",{className:"flex",children:[l.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),l.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>l.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function ob({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return l.jsx("div",{className:Ko,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:l.jsxs("div",{className:"mb-4",children:[l.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),l.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>l.jsxs("li",{children:[l.jsx("div",{className:"font-medium",children:o.title}),l.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const ld=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Ui=y.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:c,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:m,followNewMessages:w=!0,isNavigatingCheckpoint:v=!1,onScrollAway:g,onAtBottom:x},b)=>{const S=y.useRef(null),k=y.useRef(null),C=y.useRef(!1),[T,I]=y.useState(!0),N=y.useCallback(R=>{I(R),g&&g(!R),x&&x(R)},[g,x]),_=y.useMemo(()=>{if(a)return async()=>{if(!C.current){C.current=!0;try{await a()}finally{C.current=!1}}}},[a]),j=y.useMemo(()=>!w||v?!1:T?"auto":!1,[T,w,v]);return e.length===0?l.jsx("div",{className:f,style:h,children:l.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:m||"No messages yet. Start a conversation!"})}):l.jsx("div",{className:f,style:h,children:l.jsx(_x,{ref:R=>{S.current=R},scrollerRef:R=>{k.current=R instanceof HTMLDivElement?R:null},data:e,followOutput:j,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{_&&_()},atBottomStateChange:N,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(R,$)=>ld($,R),itemContent:(R,$)=>{const z=ld($,R);return l.jsx("div",{className:"mb-4 last:mb-0","data-message-id":z,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:l.jsx(ad,{message:$,messageIndex:R,isStreamingMessage:t&&n===$.id,streamingDebounceMs:r,isEditing:i===$.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:c,onRegenerate:()=>u(R),onCancelEdit:d})})}})})});Ui.displayName="MessageList";const qo=1e4;function sb(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
132
132
  `).replace(/<p>(.*?)<\/p>/gi,`$1
133
133
 
134
134
  `).replace(/<h([1-6])>(.*?)<\/h[1-6]>/gi,(o,s,i)=>`${"#".repeat(parseInt(s))} ${i}
@@ -136,4 +136,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
136
136
  `).replace(/<ul>/gi,"").replace(/<\/ul>/gi,`
137
137
  `).replace(/<ol>/gi,"").replace(/<\/ol>/gi,`
138
138
  `).replace(/<li>(.*?)<\/li>/gi,`- $1
139
- `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function sb(e,t=qo){if(!e||typeof e!="string")throw new Error("Invalid content: must be a non-empty string");if(e.length>t)throw new Error(`Message exceeds maximum length of ${t} characters`);return e}function ib(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),sb(t),ob(t)}function Wi(e){const t=e+"CollectionProvider",[n,r]=Yt(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=v=>{const{scope:g,children:x}=v,b=y.useRef(null),S=y.useRef(new Map).current;return l.jsx(o,{scope:g,itemMap:S,collectionRef:b,children:x})};i.displayName=t;const a=e+"CollectionSlot",c=Cn.createSlot(a),u=y.forwardRef((v,g)=>{const{scope:x,children:b}=v,S=s(a,x),k=je(g,S.collectionRef);return l.jsx(c,{ref:k,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=Cn.createSlot(d),m=y.forwardRef((v,g)=>{const{scope:x,children:b,...S}=v,k=y.useRef(null),C=je(g,k),T=s(d,x);return y.useEffect(()=>(T.itemMap.set(k,{ref:k,...S}),()=>void T.itemMap.delete(k))),l.jsx(h,{[f]:"",ref:C,children:b})});m.displayName=d;function w(v){const g=s(e+"CollectionConsumer",v);return y.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const S=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((T,I)=>S.indexOf(T.ref.current)-S.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:m},w,r]}var ab=p.createContext(void 0);function Go(e){const t=p.useContext(ab);return e||t||"ltr"}const lb=["top","right","bottom","left"],xn=Math.min,It=Math.max,Yo=Math.round,Xo=Math.floor,Zt=e=>({x:e,y:e}),cb={left:"right",right:"left",bottom:"top",top:"bottom"},ub={start:"end",end:"start"};function Vi(e,t,n){return It(e,xn(t,n))}function sn(e,t){return typeof e=="function"?e(t):e}function an(e){return e.split("-")[0]}function Qn(e){return e.split("-")[1]}function Ki(e){return e==="x"?"y":"x"}function qi(e){return e==="y"?"height":"width"}const db=new Set(["top","bottom"]);function Qt(e){return db.has(an(e))?"y":"x"}function Gi(e){return Ki(Qt(e))}function fb(e,t,n){n===void 0&&(n=!1);const r=Qn(e),o=Gi(e),s=qi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Jo(i)),[i,Jo(i)]}function hb(e){const t=Jo(e);return[Yi(e),t,Yi(t)]}function Yi(e){return e.replace(/start|end/g,t=>ub[t])}const ld=["left","right"],cd=["right","left"],pb=["top","bottom"],mb=["bottom","top"];function gb(e,t,n){switch(e){case"top":case"bottom":return n?t?cd:ld:t?ld:cd;case"left":case"right":return t?pb:mb;default:return[]}}function xb(e,t,n,r){const o=Qn(e);let s=gb(an(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Yi)))),s}function Jo(e){return e.replace(/left|right|bottom|top/g,t=>cb[t])}function vb(e){return{top:0,right:0,bottom:0,left:0,...e}}function ud(e){return typeof e!="number"?vb(e):{top:e,right:e,bottom:e,left:e}}function Zo(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function dd(e,t,n){let{reference:r,floating:o}=e;const s=Qt(t),i=Gi(t),a=qi(i),c=an(t),u=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let m;switch(c){case"top":m={x:d,y:r.y-o.height};break;case"bottom":m={x:d,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-o.width,y:f};break;default:m={x:r.x,y:r.y}}switch(Qn(t)){case"start":m[i]-=h*(n&&u?-1:1);break;case"end":m[i]+=h*(n&&u?-1:1);break}return m}const wb=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=dd(u,r,c),h=r,m={},w=0;for(let v=0;v<a.length;v++){const{name:g,fn:x}=a[v],{x:b,y:S,data:k,reset:C}=await x({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:m,rects:u,platform:i,elements:{reference:e,floating:t}});d=b??d,f=S??f,m={...m,[g]:{...m[g],...k}},C&&w<=50&&(w++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=dd(u,h,c)),v=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:m}};async function jr(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:m=0}=sn(t,e),w=ud(m),g=a[h?f==="floating"?"reference":"floating":f],x=Zo(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:c})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=Zo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:c}):b);return{top:(x.top-C.top+w.top)/k.y,bottom:(C.bottom-x.bottom+w.bottom)/k.y,left:(x.left-C.left+w.left)/k.x,right:(C.right-x.right+w.right)/k.x}}const bb=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:c}=t,{element:u,padding:d=0}=sn(e,t)||{};if(u==null)return{};const f=ud(d),h={x:n,y:r},m=Gi(o),w=qi(m),v=await i.getDimensions(u),g=m==="y",x=g?"top":"left",b=g?"bottom":"right",S=g?"clientHeight":"clientWidth",k=s.reference[w]+s.reference[m]-h[m]-s.floating[w],C=h[m]-s.reference[m],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let I=T?T[S]:0;(!I||!await(i.isElement==null?void 0:i.isElement(T)))&&(I=a.floating[S]||s.floating[w]);const N=k/2-C/2,_=I/2-v[w]/2-1,j=xn(f[x],_),R=xn(f[b],_),z=j,H=I-v[w]-R,O=I/2-v[w]/2+N,W=Vi(z,O,H),K=!c.arrow&&Qn(o)!=null&&O!==W&&s.reference[w]/2-(O<z?j:R)-v[w]/2<0,G=K?O<z?O-z:O-H:0;return{[m]:h[m]+G,data:{[m]:W,centerOffset:O-W-G,...K&&{alignmentOffset:G}},reset:K}}}),yb=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:c,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:v=!0,...g}=sn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=an(o),b=Qt(a),S=an(a)===a,k=await(c.isRTL==null?void 0:c.isRTL(u.floating)),C=h||(S||!v?[Jo(a)]:hb(a)),T=w!=="none";!h&&T&&C.push(...xb(a,v,w,k));const I=[a,...C],N=await jr(t,g),_=[];let j=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&_.push(N[x]),f){const O=fb(o,i,k);_.push(N[O[0]],N[O[1]])}if(j=[...j,{placement:o,overflows:_}],!_.every(O=>O<=0)){var R,z;const O=(((R=s.flip)==null?void 0:R.index)||0)+1,W=I[O];if(W&&(!(f==="alignment"?b!==Qt(W):!1)||j.every($=>Qt($.placement)===b?$.overflows[0]>0:!0)))return{data:{index:O,overflows:j},reset:{placement:W}};let K=(z=j.filter(G=>G.overflows[0]<=0).sort((G,$)=>G.overflows[1]-$.overflows[1])[0])==null?void 0:z.placement;if(!K)switch(m){case"bestFit":{var H;const G=(H=j.filter($=>{if(T){const A=Qt($.placement);return A===b||A==="y"}return!0}).map($=>[$.placement,$.overflows.filter(A=>A>0).reduce((A,D)=>A+D,0)]).sort(($,A)=>$[1]-A[1])[0])==null?void 0:H[0];G&&(K=G);break}case"initialPlacement":K=a;break}if(o!==K)return{reset:{placement:K}}}return{}}}};function fd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function hd(e){return lb.some(t=>e[t]>=0)}const Sb=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=sn(e,t);switch(r){case"referenceHidden":{const s=await jr(t,{...o,elementContext:"reference"}),i=fd(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:hd(i)}}}case"escaped":{const s=await jr(t,{...o,altBoundary:!0}),i=fd(s,n.floating);return{data:{escapedOffsets:i,escaped:hd(i)}}}default:return{}}}}},pd=new Set(["left","top"]);async function Cb(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=an(n),a=Qn(n),c=Qt(n)==="y",u=pd.has(i)?-1:1,d=s&&c?-1:1,f=sn(t,e);let{mainAxis:h,crossAxis:m,alignmentAxis:w}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof w=="number"&&(m=a==="end"?w*-1:w),c?{x:m*d,y:h*u}:{x:h*u,y:m*d}}const Tb=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,c=await Cb(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:i}}}}},Eb=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x,y:b}=g;return{x,y:b}}},...c}=sn(e,t),u={x:n,y:r},d=await jr(t,c),f=Qt(an(o)),h=Ki(f);let m=u[h],w=u[f];if(s){const g=h==="y"?"top":"left",x=h==="y"?"bottom":"right",b=m+d[g],S=m-d[x];m=Vi(b,m,S)}if(i){const g=f==="y"?"top":"left",x=f==="y"?"bottom":"right",b=w+d[g],S=w-d[x];w=Vi(b,w,S)}const v=a.fn({...t,[h]:m,[f]:w});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[h]:s,[f]:i}}}}}},kb=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:c=!0,crossAxis:u=!0}=sn(e,t),d={x:n,y:r},f=Qt(o),h=Ki(f);let m=d[h],w=d[f];const v=sn(a,t),g=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(c){const S=h==="y"?"height":"width",k=s.reference[h]-s.floating[S]+g.mainAxis,C=s.reference[h]+s.reference[S]-g.mainAxis;m<k?m=k:m>C&&(m=C)}if(u){var x,b;const S=h==="y"?"width":"height",k=pd.has(an(o)),C=s.reference[f]-s.floating[S]+(k&&((x=i.offset)==null?void 0:x[f])||0)+(k?0:g.crossAxis),T=s.reference[f]+s.reference[S]+(k?0:((b=i.offset)==null?void 0:b[f])||0)-(k?g.crossAxis:0);w<C?w=C:w>T&&(w=T)}return{[h]:m,[f]:w}}}},Ib=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:c=()=>{},...u}=sn(e,t),d=await jr(t,u),f=an(o),h=Qn(o),m=Qt(o)==="y",{width:w,height:v}=s.floating;let g,x;f==="top"||f==="bottom"?(g=f,x=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=f,g=h==="end"?"top":"bottom");const b=v-d.top-d.bottom,S=w-d.left-d.right,k=xn(v-d[g],b),C=xn(w-d[x],S),T=!t.middlewareData.shift;let I=k,N=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=b),T&&!h){const j=It(d.left,0),R=It(d.right,0),z=It(d.top,0),H=It(d.bottom,0);m?N=w-2*(j!==0||R!==0?j+R:It(d.left,d.right)):I=v-2*(z!==0||H!==0?z+H:It(d.top,d.bottom))}await c({...t,availableWidth:N,availableHeight:I});const _=await i.getDimensions(a.floating);return w!==_.width||v!==_.height?{reset:{rects:!0}}:{}}}};function Qo(){return typeof window<"u"}function er(e){return md(e)?(e.nodeName||"").toLowerCase():"#document"}function Nt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function en(e){var t;return(t=(md(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function md(e){return Qo()?e instanceof Node||e instanceof Nt(e).Node:!1}function Ht(e){return Qo()?e instanceof Element||e instanceof Nt(e).Element:!1}function tn(e){return Qo()?e instanceof HTMLElement||e instanceof Nt(e).HTMLElement:!1}function gd(e){return!Qo()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Nt(e).ShadowRoot}const Nb=new Set(["inline","contents"]);function Rr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Ut(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Nb.has(o)}const Ab=new Set(["table","td","th"]);function _b(e){return Ab.has(er(e))}const jb=[":popover-open",":modal"];function es(e){return jb.some(t=>{try{return e.matches(t)}catch{return!1}})}const Rb=["transform","translate","scale","rotate","perspective"],Pb=["transform","translate","scale","rotate","perspective","filter"],Ob=["paint","layout","strict","content"];function Xi(e){const t=Ji(),n=Ht(e)?Ut(e):e;return Rb.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||Pb.some(r=>(n.willChange||"").includes(r))||Ob.some(r=>(n.contain||"").includes(r))}function Mb(e){let t=vn(e);for(;tn(t)&&!tr(t);){if(Xi(t))return t;if(es(t))return null;t=vn(t)}return null}function Ji(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Db=new Set(["html","body","#document"]);function tr(e){return Db.has(er(e))}function Ut(e){return Nt(e).getComputedStyle(e)}function ts(e){return Ht(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function vn(e){if(er(e)==="html")return e;const t=e.assignedSlot||e.parentNode||gd(e)&&e.host||en(e);return gd(t)?t.host:t}function xd(e){const t=vn(e);return tr(t)?e.ownerDocument?e.ownerDocument.body:e.body:tn(t)&&Rr(t)?t:xd(t)}function Pr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=xd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Nt(o);if(s){const a=Zi(i);return t.concat(i,i.visualViewport||[],Rr(o)?o:[],a&&n?Pr(a):[])}return t.concat(o,Pr(o,[],n))}function Zi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function vd(e){const t=Ut(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=tn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Yo(n)!==s||Yo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Qi(e){return Ht(e)?e:e.contextElement}function nr(e){const t=Qi(e);if(!tn(t))return Zt(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=vd(t);let i=(s?Yo(n.width):n.width)/r,a=(s?Yo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Lb=Zt(0);function wd(e){const t=Nt(e);return!Ji()||!t.visualViewport?Lb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function $b(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Nt(e)?!1:t}function Dn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Qi(e);let i=Zt(1);t&&(r?Ht(r)&&(i=nr(r)):i=nr(e));const a=$b(s,n,r)?wd(s):Zt(0);let c=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=Nt(s),m=r&&Ht(r)?Nt(r):r;let w=h,v=Zi(w);for(;v&&r&&m!==w;){const g=nr(v),x=v.getBoundingClientRect(),b=Ut(v),S=x.left+(v.clientLeft+parseFloat(b.paddingLeft))*g.x,k=x.top+(v.clientTop+parseFloat(b.paddingTop))*g.y;c*=g.x,u*=g.y,d*=g.x,f*=g.y,c+=S,u+=k,w=Nt(v),v=Zi(w)}}return Zo({width:d,height:f,x:c,y:u})}function ea(e,t){const n=ts(e).scrollLeft;return t?t.left+n:Dn(en(e)).left+n}function bd(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:ea(e,r)),s=r.top+t.scrollTop;return{x:o,y:s}}function Fb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=en(r),a=t?es(t.floating):!1;if(r===i||a&&s)return n;let c={scrollLeft:0,scrollTop:0},u=Zt(1);const d=Zt(0),f=tn(r);if((f||!f&&!s)&&((er(r)!=="body"||Rr(i))&&(c=ts(r)),tn(r))){const m=Dn(r);u=nr(r),d.x=m.x+r.clientLeft,d.y=m.y+r.clientTop}const h=i&&!f&&!s?bd(i,c,!0):Zt(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-c.scrollTop*u.y+d.y+h.y}}function zb(e){return Array.from(e.getClientRects())}function Bb(e){const t=en(e),n=ts(e),r=e.ownerDocument.body,o=It(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=It(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ea(e);const a=-n.scrollTop;return Ut(r).direction==="rtl"&&(i+=It(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function Hb(e,t){const n=Nt(e),r=en(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,c=0;if(o){s=o.width,i=o.height;const u=Ji();(!u||u&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}return{width:s,height:i,x:a,y:c}}const Ub=new Set(["absolute","fixed"]);function Wb(e,t){const n=Dn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=tn(e)?nr(e):Zt(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,c=o*s.x,u=r*s.y;return{width:i,height:a,x:c,y:u}}function yd(e,t,n){let r;if(t==="viewport")r=Hb(e,n);else if(t==="document")r=Bb(en(e));else if(Ht(t))r=Wb(t,n);else{const o=wd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Zo(r)}function Sd(e,t){const n=vn(e);return n===t||!Ht(n)||tr(n)?!1:Ut(n).position==="fixed"||Sd(n,t)}function Vb(e,t){const n=t.get(e);if(n)return n;let r=Pr(e,[],!1).filter(a=>Ht(a)&&er(a)!=="body"),o=null;const s=Ut(e).position==="fixed";let i=s?vn(e):e;for(;Ht(i)&&!tr(i);){const a=Ut(i),c=Xi(i);!c&&a.position==="fixed"&&(o=null),(s?!c&&!o:!c&&a.position==="static"&&!!o&&Ub.has(o.position)||Rr(i)&&!c&&Sd(e,i))?r=r.filter(d=>d!==i):o=a,i=vn(i)}return t.set(e,r),r}function Kb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?es(t)?[]:Vb(t,this._c):[].concat(n),r],a=i[0],c=i.reduce((u,d)=>{const f=yd(t,d,o);return u.top=It(f.top,u.top),u.right=xn(f.right,u.right),u.bottom=xn(f.bottom,u.bottom),u.left=It(f.left,u.left),u},yd(t,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function qb(e){const{width:t,height:n}=vd(e);return{width:t,height:n}}function Gb(e,t,n){const r=tn(t),o=en(t),s=n==="fixed",i=Dn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const c=Zt(0);function u(){c.x=ea(o)}if(r||!r&&!s)if((er(t)!=="body"||Rr(o))&&(a=ts(t)),r){const m=Dn(t,!0,s,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?bd(o,a):Zt(0),f=i.left+a.scrollLeft-c.x-d.x,h=i.top+a.scrollTop-c.y-d.y;return{x:f,y:h,width:i.width,height:i.height}}function ta(e){return Ut(e).position==="static"}function Cd(e,t){if(!tn(e)||Ut(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return en(e)===n&&(n=n.ownerDocument.body),n}function Td(e,t){const n=Nt(e);if(es(e))return n;if(!tn(e)){let o=vn(e);for(;o&&!tr(o);){if(Ht(o)&&!ta(o))return o;o=vn(o)}return n}let r=Cd(e,t);for(;r&&_b(r)&&ta(r);)r=Cd(r,t);return r&&tr(r)&&ta(r)&&!Xi(r)?n:r||Mb(e)||n}const Yb=async function(e){const t=this.getOffsetParent||Td,n=this.getDimensions,r=await n(e.floating);return{reference:Gb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Xb(e){return Ut(e).direction==="rtl"}const Jb={convertOffsetParentRelativeRectToViewportRelativeRect:Fb,getDocumentElement:en,getClippingRect:Kb,getOffsetParent:Td,getElementRects:Yb,getClientRects:zb,getDimensions:qb,getScale:nr,isElement:Ht,isRTL:Xb};function Ed(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Zb(e,t){let n=null,r;const o=en(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:m}=u;if(a||t(),!h||!m)return;const w=Xo(f),v=Xo(o.clientWidth-(d+h)),g=Xo(o.clientHeight-(f+m)),x=Xo(d),S={rootMargin:-w+"px "+-v+"px "+-g+"px "+-x+"px",threshold:It(0,xn(1,c))||1};let k=!0;function C(T){const I=T[0].intersectionRatio;if(I!==c){if(!k)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!Ed(u,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function Qb(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=Qi(e),d=o||s?[...u?Pr(u):[],...Pr(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const f=u&&a?Zb(u,n):null;let h=-1,m=null;i&&(m=new ResizeObserver(x=>{let[b]=x;b&&b.target===u&&m&&(m.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=m)==null||S.observe(t)})),n()}),u&&!c&&m.observe(u),m.observe(t));let w,v=c?Dn(e):null;c&&g();function g(){const x=Dn(e);v&&!Ed(v,x)&&n(),v=x,w=requestAnimationFrame(g)}return n(),()=>{var x;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(x=m)==null||x.disconnect(),m=null,c&&cancelAnimationFrame(w)}}const ey=Tb,ty=Eb,ny=yb,ry=Ib,oy=Sb,kd=bb,sy=kb,iy=(e,t,n)=>{const r=new Map,o={platform:Jb,...n},s={...o.platform,_c:r};return wb(e,t,{...o,platform:s})};var ay=typeof document<"u",ly=function(){},ns=ay?y.useLayoutEffect:ly;function rs(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!rs(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!rs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Id(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Nd(e,t){const n=Id(e);return Math.round(t*n)/n}function na(e){const t=p.useRef(e);return ns(()=>{t.current=e}),t}function cy(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:c,open:u}=e,[d,f]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,m]=p.useState(r);rs(h,r)||m(r);const[w,v]=p.useState(null),[g,x]=p.useState(null),b=p.useCallback($=>{$!==T.current&&(T.current=$,v($))},[]),S=p.useCallback($=>{$!==I.current&&(I.current=$,x($))},[]),k=s||w,C=i||g,T=p.useRef(null),I=p.useRef(null),N=p.useRef(d),_=c!=null,j=na(c),R=na(o),z=na(u),H=p.useCallback(()=>{if(!T.current||!I.current)return;const $={placement:t,strategy:n,middleware:h};R.current&&($.platform=R.current),iy(T.current,I.current,$).then(A=>{const D={...A,isPositioned:z.current!==!1};O.current&&!rs(N.current,D)&&(N.current=D,qr.flushSync(()=>{f(D)}))})},[h,t,n,R,z]);ns(()=>{u===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,f($=>({...$,isPositioned:!1})))},[u]);const O=p.useRef(!1);ns(()=>(O.current=!0,()=>{O.current=!1}),[]),ns(()=>{if(k&&(T.current=k),C&&(I.current=C),k&&C){if(j.current)return j.current(k,C,H);H()}},[k,C,H,j,_]);const W=p.useMemo(()=>({reference:T,floating:I,setReference:b,setFloating:S}),[b,S]),K=p.useMemo(()=>({reference:k,floating:C}),[k,C]),G=p.useMemo(()=>{const $={position:n,left:0,top:0};if(!K.floating)return $;const A=Nd(K.floating,d.x),D=Nd(K.floating,d.y);return a?{...$,transform:"translate("+A+"px, "+D+"px)",...Id(K.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:A,top:D}},[n,a,K.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:H,refs:W,elements:K,floatingStyles:G}),[d,H,W,K,G])}const uy=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?kd({element:r.current,padding:o}).fn(n):{}:r?kd({element:r,padding:o}).fn(n):{}}}},dy=(e,t)=>({...ey(e),options:[e,t]}),fy=(e,t)=>({...ty(e),options:[e,t]}),hy=(e,t)=>({...sy(e),options:[e,t]}),py=(e,t)=>({...ny(e),options:[e,t]}),my=(e,t)=>({...ry(e),options:[e,t]}),gy=(e,t)=>({...oy(e),options:[e,t]}),xy=(e,t)=>({...uy(e),options:[e,t]});var vy="Arrow",Ad=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return l.jsx(ye.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:l.jsx("polygon",{points:"0,0 30,0 15,10"})})});Ad.displayName=vy;var wy=Ad;function _d(e){const[t,n]=p.useState(void 0);return ct(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const c=s.borderBoxSize,u=Array.isArray(c)?c[0]:c;i=u.inlineSize,a=u.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var ra="Popper",[jd,os]=Yt(ra),[by,Rd]=jd(ra),Pd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return l.jsx(by,{scope:t,anchor:r,onAnchorChange:o,children:n})};Pd.displayName=ra;var Od="PopperAnchor",Md=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Rd(Od,n),i=p.useRef(null),a=je(t,i),c=p.useRef(null);return p.useEffect(()=>{const u=c.current;c.current=(r==null?void 0:r.current)||i.current,u!==c.current&&s.onAnchorChange(c.current)}),r?null:l.jsx(ye.div,{...o,ref:a})});Md.displayName=Od;var oa="PopperContent",[yy,Sy]=jd(oa),Dd=p.forwardRef((e,t)=>{var q,M,X,ee,L,F;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:m="optimized",onPlaced:w,...v}=e,g=Rd(oa,n),[x,b]=p.useState(null),S=je(t,me=>b(me)),[k,C]=p.useState(null),T=_d(k),I=(T==null?void 0:T.width)??0,N=(T==null?void 0:T.height)??0,_=r+(s!=="center"?"-"+s:""),j=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},R=Array.isArray(u)?u:[u],z=R.length>0,H={padding:j,boundary:R.filter(Ty),altBoundary:z},{refs:O,floatingStyles:W,placement:K,isPositioned:G,middlewareData:$}=cy({strategy:"fixed",placement:_,whileElementsMounted:(...me)=>Qb(...me,{animationFrame:m==="always"}),elements:{reference:g.anchor},middleware:[dy({mainAxis:o+N,alignmentAxis:i}),c&&fy({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?hy():void 0,...H}),c&&py({...H}),my({...H,apply:({elements:me,rects:Re,availableWidth:xe,availableHeight:_e})=>{const{width:Be,height:qe}=Re.reference,$e=me.floating.style;$e.setProperty("--radix-popper-available-width",`${xe}px`),$e.setProperty("--radix-popper-available-height",`${_e}px`),$e.setProperty("--radix-popper-anchor-width",`${Be}px`),$e.setProperty("--radix-popper-anchor-height",`${qe}px`)}}),k&&xy({element:k,padding:a}),Ey({arrowWidth:I,arrowHeight:N}),h&&gy({strategy:"referenceHidden",...H})]}),[A,D]=Fd(K),U=ut(w);ct(()=>{G&&(U==null||U())},[G,U]);const J=(q=$.arrow)==null?void 0:q.x,Q=(M=$.arrow)==null?void 0:M.y,ce=((X=$.arrow)==null?void 0:X.centerOffset)!==0,[we,ke]=p.useState();return ct(()=>{x&&ke(window.getComputedStyle(x).zIndex)},[x]),l.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:G?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:we,"--radix-popper-transform-origin":[(ee=$.transformOrigin)==null?void 0:ee.x,(L=$.transformOrigin)==null?void 0:L.y].join(" "),...((F=$.hide)==null?void 0:F.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:l.jsx(yy,{scope:n,placedSide:A,onArrowChange:C,arrowX:J,arrowY:Q,shouldHideArrow:ce,children:l.jsx(ye.div,{"data-side":A,"data-align":D,...v,ref:S,style:{...v.style,animation:G?void 0:"none"}})})})});Dd.displayName=oa;var Ld="PopperArrow",Cy={top:"bottom",right:"left",bottom:"top",left:"right"},$d=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Sy(Ld,r),i=Cy[s.placedSide];return l.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:l.jsx(wy,{...o,ref:n,style:{...o.style,display:"block"}})})});$d.displayName=Ld;function Ty(e){return e!==null}var Ey=e=>({name:"transformOrigin",options:e,fn(t){var g,x,b;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,d]=Fd(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((x=o.arrow)==null?void 0:x.x)??0)+a/2,m=(((b=o.arrow)==null?void 0:b.y)??0)+c/2;let w="",v="";return u==="bottom"?(w=i?f:`${h}px`,v=`${-c}px`):u==="top"?(w=i?f:`${h}px`,v=`${r.floating.height+c}px`):u==="right"?(w=`${-c}px`,v=i?f:`${m}px`):u==="left"&&(w=`${r.floating.width+c}px`,v=i?f:`${m}px`),{data:{x:w,y:v}}}});function Fd(e){const[t,n="center"]=e.split("-");return[t,n]}var zd=Pd,Bd=Md,Hd=Dd,Ud=$d,sa="rovingFocusGroup.onEntryFocus",ky={bubbles:!1,cancelable:!0},Or="RovingFocusGroup",[ia,Wd,Iy]=Wi(Or),[Ny,Vd]=Yt(Or,[Iy]),[Ay,_y]=Ny(Or),Kd=p.forwardRef((e,t)=>l.jsx(ia.Provider,{scope:e.__scopeRovingFocusGroup,children:l.jsx(ia.Slot,{scope:e.__scopeRovingFocusGroup,children:l.jsx(jy,{...e,ref:t})})}));Kd.displayName=Or;var jy=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=p.useRef(null),m=je(t,h),w=Go(s),[v,g]=jn({prop:i,defaultProp:a??null,onChange:c,caller:Or}),[x,b]=p.useState(!1),S=ut(u),k=Wd(n),C=p.useRef(!1),[T,I]=p.useState(0);return p.useEffect(()=>{const N=h.current;if(N)return N.addEventListener(sa,S),()=>N.removeEventListener(sa,S)},[S]),l.jsx(Ay,{scope:n,orientation:r,dir:w,loop:o,currentTabStopId:v,onItemFocus:p.useCallback(N=>g(N),[g]),onItemShiftTab:p.useCallback(()=>b(!0),[]),onFocusableItemAdd:p.useCallback(()=>I(N=>N+1),[]),onFocusableItemRemove:p.useCallback(()=>I(N=>N-1),[]),children:l.jsx(ye.div,{tabIndex:x||T===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:ae(e.onMouseDown,()=>{C.current=!0}),onFocus:ae(e.onFocus,N=>{const _=!C.current;if(N.target===N.currentTarget&&_&&!x){const j=new CustomEvent(sa,ky);if(N.currentTarget.dispatchEvent(j),!j.defaultPrevented){const R=k().filter(K=>K.focusable),z=R.find(K=>K.active),H=R.find(K=>K.id===v),W=[z,H,...R].filter(Boolean).map(K=>K.ref.current);Yd(W,d)}}C.current=!1}),onBlur:ae(e.onBlur,()=>b(!1))})})}),qd="RovingFocusGroupItem",Gd=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,c=Xt(),u=s||c,d=_y(qd,n),f=d.currentTabStopId===u,h=Wd(n),{onFocusableItemAdd:m,onFocusableItemRemove:w,currentTabStopId:v}=d;return p.useEffect(()=>{if(r)return m(),()=>w()},[r,m,w]),l.jsx(ia.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:l.jsx(ye.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ae(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:ae(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:ae(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=Oy(g,d.orientation,d.dir);if(x!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let S=h().filter(k=>k.focusable).map(k=>k.ref.current);if(x==="last")S.reverse();else if(x==="prev"||x==="next"){x==="prev"&&S.reverse();const k=S.indexOf(g.currentTarget);S=d.loop?My(S,k+1):S.slice(k+1)}setTimeout(()=>Yd(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:v!=null}):i})})});Gd.displayName=qd;var Ry={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Py(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Oy(e,t,n){const r=Py(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Ry[r]}function Yd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function My(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Dy=Kd,Ly=Gd,aa=["Enter"," "],$y=["ArrowDown","PageUp","Home"],Xd=["ArrowUp","PageDown","End"],Fy=[...$y,...Xd],zy={ltr:[...aa,"ArrowRight"],rtl:[...aa,"ArrowLeft"]},By={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Mr="Menu",[Dr,Hy,Uy]=Wi(Mr),[Ln,Jd]=Yt(Mr,[Uy,os,Vd]),ss=os(),Zd=Vd(),[Wy,$n]=Ln(Mr),[Vy,Lr]=Ln(Mr),Qd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=ss(t),[c,u]=p.useState(null),d=p.useRef(!1),f=ut(s),h=Go(o);return p.useEffect(()=>{const m=()=>{d.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>d.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),l.jsx(zd,{...a,children:l.jsx(Wy,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:u,children:l.jsx(Vy,{scope:t,onClose:p.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};Qd.displayName=Mr;var Ky="MenuAnchor",la=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ss(n);return l.jsx(Bd,{...o,...r,ref:t})});la.displayName=Ky;var ca="MenuPortal",[qy,ef]=Ln(ca,{forceMount:void 0}),tf=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=$n(ca,t);return l.jsx(qy,{scope:t,forceMount:n,children:l.jsx(kt,{present:n||s.open,children:l.jsx(Ro,{asChild:!0,container:o,children:r})})})};tf.displayName=ca;var Pt="MenuContent",[Gy,ua]=Ln(Pt),nf=p.forwardRef((e,t)=>{const n=ef(Pt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=$n(Pt,e.__scopeMenu),i=Lr(Pt,e.__scopeMenu);return l.jsx(Dr.Provider,{scope:e.__scopeMenu,children:l.jsx(kt,{present:r||s.open,children:l.jsx(Dr.Slot,{scope:e.__scopeMenu,children:i.modal?l.jsx(Yy,{...o,ref:t}):l.jsx(Xy,{...o,ref:t})})})})}),Yy=p.forwardRef((e,t)=>{const n=$n(Pt,e.__scopeMenu),r=p.useRef(null),o=je(t,r);return p.useEffect(()=>{const s=r.current;if(s)return $i(s)},[]),l.jsx(da,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Xy=p.forwardRef((e,t)=>{const n=$n(Pt,e.__scopeMenu);return l.jsx(da,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Jy=Cn.createSlot("MenuContent.ScrollLock"),da=p.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:m,disableOutsideScroll:w,...v}=e,g=$n(Pt,n),x=Lr(Pt,n),b=ss(n),S=Zd(n),k=Hy(n),[C,T]=p.useState(null),I=p.useRef(null),N=je(t,I,g.onContentChange),_=p.useRef(0),j=p.useRef(""),R=p.useRef(0),z=p.useRef(null),H=p.useRef("right"),O=p.useRef(0),W=w?$o:p.Fragment,K=w?{as:Jy,allowPinchZoom:!0}:void 0,G=A=>{var q,M;const D=j.current+A,U=k().filter(X=>!X.disabled),J=document.activeElement,Q=(q=U.find(X=>X.ref.current===J))==null?void 0:q.textValue,ce=U.map(X=>X.textValue),we=c0(ce,D,Q),ke=(M=U.find(X=>X.textValue===we))==null?void 0:M.ref.current;(function X(ee){j.current=ee,window.clearTimeout(_.current),ee!==""&&(_.current=window.setTimeout(()=>X(""),1e3))})(D),ke&&setTimeout(()=>ke.focus())};p.useEffect(()=>()=>window.clearTimeout(_.current),[]),Ri();const $=p.useCallback(A=>{var U,J;return H.current===((U=z.current)==null?void 0:U.side)&&d0(A,(J=z.current)==null?void 0:J.area)},[]);return l.jsx(Gy,{scope:n,searchRef:j,onItemEnter:p.useCallback(A=>{$(A)&&A.preventDefault()},[$]),onItemLeave:p.useCallback(A=>{var D;$(A)||((D=I.current)==null||D.focus(),T(null))},[$]),onTriggerLeave:p.useCallback(A=>{$(A)&&A.preventDefault()},[$]),pointerGraceTimerRef:R,onPointerGraceIntentChange:p.useCallback(A=>{z.current=A},[]),children:l.jsx(W,{...K,children:l.jsx(jo,{asChild:!0,trapped:o,onMountAutoFocus:ae(s,A=>{var D;A.preventDefault(),(D=I.current)==null||D.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:l.jsx(_o,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:m,children:l.jsx(Dy,{asChild:!0,...S,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:ae(c,A=>{x.isUsingKeyboardRef.current||A.preventDefault()}),preventScrollOnEntryFocus:!0,children:l.jsx(Hd,{role:"menu","aria-orientation":"vertical","data-state":bf(g.open),"data-radix-menu-content":"",dir:x.dir,...b,...v,ref:N,style:{outline:"none",...v.style},onKeyDown:ae(v.onKeyDown,A=>{const U=A.target.closest("[data-radix-menu-content]")===A.currentTarget,J=A.ctrlKey||A.altKey||A.metaKey,Q=A.key.length===1;U&&(A.key==="Tab"&&A.preventDefault(),!J&&Q&&G(A.key));const ce=I.current;if(A.target!==ce||!Fy.includes(A.key))return;A.preventDefault();const ke=k().filter(q=>!q.disabled).map(q=>q.ref.current);Xd.includes(A.key)&&ke.reverse(),a0(ke)}),onBlur:ae(e.onBlur,A=>{A.currentTarget.contains(A.target)||(window.clearTimeout(_.current),j.current="")}),onPointerMove:ae(e.onPointerMove,Fr(A=>{const D=A.target,U=O.current!==A.clientX;if(A.currentTarget.contains(D)&&U){const J=A.clientX>O.current?"right":"left";H.current=J,O.current=A.clientX}}))})})})})})})});nf.displayName=Pt;var Zy="MenuGroup",fa=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(ye.div,{role:"group",...r,ref:t})});fa.displayName=Zy;var Qy="MenuLabel",rf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(ye.div,{...r,ref:t})});rf.displayName=Qy;var is="MenuItem",of="menu.itemSelect",as=p.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=p.useRef(null),i=Lr(is,e.__scopeMenu),a=ua(is,e.__scopeMenu),c=je(t,s),u=p.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(of,{bubbles:!0,cancelable:!0});f.addEventListener(of,m=>r==null?void 0:r(m),{once:!0}),zc(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return l.jsx(sf,{...o,ref:c,disabled:n,onClick:ae(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:ae(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:ae(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||aa.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});as.displayName=is;var sf=p.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ua(is,n),a=Zd(n),c=p.useRef(null),u=je(t,c),[d,f]=p.useState(!1),[h,m]=p.useState("");return p.useEffect(()=>{const w=c.current;w&&m((w.textContent??"").trim())},[s.children]),l.jsx(Dr.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:l.jsx(Ly,{asChild:!0,...a,focusable:!r,children:l.jsx(ye.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:ae(e.onPointerMove,Fr(w=>{r?i.onItemLeave(w):(i.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ae(e.onPointerLeave,Fr(w=>i.onItemLeave(w))),onFocus:ae(e.onFocus,()=>f(!0)),onBlur:ae(e.onBlur,()=>f(!1))})})})}),e0="MenuCheckboxItem",af=p.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return l.jsx(ff,{scope:e.__scopeMenu,checked:n,children:l.jsx(as,{role:"menuitemcheckbox","aria-checked":ls(n)?"mixed":n,...o,ref:t,"data-state":pa(n),onSelect:ae(o.onSelect,()=>r==null?void 0:r(ls(n)?!0:!n),{checkForDefaultPrevented:!1})})})});af.displayName=e0;var lf="MenuRadioGroup",[t0,n0]=Ln(lf,{value:void 0,onValueChange:()=>{}}),cf=p.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=ut(r);return l.jsx(t0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:l.jsx(fa,{...o,ref:t})})});cf.displayName=lf;var uf="MenuRadioItem",df=p.forwardRef((e,t)=>{const{value:n,...r}=e,o=n0(uf,e.__scopeMenu),s=n===o.value;return l.jsx(ff,{scope:e.__scopeMenu,checked:s,children:l.jsx(as,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":pa(s),onSelect:ae(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});df.displayName=uf;var ha="MenuItemIndicator",[ff,r0]=Ln(ha,{checked:!1}),hf=p.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=r0(ha,n);return l.jsx(kt,{present:r||ls(s.checked)||s.checked===!0,children:l.jsx(ye.span,{...o,ref:t,"data-state":pa(s.checked)})})});hf.displayName=ha;var o0="MenuSeparator",pf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(ye.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});pf.displayName=o0;var s0="MenuArrow",mf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ss(n);return l.jsx(Ud,{...o,...r,ref:t})});mf.displayName=s0;var i0="MenuSub",[WC,gf]=Ln(i0),$r="MenuSubTrigger",xf=p.forwardRef((e,t)=>{const n=$n($r,e.__scopeMenu),r=Lr($r,e.__scopeMenu),o=gf($r,e.__scopeMenu),s=ua($r,e.__scopeMenu),i=p.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:c}=s,u={__scopeMenu:e.__scopeMenu},d=p.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return p.useEffect(()=>d,[d]),p.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),c(null)}},[a,c]),l.jsx(la,{asChild:!0,...u,children:l.jsx(sf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":bf(n.open),...e,ref:vi(t,o.onTriggerChange),onClick:f=>{var h;(h=e.onClick)==null||h.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ae(e.onPointerMove,Fr(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ae(e.onPointerLeave,Fr(f=>{var m,w;d();const h=(m=n.content)==null?void 0:m.getBoundingClientRect();if(h){const v=(w=n.content)==null?void 0:w.dataset.side,g=v==="right",x=g?-5:5,b=h[g?"left":"right"],S=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+x,y:f.clientY},{x:b,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:b,y:h.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ae(e.onKeyDown,f=>{var m;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||zy[r.dir].includes(f.key)&&(n.onOpenChange(!0),(m=n.content)==null||m.focus(),f.preventDefault())})})})});xf.displayName=$r;var vf="MenuSubContent",wf=p.forwardRef((e,t)=>{const n=ef(Pt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=$n(Pt,e.__scopeMenu),i=Lr(Pt,e.__scopeMenu),a=gf(vf,e.__scopeMenu),c=p.useRef(null),u=je(t,c);return l.jsx(Dr.Provider,{scope:e.__scopeMenu,children:l.jsx(kt,{present:r||s.open,children:l.jsx(Dr.Slot,{scope:e.__scopeMenu,children:l.jsx(da,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=c.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ae(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ae(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ae(e.onKeyDown,d=>{var m;const f=d.currentTarget.contains(d.target),h=By[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(m=a.trigger)==null||m.focus(),d.preventDefault())})})})})})});wf.displayName=vf;function bf(e){return e?"open":"closed"}function ls(e){return e==="indeterminate"}function pa(e){return ls(e)?"indeterminate":e?"checked":"unchecked"}function a0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function l0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function c0(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=l0(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function u0(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],c=t[i],u=a.x,d=a.y,f=c.x,h=c.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function d0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return u0(n,t)}function Fr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var f0=Qd,h0=la,p0=tf,m0=nf,g0=fa,x0=rf,v0=as,w0=af,b0=cf,y0=df,S0=hf,C0=pf,T0=mf,E0=xf,k0=wf,cs="DropdownMenu",[I0,VC]=Yt(cs,[Jd]),gt=Jd(),[N0,yf]=I0(cs),Sf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,c=gt(t),u=p.useRef(null),[d,f]=jn({prop:o,defaultProp:s??!1,onChange:i,caller:cs});return l.jsx(N0,{scope:t,triggerId:Xt(),triggerRef:u,contentId:Xt(),open:d,onOpenChange:f,onOpenToggle:p.useCallback(()=>f(h=>!h),[f]),modal:a,children:l.jsx(f0,{...c,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Sf.displayName=cs;var Cf="DropdownMenuTrigger",Tf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=yf(Cf,n),i=gt(n);return l.jsx(h0,{asChild:!0,...i,children:l.jsx(ye.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:vi(t,s.triggerRef),onPointerDown:ae(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ae(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Tf.displayName=Cf;var A0="DropdownMenuPortal",Ef=e=>{const{__scopeDropdownMenu:t,...n}=e,r=gt(t);return l.jsx(p0,{...r,...n})};Ef.displayName=A0;var kf="DropdownMenuContent",If=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yf(kf,n),s=gt(n),i=p.useRef(!1);return l.jsx(m0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ae(e.onCloseAutoFocus,a=>{var c;i.current||(c=o.triggerRef.current)==null||c.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ae(e.onInteractOutside,a=>{const c=a.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,d=c.button===2||u;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});If.displayName=kf;var _0="DropdownMenuGroup",j0=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gt(n);return l.jsx(g0,{...o,...r,ref:t})});j0.displayName=_0;var R0="DropdownMenuLabel",Nf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gt(n);return l.jsx(x0,{...o,...r,ref:t})});Nf.displayName=R0;var P0="DropdownMenuItem",Af=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gt(n);return l.jsx(v0,{...o,...r,ref:t})});Af.displayName=P0;var O0="DropdownMenuCheckboxItem",_f=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gt(n);return l.jsx(w0,{...o,...r,ref:t})});_f.displayName=O0;var M0="DropdownMenuRadioGroup",D0=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gt(n);return l.jsx(b0,{...o,...r,ref:t})});D0.displayName=M0;var L0="DropdownMenuRadioItem",jf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gt(n);return l.jsx(y0,{...o,...r,ref:t})});jf.displayName=L0;var $0="DropdownMenuItemIndicator",Rf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gt(n);return l.jsx(S0,{...o,...r,ref:t})});Rf.displayName=$0;var F0="DropdownMenuSeparator",Pf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gt(n);return l.jsx(C0,{...o,...r,ref:t})});Pf.displayName=F0;var z0="DropdownMenuArrow",B0=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gt(n);return l.jsx(T0,{...o,...r,ref:t})});B0.displayName=z0;var H0="DropdownMenuSubTrigger",Of=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gt(n);return l.jsx(E0,{...o,...r,ref:t})});Of.displayName=H0;var U0="DropdownMenuSubContent",Mf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gt(n);return l.jsx(k0,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Mf.displayName=U0;var W0=Sf,V0=Tf,K0=Ef,Df=If,Lf=Nf,$f=Af,Ff=_f,zf=jf,Bf=Rf,Hf=Pf,Uf=Of,Wf=Mf;const q0=W0,G0=V0,Y0=p.forwardRef(({className:e,inset:t,children:n,...r},o)=>l.jsxs(Uf,{ref:o,className:Z("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,l.jsx(ne.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Y0.displayName=Uf.displayName;const X0=p.forwardRef(({className:e,...t},n)=>l.jsx(Wf,{ref:n,className:Z("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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",e),...t}));X0.displayName=Wf.displayName;const Vf=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>l.jsx(K0,{children:l.jsx(Df,{ref:r,sideOffset:t,className:Z("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 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",e),...n})}));Vf.displayName=Df.displayName;const ma=p.forwardRef(({className:e,inset:t,...n},r)=>l.jsx($f,{ref:r,className:Z("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));ma.displayName=$f.displayName;const J0=p.forwardRef(({className:e,children:t,checked:n,...r},o)=>l.jsxs(Ff,{ref:o,className:Z("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Bf,{children:l.jsx(ne.Check,{className:"h-4 w-4"})})}),t]}));J0.displayName=Ff.displayName;const Z0=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(zf,{ref:r,className:Z("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Bf,{children:l.jsx(ne.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Z0.displayName=zf.displayName;const Q0=p.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(Lf,{ref:r,className:Z("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Q0.displayName=Lf.displayName;const eS=p.forwardRef(({className:e,...t},n)=>l.jsx(Hf,{ref:n,className:Z("-mx-1 my-1 h-px bg-muted",e),...t}));eS.displayName=Hf.displayName;function us({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:c=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:h,onError:m}){const{api:w}=so(),{currentThreadId:v,isLoadingThread:g,listCheckpoints:x,navigateToCheckpoint:b,returnToLatest:S}=mr(),{messages:k,hasMoreHistory:C,isLoadingHistory:T,send:I,stop:N,loadOlderMessages:_}=qs(),{isStreaming:j,error:R,streamingAssistantId:z,lastCheckpointId:H,lastCheckpointNs:O}=Ol(),[W,K]=y.useState(null),[G,$]=y.useState(""),[A,D]=y.useState(null),[U,J]=y.useState([]),[Q,ce]=y.useState(0),[we,ke]=y.useState(0),[q,M]=y.useState(!1),[X,ee]=y.useState(null),[L,F]=y.useState(null),[me,Re]=y.useState(!1),[xe,_e]=y.useState(null),[Be,qe]=y.useState([]),[$e,nt]=y.useState(null),[at,ie]=y.useState(null),[te,pe]=y.useState(!1),de=y.useRef(null),Ne=y.useRef(null),Fe=y.useRef(null),Xe=y.useCallback(()=>{de.current&&(de.current.value=""),Ne.current&&(Ne.current.value=""),ce(le=>le+1),ke(le=>le+1)},[]),Ze=y.useRef(!1);y.useEffect(()=>{Ze.current&&!j&&(J([]),Xe()),Ze.current=j},[j,Xe]);const[lt,Dt]=y.useState("desktop");y.useEffect(()=>{const le=()=>{const ge=window.innerWidth;Dt(ge<640?"phone":ge<1024?"tablet":"desktop")};return le(),window.addEventListener("resize",le),()=>window.removeEventListener("resize",le)},[]),y.useEffect(()=>{let le=!1;if(!v){qe([]),nt(null),ie(null),Fe.current=null;return}const ge={threadId:v,checkpointId:H??null,checkpointNs:O??null},Me=Fe.current;if(!(Me&&Me.threadId===ge.threadId&&Me.checkpointId===ge.checkpointId&&Me.checkpointNs===ge.checkpointNs))return x(v).then(Qe=>{var ks;if(le)return;const At=((Qe==null?void 0:Qe.checkpoints)??[]).slice().sort((ln,E)=>new Date(E.createdAt).getTime()-new Date(ln.createdAt).getTime());qe(At);const rn=$e,Vr=rn&&At.some(ln=>ln.checkpointId===rn)?rn:((ks=At[0])==null?void 0:ks.checkpointId)??null;let Es=null;if(Vr){const ln=At.find(E=>E.checkpointId===Vr);Es=(ln==null?void 0:ln.checkpointNs)??null}nt(Vr),ie(Es),Fe.current=ge}).catch(Qe=>{console.error("ChatInterface - listCheckpoints error:",Qe),le||(qe([]),Fe.current=null)}),()=>{le=!0}},[v,H,O,$e,x]),y.useEffect(()=>{H&&(nt(H),ie(O??null))},[H,O]);const ir=y.useCallback(async()=>{if(!(!C||T))try{await _()}catch(le){console.warn("loadOlderMessages failed",le)}},[C,T,_]);y.useEffect(()=>{(async()=>{if(!w.baseUrl){_e(null);return}try{const ge=await w.getAgent("default");_e(ge.uiDefaultMessage||null)}catch(ge){console.warn("Failed to fetch default message:",ge),_e(null)}})()},[w]),y.useEffect(()=>{R&&!me&&(m==null||m(R))},[R,me,m]);const _a=le=>{if(le.length>qo)return`Message too long (${le.length}/${qo} characters)`;try{return ib(le),null}catch(ge){return(ge==null?void 0:ge.message)||"Invalid message"}},ja=async le=>{const ge=le.trim();if(!(!ge&&U.length===0)){if(ge){const Me=_a(ge);if(Me){D(Me);return}}try{await I(ge||"",{checkpointId:$e??H??void 0,checkpointNs:at??O??void 0,payloadExtras:W?{edit:!0,originalMessageId:W}:void 0,attachments:U}),f==null||f(ge),D(null),J([]),Xe(),K(null),$("")}catch(Me){const Qe=(Me==null?void 0:Me.message)||"Failed to send message";D(Qe),m==null||m(Qe)}}},ys=y.useCallback((le,ge)=>{u&&(K(le),$(ge),D(null))},[u]),Br=y.useCallback(()=>{K(null),$(""),D(null)},[]),Ra=y.useCallback((le,ge)=>{ys(le,ge)},[ys]),Hr=y.useCallback(le=>{const ge=Me=>{const Qe=Me.content||[],At=Qe.filter(rn=>rn.type==="text").map(rn=>rn.text).join("");if(At)return At;try{return JSON.stringify(Qe,null,2)}catch{return String(Qe)}};for(let Me=le-1;Me>=0;Me--)if(k[Me].role==="user"){const Qe=ge(k[Me]);Qe&&I(Qe,{checkpointId:$e??H??void 0,checkpointNs:at??O??void 0});break}},[k,I,$e,at,H,O]),Ss=le=>{const ge=Array.from(le.target.files||[]);J(Me=>[...Me,...ge]),le.target.value=""},Sn=le=>{J(ge=>{const Me=ge.filter((Qe,At)=>le!==At);return Me.length===0&&Xe(),Me})},Ur=async le=>{const ge=(le.target.files||[])[0];if(ge){ee(null),F(null),M(!0);try{await I("",{checkpointId:$e??H??void 0,checkpointNs:at??O??void 0,attachments:[ge]});const Me=`Uploaded ${ge.name} - processing through chat stream`;F(Me)}catch(Me){const Qe=Me instanceof Error?Me.message:"Failed to upload Excel file";console.error("Excel upload failed",Me),ee(Qe),m==null||m(Qe)}finally{M(!1),le.target.value="",Xe()}}},Wr=le=>{if(!le)return"Unknown";const ge=Date.parse(le);return Number.isNaN(ge)?le:new Date(ge).toLocaleString()},Cs=async le=>{if(v){pe(!0);try{if(!le){await S(),nt(null),ie(null);return}const ge=Be.find(Qe=>Qe.checkpointId===le),Me=(ge==null?void 0:ge.checkpointNs)??null;await b(le,Me),nt(le),ie(Me)}finally{pe(!1)}}},Pa=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,Ts=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${d.messagesArea||""}`,Oa=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return l.jsxs("div",{className:Pa,children:[!!R&&!me&&l.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[l.jsx("span",{children:R}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>Re(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:l.jsx(ne.X,{size:16})})]}),v&&Be.length>0&&l.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[l.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),l.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:$e??"",onChange:le=>{const ge=le.target.value||null;Cs(ge)},children:[l.jsx("option",{value:"",children:"Latest"}),Be.map(le=>l.jsxs("option",{value:le.checkpointId,children:[Wr(le.createdAt),le.preview?` — ${le.preview.slice(0,40)}`:""]},le.checkpointId))]})]}),l.jsxs("div",{className:`relative ${Ts}`,style:r?{maxHeight:r}:void 0,children:[l.jsx(Ui,{className:"h-full",style:{height:"100%"},messages:k,isStreaming:j,streamingAssistantId:z,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:lt,enableMessageEditing:u,editingMessageId:W,onStartReached:()=>{ir()},onEdit:Ra,onRegenerate:Hr,onCancelEdit:Br,emptyMessage:xe??void 0,isNavigatingCheckpoint:te}),g&&l.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[l.jsx(ne.Loader2,{className:"h-6 w-6 animate-spin"}),l.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]})]}),l.jsxs("div",{className:Oa,children:[W&&l.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(ne.Edit3,{size:16,className:"text-blue-600"}),l.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:Br,className:"text-blue-600 hover:bg-blue-100",children:l.jsx(ne.X,{size:16})})]})}),(a||c)&&l.jsxs("div",{className:"mb-3 space-y-3",children:[a&&l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:de,type:"file",multiple:!0,onChange:le=>Ss(le),className:"hidden"},Q),U.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2",children:U.map((le,ge)=>l.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[l.jsx(ne.Paperclip,{size:14}),l.jsx("span",{className:"truncate max-w-[150px]",children:le.name}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>Sn(ge),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${le.name}`,children:l.jsx(ne.X,{size:12})})]},ge))})]}),c&&l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:Ne,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Ur,className:"hidden"},we),q&&l.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[l.jsx(ne.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),L&&!q&&l.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:L}),X&&!q&&l.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:X})]})]}),A&&l.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:A}),l.jsxs("div",{className:"flex items-end gap-2",children:[(a||c)&&l.jsxs(q0,{children:[l.jsx(G0,{asChild:!0,children:l.jsx(Le,{type:"button",size:"icon",variant:"outline",disabled:j,title:"More input actions",className:d.moreButton||"",children:l.jsx(ne.Plus,{size:16})})}),l.jsxs(Vf,{align:"start",sideOffset:6,className:"w-52",children:[a&&l.jsxs(ma,{onClick:()=>{var le;return(le=de.current)==null?void 0:le.click()},className:"cursor-pointer",children:[l.jsx(ne.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),c&&l.jsxs(ma,{onClick:()=>{var le;q||(le=Ne.current)==null||le.click()},className:`cursor-pointer ${q?"opacity-60 pointer-events-none":""}`,children:[l.jsx(ne.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),l.jsx("div",{className:"flex-1",children:l.jsx(wg,{initialValue:G,editingMessageId:W,placeholder:W?"Edit your message...":t,isStreaming:j,disabled:!1,maxLength:qo,onSend:ja,onCancelEdit:Br,onStop:N,allowEmptySend:U.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${W?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${A?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const ds=p.forwardRef(({className:e,type:t,...n},r)=>l.jsx("input",{type:t,className:Z("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));ds.displayName="Input";function ga(e,[t,n]){return Math.min(n,Math.max(t,e))}function tS(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var xa="ScrollArea",[Kf,KC]=Yt(xa),[nS,Ot]=Kf(xa),qf=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,c]=p.useState(null),[u,d]=p.useState(null),[f,h]=p.useState(null),[m,w]=p.useState(null),[v,g]=p.useState(null),[x,b]=p.useState(0),[S,k]=p.useState(0),[C,T]=p.useState(!1),[I,N]=p.useState(!1),_=je(t,R=>c(R)),j=Go(o);return l.jsx(nS,{scope:n,type:r,dir:j,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:m,onScrollbarXChange:w,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:v,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:N,onCornerWidthChange:b,onCornerHeightChange:k,children:l.jsx(ye.div,{dir:j,...i,ref:_,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});qf.displayName=xa;var Gf="ScrollAreaViewport",Yf=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Ot(Gf,n),a=p.useRef(null),c=je(t,a,i.onViewportChange);return l.jsxs(l.Fragment,{children:[l.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),l.jsx(ye.div,{"data-radix-scroll-area-viewport":"",...s,ref:c,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:l.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Yf.displayName=Gf;var nn="ScrollAreaScrollbar",va=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ot(nn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return p.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?l.jsx(rS,{...r,ref:t,forceMount:n}):o.type==="scroll"?l.jsx(oS,{...r,ref:t,forceMount:n}):o.type==="auto"?l.jsx(Xf,{...r,ref:t,forceMount:n}):o.type==="always"?l.jsx(wa,{...r,ref:t}):null});va.displayName=nn;var rS=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ot(nn,e.__scopeScrollArea),[s,i]=p.useState(!1);return p.useEffect(()=>{const a=o.scrollArea;let c=0;if(a){const u=()=>{window.clearTimeout(c),i(!0)},d=()=>{c=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),l.jsx(kt,{present:n||s,children:l.jsx(Xf,{"data-state":s?"visible":"hidden",...r,ref:t})})}),oS=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ot(nn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ms(()=>c("SCROLL_END"),100),[a,c]=tS("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return p.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,c]),p.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const m=u[d];f!==m&&(c("SCROLL"),i()),f=m};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,c,i]),l.jsx(kt,{present:n||a!=="hidden",children:l.jsx(wa,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ae(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:ae(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),Xf=p.forwardRef((e,t)=>{const n=Ot(nn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=p.useState(!1),a=e.orientation==="horizontal",c=ms(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return rr(n.viewport,c),rr(n.content,c),l.jsx(kt,{present:r||s,children:l.jsx(wa,{"data-state":s?"visible":"hidden",...o,ref:t})})}),wa=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Ot(nn,e.__scopeScrollArea),s=p.useRef(null),i=p.useRef(0),[a,c]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=th(a.viewport,a.content),d={...r,sizes:a,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,m){return uS(h,i.current,a,m)}return n==="horizontal"?l.jsx(sS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,m=nh(h,a,o.dir);s.current.style.transform=`translate3d(${m}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?l.jsx(iS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,m=nh(h,a);s.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),sS=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Ot(nn,e.__scopeScrollArea),[i,a]=p.useState(),c=p.useRef(null),u=je(t,c,s.onScrollbarXChange);return p.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(Zf,{"data-orientation":"horizontal",...o,ref:u,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":ps(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(h),oh(h,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:hs(i.paddingLeft),paddingEnd:hs(i.paddingRight)}})}})}),iS=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Ot(nn,e.__scopeScrollArea),[i,a]=p.useState(),c=p.useRef(null),u=je(t,c,s.onScrollbarYChange);return p.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(Zf,{"data-orientation":"vertical",...o,ref:u,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":ps(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(h),oh(h,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:hs(i.paddingTop),paddingEnd:hs(i.paddingBottom)}})}})}),[aS,Jf]=Kf(nn),Zf=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,m=Ot(nn,n),[w,v]=p.useState(null),g=je(t,_=>v(_)),x=p.useRef(null),b=p.useRef(""),S=m.viewport,k=r.content-r.viewport,C=ut(d),T=ut(c),I=ms(f,10);function N(_){if(x.current){const j=_.clientX-x.current.left,R=_.clientY-x.current.top;u({x:j,y:R})}}return p.useEffect(()=>{const _=j=>{const R=j.target;(w==null?void 0:w.contains(R))&&C(j,k)};return document.addEventListener("wheel",_,{passive:!1}),()=>document.removeEventListener("wheel",_,{passive:!1})},[S,w,k,C]),p.useEffect(T,[r,T]),rr(w,I),rr(m.content,I),l.jsx(aS,{scope:n,scrollbar:w,hasThumb:o,onThumbChange:ut(s),onThumbPointerUp:ut(i),onThumbPositionChange:T,onThumbPointerDown:ut(a),children:l.jsx(ye.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:ae(e.onPointerDown,_=>{_.button===0&&(_.target.setPointerCapture(_.pointerId),x.current=w.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),N(_))}),onPointerMove:ae(e.onPointerMove,N),onPointerUp:ae(e.onPointerUp,_=>{const j=_.target;j.hasPointerCapture(_.pointerId)&&j.releasePointerCapture(_.pointerId),document.body.style.webkitUserSelect=b.current,m.viewport&&(m.viewport.style.scrollBehavior=""),x.current=null})})})}),fs="ScrollAreaThumb",Qf=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Jf(fs,e.__scopeScrollArea);return l.jsx(kt,{present:n||o.hasThumb,children:l.jsx(lS,{ref:t,...r})})}),lS=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Ot(fs,n),i=Jf(fs,n),{onThumbPositionChange:a}=i,c=je(t,f=>i.onThumbChange(f)),u=p.useRef(void 0),d=ms(()=>{u.current&&(u.current(),u.current=void 0)},100);return p.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const m=dS(f,a);u.current=m,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),l.jsx(ye.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ae(e.onPointerDownCapture,f=>{const m=f.target.getBoundingClientRect(),w=f.clientX-m.left,v=f.clientY-m.top;i.onThumbPointerDown({x:w,y:v})}),onPointerUp:ae(e.onPointerUp,i.onThumbPointerUp)})});Qf.displayName=fs;var ba="ScrollAreaCorner",eh=p.forwardRef((e,t)=>{const n=Ot(ba,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?l.jsx(cS,{...e,ref:t}):null});eh.displayName=ba;var cS=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Ot(ba,n),[s,i]=p.useState(0),[a,c]=p.useState(0),u=!!(s&&a);return rr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),c(d)}),rr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?l.jsx(ye.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function hs(e){return e?parseInt(e,10):0}function th(e,t){const n=e/t;return isNaN(n)?0:n}function ps(e){const t=th(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function uS(e,t,n,r="ltr"){const o=ps(n),s=o/2,i=t||s,a=o-i,c=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return rh([c,u],f)(e)}function nh(e,t,n="ltr"){const r=ps(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,c=n==="ltr"?[0,i]:[i*-1,0],u=ga(e,c);return rh([0,i],[0,a])(u)}function rh(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function oh(e,t){return e>0&&e<t}var dS=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function ms(e,t){const n=ut(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function rr(e,t){const n=ut(t);ct(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var sh=qf,fS=Yf,hS=eh;const ih=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(sh,{ref:r,className:Z("relative overflow-hidden",e),...n,children:[l.jsx(fS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),l.jsx(ah,{}),l.jsx(hS,{})]}));ih.displayName=sh.displayName;const ah=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>l.jsx(va,{ref:r,orientation:t,className:Z("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:l.jsx(Qf,{className:"relative flex-1 rounded-full bg-border"})}));ah.displayName=va.displayName;function ya({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:c,onThreadCreate:u,onThreadDelete:d}){const{loadThread:f,threads:h,currentThreadId:m,createThread:w,deleteThread:v,renameThread:g,isLoadingThreads:x}=mr(),[b,S]=y.useState(h??[]),[k,C]=y.useState(null),[T,I]=y.useState(""),[N,_]=y.useState(!1);y.useEffect(()=>{S(h??[])},[h]);const j=async A=>{try{await f(A),a==null||a(A),c==null||c(A)}catch(D){console.error("Failed to select thread:",D)}},R=async()=>{try{_(!0);const A=await w();u==null||u(A),a==null||a(A)}catch(A){console.error("Failed to create thread:",A)}finally{_(!1)}},z=async(A,D)=>{if(D.stopPropagation(),!!confirm("Delete this thread?"))try{await v(A),d==null||d(A)}catch(U){console.error("Failed to delete thread:",U)}},H=(A,D)=>{D.stopPropagation(),C(A.threadId),I(A.title||`Thread ${A.threadId.slice(0,8)}`)},O=async A=>{if(T.trim())try{await g(A,T.trim()),C(null),I("")}catch(D){console.error("Failed to update title:",D)}},W=()=>{C(null),I("")},K=(A,D)=>{A.key==="Enter"?O(D):A.key==="Escape"&&W()},G=A=>{if(!A)return"";try{const D=new Date(A),J=new Date().getTime()-D.getTime(),Q=Math.floor(J/(1e3*60*60*24));return Q===0?D.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Q===1?"Yesterday":Q<7?`${Q} days ago`:D.toLocaleDateString()}catch{return""}},$=A=>A.title||`Thread ${A.threadId.slice(0,8)}`;return l.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&l.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:l.jsx(Le,{onClick:R,disabled:N||x,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:N?"Creating...":"New Chat",children:l.jsx(ne.MessageSquarePlus,{size:20})})}),l.jsx(ih,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:l.jsx("div",{className:"p-2 space-y-1 pb-4",children:x?l.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[l.jsx(ne.Loader2,{className:"h-5 w-5 animate-spin"}),l.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):b.length===0?l.jsxs("div",{className:"text-center py-8 text-slate-400",children:[l.jsx(ne.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),l.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):b.slice().sort((A,D)=>new Date(D.updatedAt||D.createdAt||"").getTime()-new Date(A.updatedAt||A.createdAt||"").getTime()).map(A=>l.jsxs("div",{onClick:()=>j(A.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??m)===A.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("div",{className:"flex-1 min-w-0",children:k===A.threadId?l.jsxs("div",{className:"flex items-center gap-2",onClick:D=>D.stopPropagation(),children:[l.jsx(ds,{value:T,onChange:D=>I(D.target.value),onKeyDown:D=>K(D,A.threadId),className:"h-6 text-sm",autoFocus:!0}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>O(A.threadId),className:"h-6 w-6 p-0",children:l.jsx(ne.Check,{size:12})}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:W,className:"h-6 w-6 p-0",children:l.jsx(ne.X,{size:12})})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:$(A)}),l.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[l.jsx(ne.Calendar,{size:10}),l.jsx("span",{children:G(A.updatedAt||A.createdAt)})]})]})}),l.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&k!==A.threadId&&l.jsx(Le,{variant:"ghost",size:"sm",onClick:D=>H(A,D),className:"h-6 w-6 p-0",title:"Edit title",children:l.jsx(ne.Edit3,{size:12})}),n&&l.jsx(Le,{variant:"ghost",size:"sm",onClick:D=>z(A.threadId,D),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:l.jsx(ne.Trash2,{size:12})})]})]}),i===A.threadId&&l.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},A.threadId))})})]})}function or(e){if(!(typeof globalThis>"u"))return globalThis[e]}function pS(e){if(typeof e!="string")return;const t=e.trim();if(t)return t.replace(/\/+$/g,"")}function lh(){const e=[or("__API_BASE_URL__"),or("__CHAT_API_BASE_URL__"),or("__CHAT_API_URL__")];for(const t of e){const n=pS(t);if(n)return n}}function ch(){const e=[or("__API_AUTH_TOKEN__"),or("__CHAT_API_KEY__"),or("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function uh(){const e={},t=lh(),n=ch();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function dh(){const e=uh(),t=cn.getAuthToken(),n=lh();return{apiBaseUrl:e.baseUrl||cn.baseUrl||n||"http://localhost:8000",apiKey:t||e.apiKey||ch()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const fh="chat-settings";function mS(){try{const e=localStorage.getItem(fh);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function gS(e){try{localStorage.setItem(fh,JSON.stringify(e)),e.apiKey&&cn.setAuthToken(e.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function xS(){const e=dh(),t=mS(),n=cn.getAuthToken();return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:cn.baseUrl||t.apiBaseUrl||e.apiBaseUrl}}function vS(e){e.apiKey&&cn.setAuthToken(e.apiKey),gS(e)}var wS="Label",hh=p.forwardRef((e,t)=>l.jsx(ye.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));hh.displayName=wS;var ph=hh;const bS=Kr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Mt=p.forwardRef(({className:e,...t},n)=>l.jsx(ph,{ref:n,className:Z(bS(),e),...t}));Mt.displayName=ph.displayName;function mh(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var gs="Switch",[yS,qC]=Yt(gs),[SS,CS]=yS(gs),gh=p.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:c="on",onCheckedChange:u,form:d,...f}=e,[h,m]=p.useState(null),w=je(t,S=>m(S)),v=p.useRef(!1),g=h?d||!!h.closest("form"):!0,[x,b]=jn({prop:o,defaultProp:s??!1,onChange:u,caller:gs});return l.jsxs(SS,{scope:n,checked:x,disabled:a,children:[l.jsx(ye.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":bh(x),"data-disabled":a?"":void 0,disabled:a,value:c,...f,ref:w,onClick:ae(e.onClick,S=>{b(k=>!k),g&&(v.current=S.isPropagationStopped(),v.current||S.stopPropagation())})}),g&&l.jsx(wh,{control:h,bubbles:!v.current,name:r,value:c,checked:x,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});gh.displayName=gs;var xh="SwitchThumb",vh=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=CS(xh,n);return l.jsx(ye.span,{"data-state":bh(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});vh.displayName=xh;var TS="SwitchBubbleInput",wh=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=p.useRef(null),a=je(i,s),c=mh(n),u=_d(t);return p.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==n&&m){const w=new Event("click",{bubbles:r});m.call(d,n),d.dispatchEvent(w)}},[c,n,r]),l.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});wh.displayName=TS;function bh(e){return e?"checked":"unchecked"}var yh=gh,ES=vh;const wn=p.forwardRef(({className:e,...t},n)=>l.jsx(yh,{className:Z("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:l.jsx(ES,{className:Z("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));wn.displayName=yh.displayName;var Sh=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),kS="VisuallyHidden",IS=p.forwardRef((e,t)=>l.jsx(ye.span,{...e,ref:t,style:{...Sh,...e.style}}));IS.displayName=kS;var NS=[" ","Enter","ArrowUp","ArrowDown"],AS=[" ","Enter"],Fn="Select",[xs,vs,_S]=Wi(Fn),[sr,GC]=Yt(Fn,[_S,os]),ws=os(),[jS,bn]=sr(Fn),[RS,PS]=sr(Fn),Ch=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:c,dir:u,name:d,autoComplete:f,disabled:h,required:m,form:w}=e,v=ws(t),[g,x]=p.useState(null),[b,S]=p.useState(null),[k,C]=p.useState(!1),T=Go(u),[I,N]=jn({prop:r,defaultProp:o??!1,onChange:s,caller:Fn}),[_,j]=jn({prop:i,defaultProp:a,onChange:c,caller:Fn}),R=p.useRef(null),z=g?w||!!g.closest("form"):!0,[H,O]=p.useState(new Set),W=Array.from(H).map(K=>K.props.value).join(";");return l.jsx(zd,{...v,children:l.jsxs(jS,{required:m,scope:t,trigger:g,onTriggerChange:x,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:Xt(),value:_,onValueChange:j,open:I,onOpenChange:N,dir:T,triggerPointerDownPosRef:R,disabled:h,children:[l.jsx(xs.Provider,{scope:t,children:l.jsx(RS,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback(K=>{O(G=>new Set(G).add(K))},[]),onNativeOptionRemove:p.useCallback(K=>{O(G=>{const $=new Set(G);return $.delete(K),$})},[]),children:n})}),z?l.jsxs(qh,{"aria-hidden":!0,required:m,tabIndex:-1,name:d,autoComplete:f,value:_,onChange:K=>j(K.target.value),disabled:h,form:w,children:[_===void 0?l.jsx("option",{value:""}):null,Array.from(H)]},W):null]})})};Ch.displayName=Fn;var Th="SelectTrigger",Eh=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ws(n),i=bn(Th,n),a=i.disabled||r,c=je(t,i.onTriggerChange),u=vs(n),d=p.useRef("touch"),[f,h,m]=Yh(v=>{const g=u().filter(S=>!S.disabled),x=g.find(S=>S.value===i.value),b=Xh(g,v,x);b!==void 0&&i.onValueChange(b.value)}),w=v=>{a||(i.onOpenChange(!0),m()),v&&(i.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return l.jsx(Bd,{asChild:!0,...s,children:l.jsx(ye.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Gh(i.value)?"":void 0,...o,ref:c,onClick:ae(o.onClick,v=>{v.currentTarget.focus(),d.current!=="mouse"&&w(v)}),onPointerDown:ae(o.onPointerDown,v=>{d.current=v.pointerType;const g=v.target;g.hasPointerCapture(v.pointerId)&&g.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(w(v),v.preventDefault())}),onKeyDown:ae(o.onKeyDown,v=>{const g=f.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&h(v.key),!(g&&v.key===" ")&&NS.includes(v.key)&&(w(),v.preventDefault())})})})});Eh.displayName=Th;var kh="SelectValue",Ih=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,c=bn(kh,n),{onValueNodeHasChildrenChange:u}=c,d=s!==void 0,f=je(t,c.onValueNodeChange);return ct(()=>{u(d)},[u,d]),l.jsx(ye.span,{...a,ref:f,style:{pointerEvents:"none"},children:Gh(c.value)?l.jsx(l.Fragment,{children:i}):s})});Ih.displayName=kh;var OS="SelectIcon",Nh=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return l.jsx(ye.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Nh.displayName=OS;var MS="SelectPortal",Ah=e=>l.jsx(Ro,{asChild:!0,...e});Ah.displayName=MS;var zn="SelectContent",_h=p.forwardRef((e,t)=>{const n=bn(zn,e.__scopeSelect),[r,o]=p.useState();if(ct(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?qr.createPortal(l.jsx(jh,{scope:e.__scopeSelect,children:l.jsx(xs.Slot,{scope:e.__scopeSelect,children:l.jsx("div",{children:e.children})})}),s):null}return l.jsx(Rh,{...e,ref:t})});_h.displayName=zn;var Wt=10,[jh,yn]=sr(zn),DS="SelectContentImpl",LS=Cn.createSlot("SelectContent.RemoveScroll"),Rh=p.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:m,sticky:w,hideWhenDetached:v,avoidCollisions:g,...x}=e,b=bn(zn,n),[S,k]=p.useState(null),[C,T]=p.useState(null),I=je(t,q=>k(q)),[N,_]=p.useState(null),[j,R]=p.useState(null),z=vs(n),[H,O]=p.useState(!1),W=p.useRef(!1);p.useEffect(()=>{if(S)return $i(S)},[S]),Ri();const K=p.useCallback(q=>{const[M,...X]=z().map(F=>F.ref.current),[ee]=X.slice(-1),L=document.activeElement;for(const F of q)if(F===L||(F==null||F.scrollIntoView({block:"nearest"}),F===M&&C&&(C.scrollTop=0),F===ee&&C&&(C.scrollTop=C.scrollHeight),F==null||F.focus(),document.activeElement!==L))return},[z,C]),G=p.useCallback(()=>K([N,S]),[K,N,S]);p.useEffect(()=>{H&&G()},[H,G]);const{onOpenChange:$,triggerPointerDownPosRef:A}=b;p.useEffect(()=>{if(S){let q={x:0,y:0};const M=ee=>{var L,F;q={x:Math.abs(Math.round(ee.pageX)-(((L=A.current)==null?void 0:L.x)??0)),y:Math.abs(Math.round(ee.pageY)-(((F=A.current)==null?void 0:F.y)??0))}},X=ee=>{q.x<=10&&q.y<=10?ee.preventDefault():S.contains(ee.target)||$(!1),document.removeEventListener("pointermove",M),A.current=null};return A.current!==null&&(document.addEventListener("pointermove",M),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",M),document.removeEventListener("pointerup",X,{capture:!0})}}},[S,$,A]),p.useEffect(()=>{const q=()=>$(!1);return window.addEventListener("blur",q),window.addEventListener("resize",q),()=>{window.removeEventListener("blur",q),window.removeEventListener("resize",q)}},[$]);const[D,U]=Yh(q=>{const M=z().filter(L=>!L.disabled),X=M.find(L=>L.ref.current===document.activeElement),ee=Xh(M,q,X);ee&&setTimeout(()=>ee.ref.current.focus())}),J=p.useCallback((q,M,X)=>{const ee=!W.current&&!X;(b.value!==void 0&&b.value===M||ee)&&(_(q),ee&&(W.current=!0))},[b.value]),Q=p.useCallback(()=>S==null?void 0:S.focus(),[S]),ce=p.useCallback((q,M,X)=>{const ee=!W.current&&!X;(b.value!==void 0&&b.value===M||ee)&&R(q)},[b.value]),we=r==="popper"?Sa:Ph,ke=we===Sa?{side:a,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:m,sticky:w,hideWhenDetached:v,avoidCollisions:g}:{};return l.jsx(jh,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:J,selectedItem:N,onItemLeave:Q,itemTextRefCallback:ce,focusSelectedItem:G,selectedItemText:j,position:r,isPositioned:H,searchRef:D,children:l.jsx($o,{as:LS,allowPinchZoom:!0,children:l.jsx(jo,{asChild:!0,trapped:b.open,onMountAutoFocus:q=>{q.preventDefault()},onUnmountAutoFocus:ae(o,q=>{var M;(M=b.trigger)==null||M.focus({preventScroll:!0}),q.preventDefault()}),children:l.jsx(_o,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:q=>q.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:l.jsx(we,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:q=>q.preventDefault(),...x,...ke,onPlaced:()=>O(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:ae(x.onKeyDown,q=>{const M=q.ctrlKey||q.altKey||q.metaKey;if(q.key==="Tab"&&q.preventDefault(),!M&&q.key.length===1&&U(q.key),["ArrowUp","ArrowDown","Home","End"].includes(q.key)){let ee=z().filter(L=>!L.disabled).map(L=>L.ref.current);if(["ArrowUp","End"].includes(q.key)&&(ee=ee.slice().reverse()),["ArrowUp","ArrowDown"].includes(q.key)){const L=q.target,F=ee.indexOf(L);ee=ee.slice(F+1)}setTimeout(()=>K(ee)),q.preventDefault()}})})})})})})});Rh.displayName=DS;var $S="SelectItemAlignedPosition",Ph=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=bn(zn,n),i=yn(zn,n),[a,c]=p.useState(null),[u,d]=p.useState(null),f=je(t,I=>d(I)),h=vs(n),m=p.useRef(!1),w=p.useRef(!0),{viewport:v,selectedItem:g,selectedItemText:x,focusSelectedItem:b}=i,S=p.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&v&&g&&x){const I=s.trigger.getBoundingClientRect(),N=u.getBoundingClientRect(),_=s.valueNode.getBoundingClientRect(),j=x.getBoundingClientRect();if(s.dir!=="rtl"){const L=j.left-N.left,F=_.left-L,me=I.left-F,Re=I.width+me,xe=Math.max(Re,N.width),_e=window.innerWidth-Wt,Be=ga(F,[Wt,Math.max(Wt,_e-xe)]);a.style.minWidth=Re+"px",a.style.left=Be+"px"}else{const L=N.right-j.right,F=window.innerWidth-_.right-L,me=window.innerWidth-I.right-F,Re=I.width+me,xe=Math.max(Re,N.width),_e=window.innerWidth-Wt,Be=ga(F,[Wt,Math.max(Wt,_e-xe)]);a.style.minWidth=Re+"px",a.style.right=Be+"px"}const R=h(),z=window.innerHeight-Wt*2,H=v.scrollHeight,O=window.getComputedStyle(u),W=parseInt(O.borderTopWidth,10),K=parseInt(O.paddingTop,10),G=parseInt(O.borderBottomWidth,10),$=parseInt(O.paddingBottom,10),A=W+K+H+$+G,D=Math.min(g.offsetHeight*5,A),U=window.getComputedStyle(v),J=parseInt(U.paddingTop,10),Q=parseInt(U.paddingBottom,10),ce=I.top+I.height/2-Wt,we=z-ce,ke=g.offsetHeight/2,q=g.offsetTop+ke,M=W+K+q,X=A-M;if(M<=ce){const L=R.length>0&&g===R[R.length-1].ref.current;a.style.bottom="0px";const F=u.clientHeight-v.offsetTop-v.offsetHeight,me=Math.max(we,ke+(L?Q:0)+F+G),Re=M+me;a.style.height=Re+"px"}else{const L=R.length>0&&g===R[0].ref.current;a.style.top="0px";const me=Math.max(ce,W+v.offsetTop+(L?J:0)+ke)+X;a.style.height=me+"px",v.scrollTop=M-ce+v.offsetTop}a.style.margin=`${Wt}px 0`,a.style.minHeight=D+"px",a.style.maxHeight=z+"px",r==null||r(),requestAnimationFrame(()=>m.current=!0)}},[h,s.trigger,s.valueNode,a,u,v,g,x,s.dir,r]);ct(()=>S(),[S]);const[k,C]=p.useState();ct(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const T=p.useCallback(I=>{I&&w.current===!0&&(S(),b==null||b(),w.current=!1)},[S,b]);return l.jsx(zS,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:m,onScrollButtonChange:T,children:l.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:l.jsx(ye.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Ph.displayName=$S;var FS="SelectPopperPosition",Sa=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Wt,...s}=e,i=ws(n);return l.jsx(Hd,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Sa.displayName=FS;var[zS,Ca]=sr(zn,{}),Ta="SelectViewport",Oh=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=yn(Ta,n),i=Ca(Ta,n),a=je(t,s.onViewportChange),c=p.useRef(0);return l.jsxs(l.Fragment,{children:[l.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),l.jsx(xs.Slot,{scope:n,children:l.jsx(ye.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ae(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const m=Math.abs(c.current-d.scrollTop);if(m>0){const w=window.innerHeight-Wt*2,v=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),x=Math.max(v,g);if(x<w){const b=x+m,S=Math.min(w,b),k=b-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,f.style.justifyContent="flex-end")}}}c.current=d.scrollTop})})})]})});Oh.displayName=Ta;var Mh="SelectGroup",[BS,HS]=sr(Mh),US=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Xt();return l.jsx(BS,{scope:n,id:o,children:l.jsx(ye.div,{role:"group","aria-labelledby":o,...r,ref:t})})});US.displayName=Mh;var Dh="SelectLabel",Lh=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=HS(Dh,n);return l.jsx(ye.div,{id:o.id,...r,ref:t})});Lh.displayName=Dh;var bs="SelectItem",[WS,$h]=sr(bs),Fh=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=bn(bs,n),c=yn(bs,n),u=a.value===r,[d,f]=p.useState(s??""),[h,m]=p.useState(!1),w=je(t,b=>{var S;return(S=c.itemRefCallback)==null?void 0:S.call(c,b,r,o)}),v=Xt(),g=p.useRef("touch"),x=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return l.jsx(WS,{scope:n,value:r,disabled:o,textId:v,isSelected:u,onItemTextChange:p.useCallback(b=>{f(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:l.jsx(xs.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:l.jsx(ye.div,{role:"option","aria-labelledby":v,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:w,onFocus:ae(i.onFocus,()=>m(!0)),onBlur:ae(i.onBlur,()=>m(!1)),onClick:ae(i.onClick,()=>{g.current!=="mouse"&&x()}),onPointerUp:ae(i.onPointerUp,()=>{g.current==="mouse"&&x()}),onPointerDown:ae(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:ae(i.onPointerMove,b=>{var S;g.current=b.pointerType,o?(S=c.onItemLeave)==null||S.call(c):g.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ae(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=c.onItemLeave)==null||S.call(c))}),onKeyDown:ae(i.onKeyDown,b=>{var k;((k=c.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(AS.includes(b.key)&&x(),b.key===" "&&b.preventDefault())})})})})});Fh.displayName=bs;var zr="SelectItemText",zh=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=bn(zr,n),a=yn(zr,n),c=$h(zr,n),u=PS(zr,n),[d,f]=p.useState(null),h=je(t,x=>f(x),c.onItemTextChange,x=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,x,c.value,c.disabled)}),m=d==null?void 0:d.textContent,w=p.useMemo(()=>l.jsx("option",{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:v,onNativeOptionRemove:g}=u;return ct(()=>(v(w),()=>g(w)),[v,g,w]),l.jsxs(l.Fragment,{children:[l.jsx(ye.span,{id:c.textId,...s,ref:h}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?qr.createPortal(s.children,i.valueNode):null]})});zh.displayName=zr;var Bh="SelectItemIndicator",Hh=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return $h(Bh,n).isSelected?l.jsx(ye.span,{"aria-hidden":!0,...r,ref:t}):null});Hh.displayName=Bh;var Ea="SelectScrollUpButton",Uh=p.forwardRef((e,t)=>{const n=yn(Ea,e.__scopeSelect),r=Ca(Ea,e.__scopeSelect),[o,s]=p.useState(!1),i=je(t,r.onScrollButtonChange);return ct(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollTop>0;s(u)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?l.jsx(Vh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop-c.offsetHeight)}}):null});Uh.displayName=Ea;var ka="SelectScrollDownButton",Wh=p.forwardRef((e,t)=>{const n=yn(ka,e.__scopeSelect),r=Ca(ka,e.__scopeSelect),[o,s]=p.useState(!1),i=je(t,r.onScrollButtonChange);return ct(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollHeight-c.clientHeight,d=Math.ceil(c.scrollTop)<u;s(d)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?l.jsx(Vh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop+c.offsetHeight)}}):null});Wh.displayName=ka;var Vh=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=yn("SelectScrollButton",n),i=p.useRef(null),a=vs(n),c=p.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return p.useEffect(()=>()=>c(),[c]),ct(()=>{var d;const u=a().find(f=>f.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),l.jsx(ye.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ae(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ae(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ae(o.onPointerLeave,()=>{c()})})}),VS="SelectSeparator",Kh=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return l.jsx(ye.div,{"aria-hidden":!0,...r,ref:t})});Kh.displayName=VS;var Ia="SelectArrow",KS=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ws(n),s=bn(Ia,n),i=yn(Ia,n);return s.open&&i.position==="popper"?l.jsx(Ud,{...o,...r,ref:t}):null});KS.displayName=Ia;var qS="SelectBubbleInput",qh=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),s=je(r,o),i=mh(t);return p.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),l.jsx(ye.select,{...n,style:{...Sh,...n.style},ref:s,defaultValue:t})});qh.displayName=qS;function Gh(e){return e===""||e===void 0}function Yh(e){const t=ut(e),n=p.useRef(""),r=p.useRef(0),o=p.useCallback(i=>{const a=n.current+i;t(a),function c(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>c(""),1e3))}(a)},[t]),s=p.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Xh(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=GS(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function GS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var YS=Ch,Jh=Eh,XS=Ih,JS=Nh,ZS=Ah,Zh=_h,QS=Oh,Qh=Lh,ep=Fh,eC=zh,tC=Hh,tp=Uh,np=Wh,rp=Kh;const op=YS,sp=XS,Na=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Jh,{ref:r,className:Z("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,l.jsx(JS,{asChild:!0,children:l.jsx(ne.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Na.displayName=Jh.displayName;const ip=p.forwardRef(({className:e,...t},n)=>l.jsx(tp,{ref:n,className:Z("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(ne.ChevronUp,{className:"h-4 w-4"})}));ip.displayName=tp.displayName;const ap=p.forwardRef(({className:e,...t},n)=>l.jsx(np,{ref:n,className:Z("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(ne.ChevronDown,{className:"h-4 w-4"})}));ap.displayName=np.displayName;const Aa=p.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>l.jsx(ZS,{children:l.jsxs(Zh,{ref:o,className:Z("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",n==="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",e),position:n,...r,children:[l.jsx(ip,{}),l.jsx(QS,{className:Z("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),l.jsx(ap,{})]})}));Aa.displayName=Zh.displayName;const nC=p.forwardRef(({className:e,...t},n)=>l.jsx(Qh,{ref:n,className:Z("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));nC.displayName=Qh.displayName;const Bn=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(ep,{ref:r,className:Z("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(tC,{children:l.jsx(ne.Check,{className:"h-4 w-4"})})}),l.jsx(eC,{children:t})]}));Bn.displayName=ep.displayName;const rC=p.forwardRef(({className:e,...t},n)=>l.jsx(rp,{ref:n,className:Z("-mx-1 my-1 h-px bg-muted",e),...t}));rC.displayName=rp.displayName;var oC="Separator",lp="horizontal",sC=["horizontal","vertical"],cp=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=lp,...o}=e,s=iC(r)?r:lp,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return l.jsx(ye.div,{"data-orientation":s,...a,...o,ref:t})});cp.displayName=oC;function iC(e){return sC.includes(e)}var up=cp;const dp=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>l.jsx(up,{ref:o,decorative:n,orientation:t,className:Z("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));dp.displayName=up.displayName;const aC=Yu,lC=Bw,cC=Xu,fp=p.forwardRef(({className:e,...t},n)=>l.jsx(Uo,{className:Z("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));fp.displayName=Uo.displayName;const uC=Kr.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),hp=p.forwardRef(({side:e="right",className:t,children:n,...r},o)=>l.jsxs(cC,{children:[l.jsx(fp,{}),l.jsxs(Wo,{ref:o,className:Z(uC({side:e}),t),...r,children:[n,l.jsxs(Ju,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[l.jsx(ne.X,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));hp.displayName=Wo.displayName;const pp=({className:e,...t})=>l.jsx("div",{className:Z("flex flex-col space-y-2 text-center sm:text-left",e),...t});pp.displayName="SheetHeader";const mp=p.forwardRef(({className:e,...t},n)=>l.jsx(On,{ref:n,className:Z("text-lg font-semibold text-foreground",e),...t}));mp.displayName=On.displayName;const gp=p.forwardRef(({className:e,...t},n)=>l.jsx(Vo,{ref:n,className:Z("text-sm text-muted-foreground",e),...t}));gp.displayName=Vo.displayName;const dC={api:{baseUrl:"http://localhost:8000/api",authToken:"",enableAuth:!1},ui:{layout:"sidebar",theme:"light",showTimestamps:!0,showAgentNames:!0,compactMessages:!1},behavior:{autoSave:!0,enableStreaming:!0,showTypingIndicator:!0}};function fC({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=y.useState(!1),[s,i]=y.useState(!1),[a,c]=y.useState(e),[u,d]=y.useState(!1),{toast:f}=Ii();y.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),y.useEffect(()=>{c(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},m=()=>{c(dC),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},w=()=>{c(e),d(!1),o(!1)},v=async()=>{try{const x=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${x.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return l.jsxs(aC,{open:r,onOpenChange:o,children:[l.jsx(lC,{asChild:!0,children:l.jsxs(Le,{variant:"outline",size:"sm",className:n,children:[l.jsx(ne.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&l.jsx(xi,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),l.jsxs(hp,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[l.jsxs(pp,{children:[l.jsx(mp,{children:"Chat Settings"}),l.jsx(gp,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),l.jsxs("div",{className:"space-y-6 py-6",children:[l.jsxs(kr,{children:[l.jsx(Ir,{className:"pb-3",children:l.jsxs(Nr,{className:"text-lg flex items-center gap-2",children:[l.jsx(ne.Server,{className:"h-5 w-5"}),"API Configuration"]})}),l.jsxs(Co,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(Mt,{htmlFor:"api-url",children:"API Base URL"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(ds,{id:"api-url",value:a.api.baseUrl,onChange:g=>c(x=>({...x,api:{...x.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),l.jsx(Le,{variant:"outline",onClick:v,children:"Test"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Mt,{htmlFor:"enable-auth",children:"Enable Authentication"}),l.jsx(wn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>c(x=>({...x,api:{...x.api,enableAuth:g}}))})]}),a.api.enableAuth&&l.jsxs("div",{className:"space-y-2",children:[l.jsx(Mt,{htmlFor:"auth-token",children:"Authentication Token"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(ds,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>c(x=>({...x,api:{...x.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),l.jsx(Le,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?l.jsx(ne.EyeOff,{className:"h-4 w-4"}):l.jsx(ne.Eye,{className:"h-4 w-4"})})]})]})]})]}),l.jsxs(kr,{children:[l.jsx(Ir,{className:"pb-3",children:l.jsxs(Nr,{className:"text-lg flex items-center gap-2",children:[l.jsx(ne.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),l.jsxs(Co,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(Mt,{htmlFor:"layout",children:"Layout Style"}),l.jsxs(op,{value:a.ui.layout,onValueChange:g=>c(x=>({...x,ui:{...x.ui,layout:g}})),children:[l.jsx(Na,{children:l.jsx(sp,{})}),l.jsxs(Aa,{children:[l.jsx(Bn,{value:"sidebar",children:"Sidebar Layout"}),l.jsx(Bn,{value:"fullscreen",children:"Fullscreen"}),l.jsx(Bn,{value:"tabs",children:"Tabbed Interface"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(Mt,{htmlFor:"theme",children:"Theme"}),l.jsxs(op,{value:a.ui.theme,onValueChange:g=>c(x=>({...x,ui:{...x.ui,theme:g}})),children:[l.jsx(Na,{children:l.jsx(sp,{})}),l.jsxs(Aa,{children:[l.jsx(Bn,{value:"light",children:"Light"}),l.jsx(Bn,{value:"dark",children:"Dark"}),l.jsx(Bn,{value:"system",children:"System"})]})]})]}),l.jsx(dp,{}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Mt,{htmlFor:"show-timestamps",children:"Show Timestamps"}),l.jsx(wn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,showTimestamps:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Mt,{htmlFor:"show-agent-names",children:"Show Agent Names"}),l.jsx(wn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,showAgentNames:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Mt,{htmlFor:"compact-messages",children:"Compact Messages"}),l.jsx(wn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,compactMessages:g}}))})]})]})]})]}),l.jsxs(kr,{children:[l.jsx(Ir,{className:"pb-3",children:l.jsxs(Nr,{className:"text-lg flex items-center gap-2",children:[l.jsx(ne.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),l.jsxs(Co,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(Mt,{htmlFor:"auto-save",children:"Auto-save Conversations"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),l.jsx(wn,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,autoSave:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(Mt,{htmlFor:"enable-streaming",children:"Enable Streaming"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),l.jsx(wn,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,enableStreaming:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(Mt,{htmlFor:"typing-indicator",children:"Typing Indicator"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),l.jsx(wn,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,showTypingIndicator:g}}))})]})]})]})]}),l.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[l.jsxs(Le,{variant:"outline",onClick:m,children:[l.jsx(ne.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Le,{variant:"outline",onClick:w,children:"Cancel"}),l.jsxs(Le,{onClick:h,disabled:!u,children:[l.jsx(ne.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function hC({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),c=y.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?l.jsx(io,{...s,onThreadChange:c,children:l.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:l.jsx(us,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?l.jsx(io,{...s,onThreadChange:c,children:l.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:l.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&l.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:l.jsx(ya,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),l.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:l.jsx(us,{onError:s.onError,enableFileUpload:!0})})]})})}):l.jsx(io,{...s,onThreadChange:c,children:l.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&l.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:l.jsx(ya,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),l.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:l.jsx(us,{onError:s.onError,enableFileUpload:!0})})]})})}Ce.ChatApi=_l,Ce.ChatInterface=us,Ce.ChatProviders=io,Ce.ChatSettings=fC,Ce.MarkdownContent=Ti,Ce.MessageComponent=id,Ce.MessageList=Ui,Ce.ThreadManager=ya,Ce.applySettings=vS,Ce.chatApiClient=cn,Ce.default=hC,Ce.del=Al,Ce.get=St,Ce.getChatToken=kl,Ce.getCurrentSettings=xS,Ce.getDefaultApiConfig=uh,Ce.getDefaultChatSettings=dh,Ce.onChatTokenChanged=Il,Ce.post=Us,Ce.put=Nl,Ce.setChatToken=Hs,Ce.useApi=so,Ce.useChatStream=$l,Ce.useMessages=qs,Ce.useMessagesReducer=Dl,Ce.useStream=Ol,Ce.useThreads=mr,Object.defineProperties(Ce,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
139
+ `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function ib(e,t=qo){if(!e||typeof e!="string")throw new Error("Invalid content: must be a non-empty string");if(e.length>t)throw new Error(`Message exceeds maximum length of ${t} characters`);return e}function ab(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),ib(t),sb(t)}function Wi(e){const t=e+"CollectionProvider",[n,r]=Yt(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=v=>{const{scope:g,children:x}=v,b=y.useRef(null),S=y.useRef(new Map).current;return l.jsx(o,{scope:g,itemMap:S,collectionRef:b,children:x})};i.displayName=t;const a=e+"CollectionSlot",c=Cn.createSlot(a),u=y.forwardRef((v,g)=>{const{scope:x,children:b}=v,S=s(a,x),k=Pe(g,S.collectionRef);return l.jsx(c,{ref:k,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=Cn.createSlot(d),m=y.forwardRef((v,g)=>{const{scope:x,children:b,...S}=v,k=y.useRef(null),C=Pe(g,k),T=s(d,x);return y.useEffect(()=>(T.itemMap.set(k,{ref:k,...S}),()=>void T.itemMap.delete(k))),l.jsx(h,{[f]:"",ref:C,children:b})});m.displayName=d;function w(v){const g=s(e+"CollectionConsumer",v);return y.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const S=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((T,I)=>S.indexOf(T.ref.current)-S.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:m},w,r]}var lb=p.createContext(void 0);function Go(e){const t=p.useContext(lb);return e||t||"ltr"}const cb=["top","right","bottom","left"],xn=Math.min,It=Math.max,Yo=Math.round,Xo=Math.floor,Zt=e=>({x:e,y:e}),ub={left:"right",right:"left",bottom:"top",top:"bottom"},db={start:"end",end:"start"};function Vi(e,t,n){return It(e,xn(t,n))}function sn(e,t){return typeof e=="function"?e(t):e}function an(e){return e.split("-")[0]}function Qn(e){return e.split("-")[1]}function Ki(e){return e==="x"?"y":"x"}function qi(e){return e==="y"?"height":"width"}const fb=new Set(["top","bottom"]);function Qt(e){return fb.has(an(e))?"y":"x"}function Gi(e){return Ki(Qt(e))}function hb(e,t,n){n===void 0&&(n=!1);const r=Qn(e),o=Gi(e),s=qi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Jo(i)),[i,Jo(i)]}function pb(e){const t=Jo(e);return[Yi(e),t,Yi(t)]}function Yi(e){return e.replace(/start|end/g,t=>db[t])}const cd=["left","right"],ud=["right","left"],mb=["top","bottom"],gb=["bottom","top"];function xb(e,t,n){switch(e){case"top":case"bottom":return n?t?ud:cd:t?cd:ud;case"left":case"right":return t?mb:gb;default:return[]}}function vb(e,t,n,r){const o=Qn(e);let s=xb(an(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Yi)))),s}function Jo(e){return e.replace(/left|right|bottom|top/g,t=>ub[t])}function wb(e){return{top:0,right:0,bottom:0,left:0,...e}}function dd(e){return typeof e!="number"?wb(e):{top:e,right:e,bottom:e,left:e}}function Zo(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function fd(e,t,n){let{reference:r,floating:o}=e;const s=Qt(t),i=Gi(t),a=qi(i),c=an(t),u=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let m;switch(c){case"top":m={x:d,y:r.y-o.height};break;case"bottom":m={x:d,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-o.width,y:f};break;default:m={x:r.x,y:r.y}}switch(Qn(t)){case"start":m[i]-=h*(n&&u?-1:1);break;case"end":m[i]+=h*(n&&u?-1:1);break}return m}const bb=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=fd(u,r,c),h=r,m={},w=0;for(let v=0;v<a.length;v++){const{name:g,fn:x}=a[v],{x:b,y:S,data:k,reset:C}=await x({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:m,rects:u,platform:i,elements:{reference:e,floating:t}});d=b??d,f=S??f,m={...m,[g]:{...m[g],...k}},C&&w<=50&&(w++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=fd(u,h,c)),v=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:m}};async function jr(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:m=0}=sn(t,e),w=dd(m),g=a[h?f==="floating"?"reference":"floating":f],x=Zo(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:c})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=Zo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:c}):b);return{top:(x.top-C.top+w.top)/k.y,bottom:(C.bottom-x.bottom+w.bottom)/k.y,left:(x.left-C.left+w.left)/k.x,right:(C.right-x.right+w.right)/k.x}}const yb=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:c}=t,{element:u,padding:d=0}=sn(e,t)||{};if(u==null)return{};const f=dd(d),h={x:n,y:r},m=Gi(o),w=qi(m),v=await i.getDimensions(u),g=m==="y",x=g?"top":"left",b=g?"bottom":"right",S=g?"clientHeight":"clientWidth",k=s.reference[w]+s.reference[m]-h[m]-s.floating[w],C=h[m]-s.reference[m],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let I=T?T[S]:0;(!I||!await(i.isElement==null?void 0:i.isElement(T)))&&(I=a.floating[S]||s.floating[w]);const N=k/2-C/2,_=I/2-v[w]/2-1,j=xn(f[x],_),R=xn(f[b],_),$=j,z=I-v[w]-R,O=I/2-v[w]/2+N,W=Vi($,O,z),B=!c.arrow&&Qn(o)!=null&&O!==W&&s.reference[w]/2-(O<$?j:R)-v[w]/2<0,q=B?O<$?O-$:O-z:0;return{[m]:h[m]+q,data:{[m]:W,centerOffset:O-W-q,...B&&{alignmentOffset:q}},reset:B}}}),Sb=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:c,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:v=!0,...g}=sn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=an(o),b=Qt(a),S=an(a)===a,k=await(c.isRTL==null?void 0:c.isRTL(u.floating)),C=h||(S||!v?[Jo(a)]:pb(a)),T=w!=="none";!h&&T&&C.push(...vb(a,v,w,k));const I=[a,...C],N=await jr(t,g),_=[];let j=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&_.push(N[x]),f){const O=hb(o,i,k);_.push(N[O[0]],N[O[1]])}if(j=[...j,{placement:o,overflows:_}],!_.every(O=>O<=0)){var R,$;const O=(((R=s.flip)==null?void 0:R.index)||0)+1,W=I[O];if(W&&(!(f==="alignment"?b!==Qt(W):!1)||j.every(L=>Qt(L.placement)===b?L.overflows[0]>0:!0)))return{data:{index:O,overflows:j},reset:{placement:W}};let B=($=j.filter(q=>q.overflows[0]<=0).sort((q,L)=>q.overflows[1]-L.overflows[1])[0])==null?void 0:$.placement;if(!B)switch(m){case"bestFit":{var z;const q=(z=j.filter(L=>{if(T){const A=Qt(L.placement);return A===b||A==="y"}return!0}).map(L=>[L.placement,L.overflows.filter(A=>A>0).reduce((A,D)=>A+D,0)]).sort((L,A)=>L[1]-A[1])[0])==null?void 0:z[0];q&&(B=q);break}case"initialPlacement":B=a;break}if(o!==B)return{reset:{placement:B}}}return{}}}};function hd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function pd(e){return cb.some(t=>e[t]>=0)}const Cb=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=sn(e,t);switch(r){case"referenceHidden":{const s=await jr(t,{...o,elementContext:"reference"}),i=hd(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:pd(i)}}}case"escaped":{const s=await jr(t,{...o,altBoundary:!0}),i=hd(s,n.floating);return{data:{escapedOffsets:i,escaped:pd(i)}}}default:return{}}}}},md=new Set(["left","top"]);async function Tb(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=an(n),a=Qn(n),c=Qt(n)==="y",u=md.has(i)?-1:1,d=s&&c?-1:1,f=sn(t,e);let{mainAxis:h,crossAxis:m,alignmentAxis:w}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof w=="number"&&(m=a==="end"?w*-1:w),c?{x:m*d,y:h*u}:{x:h*u,y:m*d}}const Eb=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,c=await Tb(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:i}}}}},kb=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x,y:b}=g;return{x,y:b}}},...c}=sn(e,t),u={x:n,y:r},d=await jr(t,c),f=Qt(an(o)),h=Ki(f);let m=u[h],w=u[f];if(s){const g=h==="y"?"top":"left",x=h==="y"?"bottom":"right",b=m+d[g],S=m-d[x];m=Vi(b,m,S)}if(i){const g=f==="y"?"top":"left",x=f==="y"?"bottom":"right",b=w+d[g],S=w-d[x];w=Vi(b,w,S)}const v=a.fn({...t,[h]:m,[f]:w});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[h]:s,[f]:i}}}}}},Ib=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:c=!0,crossAxis:u=!0}=sn(e,t),d={x:n,y:r},f=Qt(o),h=Ki(f);let m=d[h],w=d[f];const v=sn(a,t),g=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(c){const S=h==="y"?"height":"width",k=s.reference[h]-s.floating[S]+g.mainAxis,C=s.reference[h]+s.reference[S]-g.mainAxis;m<k?m=k:m>C&&(m=C)}if(u){var x,b;const S=h==="y"?"width":"height",k=md.has(an(o)),C=s.reference[f]-s.floating[S]+(k&&((x=i.offset)==null?void 0:x[f])||0)+(k?0:g.crossAxis),T=s.reference[f]+s.reference[S]+(k?0:((b=i.offset)==null?void 0:b[f])||0)-(k?g.crossAxis:0);w<C?w=C:w>T&&(w=T)}return{[h]:m,[f]:w}}}},Nb=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:c=()=>{},...u}=sn(e,t),d=await jr(t,u),f=an(o),h=Qn(o),m=Qt(o)==="y",{width:w,height:v}=s.floating;let g,x;f==="top"||f==="bottom"?(g=f,x=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=f,g=h==="end"?"top":"bottom");const b=v-d.top-d.bottom,S=w-d.left-d.right,k=xn(v-d[g],b),C=xn(w-d[x],S),T=!t.middlewareData.shift;let I=k,N=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=b),T&&!h){const j=It(d.left,0),R=It(d.right,0),$=It(d.top,0),z=It(d.bottom,0);m?N=w-2*(j!==0||R!==0?j+R:It(d.left,d.right)):I=v-2*($!==0||z!==0?$+z:It(d.top,d.bottom))}await c({...t,availableWidth:N,availableHeight:I});const _=await i.getDimensions(a.floating);return w!==_.width||v!==_.height?{reset:{rects:!0}}:{}}}};function Qo(){return typeof window<"u"}function er(e){return gd(e)?(e.nodeName||"").toLowerCase():"#document"}function Nt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function en(e){var t;return(t=(gd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function gd(e){return Qo()?e instanceof Node||e instanceof Nt(e).Node:!1}function Ht(e){return Qo()?e instanceof Element||e instanceof Nt(e).Element:!1}function tn(e){return Qo()?e instanceof HTMLElement||e instanceof Nt(e).HTMLElement:!1}function xd(e){return!Qo()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Nt(e).ShadowRoot}const Ab=new Set(["inline","contents"]);function Rr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Ut(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Ab.has(o)}const _b=new Set(["table","td","th"]);function jb(e){return _b.has(er(e))}const Rb=[":popover-open",":modal"];function es(e){return Rb.some(t=>{try{return e.matches(t)}catch{return!1}})}const Pb=["transform","translate","scale","rotate","perspective"],Ob=["transform","translate","scale","rotate","perspective","filter"],Mb=["paint","layout","strict","content"];function Xi(e){const t=Ji(),n=Ht(e)?Ut(e):e;return Pb.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||Ob.some(r=>(n.willChange||"").includes(r))||Mb.some(r=>(n.contain||"").includes(r))}function Db(e){let t=vn(e);for(;tn(t)&&!tr(t);){if(Xi(t))return t;if(es(t))return null;t=vn(t)}return null}function Ji(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Lb=new Set(["html","body","#document"]);function tr(e){return Lb.has(er(e))}function Ut(e){return Nt(e).getComputedStyle(e)}function ts(e){return Ht(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function vn(e){if(er(e)==="html")return e;const t=e.assignedSlot||e.parentNode||xd(e)&&e.host||en(e);return xd(t)?t.host:t}function vd(e){const t=vn(e);return tr(t)?e.ownerDocument?e.ownerDocument.body:e.body:tn(t)&&Rr(t)?t:vd(t)}function Pr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=vd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Nt(o);if(s){const a=Zi(i);return t.concat(i,i.visualViewport||[],Rr(o)?o:[],a&&n?Pr(a):[])}return t.concat(o,Pr(o,[],n))}function Zi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function wd(e){const t=Ut(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=tn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Yo(n)!==s||Yo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Qi(e){return Ht(e)?e:e.contextElement}function nr(e){const t=Qi(e);if(!tn(t))return Zt(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=wd(t);let i=(s?Yo(n.width):n.width)/r,a=(s?Yo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const $b=Zt(0);function bd(e){const t=Nt(e);return!Ji()||!t.visualViewport?$b:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Fb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Nt(e)?!1:t}function Dn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Qi(e);let i=Zt(1);t&&(r?Ht(r)&&(i=nr(r)):i=nr(e));const a=Fb(s,n,r)?bd(s):Zt(0);let c=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=Nt(s),m=r&&Ht(r)?Nt(r):r;let w=h,v=Zi(w);for(;v&&r&&m!==w;){const g=nr(v),x=v.getBoundingClientRect(),b=Ut(v),S=x.left+(v.clientLeft+parseFloat(b.paddingLeft))*g.x,k=x.top+(v.clientTop+parseFloat(b.paddingTop))*g.y;c*=g.x,u*=g.y,d*=g.x,f*=g.y,c+=S,u+=k,w=Nt(v),v=Zi(w)}}return Zo({width:d,height:f,x:c,y:u})}function ea(e,t){const n=ts(e).scrollLeft;return t?t.left+n:Dn(en(e)).left+n}function yd(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:ea(e,r)),s=r.top+t.scrollTop;return{x:o,y:s}}function zb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=en(r),a=t?es(t.floating):!1;if(r===i||a&&s)return n;let c={scrollLeft:0,scrollTop:0},u=Zt(1);const d=Zt(0),f=tn(r);if((f||!f&&!s)&&((er(r)!=="body"||Rr(i))&&(c=ts(r)),tn(r))){const m=Dn(r);u=nr(r),d.x=m.x+r.clientLeft,d.y=m.y+r.clientTop}const h=i&&!f&&!s?yd(i,c,!0):Zt(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-c.scrollTop*u.y+d.y+h.y}}function Bb(e){return Array.from(e.getClientRects())}function Hb(e){const t=en(e),n=ts(e),r=e.ownerDocument.body,o=It(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=It(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ea(e);const a=-n.scrollTop;return Ut(r).direction==="rtl"&&(i+=It(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function Ub(e,t){const n=Nt(e),r=en(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,c=0;if(o){s=o.width,i=o.height;const u=Ji();(!u||u&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}return{width:s,height:i,x:a,y:c}}const Wb=new Set(["absolute","fixed"]);function Vb(e,t){const n=Dn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=tn(e)?nr(e):Zt(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,c=o*s.x,u=r*s.y;return{width:i,height:a,x:c,y:u}}function Sd(e,t,n){let r;if(t==="viewport")r=Ub(e,n);else if(t==="document")r=Hb(en(e));else if(Ht(t))r=Vb(t,n);else{const o=bd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Zo(r)}function Cd(e,t){const n=vn(e);return n===t||!Ht(n)||tr(n)?!1:Ut(n).position==="fixed"||Cd(n,t)}function Kb(e,t){const n=t.get(e);if(n)return n;let r=Pr(e,[],!1).filter(a=>Ht(a)&&er(a)!=="body"),o=null;const s=Ut(e).position==="fixed";let i=s?vn(e):e;for(;Ht(i)&&!tr(i);){const a=Ut(i),c=Xi(i);!c&&a.position==="fixed"&&(o=null),(s?!c&&!o:!c&&a.position==="static"&&!!o&&Wb.has(o.position)||Rr(i)&&!c&&Cd(e,i))?r=r.filter(d=>d!==i):o=a,i=vn(i)}return t.set(e,r),r}function qb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?es(t)?[]:Kb(t,this._c):[].concat(n),r],a=i[0],c=i.reduce((u,d)=>{const f=Sd(t,d,o);return u.top=It(f.top,u.top),u.right=xn(f.right,u.right),u.bottom=xn(f.bottom,u.bottom),u.left=It(f.left,u.left),u},Sd(t,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Gb(e){const{width:t,height:n}=wd(e);return{width:t,height:n}}function Yb(e,t,n){const r=tn(t),o=en(t),s=n==="fixed",i=Dn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const c=Zt(0);function u(){c.x=ea(o)}if(r||!r&&!s)if((er(t)!=="body"||Rr(o))&&(a=ts(t)),r){const m=Dn(t,!0,s,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?yd(o,a):Zt(0),f=i.left+a.scrollLeft-c.x-d.x,h=i.top+a.scrollTop-c.y-d.y;return{x:f,y:h,width:i.width,height:i.height}}function ta(e){return Ut(e).position==="static"}function Td(e,t){if(!tn(e)||Ut(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return en(e)===n&&(n=n.ownerDocument.body),n}function Ed(e,t){const n=Nt(e);if(es(e))return n;if(!tn(e)){let o=vn(e);for(;o&&!tr(o);){if(Ht(o)&&!ta(o))return o;o=vn(o)}return n}let r=Td(e,t);for(;r&&jb(r)&&ta(r);)r=Td(r,t);return r&&tr(r)&&ta(r)&&!Xi(r)?n:r||Db(e)||n}const Xb=async function(e){const t=this.getOffsetParent||Ed,n=this.getDimensions,r=await n(e.floating);return{reference:Yb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Jb(e){return Ut(e).direction==="rtl"}const Zb={convertOffsetParentRelativeRectToViewportRelativeRect:zb,getDocumentElement:en,getClippingRect:qb,getOffsetParent:Ed,getElementRects:Xb,getClientRects:Bb,getDimensions:Gb,getScale:nr,isElement:Ht,isRTL:Jb};function kd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Qb(e,t){let n=null,r;const o=en(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:m}=u;if(a||t(),!h||!m)return;const w=Xo(f),v=Xo(o.clientWidth-(d+h)),g=Xo(o.clientHeight-(f+m)),x=Xo(d),S={rootMargin:-w+"px "+-v+"px "+-g+"px "+-x+"px",threshold:It(0,xn(1,c))||1};let k=!0;function C(T){const I=T[0].intersectionRatio;if(I!==c){if(!k)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!kd(u,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function ey(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=Qi(e),d=o||s?[...u?Pr(u):[],...Pr(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const f=u&&a?Qb(u,n):null;let h=-1,m=null;i&&(m=new ResizeObserver(x=>{let[b]=x;b&&b.target===u&&m&&(m.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=m)==null||S.observe(t)})),n()}),u&&!c&&m.observe(u),m.observe(t));let w,v=c?Dn(e):null;c&&g();function g(){const x=Dn(e);v&&!kd(v,x)&&n(),v=x,w=requestAnimationFrame(g)}return n(),()=>{var x;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(x=m)==null||x.disconnect(),m=null,c&&cancelAnimationFrame(w)}}const ty=Eb,ny=kb,ry=Sb,oy=Nb,sy=Cb,Id=yb,iy=Ib,ay=(e,t,n)=>{const r=new Map,o={platform:Zb,...n},s={...o.platform,_c:r};return bb(e,t,{...o,platform:s})};var ly=typeof document<"u",cy=function(){},ns=ly?y.useLayoutEffect:cy;function rs(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!rs(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!rs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Nd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ad(e,t){const n=Nd(e);return Math.round(t*n)/n}function na(e){const t=p.useRef(e);return ns(()=>{t.current=e}),t}function uy(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:c,open:u}=e,[d,f]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,m]=p.useState(r);rs(h,r)||m(r);const[w,v]=p.useState(null),[g,x]=p.useState(null),b=p.useCallback(L=>{L!==T.current&&(T.current=L,v(L))},[]),S=p.useCallback(L=>{L!==I.current&&(I.current=L,x(L))},[]),k=s||w,C=i||g,T=p.useRef(null),I=p.useRef(null),N=p.useRef(d),_=c!=null,j=na(c),R=na(o),$=na(u),z=p.useCallback(()=>{if(!T.current||!I.current)return;const L={placement:t,strategy:n,middleware:h};R.current&&(L.platform=R.current),ay(T.current,I.current,L).then(A=>{const D={...A,isPositioned:$.current!==!1};O.current&&!rs(N.current,D)&&(N.current=D,qr.flushSync(()=>{f(D)}))})},[h,t,n,R,$]);ns(()=>{u===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,f(L=>({...L,isPositioned:!1})))},[u]);const O=p.useRef(!1);ns(()=>(O.current=!0,()=>{O.current=!1}),[]),ns(()=>{if(k&&(T.current=k),C&&(I.current=C),k&&C){if(j.current)return j.current(k,C,z);z()}},[k,C,z,j,_]);const W=p.useMemo(()=>({reference:T,floating:I,setReference:b,setFloating:S}),[b,S]),B=p.useMemo(()=>({reference:k,floating:C}),[k,C]),q=p.useMemo(()=>{const L={position:n,left:0,top:0};if(!B.floating)return L;const A=Ad(B.floating,d.x),D=Ad(B.floating,d.y);return a?{...L,transform:"translate("+A+"px, "+D+"px)",...Nd(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:A,top:D}},[n,a,B.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:z,refs:W,elements:B,floatingStyles:q}),[d,z,W,B,q])}const dy=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Id({element:r.current,padding:o}).fn(n):{}:r?Id({element:r,padding:o}).fn(n):{}}}},fy=(e,t)=>({...ty(e),options:[e,t]}),hy=(e,t)=>({...ny(e),options:[e,t]}),py=(e,t)=>({...iy(e),options:[e,t]}),my=(e,t)=>({...ry(e),options:[e,t]}),gy=(e,t)=>({...oy(e),options:[e,t]}),xy=(e,t)=>({...sy(e),options:[e,t]}),vy=(e,t)=>({...dy(e),options:[e,t]});var wy="Arrow",_d=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return l.jsx(Se.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:l.jsx("polygon",{points:"0,0 30,0 15,10"})})});_d.displayName=wy;var by=_d;function jd(e){const[t,n]=p.useState(void 0);return ct(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const c=s.borderBoxSize,u=Array.isArray(c)?c[0]:c;i=u.inlineSize,a=u.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var ra="Popper",[Rd,os]=Yt(ra),[yy,Pd]=Rd(ra),Od=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return l.jsx(yy,{scope:t,anchor:r,onAnchorChange:o,children:n})};Od.displayName=ra;var Md="PopperAnchor",Dd=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Pd(Md,n),i=p.useRef(null),a=Pe(t,i),c=p.useRef(null);return p.useEffect(()=>{const u=c.current;c.current=(r==null?void 0:r.current)||i.current,u!==c.current&&s.onAnchorChange(c.current)}),r?null:l.jsx(Se.div,{...o,ref:a})});Dd.displayName=Md;var oa="PopperContent",[Sy,Cy]=Rd(oa),Ld=p.forwardRef((e,t)=>{var K,M,Y,ee,de,ce;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:m="optimized",onPlaced:w,...v}=e,g=Pd(oa,n),[x,b]=p.useState(null),S=Pe(t,ze=>b(ze)),[k,C]=p.useState(null),T=jd(k),I=(T==null?void 0:T.width)??0,N=(T==null?void 0:T.height)??0,_=r+(s!=="center"?"-"+s:""),j=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},R=Array.isArray(u)?u:[u],$=R.length>0,z={padding:j,boundary:R.filter(Ey),altBoundary:$},{refs:O,floatingStyles:W,placement:B,isPositioned:q,middlewareData:L}=uy({strategy:"fixed",placement:_,whileElementsMounted:(...ze)=>ey(...ze,{animationFrame:m==="always"}),elements:{reference:g.anchor},middleware:[fy({mainAxis:o+N,alignmentAxis:i}),c&&hy({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?py():void 0,...z}),c&&my({...z}),gy({...z,apply:({elements:ze,rects:Ye,availableWidth:V,availableHeight:J})=>{const{width:be,height:Oe}=Ye.reference,_e=ze.floating.style;_e.setProperty("--radix-popper-available-width",`${V}px`),_e.setProperty("--radix-popper-available-height",`${J}px`),_e.setProperty("--radix-popper-anchor-width",`${be}px`),_e.setProperty("--radix-popper-anchor-height",`${Oe}px`)}}),k&&vy({element:k,padding:a}),ky({arrowWidth:I,arrowHeight:N}),h&&xy({strategy:"referenceHidden",...z})]}),[A,D]=zd(B),H=ut(w);ct(()=>{q&&(H==null||H())},[q,H]);const X=(K=L.arrow)==null?void 0:K.x,Q=(M=L.arrow)==null?void 0:M.y,ue=((Y=L.arrow)==null?void 0:Y.centerOffset)!==0,[we,Ie]=p.useState();return ct(()=>{x&&Ie(window.getComputedStyle(x).zIndex)},[x]),l.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:q?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:we,"--radix-popper-transform-origin":[(ee=L.transformOrigin)==null?void 0:ee.x,(de=L.transformOrigin)==null?void 0:de.y].join(" "),...((ce=L.hide)==null?void 0:ce.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:l.jsx(Sy,{scope:n,placedSide:A,onArrowChange:C,arrowX:X,arrowY:Q,shouldHideArrow:ue,children:l.jsx(Se.div,{"data-side":A,"data-align":D,...v,ref:S,style:{...v.style,animation:q?void 0:"none"}})})})});Ld.displayName=oa;var $d="PopperArrow",Ty={top:"bottom",right:"left",bottom:"top",left:"right"},Fd=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Cy($d,r),i=Ty[s.placedSide];return l.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:l.jsx(by,{...o,ref:n,style:{...o.style,display:"block"}})})});Fd.displayName=$d;function Ey(e){return e!==null}var ky=e=>({name:"transformOrigin",options:e,fn(t){var g,x,b;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,d]=zd(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((x=o.arrow)==null?void 0:x.x)??0)+a/2,m=(((b=o.arrow)==null?void 0:b.y)??0)+c/2;let w="",v="";return u==="bottom"?(w=i?f:`${h}px`,v=`${-c}px`):u==="top"?(w=i?f:`${h}px`,v=`${r.floating.height+c}px`):u==="right"?(w=`${-c}px`,v=i?f:`${m}px`):u==="left"&&(w=`${r.floating.width+c}px`,v=i?f:`${m}px`),{data:{x:w,y:v}}}});function zd(e){const[t,n="center"]=e.split("-");return[t,n]}var Bd=Od,Hd=Dd,Ud=Ld,Wd=Fd,sa="rovingFocusGroup.onEntryFocus",Iy={bubbles:!1,cancelable:!0},Or="RovingFocusGroup",[ia,Vd,Ny]=Wi(Or),[Ay,Kd]=Yt(Or,[Ny]),[_y,jy]=Ay(Or),qd=p.forwardRef((e,t)=>l.jsx(ia.Provider,{scope:e.__scopeRovingFocusGroup,children:l.jsx(ia.Slot,{scope:e.__scopeRovingFocusGroup,children:l.jsx(Ry,{...e,ref:t})})}));qd.displayName=Or;var Ry=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=p.useRef(null),m=Pe(t,h),w=Go(s),[v,g]=jn({prop:i,defaultProp:a??null,onChange:c,caller:Or}),[x,b]=p.useState(!1),S=ut(u),k=Vd(n),C=p.useRef(!1),[T,I]=p.useState(0);return p.useEffect(()=>{const N=h.current;if(N)return N.addEventListener(sa,S),()=>N.removeEventListener(sa,S)},[S]),l.jsx(_y,{scope:n,orientation:r,dir:w,loop:o,currentTabStopId:v,onItemFocus:p.useCallback(N=>g(N),[g]),onItemShiftTab:p.useCallback(()=>b(!0),[]),onFocusableItemAdd:p.useCallback(()=>I(N=>N+1),[]),onFocusableItemRemove:p.useCallback(()=>I(N=>N-1),[]),children:l.jsx(Se.div,{tabIndex:x||T===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:se(e.onMouseDown,()=>{C.current=!0}),onFocus:se(e.onFocus,N=>{const _=!C.current;if(N.target===N.currentTarget&&_&&!x){const j=new CustomEvent(sa,Iy);if(N.currentTarget.dispatchEvent(j),!j.defaultPrevented){const R=k().filter(B=>B.focusable),$=R.find(B=>B.active),z=R.find(B=>B.id===v),W=[$,z,...R].filter(Boolean).map(B=>B.ref.current);Xd(W,d)}}C.current=!1}),onBlur:se(e.onBlur,()=>b(!1))})})}),Gd="RovingFocusGroupItem",Yd=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,c=Xt(),u=s||c,d=jy(Gd,n),f=d.currentTabStopId===u,h=Vd(n),{onFocusableItemAdd:m,onFocusableItemRemove:w,currentTabStopId:v}=d;return p.useEffect(()=>{if(r)return m(),()=>w()},[r,m,w]),l.jsx(ia.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:l.jsx(Se.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:se(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:se(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:se(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=My(g,d.orientation,d.dir);if(x!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let S=h().filter(k=>k.focusable).map(k=>k.ref.current);if(x==="last")S.reverse();else if(x==="prev"||x==="next"){x==="prev"&&S.reverse();const k=S.indexOf(g.currentTarget);S=d.loop?Dy(S,k+1):S.slice(k+1)}setTimeout(()=>Xd(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:v!=null}):i})})});Yd.displayName=Gd;var Py={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Oy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function My(e,t,n){const r=Oy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Py[r]}function Xd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Dy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ly=qd,$y=Yd,aa=["Enter"," "],Fy=["ArrowDown","PageUp","Home"],Jd=["ArrowUp","PageDown","End"],zy=[...Fy,...Jd],By={ltr:[...aa,"ArrowRight"],rtl:[...aa,"ArrowLeft"]},Hy={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Mr="Menu",[Dr,Uy,Wy]=Wi(Mr),[Ln,Zd]=Yt(Mr,[Wy,os,Kd]),ss=os(),Qd=Kd(),[Vy,$n]=Ln(Mr),[Ky,Lr]=Ln(Mr),ef=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=ss(t),[c,u]=p.useState(null),d=p.useRef(!1),f=ut(s),h=Go(o);return p.useEffect(()=>{const m=()=>{d.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>d.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),l.jsx(Bd,{...a,children:l.jsx(Vy,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:u,children:l.jsx(Ky,{scope:t,onClose:p.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};ef.displayName=Mr;var qy="MenuAnchor",la=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ss(n);return l.jsx(Hd,{...o,...r,ref:t})});la.displayName=qy;var ca="MenuPortal",[Gy,tf]=Ln(ca,{forceMount:void 0}),nf=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=$n(ca,t);return l.jsx(Gy,{scope:t,forceMount:n,children:l.jsx(kt,{present:n||s.open,children:l.jsx(Ro,{asChild:!0,container:o,children:r})})})};nf.displayName=ca;var Pt="MenuContent",[Yy,ua]=Ln(Pt),rf=p.forwardRef((e,t)=>{const n=tf(Pt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=$n(Pt,e.__scopeMenu),i=Lr(Pt,e.__scopeMenu);return l.jsx(Dr.Provider,{scope:e.__scopeMenu,children:l.jsx(kt,{present:r||s.open,children:l.jsx(Dr.Slot,{scope:e.__scopeMenu,children:i.modal?l.jsx(Xy,{...o,ref:t}):l.jsx(Jy,{...o,ref:t})})})})}),Xy=p.forwardRef((e,t)=>{const n=$n(Pt,e.__scopeMenu),r=p.useRef(null),o=Pe(t,r);return p.useEffect(()=>{const s=r.current;if(s)return $i(s)},[]),l.jsx(da,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:se(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Jy=p.forwardRef((e,t)=>{const n=$n(Pt,e.__scopeMenu);return l.jsx(da,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Zy=Cn.createSlot("MenuContent.ScrollLock"),da=p.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:m,disableOutsideScroll:w,...v}=e,g=$n(Pt,n),x=Lr(Pt,n),b=ss(n),S=Qd(n),k=Uy(n),[C,T]=p.useState(null),I=p.useRef(null),N=Pe(t,I,g.onContentChange),_=p.useRef(0),j=p.useRef(""),R=p.useRef(0),$=p.useRef(null),z=p.useRef("right"),O=p.useRef(0),W=w?$o:p.Fragment,B=w?{as:Zy,allowPinchZoom:!0}:void 0,q=A=>{var K,M;const D=j.current+A,H=k().filter(Y=>!Y.disabled),X=document.activeElement,Q=(K=H.find(Y=>Y.ref.current===X))==null?void 0:K.textValue,ue=H.map(Y=>Y.textValue),we=u0(ue,D,Q),Ie=(M=H.find(Y=>Y.textValue===we))==null?void 0:M.ref.current;(function Y(ee){j.current=ee,window.clearTimeout(_.current),ee!==""&&(_.current=window.setTimeout(()=>Y(""),1e3))})(D),Ie&&setTimeout(()=>Ie.focus())};p.useEffect(()=>()=>window.clearTimeout(_.current),[]),Ri();const L=p.useCallback(A=>{var H,X;return z.current===((H=$.current)==null?void 0:H.side)&&f0(A,(X=$.current)==null?void 0:X.area)},[]);return l.jsx(Yy,{scope:n,searchRef:j,onItemEnter:p.useCallback(A=>{L(A)&&A.preventDefault()},[L]),onItemLeave:p.useCallback(A=>{var D;L(A)||((D=I.current)==null||D.focus(),T(null))},[L]),onTriggerLeave:p.useCallback(A=>{L(A)&&A.preventDefault()},[L]),pointerGraceTimerRef:R,onPointerGraceIntentChange:p.useCallback(A=>{$.current=A},[]),children:l.jsx(W,{...B,children:l.jsx(jo,{asChild:!0,trapped:o,onMountAutoFocus:se(s,A=>{var D;A.preventDefault(),(D=I.current)==null||D.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:l.jsx(_o,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:m,children:l.jsx(Ly,{asChild:!0,...S,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:se(c,A=>{x.isUsingKeyboardRef.current||A.preventDefault()}),preventScrollOnEntryFocus:!0,children:l.jsx(Ud,{role:"menu","aria-orientation":"vertical","data-state":yf(g.open),"data-radix-menu-content":"",dir:x.dir,...b,...v,ref:N,style:{outline:"none",...v.style},onKeyDown:se(v.onKeyDown,A=>{const H=A.target.closest("[data-radix-menu-content]")===A.currentTarget,X=A.ctrlKey||A.altKey||A.metaKey,Q=A.key.length===1;H&&(A.key==="Tab"&&A.preventDefault(),!X&&Q&&q(A.key));const ue=I.current;if(A.target!==ue||!zy.includes(A.key))return;A.preventDefault();const Ie=k().filter(K=>!K.disabled).map(K=>K.ref.current);Jd.includes(A.key)&&Ie.reverse(),l0(Ie)}),onBlur:se(e.onBlur,A=>{A.currentTarget.contains(A.target)||(window.clearTimeout(_.current),j.current="")}),onPointerMove:se(e.onPointerMove,Fr(A=>{const D=A.target,H=O.current!==A.clientX;if(A.currentTarget.contains(D)&&H){const X=A.clientX>O.current?"right":"left";z.current=X,O.current=A.clientX}}))})})})})})})});rf.displayName=Pt;var Qy="MenuGroup",fa=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(Se.div,{role:"group",...r,ref:t})});fa.displayName=Qy;var e0="MenuLabel",of=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(Se.div,{...r,ref:t})});of.displayName=e0;var is="MenuItem",sf="menu.itemSelect",as=p.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=p.useRef(null),i=Lr(is,e.__scopeMenu),a=ua(is,e.__scopeMenu),c=Pe(t,s),u=p.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(sf,{bubbles:!0,cancelable:!0});f.addEventListener(sf,m=>r==null?void 0:r(m),{once:!0}),Bc(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return l.jsx(af,{...o,ref:c,disabled:n,onClick:se(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:se(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:se(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||aa.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});as.displayName=is;var af=p.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ua(is,n),a=Qd(n),c=p.useRef(null),u=Pe(t,c),[d,f]=p.useState(!1),[h,m]=p.useState("");return p.useEffect(()=>{const w=c.current;w&&m((w.textContent??"").trim())},[s.children]),l.jsx(Dr.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:l.jsx($y,{asChild:!0,...a,focusable:!r,children:l.jsx(Se.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:se(e.onPointerMove,Fr(w=>{r?i.onItemLeave(w):(i.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:se(e.onPointerLeave,Fr(w=>i.onItemLeave(w))),onFocus:se(e.onFocus,()=>f(!0)),onBlur:se(e.onBlur,()=>f(!1))})})})}),t0="MenuCheckboxItem",lf=p.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return l.jsx(hf,{scope:e.__scopeMenu,checked:n,children:l.jsx(as,{role:"menuitemcheckbox","aria-checked":ls(n)?"mixed":n,...o,ref:t,"data-state":pa(n),onSelect:se(o.onSelect,()=>r==null?void 0:r(ls(n)?!0:!n),{checkForDefaultPrevented:!1})})})});lf.displayName=t0;var cf="MenuRadioGroup",[n0,r0]=Ln(cf,{value:void 0,onValueChange:()=>{}}),uf=p.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=ut(r);return l.jsx(n0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:l.jsx(fa,{...o,ref:t})})});uf.displayName=cf;var df="MenuRadioItem",ff=p.forwardRef((e,t)=>{const{value:n,...r}=e,o=r0(df,e.__scopeMenu),s=n===o.value;return l.jsx(hf,{scope:e.__scopeMenu,checked:s,children:l.jsx(as,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":pa(s),onSelect:se(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});ff.displayName=df;var ha="MenuItemIndicator",[hf,o0]=Ln(ha,{checked:!1}),pf=p.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=o0(ha,n);return l.jsx(kt,{present:r||ls(s.checked)||s.checked===!0,children:l.jsx(Se.span,{...o,ref:t,"data-state":pa(s.checked)})})});pf.displayName=ha;var s0="MenuSeparator",mf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(Se.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});mf.displayName=s0;var i0="MenuArrow",gf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ss(n);return l.jsx(Wd,{...o,...r,ref:t})});gf.displayName=i0;var a0="MenuSub",[VC,xf]=Ln(a0),$r="MenuSubTrigger",vf=p.forwardRef((e,t)=>{const n=$n($r,e.__scopeMenu),r=Lr($r,e.__scopeMenu),o=xf($r,e.__scopeMenu),s=ua($r,e.__scopeMenu),i=p.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:c}=s,u={__scopeMenu:e.__scopeMenu},d=p.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return p.useEffect(()=>d,[d]),p.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),c(null)}},[a,c]),l.jsx(la,{asChild:!0,...u,children:l.jsx(af,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":yf(n.open),...e,ref:vi(t,o.onTriggerChange),onClick:f=>{var h;(h=e.onClick)==null||h.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:se(e.onPointerMove,Fr(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:se(e.onPointerLeave,Fr(f=>{var m,w;d();const h=(m=n.content)==null?void 0:m.getBoundingClientRect();if(h){const v=(w=n.content)==null?void 0:w.dataset.side,g=v==="right",x=g?-5:5,b=h[g?"left":"right"],S=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+x,y:f.clientY},{x:b,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:b,y:h.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:se(e.onKeyDown,f=>{var m;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||By[r.dir].includes(f.key)&&(n.onOpenChange(!0),(m=n.content)==null||m.focus(),f.preventDefault())})})})});vf.displayName=$r;var wf="MenuSubContent",bf=p.forwardRef((e,t)=>{const n=tf(Pt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=$n(Pt,e.__scopeMenu),i=Lr(Pt,e.__scopeMenu),a=xf(wf,e.__scopeMenu),c=p.useRef(null),u=Pe(t,c);return l.jsx(Dr.Provider,{scope:e.__scopeMenu,children:l.jsx(kt,{present:r||s.open,children:l.jsx(Dr.Slot,{scope:e.__scopeMenu,children:l.jsx(da,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=c.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:se(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:se(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:se(e.onKeyDown,d=>{var m;const f=d.currentTarget.contains(d.target),h=Hy[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(m=a.trigger)==null||m.focus(),d.preventDefault())})})})})})});bf.displayName=wf;function yf(e){return e?"open":"closed"}function ls(e){return e==="indeterminate"}function pa(e){return ls(e)?"indeterminate":e?"checked":"unchecked"}function l0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function c0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function u0(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=c0(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function d0(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],c=t[i],u=a.x,d=a.y,f=c.x,h=c.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function f0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return d0(n,t)}function Fr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var h0=ef,p0=la,m0=nf,g0=rf,x0=fa,v0=of,w0=as,b0=lf,y0=uf,S0=ff,C0=pf,T0=mf,E0=gf,k0=vf,I0=bf,cs="DropdownMenu",[N0,KC]=Yt(cs,[Zd]),gt=Zd(),[A0,Sf]=N0(cs),Cf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,c=gt(t),u=p.useRef(null),[d,f]=jn({prop:o,defaultProp:s??!1,onChange:i,caller:cs});return l.jsx(A0,{scope:t,triggerId:Xt(),triggerRef:u,contentId:Xt(),open:d,onOpenChange:f,onOpenToggle:p.useCallback(()=>f(h=>!h),[f]),modal:a,children:l.jsx(h0,{...c,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Cf.displayName=cs;var Tf="DropdownMenuTrigger",Ef=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Sf(Tf,n),i=gt(n);return l.jsx(p0,{asChild:!0,...i,children:l.jsx(Se.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:vi(t,s.triggerRef),onPointerDown:se(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:se(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Ef.displayName=Tf;var _0="DropdownMenuPortal",kf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=gt(t);return l.jsx(m0,{...r,...n})};kf.displayName=_0;var If="DropdownMenuContent",Nf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Sf(If,n),s=gt(n),i=p.useRef(!1);return l.jsx(g0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:se(e.onCloseAutoFocus,a=>{var c;i.current||(c=o.triggerRef.current)==null||c.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:se(e.onInteractOutside,a=>{const c=a.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,d=c.button===2||u;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Nf.displayName=If;var j0="DropdownMenuGroup",R0=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gt(n);return l.jsx(x0,{...o,...r,ref:t})});R0.displayName=j0;var P0="DropdownMenuLabel",Af=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gt(n);return l.jsx(v0,{...o,...r,ref:t})});Af.displayName=P0;var O0="DropdownMenuItem",_f=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gt(n);return l.jsx(w0,{...o,...r,ref:t})});_f.displayName=O0;var M0="DropdownMenuCheckboxItem",jf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gt(n);return l.jsx(b0,{...o,...r,ref:t})});jf.displayName=M0;var D0="DropdownMenuRadioGroup",L0=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gt(n);return l.jsx(y0,{...o,...r,ref:t})});L0.displayName=D0;var $0="DropdownMenuRadioItem",Rf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gt(n);return l.jsx(S0,{...o,...r,ref:t})});Rf.displayName=$0;var F0="DropdownMenuItemIndicator",Pf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gt(n);return l.jsx(C0,{...o,...r,ref:t})});Pf.displayName=F0;var z0="DropdownMenuSeparator",Of=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gt(n);return l.jsx(T0,{...o,...r,ref:t})});Of.displayName=z0;var B0="DropdownMenuArrow",H0=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gt(n);return l.jsx(E0,{...o,...r,ref:t})});H0.displayName=B0;var U0="DropdownMenuSubTrigger",Mf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gt(n);return l.jsx(k0,{...o,...r,ref:t})});Mf.displayName=U0;var W0="DropdownMenuSubContent",Df=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gt(n);return l.jsx(I0,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Df.displayName=W0;var V0=Cf,K0=Ef,q0=kf,Lf=Nf,$f=Af,Ff=_f,zf=jf,Bf=Rf,Hf=Pf,Uf=Of,Wf=Mf,Vf=Df;const G0=V0,Y0=K0,X0=p.forwardRef(({className:e,inset:t,children:n,...r},o)=>l.jsxs(Wf,{ref:o,className:Z("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,l.jsx(te.ChevronRight,{className:"ml-auto h-4 w-4"})]}));X0.displayName=Wf.displayName;const J0=p.forwardRef(({className:e,...t},n)=>l.jsx(Vf,{ref:n,className:Z("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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",e),...t}));J0.displayName=Vf.displayName;const Kf=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>l.jsx(q0,{children:l.jsx(Lf,{ref:r,sideOffset:t,className:Z("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 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",e),...n})}));Kf.displayName=Lf.displayName;const ma=p.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(Ff,{ref:r,className:Z("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));ma.displayName=Ff.displayName;const Z0=p.forwardRef(({className:e,children:t,checked:n,...r},o)=>l.jsxs(zf,{ref:o,className:Z("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Hf,{children:l.jsx(te.Check,{className:"h-4 w-4"})})}),t]}));Z0.displayName=zf.displayName;const Q0=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Bf,{ref:r,className:Z("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Hf,{children:l.jsx(te.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Q0.displayName=Bf.displayName;const eS=p.forwardRef(({className:e,inset:t,...n},r)=>l.jsx($f,{ref:r,className:Z("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));eS.displayName=$f.displayName;const tS=p.forwardRef(({className:e,...t},n)=>l.jsx(Uf,{ref:n,className:Z("-mx-1 my-1 h-px bg-muted",e),...t}));tS.displayName=Uf.displayName;function us({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:c=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:h,onError:m}){const{api:w}=so(),{currentThreadId:v,isLoadingThread:g,listCheckpoints:x,navigateToCheckpoint:b,returnToLatest:S}=mr(),{messages:k,hasMoreHistory:C,isLoadingHistory:T,send:I,stop:N,loadOlderMessages:_}=qs(),{isStreaming:j,error:R,streamingAssistantId:$,lastCheckpointId:z,lastCheckpointNs:O}=Ol(),[W,B]=y.useState(null),[q,L]=y.useState(""),[A,D]=y.useState(null),[H,X]=y.useState([]),[Q,ue]=y.useState(0),[we,Ie]=y.useState(0),[K,M]=y.useState(!1),[Y,ee]=y.useState(null),[de,ce]=y.useState(null),[ze,Ye]=y.useState(!1),[V,J]=y.useState(null),[be,Oe]=y.useState([]),[_e,et]=y.useState(null),[st,ie]=y.useState(null),[ae,me]=y.useState(!1),ge=y.useRef(null),ke=y.useRef(null),je=y.useRef(null),Ke=y.useCallback(()=>{ge.current&&(ge.current.value=""),ke.current&&(ke.current.value=""),ue(le=>le+1),Ie(le=>le+1)},[]),qe=y.useRef(!1);y.useEffect(()=>{qe.current&&!j&&(X([]),Ke()),qe.current=j},[j,Ke]);const[lt,Dt]=y.useState("desktop");y.useEffect(()=>{const le=()=>{const xe=window.innerWidth;Dt(xe<640?"phone":xe<1024?"tablet":"desktop")};return le(),window.addEventListener("resize",le),()=>window.removeEventListener("resize",le)},[]),y.useEffect(()=>{let le=!1;if(!v){Oe([]),et(null),ie(null),je.current=null;return}const xe={threadId:v,checkpointId:z??null,checkpointNs:O??null},Le=je.current;if(!(Le&&Le.threadId===xe.threadId&&Le.checkpointId===xe.checkpointId&&Le.checkpointNs===xe.checkpointNs))return x(v).then(Qe=>{var ks;if(le)return;const At=((Qe==null?void 0:Qe.checkpoints)??[]).slice().sort((ln,E)=>new Date(E.createdAt).getTime()-new Date(ln.createdAt).getTime());Oe(At);const rn=_e,Vr=rn&&At.some(ln=>ln.checkpointId===rn)?rn:((ks=At[0])==null?void 0:ks.checkpointId)??null;let Es=null;if(Vr){const ln=At.find(E=>E.checkpointId===Vr);Es=(ln==null?void 0:ln.checkpointNs)??null}et(Vr),ie(Es),je.current=xe}).catch(Qe=>{console.error("ChatInterface - listCheckpoints error:",Qe),le||(Oe([]),je.current=null)}),()=>{le=!0}},[v,z,O,_e,x]),y.useEffect(()=>{z&&(et(z),ie(O??null))},[z,O]);const ir=y.useCallback(async()=>{if(!(!C||T))try{await _()}catch(le){console.warn("loadOlderMessages failed",le)}},[C,T,_]);y.useEffect(()=>{(async()=>{if(!w.baseUrl){J(null);return}try{const xe=await w.getAgent("default");J(xe.uiDefaultMessage||null)}catch(xe){console.warn("Failed to fetch default message:",xe),J(null)}})()},[w]),y.useEffect(()=>{R&&!ze&&(m==null||m(R))},[R,ze,m]);const _a=le=>{if(le.length>qo)return`Message too long (${le.length}/${qo} characters)`;try{return ab(le),null}catch(xe){return(xe==null?void 0:xe.message)||"Invalid message"}},ja=async le=>{const xe=le.trim();if(!(!xe&&H.length===0)){if(xe){const Le=_a(xe);if(Le){D(Le);return}}try{await I(xe||"",{checkpointId:_e??z??void 0,checkpointNs:st??O??void 0,payloadExtras:W?{edit:!0,originalMessageId:W}:void 0,attachments:H}),f==null||f(xe),D(null),X([]),Ke(),B(null),L("")}catch(Le){const Qe=(Le==null?void 0:Le.message)||"Failed to send message";D(Qe),m==null||m(Qe)}}},ys=y.useCallback((le,xe)=>{u&&(B(le),L(xe),D(null))},[u]),Br=y.useCallback(()=>{B(null),L(""),D(null)},[]),Ra=y.useCallback((le,xe)=>{ys(le,xe)},[ys]),Hr=y.useCallback(le=>{const xe=Le=>{const Qe=Le.content||[],At=Qe.filter(rn=>rn.type==="text").map(rn=>rn.text).join("");if(At)return At;try{return JSON.stringify(Qe,null,2)}catch{return String(Qe)}};for(let Le=le-1;Le>=0;Le--)if(k[Le].role==="user"){const Qe=xe(k[Le]);Qe&&I(Qe,{checkpointId:_e??z??void 0,checkpointNs:st??O??void 0});break}},[k,I,_e,st,z,O]),Ss=le=>{const xe=Array.from(le.target.files||[]);X(Le=>[...Le,...xe]),le.target.value=""},Sn=le=>{X(xe=>{const Le=xe.filter((Qe,At)=>le!==At);return Le.length===0&&Ke(),Le})},Ur=async le=>{const xe=(le.target.files||[])[0];if(xe){ee(null),ce(null),M(!0);try{await I("",{checkpointId:_e??z??void 0,checkpointNs:st??O??void 0,attachments:[xe]});const Le=`Uploaded ${xe.name} - processing through chat stream`;ce(Le)}catch(Le){const Qe=Le instanceof Error?Le.message:"Failed to upload Excel file";console.error("Excel upload failed",Le),ee(Qe),m==null||m(Qe)}finally{M(!1),le.target.value="",Ke()}}},Wr=le=>{if(!le)return"Unknown";const xe=Date.parse(le);return Number.isNaN(xe)?le:new Date(xe).toLocaleString()},Cs=async le=>{if(v){me(!0);try{if(!le){await S(),et(null),ie(null);return}const xe=be.find(Qe=>Qe.checkpointId===le),Le=(xe==null?void 0:xe.checkpointNs)??null;await b(le,Le),et(le),ie(Le)}finally{me(!1)}}},Pa=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,Ts=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${d.messagesArea||""}`,Oa=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return l.jsxs("div",{className:Pa,children:[!!R&&!ze&&l.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[l.jsx("span",{children:R}),l.jsx(Fe,{variant:"ghost",size:"sm",onClick:()=>Ye(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:l.jsx(te.X,{size:16})})]}),v&&be.length>0&&l.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[l.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),l.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:_e??"",onChange:le=>{const xe=le.target.value||null;Cs(xe)},children:[l.jsx("option",{value:"",children:"Latest"}),be.map(le=>l.jsxs("option",{value:le.checkpointId,children:[Wr(le.createdAt),le.preview?` — ${le.preview.slice(0,40)}`:""]},le.checkpointId))]})]}),l.jsxs("div",{className:`relative ${Ts}`,style:r?{maxHeight:r}:void 0,children:[l.jsx(Ui,{className:"h-full",style:{height:"100%"},messages:k,isStreaming:j,streamingAssistantId:$,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:lt,enableMessageEditing:u,editingMessageId:W,onStartReached:()=>{ir()},onEdit:Ra,onRegenerate:Hr,onCancelEdit:Br,emptyMessage:V??void 0,isNavigatingCheckpoint:ae}),g&&l.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[l.jsx(te.Loader2,{className:"h-6 w-6 animate-spin"}),l.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]})]}),l.jsxs("div",{className:Oa,children:[W&&l.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(te.Edit3,{size:16,className:"text-blue-600"}),l.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),l.jsx(Fe,{variant:"ghost",size:"sm",onClick:Br,className:"text-blue-600 hover:bg-blue-100",children:l.jsx(te.X,{size:16})})]})}),(a||c)&&l.jsxs("div",{className:"mb-3 space-y-3",children:[a&&l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:ge,type:"file",multiple:!0,onChange:le=>Ss(le),className:"hidden"},Q),H.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2",children:H.map((le,xe)=>l.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[l.jsx(te.Paperclip,{size:14}),l.jsx("span",{className:"truncate max-w-[150px]",children:le.name}),l.jsx(Fe,{variant:"ghost",size:"sm",onClick:()=>Sn(xe),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${le.name}`,children:l.jsx(te.X,{size:12})})]},xe))})]}),c&&l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:ke,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Ur,className:"hidden"},we),K&&l.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[l.jsx(te.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),de&&!K&&l.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:de}),Y&&!K&&l.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Y})]})]}),A&&l.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:A}),l.jsxs("div",{className:"flex items-end gap-2",children:[(a||c)&&l.jsxs(G0,{children:[l.jsx(Y0,{asChild:!0,children:l.jsx(Fe,{type:"button",size:"icon",variant:"outline",disabled:j,title:"More input actions",className:d.moreButton||"",children:l.jsx(te.Plus,{size:16})})}),l.jsxs(Kf,{align:"start",sideOffset:6,className:"w-52",children:[a&&l.jsxs(ma,{onClick:()=>{var le;return(le=ge.current)==null?void 0:le.click()},className:"cursor-pointer",children:[l.jsx(te.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),c&&l.jsxs(ma,{onClick:()=>{var le;K||(le=ke.current)==null||le.click()},className:`cursor-pointer ${K?"opacity-60 pointer-events-none":""}`,children:[l.jsx(te.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),l.jsx("div",{className:"flex-1",children:l.jsx(bg,{initialValue:q,editingMessageId:W,placeholder:W?"Edit your message...":t,isStreaming:j,disabled:!1,maxLength:qo,onSend:ja,onCancelEdit:Br,onStop:N,allowEmptySend:H.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${W?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${A?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const ds=p.forwardRef(({className:e,type:t,...n},r)=>l.jsx("input",{type:t,className:Z("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));ds.displayName="Input";function ga(e,[t,n]){return Math.min(n,Math.max(t,e))}function nS(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var xa="ScrollArea",[qf,qC]=Yt(xa),[rS,Ot]=qf(xa),Gf=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,c]=p.useState(null),[u,d]=p.useState(null),[f,h]=p.useState(null),[m,w]=p.useState(null),[v,g]=p.useState(null),[x,b]=p.useState(0),[S,k]=p.useState(0),[C,T]=p.useState(!1),[I,N]=p.useState(!1),_=Pe(t,R=>c(R)),j=Go(o);return l.jsx(rS,{scope:n,type:r,dir:j,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:m,onScrollbarXChange:w,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:v,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:N,onCornerWidthChange:b,onCornerHeightChange:k,children:l.jsx(Se.div,{dir:j,...i,ref:_,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Gf.displayName=xa;var Yf="ScrollAreaViewport",Xf=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Ot(Yf,n),a=p.useRef(null),c=Pe(t,a,i.onViewportChange);return l.jsxs(l.Fragment,{children:[l.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),l.jsx(Se.div,{"data-radix-scroll-area-viewport":"",...s,ref:c,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:l.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Xf.displayName=Yf;var nn="ScrollAreaScrollbar",va=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ot(nn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return p.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?l.jsx(oS,{...r,ref:t,forceMount:n}):o.type==="scroll"?l.jsx(sS,{...r,ref:t,forceMount:n}):o.type==="auto"?l.jsx(Jf,{...r,ref:t,forceMount:n}):o.type==="always"?l.jsx(wa,{...r,ref:t}):null});va.displayName=nn;var oS=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ot(nn,e.__scopeScrollArea),[s,i]=p.useState(!1);return p.useEffect(()=>{const a=o.scrollArea;let c=0;if(a){const u=()=>{window.clearTimeout(c),i(!0)},d=()=>{c=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),l.jsx(kt,{present:n||s,children:l.jsx(Jf,{"data-state":s?"visible":"hidden",...r,ref:t})})}),sS=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ot(nn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ms(()=>c("SCROLL_END"),100),[a,c]=nS("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return p.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,c]),p.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const m=u[d];f!==m&&(c("SCROLL"),i()),f=m};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,c,i]),l.jsx(kt,{present:n||a!=="hidden",children:l.jsx(wa,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:se(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:se(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),Jf=p.forwardRef((e,t)=>{const n=Ot(nn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=p.useState(!1),a=e.orientation==="horizontal",c=ms(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return rr(n.viewport,c),rr(n.content,c),l.jsx(kt,{present:r||s,children:l.jsx(wa,{"data-state":s?"visible":"hidden",...o,ref:t})})}),wa=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Ot(nn,e.__scopeScrollArea),s=p.useRef(null),i=p.useRef(0),[a,c]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=nh(a.viewport,a.content),d={...r,sizes:a,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,m){return dS(h,i.current,a,m)}return n==="horizontal"?l.jsx(iS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,m=rh(h,a,o.dir);s.current.style.transform=`translate3d(${m}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?l.jsx(aS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,m=rh(h,a);s.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),iS=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Ot(nn,e.__scopeScrollArea),[i,a]=p.useState(),c=p.useRef(null),u=Pe(t,c,s.onScrollbarXChange);return p.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(Qf,{"data-orientation":"horizontal",...o,ref:u,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":ps(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(h),sh(h,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:hs(i.paddingLeft),paddingEnd:hs(i.paddingRight)}})}})}),aS=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Ot(nn,e.__scopeScrollArea),[i,a]=p.useState(),c=p.useRef(null),u=Pe(t,c,s.onScrollbarYChange);return p.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(Qf,{"data-orientation":"vertical",...o,ref:u,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":ps(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(h),sh(h,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:hs(i.paddingTop),paddingEnd:hs(i.paddingBottom)}})}})}),[lS,Zf]=qf(nn),Qf=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,m=Ot(nn,n),[w,v]=p.useState(null),g=Pe(t,_=>v(_)),x=p.useRef(null),b=p.useRef(""),S=m.viewport,k=r.content-r.viewport,C=ut(d),T=ut(c),I=ms(f,10);function N(_){if(x.current){const j=_.clientX-x.current.left,R=_.clientY-x.current.top;u({x:j,y:R})}}return p.useEffect(()=>{const _=j=>{const R=j.target;(w==null?void 0:w.contains(R))&&C(j,k)};return document.addEventListener("wheel",_,{passive:!1}),()=>document.removeEventListener("wheel",_,{passive:!1})},[S,w,k,C]),p.useEffect(T,[r,T]),rr(w,I),rr(m.content,I),l.jsx(lS,{scope:n,scrollbar:w,hasThumb:o,onThumbChange:ut(s),onThumbPointerUp:ut(i),onThumbPositionChange:T,onThumbPointerDown:ut(a),children:l.jsx(Se.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:se(e.onPointerDown,_=>{_.button===0&&(_.target.setPointerCapture(_.pointerId),x.current=w.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),N(_))}),onPointerMove:se(e.onPointerMove,N),onPointerUp:se(e.onPointerUp,_=>{const j=_.target;j.hasPointerCapture(_.pointerId)&&j.releasePointerCapture(_.pointerId),document.body.style.webkitUserSelect=b.current,m.viewport&&(m.viewport.style.scrollBehavior=""),x.current=null})})})}),fs="ScrollAreaThumb",eh=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Zf(fs,e.__scopeScrollArea);return l.jsx(kt,{present:n||o.hasThumb,children:l.jsx(cS,{ref:t,...r})})}),cS=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Ot(fs,n),i=Zf(fs,n),{onThumbPositionChange:a}=i,c=Pe(t,f=>i.onThumbChange(f)),u=p.useRef(void 0),d=ms(()=>{u.current&&(u.current(),u.current=void 0)},100);return p.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const m=fS(f,a);u.current=m,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),l.jsx(Se.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:se(e.onPointerDownCapture,f=>{const m=f.target.getBoundingClientRect(),w=f.clientX-m.left,v=f.clientY-m.top;i.onThumbPointerDown({x:w,y:v})}),onPointerUp:se(e.onPointerUp,i.onThumbPointerUp)})});eh.displayName=fs;var ba="ScrollAreaCorner",th=p.forwardRef((e,t)=>{const n=Ot(ba,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?l.jsx(uS,{...e,ref:t}):null});th.displayName=ba;var uS=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Ot(ba,n),[s,i]=p.useState(0),[a,c]=p.useState(0),u=!!(s&&a);return rr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),c(d)}),rr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?l.jsx(Se.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function hs(e){return e?parseInt(e,10):0}function nh(e,t){const n=e/t;return isNaN(n)?0:n}function ps(e){const t=nh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function dS(e,t,n,r="ltr"){const o=ps(n),s=o/2,i=t||s,a=o-i,c=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return oh([c,u],f)(e)}function rh(e,t,n="ltr"){const r=ps(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,c=n==="ltr"?[0,i]:[i*-1,0],u=ga(e,c);return oh([0,i],[0,a])(u)}function oh(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function sh(e,t){return e>0&&e<t}var fS=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function ms(e,t){const n=ut(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function rr(e,t){const n=ut(t);ct(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var ih=Gf,hS=Xf,pS=th;const ah=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(ih,{ref:r,className:Z("relative overflow-hidden",e),...n,children:[l.jsx(hS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),l.jsx(lh,{}),l.jsx(pS,{})]}));ah.displayName=ih.displayName;const lh=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>l.jsx(va,{ref:r,orientation:t,className:Z("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:l.jsx(eh,{className:"relative flex-1 rounded-full bg-border"})}));lh.displayName=va.displayName;function ya({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:c,onThreadCreate:u,onThreadDelete:d}){const{loadThread:f,threads:h,currentThreadId:m,createThread:w,deleteThread:v,renameThread:g,isLoadingThreads:x}=mr(),[b,S]=y.useState(h??[]),[k,C]=y.useState(null),[T,I]=y.useState(""),[N,_]=y.useState(!1);y.useEffect(()=>{S(h??[])},[h]);const j=async A=>{try{await f(A),a==null||a(A),c==null||c(A)}catch(D){console.error("Failed to select thread:",D)}},R=async()=>{try{_(!0);const A=await w();u==null||u(A),a==null||a(A)}catch(A){console.error("Failed to create thread:",A)}finally{_(!1)}},$=async(A,D)=>{if(D.stopPropagation(),!!confirm("Delete this thread?"))try{await v(A),d==null||d(A)}catch(H){console.error("Failed to delete thread:",H)}},z=(A,D)=>{D.stopPropagation(),C(A.threadId),I(A.title||`Thread ${A.threadId.slice(0,8)}`)},O=async A=>{if(T.trim())try{await g(A,T.trim()),C(null),I("")}catch(D){console.error("Failed to update title:",D)}},W=()=>{C(null),I("")},B=(A,D)=>{A.key==="Enter"?O(D):A.key==="Escape"&&W()},q=A=>{if(!A)return"";try{const D=new Date(A),X=new Date().getTime()-D.getTime(),Q=Math.floor(X/(1e3*60*60*24));return Q===0?D.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Q===1?"Yesterday":Q<7?`${Q} days ago`:D.toLocaleDateString()}catch{return""}},L=A=>A.title||`Thread ${A.threadId.slice(0,8)}`;return l.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&l.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:l.jsx(Fe,{onClick:R,disabled:N||x,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:N?"Creating...":"New Chat",children:l.jsx(te.MessageSquarePlus,{size:20})})}),l.jsx(ah,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:l.jsx("div",{className:"p-2 space-y-1 pb-4",children:x?l.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[l.jsx(te.Loader2,{className:"h-5 w-5 animate-spin"}),l.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):b.length===0?l.jsxs("div",{className:"text-center py-8 text-slate-400",children:[l.jsx(te.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),l.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):b.slice().sort((A,D)=>new Date(D.updatedAt||D.createdAt||"").getTime()-new Date(A.updatedAt||A.createdAt||"").getTime()).map(A=>l.jsxs("div",{onClick:()=>j(A.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??m)===A.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("div",{className:"flex-1 min-w-0",children:k===A.threadId?l.jsxs("div",{className:"flex items-center gap-2",onClick:D=>D.stopPropagation(),children:[l.jsx(ds,{value:T,onChange:D=>I(D.target.value),onKeyDown:D=>B(D,A.threadId),className:"h-6 text-sm",autoFocus:!0}),l.jsx(Fe,{variant:"ghost",size:"sm",onClick:()=>O(A.threadId),className:"h-6 w-6 p-0",children:l.jsx(te.Check,{size:12})}),l.jsx(Fe,{variant:"ghost",size:"sm",onClick:W,className:"h-6 w-6 p-0",children:l.jsx(te.X,{size:12})})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:L(A)}),l.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[l.jsx(te.Calendar,{size:10}),l.jsx("span",{children:q(A.updatedAt||A.createdAt)})]})]})}),l.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&k!==A.threadId&&l.jsx(Fe,{variant:"ghost",size:"sm",onClick:D=>z(A,D),className:"h-6 w-6 p-0",title:"Edit title",children:l.jsx(te.Edit3,{size:12})}),n&&l.jsx(Fe,{variant:"ghost",size:"sm",onClick:D=>$(A.threadId,D),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:l.jsx(te.Trash2,{size:12})})]})]}),i===A.threadId&&l.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},A.threadId))})})]})}function or(e){if(!(typeof globalThis>"u"))return globalThis[e]}function mS(e){if(typeof e!="string")return;const t=e.trim();if(t)return t.replace(/\/+$/g,"")}function ch(){const e=[or("__API_BASE_URL__"),or("__CHAT_API_BASE_URL__"),or("__CHAT_API_URL__")];for(const t of e){const n=mS(t);if(n)return n}}function uh(){const e=[or("__API_AUTH_TOKEN__"),or("__CHAT_API_KEY__"),or("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function dh(){const e={},t=ch(),n=uh();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function fh(){const e=dh(),t=cn.getAuthToken(),n=ch();return{apiBaseUrl:e.baseUrl||cn.baseUrl||n||"http://localhost:8000",apiKey:t||e.apiKey||uh()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const hh="chat-settings";function gS(){try{const e=localStorage.getItem(hh);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function xS(e){try{localStorage.setItem(hh,JSON.stringify(e)),e.apiKey&&cn.setAuthToken(e.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function vS(){const e=fh(),t=gS(),n=cn.getAuthToken();return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:cn.baseUrl||t.apiBaseUrl||e.apiBaseUrl}}function wS(e){e.apiKey&&cn.setAuthToken(e.apiKey),xS(e)}var bS="Label",ph=p.forwardRef((e,t)=>l.jsx(Se.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));ph.displayName=bS;var mh=ph;const yS=Kr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Mt=p.forwardRef(({className:e,...t},n)=>l.jsx(mh,{ref:n,className:Z(yS(),e),...t}));Mt.displayName=mh.displayName;function gh(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var gs="Switch",[SS,GC]=Yt(gs),[CS,TS]=SS(gs),xh=p.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:c="on",onCheckedChange:u,form:d,...f}=e,[h,m]=p.useState(null),w=Pe(t,S=>m(S)),v=p.useRef(!1),g=h?d||!!h.closest("form"):!0,[x,b]=jn({prop:o,defaultProp:s??!1,onChange:u,caller:gs});return l.jsxs(CS,{scope:n,checked:x,disabled:a,children:[l.jsx(Se.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":yh(x),"data-disabled":a?"":void 0,disabled:a,value:c,...f,ref:w,onClick:se(e.onClick,S=>{b(k=>!k),g&&(v.current=S.isPropagationStopped(),v.current||S.stopPropagation())})}),g&&l.jsx(bh,{control:h,bubbles:!v.current,name:r,value:c,checked:x,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});xh.displayName=gs;var vh="SwitchThumb",wh=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=TS(vh,n);return l.jsx(Se.span,{"data-state":yh(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});wh.displayName=vh;var ES="SwitchBubbleInput",bh=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=p.useRef(null),a=Pe(i,s),c=gh(n),u=jd(t);return p.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==n&&m){const w=new Event("click",{bubbles:r});m.call(d,n),d.dispatchEvent(w)}},[c,n,r]),l.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});bh.displayName=ES;function yh(e){return e?"checked":"unchecked"}var Sh=xh,kS=wh;const wn=p.forwardRef(({className:e,...t},n)=>l.jsx(Sh,{className:Z("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:l.jsx(kS,{className:Z("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));wn.displayName=Sh.displayName;var Ch=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),IS="VisuallyHidden",NS=p.forwardRef((e,t)=>l.jsx(Se.span,{...e,ref:t,style:{...Ch,...e.style}}));NS.displayName=IS;var AS=[" ","Enter","ArrowUp","ArrowDown"],_S=[" ","Enter"],Fn="Select",[xs,vs,jS]=Wi(Fn),[sr,YC]=Yt(Fn,[jS,os]),ws=os(),[RS,bn]=sr(Fn),[PS,OS]=sr(Fn),Th=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:c,dir:u,name:d,autoComplete:f,disabled:h,required:m,form:w}=e,v=ws(t),[g,x]=p.useState(null),[b,S]=p.useState(null),[k,C]=p.useState(!1),T=Go(u),[I,N]=jn({prop:r,defaultProp:o??!1,onChange:s,caller:Fn}),[_,j]=jn({prop:i,defaultProp:a,onChange:c,caller:Fn}),R=p.useRef(null),$=g?w||!!g.closest("form"):!0,[z,O]=p.useState(new Set),W=Array.from(z).map(B=>B.props.value).join(";");return l.jsx(Bd,{...v,children:l.jsxs(RS,{required:m,scope:t,trigger:g,onTriggerChange:x,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:Xt(),value:_,onValueChange:j,open:I,onOpenChange:N,dir:T,triggerPointerDownPosRef:R,disabled:h,children:[l.jsx(xs.Provider,{scope:t,children:l.jsx(PS,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback(B=>{O(q=>new Set(q).add(B))},[]),onNativeOptionRemove:p.useCallback(B=>{O(q=>{const L=new Set(q);return L.delete(B),L})},[]),children:n})}),$?l.jsxs(Gh,{"aria-hidden":!0,required:m,tabIndex:-1,name:d,autoComplete:f,value:_,onChange:B=>j(B.target.value),disabled:h,form:w,children:[_===void 0?l.jsx("option",{value:""}):null,Array.from(z)]},W):null]})})};Th.displayName=Fn;var Eh="SelectTrigger",kh=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ws(n),i=bn(Eh,n),a=i.disabled||r,c=Pe(t,i.onTriggerChange),u=vs(n),d=p.useRef("touch"),[f,h,m]=Xh(v=>{const g=u().filter(S=>!S.disabled),x=g.find(S=>S.value===i.value),b=Jh(g,v,x);b!==void 0&&i.onValueChange(b.value)}),w=v=>{a||(i.onOpenChange(!0),m()),v&&(i.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return l.jsx(Hd,{asChild:!0,...s,children:l.jsx(Se.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Yh(i.value)?"":void 0,...o,ref:c,onClick:se(o.onClick,v=>{v.currentTarget.focus(),d.current!=="mouse"&&w(v)}),onPointerDown:se(o.onPointerDown,v=>{d.current=v.pointerType;const g=v.target;g.hasPointerCapture(v.pointerId)&&g.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(w(v),v.preventDefault())}),onKeyDown:se(o.onKeyDown,v=>{const g=f.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&h(v.key),!(g&&v.key===" ")&&AS.includes(v.key)&&(w(),v.preventDefault())})})})});kh.displayName=Eh;var Ih="SelectValue",Nh=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,c=bn(Ih,n),{onValueNodeHasChildrenChange:u}=c,d=s!==void 0,f=Pe(t,c.onValueNodeChange);return ct(()=>{u(d)},[u,d]),l.jsx(Se.span,{...a,ref:f,style:{pointerEvents:"none"},children:Yh(c.value)?l.jsx(l.Fragment,{children:i}):s})});Nh.displayName=Ih;var MS="SelectIcon",Ah=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return l.jsx(Se.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Ah.displayName=MS;var DS="SelectPortal",_h=e=>l.jsx(Ro,{asChild:!0,...e});_h.displayName=DS;var zn="SelectContent",jh=p.forwardRef((e,t)=>{const n=bn(zn,e.__scopeSelect),[r,o]=p.useState();if(ct(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?qr.createPortal(l.jsx(Rh,{scope:e.__scopeSelect,children:l.jsx(xs.Slot,{scope:e.__scopeSelect,children:l.jsx("div",{children:e.children})})}),s):null}return l.jsx(Ph,{...e,ref:t})});jh.displayName=zn;var Wt=10,[Rh,yn]=sr(zn),LS="SelectContentImpl",$S=Cn.createSlot("SelectContent.RemoveScroll"),Ph=p.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:m,sticky:w,hideWhenDetached:v,avoidCollisions:g,...x}=e,b=bn(zn,n),[S,k]=p.useState(null),[C,T]=p.useState(null),I=Pe(t,K=>k(K)),[N,_]=p.useState(null),[j,R]=p.useState(null),$=vs(n),[z,O]=p.useState(!1),W=p.useRef(!1);p.useEffect(()=>{if(S)return $i(S)},[S]),Ri();const B=p.useCallback(K=>{const[M,...Y]=$().map(ce=>ce.ref.current),[ee]=Y.slice(-1),de=document.activeElement;for(const ce of K)if(ce===de||(ce==null||ce.scrollIntoView({block:"nearest"}),ce===M&&C&&(C.scrollTop=0),ce===ee&&C&&(C.scrollTop=C.scrollHeight),ce==null||ce.focus(),document.activeElement!==de))return},[$,C]),q=p.useCallback(()=>B([N,S]),[B,N,S]);p.useEffect(()=>{z&&q()},[z,q]);const{onOpenChange:L,triggerPointerDownPosRef:A}=b;p.useEffect(()=>{if(S){let K={x:0,y:0};const M=ee=>{var de,ce;K={x:Math.abs(Math.round(ee.pageX)-(((de=A.current)==null?void 0:de.x)??0)),y:Math.abs(Math.round(ee.pageY)-(((ce=A.current)==null?void 0:ce.y)??0))}},Y=ee=>{K.x<=10&&K.y<=10?ee.preventDefault():S.contains(ee.target)||L(!1),document.removeEventListener("pointermove",M),A.current=null};return A.current!==null&&(document.addEventListener("pointermove",M),document.addEventListener("pointerup",Y,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",M),document.removeEventListener("pointerup",Y,{capture:!0})}}},[S,L,A]),p.useEffect(()=>{const K=()=>L(!1);return window.addEventListener("blur",K),window.addEventListener("resize",K),()=>{window.removeEventListener("blur",K),window.removeEventListener("resize",K)}},[L]);const[D,H]=Xh(K=>{const M=$().filter(de=>!de.disabled),Y=M.find(de=>de.ref.current===document.activeElement),ee=Jh(M,K,Y);ee&&setTimeout(()=>ee.ref.current.focus())}),X=p.useCallback((K,M,Y)=>{const ee=!W.current&&!Y;(b.value!==void 0&&b.value===M||ee)&&(_(K),ee&&(W.current=!0))},[b.value]),Q=p.useCallback(()=>S==null?void 0:S.focus(),[S]),ue=p.useCallback((K,M,Y)=>{const ee=!W.current&&!Y;(b.value!==void 0&&b.value===M||ee)&&R(K)},[b.value]),we=r==="popper"?Sa:Oh,Ie=we===Sa?{side:a,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:m,sticky:w,hideWhenDetached:v,avoidCollisions:g}:{};return l.jsx(Rh,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:X,selectedItem:N,onItemLeave:Q,itemTextRefCallback:ue,focusSelectedItem:q,selectedItemText:j,position:r,isPositioned:z,searchRef:D,children:l.jsx($o,{as:$S,allowPinchZoom:!0,children:l.jsx(jo,{asChild:!0,trapped:b.open,onMountAutoFocus:K=>{K.preventDefault()},onUnmountAutoFocus:se(o,K=>{var M;(M=b.trigger)==null||M.focus({preventScroll:!0}),K.preventDefault()}),children:l.jsx(_o,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:K=>K.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:l.jsx(we,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:K=>K.preventDefault(),...x,...Ie,onPlaced:()=>O(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:se(x.onKeyDown,K=>{const M=K.ctrlKey||K.altKey||K.metaKey;if(K.key==="Tab"&&K.preventDefault(),!M&&K.key.length===1&&H(K.key),["ArrowUp","ArrowDown","Home","End"].includes(K.key)){let ee=$().filter(de=>!de.disabled).map(de=>de.ref.current);if(["ArrowUp","End"].includes(K.key)&&(ee=ee.slice().reverse()),["ArrowUp","ArrowDown"].includes(K.key)){const de=K.target,ce=ee.indexOf(de);ee=ee.slice(ce+1)}setTimeout(()=>B(ee)),K.preventDefault()}})})})})})})});Ph.displayName=LS;var FS="SelectItemAlignedPosition",Oh=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=bn(zn,n),i=yn(zn,n),[a,c]=p.useState(null),[u,d]=p.useState(null),f=Pe(t,I=>d(I)),h=vs(n),m=p.useRef(!1),w=p.useRef(!0),{viewport:v,selectedItem:g,selectedItemText:x,focusSelectedItem:b}=i,S=p.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&v&&g&&x){const I=s.trigger.getBoundingClientRect(),N=u.getBoundingClientRect(),_=s.valueNode.getBoundingClientRect(),j=x.getBoundingClientRect();if(s.dir!=="rtl"){const de=j.left-N.left,ce=_.left-de,ze=I.left-ce,Ye=I.width+ze,V=Math.max(Ye,N.width),J=window.innerWidth-Wt,be=ga(ce,[Wt,Math.max(Wt,J-V)]);a.style.minWidth=Ye+"px",a.style.left=be+"px"}else{const de=N.right-j.right,ce=window.innerWidth-_.right-de,ze=window.innerWidth-I.right-ce,Ye=I.width+ze,V=Math.max(Ye,N.width),J=window.innerWidth-Wt,be=ga(ce,[Wt,Math.max(Wt,J-V)]);a.style.minWidth=Ye+"px",a.style.right=be+"px"}const R=h(),$=window.innerHeight-Wt*2,z=v.scrollHeight,O=window.getComputedStyle(u),W=parseInt(O.borderTopWidth,10),B=parseInt(O.paddingTop,10),q=parseInt(O.borderBottomWidth,10),L=parseInt(O.paddingBottom,10),A=W+B+z+L+q,D=Math.min(g.offsetHeight*5,A),H=window.getComputedStyle(v),X=parseInt(H.paddingTop,10),Q=parseInt(H.paddingBottom,10),ue=I.top+I.height/2-Wt,we=$-ue,Ie=g.offsetHeight/2,K=g.offsetTop+Ie,M=W+B+K,Y=A-M;if(M<=ue){const de=R.length>0&&g===R[R.length-1].ref.current;a.style.bottom="0px";const ce=u.clientHeight-v.offsetTop-v.offsetHeight,ze=Math.max(we,Ie+(de?Q:0)+ce+q),Ye=M+ze;a.style.height=Ye+"px"}else{const de=R.length>0&&g===R[0].ref.current;a.style.top="0px";const ze=Math.max(ue,W+v.offsetTop+(de?X:0)+Ie)+Y;a.style.height=ze+"px",v.scrollTop=M-ue+v.offsetTop}a.style.margin=`${Wt}px 0`,a.style.minHeight=D+"px",a.style.maxHeight=$+"px",r==null||r(),requestAnimationFrame(()=>m.current=!0)}},[h,s.trigger,s.valueNode,a,u,v,g,x,s.dir,r]);ct(()=>S(),[S]);const[k,C]=p.useState();ct(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const T=p.useCallback(I=>{I&&w.current===!0&&(S(),b==null||b(),w.current=!1)},[S,b]);return l.jsx(BS,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:m,onScrollButtonChange:T,children:l.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:l.jsx(Se.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Oh.displayName=FS;var zS="SelectPopperPosition",Sa=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Wt,...s}=e,i=ws(n);return l.jsx(Ud,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Sa.displayName=zS;var[BS,Ca]=sr(zn,{}),Ta="SelectViewport",Mh=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=yn(Ta,n),i=Ca(Ta,n),a=Pe(t,s.onViewportChange),c=p.useRef(0);return l.jsxs(l.Fragment,{children:[l.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),l.jsx(xs.Slot,{scope:n,children:l.jsx(Se.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:se(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const m=Math.abs(c.current-d.scrollTop);if(m>0){const w=window.innerHeight-Wt*2,v=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),x=Math.max(v,g);if(x<w){const b=x+m,S=Math.min(w,b),k=b-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,f.style.justifyContent="flex-end")}}}c.current=d.scrollTop})})})]})});Mh.displayName=Ta;var Dh="SelectGroup",[HS,US]=sr(Dh),WS=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Xt();return l.jsx(HS,{scope:n,id:o,children:l.jsx(Se.div,{role:"group","aria-labelledby":o,...r,ref:t})})});WS.displayName=Dh;var Lh="SelectLabel",$h=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=US(Lh,n);return l.jsx(Se.div,{id:o.id,...r,ref:t})});$h.displayName=Lh;var bs="SelectItem",[VS,Fh]=sr(bs),zh=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=bn(bs,n),c=yn(bs,n),u=a.value===r,[d,f]=p.useState(s??""),[h,m]=p.useState(!1),w=Pe(t,b=>{var S;return(S=c.itemRefCallback)==null?void 0:S.call(c,b,r,o)}),v=Xt(),g=p.useRef("touch"),x=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return l.jsx(VS,{scope:n,value:r,disabled:o,textId:v,isSelected:u,onItemTextChange:p.useCallback(b=>{f(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:l.jsx(xs.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:l.jsx(Se.div,{role:"option","aria-labelledby":v,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:w,onFocus:se(i.onFocus,()=>m(!0)),onBlur:se(i.onBlur,()=>m(!1)),onClick:se(i.onClick,()=>{g.current!=="mouse"&&x()}),onPointerUp:se(i.onPointerUp,()=>{g.current==="mouse"&&x()}),onPointerDown:se(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:se(i.onPointerMove,b=>{var S;g.current=b.pointerType,o?(S=c.onItemLeave)==null||S.call(c):g.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:se(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=c.onItemLeave)==null||S.call(c))}),onKeyDown:se(i.onKeyDown,b=>{var k;((k=c.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(_S.includes(b.key)&&x(),b.key===" "&&b.preventDefault())})})})})});zh.displayName=bs;var zr="SelectItemText",Bh=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=bn(zr,n),a=yn(zr,n),c=Fh(zr,n),u=OS(zr,n),[d,f]=p.useState(null),h=Pe(t,x=>f(x),c.onItemTextChange,x=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,x,c.value,c.disabled)}),m=d==null?void 0:d.textContent,w=p.useMemo(()=>l.jsx("option",{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:v,onNativeOptionRemove:g}=u;return ct(()=>(v(w),()=>g(w)),[v,g,w]),l.jsxs(l.Fragment,{children:[l.jsx(Se.span,{id:c.textId,...s,ref:h}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?qr.createPortal(s.children,i.valueNode):null]})});Bh.displayName=zr;var Hh="SelectItemIndicator",Uh=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Fh(Hh,n).isSelected?l.jsx(Se.span,{"aria-hidden":!0,...r,ref:t}):null});Uh.displayName=Hh;var Ea="SelectScrollUpButton",Wh=p.forwardRef((e,t)=>{const n=yn(Ea,e.__scopeSelect),r=Ca(Ea,e.__scopeSelect),[o,s]=p.useState(!1),i=Pe(t,r.onScrollButtonChange);return ct(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollTop>0;s(u)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?l.jsx(Kh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop-c.offsetHeight)}}):null});Wh.displayName=Ea;var ka="SelectScrollDownButton",Vh=p.forwardRef((e,t)=>{const n=yn(ka,e.__scopeSelect),r=Ca(ka,e.__scopeSelect),[o,s]=p.useState(!1),i=Pe(t,r.onScrollButtonChange);return ct(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollHeight-c.clientHeight,d=Math.ceil(c.scrollTop)<u;s(d)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?l.jsx(Kh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop+c.offsetHeight)}}):null});Vh.displayName=ka;var Kh=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=yn("SelectScrollButton",n),i=p.useRef(null),a=vs(n),c=p.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return p.useEffect(()=>()=>c(),[c]),ct(()=>{var d;const u=a().find(f=>f.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),l.jsx(Se.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:se(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:se(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:se(o.onPointerLeave,()=>{c()})})}),KS="SelectSeparator",qh=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return l.jsx(Se.div,{"aria-hidden":!0,...r,ref:t})});qh.displayName=KS;var Ia="SelectArrow",qS=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ws(n),s=bn(Ia,n),i=yn(Ia,n);return s.open&&i.position==="popper"?l.jsx(Wd,{...o,...r,ref:t}):null});qS.displayName=Ia;var GS="SelectBubbleInput",Gh=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),s=Pe(r,o),i=gh(t);return p.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),l.jsx(Se.select,{...n,style:{...Ch,...n.style},ref:s,defaultValue:t})});Gh.displayName=GS;function Yh(e){return e===""||e===void 0}function Xh(e){const t=ut(e),n=p.useRef(""),r=p.useRef(0),o=p.useCallback(i=>{const a=n.current+i;t(a),function c(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>c(""),1e3))}(a)},[t]),s=p.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Jh(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=YS(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function YS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var XS=Th,Zh=kh,JS=Nh,ZS=Ah,QS=_h,Qh=jh,eC=Mh,ep=$h,tp=zh,tC=Bh,nC=Uh,np=Wh,rp=Vh,op=qh;const sp=XS,ip=JS,Na=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Zh,{ref:r,className:Z("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,l.jsx(ZS,{asChild:!0,children:l.jsx(te.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Na.displayName=Zh.displayName;const ap=p.forwardRef(({className:e,...t},n)=>l.jsx(np,{ref:n,className:Z("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(te.ChevronUp,{className:"h-4 w-4"})}));ap.displayName=np.displayName;const lp=p.forwardRef(({className:e,...t},n)=>l.jsx(rp,{ref:n,className:Z("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(te.ChevronDown,{className:"h-4 w-4"})}));lp.displayName=rp.displayName;const Aa=p.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>l.jsx(QS,{children:l.jsxs(Qh,{ref:o,className:Z("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",n==="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",e),position:n,...r,children:[l.jsx(ap,{}),l.jsx(eC,{className:Z("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),l.jsx(lp,{})]})}));Aa.displayName=Qh.displayName;const rC=p.forwardRef(({className:e,...t},n)=>l.jsx(ep,{ref:n,className:Z("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));rC.displayName=ep.displayName;const Bn=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(tp,{ref:r,className:Z("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(nC,{children:l.jsx(te.Check,{className:"h-4 w-4"})})}),l.jsx(tC,{children:t})]}));Bn.displayName=tp.displayName;const oC=p.forwardRef(({className:e,...t},n)=>l.jsx(op,{ref:n,className:Z("-mx-1 my-1 h-px bg-muted",e),...t}));oC.displayName=op.displayName;var sC="Separator",cp="horizontal",iC=["horizontal","vertical"],up=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=cp,...o}=e,s=aC(r)?r:cp,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return l.jsx(Se.div,{"data-orientation":s,...a,...o,ref:t})});up.displayName=sC;function aC(e){return iC.includes(e)}var dp=up;const fp=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>l.jsx(dp,{ref:o,decorative:n,orientation:t,className:Z("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));fp.displayName=dp.displayName;const lC=Xu,cC=Hw,uC=Ju,hp=p.forwardRef(({className:e,...t},n)=>l.jsx(Uo,{className:Z("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));hp.displayName=Uo.displayName;const dC=Kr.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),pp=p.forwardRef(({side:e="right",className:t,children:n,...r},o)=>l.jsxs(uC,{children:[l.jsx(hp,{}),l.jsxs(Wo,{ref:o,className:Z(dC({side:e}),t),...r,children:[n,l.jsxs(Zu,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[l.jsx(te.X,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));pp.displayName=Wo.displayName;const mp=({className:e,...t})=>l.jsx("div",{className:Z("flex flex-col space-y-2 text-center sm:text-left",e),...t});mp.displayName="SheetHeader";const gp=p.forwardRef(({className:e,...t},n)=>l.jsx(On,{ref:n,className:Z("text-lg font-semibold text-foreground",e),...t}));gp.displayName=On.displayName;const xp=p.forwardRef(({className:e,...t},n)=>l.jsx(Vo,{ref:n,className:Z("text-sm text-muted-foreground",e),...t}));xp.displayName=Vo.displayName;const fC={api:{baseUrl:"http://localhost:8000/api",authToken:"",enableAuth:!1},ui:{layout:"sidebar",theme:"light",showTimestamps:!0,showAgentNames:!0,compactMessages:!1},behavior:{autoSave:!0,enableStreaming:!0,showTypingIndicator:!0}};function hC({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=y.useState(!1),[s,i]=y.useState(!1),[a,c]=y.useState(e),[u,d]=y.useState(!1),{toast:f}=Ii();y.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),y.useEffect(()=>{c(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},m=()=>{c(fC),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},w=()=>{c(e),d(!1),o(!1)},v=async()=>{try{const x=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${x.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return l.jsxs(lC,{open:r,onOpenChange:o,children:[l.jsx(cC,{asChild:!0,children:l.jsxs(Fe,{variant:"outline",size:"sm",className:n,children:[l.jsx(te.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&l.jsx(xi,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),l.jsxs(pp,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[l.jsxs(mp,{children:[l.jsx(gp,{children:"Chat Settings"}),l.jsx(xp,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),l.jsxs("div",{className:"space-y-6 py-6",children:[l.jsxs(kr,{children:[l.jsx(Ir,{className:"pb-3",children:l.jsxs(Nr,{className:"text-lg flex items-center gap-2",children:[l.jsx(te.Server,{className:"h-5 w-5"}),"API Configuration"]})}),l.jsxs(Co,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(Mt,{htmlFor:"api-url",children:"API Base URL"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(ds,{id:"api-url",value:a.api.baseUrl,onChange:g=>c(x=>({...x,api:{...x.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),l.jsx(Fe,{variant:"outline",onClick:v,children:"Test"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Mt,{htmlFor:"enable-auth",children:"Enable Authentication"}),l.jsx(wn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>c(x=>({...x,api:{...x.api,enableAuth:g}}))})]}),a.api.enableAuth&&l.jsxs("div",{className:"space-y-2",children:[l.jsx(Mt,{htmlFor:"auth-token",children:"Authentication Token"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(ds,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>c(x=>({...x,api:{...x.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),l.jsx(Fe,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?l.jsx(te.EyeOff,{className:"h-4 w-4"}):l.jsx(te.Eye,{className:"h-4 w-4"})})]})]})]})]}),l.jsxs(kr,{children:[l.jsx(Ir,{className:"pb-3",children:l.jsxs(Nr,{className:"text-lg flex items-center gap-2",children:[l.jsx(te.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),l.jsxs(Co,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(Mt,{htmlFor:"layout",children:"Layout Style"}),l.jsxs(sp,{value:a.ui.layout,onValueChange:g=>c(x=>({...x,ui:{...x.ui,layout:g}})),children:[l.jsx(Na,{children:l.jsx(ip,{})}),l.jsxs(Aa,{children:[l.jsx(Bn,{value:"sidebar",children:"Sidebar Layout"}),l.jsx(Bn,{value:"fullscreen",children:"Fullscreen"}),l.jsx(Bn,{value:"tabs",children:"Tabbed Interface"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(Mt,{htmlFor:"theme",children:"Theme"}),l.jsxs(sp,{value:a.ui.theme,onValueChange:g=>c(x=>({...x,ui:{...x.ui,theme:g}})),children:[l.jsx(Na,{children:l.jsx(ip,{})}),l.jsxs(Aa,{children:[l.jsx(Bn,{value:"light",children:"Light"}),l.jsx(Bn,{value:"dark",children:"Dark"}),l.jsx(Bn,{value:"system",children:"System"})]})]})]}),l.jsx(fp,{}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Mt,{htmlFor:"show-timestamps",children:"Show Timestamps"}),l.jsx(wn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,showTimestamps:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Mt,{htmlFor:"show-agent-names",children:"Show Agent Names"}),l.jsx(wn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,showAgentNames:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Mt,{htmlFor:"compact-messages",children:"Compact Messages"}),l.jsx(wn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,compactMessages:g}}))})]})]})]})]}),l.jsxs(kr,{children:[l.jsx(Ir,{className:"pb-3",children:l.jsxs(Nr,{className:"text-lg flex items-center gap-2",children:[l.jsx(te.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),l.jsxs(Co,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(Mt,{htmlFor:"auto-save",children:"Auto-save Conversations"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),l.jsx(wn,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,autoSave:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(Mt,{htmlFor:"enable-streaming",children:"Enable Streaming"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),l.jsx(wn,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,enableStreaming:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(Mt,{htmlFor:"typing-indicator",children:"Typing Indicator"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),l.jsx(wn,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,showTypingIndicator:g}}))})]})]})]})]}),l.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[l.jsxs(Fe,{variant:"outline",onClick:m,children:[l.jsx(te.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Fe,{variant:"outline",onClick:w,children:"Cancel"}),l.jsxs(Fe,{onClick:h,disabled:!u,children:[l.jsx(te.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function pC({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),c=y.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?l.jsx(io,{...s,onThreadChange:c,children:l.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:l.jsx(us,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?l.jsx(io,{...s,onThreadChange:c,children:l.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:l.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&l.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:l.jsx(ya,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),l.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:l.jsx(us,{onError:s.onError,enableFileUpload:!0})})]})})}):l.jsx(io,{...s,onThreadChange:c,children:l.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&l.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:l.jsx(ya,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),l.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:l.jsx(us,{onError:s.onError,enableFileUpload:!0})})]})})}Te.ChatApi=_l,Te.ChatInterface=us,Te.ChatProviders=io,Te.ChatSettings=hC,Te.MarkdownContent=Ti,Te.MessageComponent=ad,Te.MessageList=Ui,Te.ThreadManager=ya,Te.applySettings=wS,Te.chatApiClient=cn,Te.default=pC,Te.del=Al,Te.get=St,Te.getChatToken=kl,Te.getCurrentSettings=vS,Te.getDefaultApiConfig=dh,Te.getDefaultChatSettings=fh,Te.onChatTokenChanged=Il,Te.post=Us,Te.put=Nl,Te.setChatToken=Hs,Te.useApi=so,Te.useChatStream=Fl,Te.useMessages=qs,Te.useMessagesReducer=Ll,Te.useStream=Ol,Te.useThreads=mr,Object.defineProperties(Te,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});