teodor-new-chat-ui 4.3.42 → 4.3.44

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(Ne,w){typeof exports=="object"&&typeof module<"u"?w(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"],w):(Ne=typeof globalThis<"u"?globalThis:Ne||self,w(Ne.NewChatUI={},Ne.React,Ne.LucideReact,Ne.reactSlot,Ne.classVarianceAuthority,Ne.clsx,Ne.tailwindMerge,Ne.ReactDOM))})(this,function(Ne,w,ue,or,Po,jm,Rm,pi){"use strict";var YT=Object.defineProperty;var XT=(Ne,w,ue)=>w in Ne?YT(Ne,w,{enumerable:!0,configurable:!0,writable:!0,value:ue}):Ne[w]=ue;var Am=(Ne,w,ue)=>XT(Ne,typeof w!="symbol"?w+"":w,ue);function Il(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 m=Il(w),Oo=Il(pi);var mi={exports:{}},Vr={};/**
1
+ (function(Ne,w){typeof exports=="object"&&typeof module<"u"?w(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"],w):(Ne=typeof globalThis<"u"?globalThis:Ne||self,w(Ne.NewChatUI={},Ne.React,Ne.LucideReact,Ne.reactSlot,Ne.classVarianceAuthority,Ne.clsx,Ne.tailwindMerge,Ne.ReactDOM))})(this,function(Ne,w,ue,or,Po,Am,_m,pi){"use strict";var Xk=Object.defineProperty;var Jk=(Ne,w,ue)=>w in Ne?Xk(Ne,w,{enumerable:!0,configurable:!0,writable:!0,value:ue}):Ne[w]=ue;var Im=(Ne,w,ue)=>Jk(Ne,typeof w!="symbol"?w+"":w,ue);function Il(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 m=Il(w),Oo=Il(pi);var mi={exports:{}},Vr={};/**
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 Nl;function Pm(){if(Nl)return Vr;Nl=1;var e=w,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,l,u){var d,f={},h=null,p=null;u!==void 0&&(h=""+u),l.key!==void 0&&(h=""+l.key),l.ref!==void 0&&(p=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(f[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)f[d]===void 0&&(f[d]=l[d]);return{$$typeof:t,type:a,key:h,ref:p,props:f,_owner:o.current}}return Vr.Fragment=n,Vr.jsx=i,Vr.jsxs=i,Vr}var Kr={};/**
9
+ */var Nl;function jm(){if(Nl)return Vr;Nl=1;var e=w,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,l,u){var d,f={},h=null,p=null;u!==void 0&&(h=""+u),l.key!==void 0&&(h=""+l.key),l.ref!==void 0&&(p=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(f[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)f[d]===void 0&&(f[d]=l[d]);return{$$typeof:t,type:a,key:h,ref:p,props:f,_owner:o.current}}return Vr.Fragment=n,Vr.jsx=i,Vr.jsxs=i,Vr}var Kr={};/**
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 Al;function Om(){return Al||(Al=1,process.env.NODE_ENV!=="production"&&function(){var e=w,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"),l=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"),p=Symbol.for("react.offscreen"),v=Symbol.iterator,x="@@iterator";function g(S){if(S===null||typeof S!="object")return null;var P=v&&S[v]||S[x];return typeof P=="function"?P:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(S){{for(var P=arguments.length,B=new Array(P>1?P-1:0),oe=1;oe<P;oe++)B[oe-1]=arguments[oe];C("error",S,B)}}function C(S,P,B){{var oe=y.ReactDebugCurrentFrame,Te=oe.getStackAddendum();Te!==""&&(P+="%s",B=B.concat([Te]));var $e=B.map(function(Me){return String(Me)});$e.unshift("Warning: "+P),Function.prototype.apply.call(console[S],console,$e)}}var E=!1,T=!1,k=!1,I=!1,_=!1,R;R=Symbol.for("react.module.reference");function j(S){return!!(typeof S=="string"||typeof S=="function"||S===r||S===s||_||S===o||S===u||S===d||I||S===p||E||T||k||typeof S=="object"&&S!==null&&(S.$$typeof===h||S.$$typeof===f||S.$$typeof===i||S.$$typeof===a||S.$$typeof===l||S.$$typeof===R||S.getModuleId!==void 0))}function H(S,P,B){var oe=S.displayName;if(oe)return oe;var Te=P.displayName||P.name||"";return Te!==""?B+"("+Te+")":B}function F(S){return S.displayName||"Context"}function U(S){if(S==null)return null;if(typeof S.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof S=="function")return S.displayName||S.name||null;if(typeof S=="string")return S;switch(S){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 S=="object")switch(S.$$typeof){case a:var P=S;return F(P)+".Consumer";case i:var B=S;return F(B._context)+".Provider";case l:return H(S,S.render,"ForwardRef");case f:var oe=S.displayName||null;return oe!==null?oe:U(S.type)||"Memo";case h:{var Te=S,$e=Te._payload,Me=Te._init;try{return U(Me($e))}catch{return null}}}return null}var D=Object.assign,G=0,W,ne,$,z,ie,M,Y;function ce(){}ce.__reactDisabledLog=!0;function be(){{if(G===0){W=console.log,ne=console.info,$=console.warn,z=console.error,ie=console.group,M=console.groupCollapsed,Y=console.groupEnd;var S={configurable:!0,enumerable:!0,value:ce,writable:!0};Object.defineProperties(console,{info:S,log:S,warn:S,error:S,group:S,groupCollapsed:S,groupEnd:S})}G++}}function ge(){{if(G--,G===0){var S={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:D({},S,{value:W}),info:D({},S,{value:ne}),warn:D({},S,{value:$}),error:D({},S,{value:z}),group:D({},S,{value:ie}),groupCollapsed:D({},S,{value:M}),groupEnd:D({},S,{value:Y})})}G<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ye=y.ReactCurrentDispatcher,K;function L(S,P,B){{if(K===void 0)try{throw Error()}catch(Te){var oe=Te.stack.trim().match(/\n( *(at )?)/);K=oe&&oe[1]||""}return`
18
- `+K+S}}var Z=!1,ee;{var me=typeof WeakMap=="function"?WeakMap:Map;ee=new me}function se(S,P){if(!S||Z)return"";{var B=ee.get(S);if(B!==void 0)return B}var oe;Z=!0;var Te=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var $e;$e=ye.current,ye.current=null,be();try{if(P){var Me=function(){throw Error()};if(Object.defineProperty(Me.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Me,[])}catch(_t){oe=_t}Reflect.construct(S,[],Me)}else{try{Me.call()}catch(_t){oe=_t}S.call(Me.prototype)}}else{try{throw Error()}catch(_t){oe=_t}S()}}catch(_t){if(_t&&oe&&typeof _t.stack=="string"){for(var ke=_t.stack.split(`
17
+ */var Al;function Rm(){return Al||(Al=1,process.env.NODE_ENV!=="production"&&function(){var e=w,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"),l=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"),p=Symbol.for("react.offscreen"),v=Symbol.iterator,x="@@iterator";function g(S){if(S===null||typeof S!="object")return null;var P=v&&S[v]||S[x];return typeof P=="function"?P:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(S){{for(var P=arguments.length,B=new Array(P>1?P-1:0),oe=1;oe<P;oe++)B[oe-1]=arguments[oe];C("error",S,B)}}function C(S,P,B){{var oe=y.ReactDebugCurrentFrame,ke=oe.getStackAddendum();ke!==""&&(P+="%s",B=B.concat([ke]));var $e=B.map(function(Me){return String(Me)});$e.unshift("Warning: "+P),Function.prototype.apply.call(console[S],console,$e)}}var E=!1,k=!1,T=!1,I=!1,_=!1,R;R=Symbol.for("react.module.reference");function j(S){return!!(typeof S=="string"||typeof S=="function"||S===r||S===s||_||S===o||S===u||S===d||I||S===p||E||k||T||typeof S=="object"&&S!==null&&(S.$$typeof===h||S.$$typeof===f||S.$$typeof===i||S.$$typeof===a||S.$$typeof===l||S.$$typeof===R||S.getModuleId!==void 0))}function H(S,P,B){var oe=S.displayName;if(oe)return oe;var ke=P.displayName||P.name||"";return ke!==""?B+"("+ke+")":B}function F(S){return S.displayName||"Context"}function U(S){if(S==null)return null;if(typeof S.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof S=="function")return S.displayName||S.name||null;if(typeof S=="string")return S;switch(S){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 S=="object")switch(S.$$typeof){case a:var P=S;return F(P)+".Consumer";case i:var B=S;return F(B._context)+".Provider";case l:return H(S,S.render,"ForwardRef");case f:var oe=S.displayName||null;return oe!==null?oe:U(S.type)||"Memo";case h:{var ke=S,$e=ke._payload,Me=ke._init;try{return U(Me($e))}catch{return null}}}return null}var D=Object.assign,G=0,W,ne,$,z,ie,M,Y;function ce(){}ce.__reactDisabledLog=!0;function be(){{if(G===0){W=console.log,ne=console.info,$=console.warn,z=console.error,ie=console.group,M=console.groupCollapsed,Y=console.groupEnd;var S={configurable:!0,enumerable:!0,value:ce,writable:!0};Object.defineProperties(console,{info:S,log:S,warn:S,error:S,group:S,groupCollapsed:S,groupEnd:S})}G++}}function ge(){{if(G--,G===0){var S={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:D({},S,{value:W}),info:D({},S,{value:ne}),warn:D({},S,{value:$}),error:D({},S,{value:z}),group:D({},S,{value:ie}),groupCollapsed:D({},S,{value:M}),groupEnd:D({},S,{value:Y})})}G<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ye=y.ReactCurrentDispatcher,K;function L(S,P,B){{if(K===void 0)try{throw Error()}catch(ke){var oe=ke.stack.trim().match(/\n( *(at )?)/);K=oe&&oe[1]||""}return`
18
+ `+K+S}}var Z=!1,ee;{var me=typeof WeakMap=="function"?WeakMap:Map;ee=new me}function se(S,P){if(!S||Z)return"";{var B=ee.get(S);if(B!==void 0)return B}var oe;Z=!0;var ke=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var $e;$e=ye.current,ye.current=null,be();try{if(P){var Me=function(){throw Error()};if(Object.defineProperty(Me.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Me,[])}catch(_t){oe=_t}Reflect.construct(S,[],Me)}else{try{Me.call()}catch(_t){oe=_t}S.call(Me.prototype)}}else{try{throw Error()}catch(_t){oe=_t}S()}}catch(_t){if(_t&&oe&&typeof _t.stack=="string"){for(var Te=_t.stack.split(`
19
19
  `),It=oe.stack.split(`
20
- `),dt=ke.length-1,ht=It.length-1;dt>=1&&ht>=0&&ke[dt]!==It[ht];)ht--;for(;dt>=1&&ht>=0;dt--,ht--)if(ke[dt]!==It[ht]){if(dt!==1||ht!==1)do if(dt--,ht--,ht<0||ke[dt]!==It[ht]){var Bt=`
21
- `+ke[dt].replace(" at new "," at ");return S.displayName&&Bt.includes("<anonymous>")&&(Bt=Bt.replace("<anonymous>",S.displayName)),typeof S=="function"&&ee.set(S,Bt),Bt}while(dt>=1&&ht>=0);break}}}finally{Z=!1,ye.current=$e,ge(),Error.prepareStackTrace=Te}var Un=S?S.displayName||S.name:"",Jt=Un?L(Un):"";return typeof S=="function"&&ee.set(S,Jt),Jt}function ae(S,P,B){return se(S,!1)}function He(S){var P=S.prototype;return!!(P&&P.isReactComponent)}function Je(S,P,B){if(S==null)return"";if(typeof S=="function")return se(S,He(S));if(typeof S=="string")return L(S);switch(S){case u:return L("Suspense");case d:return L("SuspenseList")}if(typeof S=="object")switch(S.$$typeof){case l:return ae(S.render);case f:return Je(S.type,P,B);case h:{var oe=S,Te=oe._payload,$e=oe._init;try{return Je($e(Te),P,B)}catch{}}}return""}var je=Object.prototype.hasOwnProperty,Ue={},et=y.ReactDebugCurrentFrame;function Ze(S){if(S){var P=S._owner,B=Je(S.type,S._source,P?P.type:null);et.setExtraStackFrame(B)}else et.setExtraStackFrame(null)}function Pe(S,P,B,oe,Te){{var $e=Function.call.bind(je);for(var Me in S)if($e(S,Me)){var ke=void 0;try{if(typeof S[Me]!="function"){var It=Error((oe||"React class")+": "+B+" type `"+Me+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof S[Me]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw It.name="Invariant Violation",It}ke=S[Me](P,Me,oe,B,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(dt){ke=dt}ke&&!(ke instanceof Error)&&(Ze(Te),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).",oe||"React class",B,Me,typeof ke),Ze(null)),ke instanceof Error&&!(ke.message in Ue)&&(Ue[ke.message]=!0,Ze(Te),b("Failed %s type: %s",B,ke.message),Ze(null))}}}var Ct=Array.isArray;function kt(S){return Ct(S)}function Et(S){{var P=typeof Symbol=="function"&&Symbol.toStringTag,B=P&&S[Symbol.toStringTag]||S.constructor.name||"Object";return B}}function st(S){try{return tt(S),!1}catch{return!0}}function tt(S){return""+S}function ze(S){if(st(S))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Et(S)),tt(S)}var ct=y.ReactCurrentOwner,bt={key:!0,ref:!0,__self:!0,__source:!0},X,xe;function de(S){if(je.call(S,"ref")){var P=Object.getOwnPropertyDescriptor(S,"ref").get;if(P&&P.isReactWarning)return!1}return S.ref!==void 0}function _e(S){if(je.call(S,"key")){var P=Object.getOwnPropertyDescriptor(S,"key").get;if(P&&P.isReactWarning)return!1}return S.key!==void 0}function Fe(S,P){typeof S.ref=="string"&&ct.current}function nt(S,P){{var B=function(){X||(X=!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)",P))};B.isReactWarning=!0,Object.defineProperty(S,"key",{get:B,configurable:!0})}}function pt(S,P){{var B=function(){xe||(xe=!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)",P))};B.isReactWarning=!0,Object.defineProperty(S,"ref",{get:B,configurable:!0})}}var Qe=function(S,P,B,oe,Te,$e,Me){var ke={$$typeof:t,type:S,key:P,ref:B,props:Me,_owner:$e};return ke._store={},Object.defineProperty(ke._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(ke,"_self",{configurable:!1,enumerable:!1,writable:!1,value:oe}),Object.defineProperty(ke,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Te}),Object.freeze&&(Object.freeze(ke.props),Object.freeze(ke)),ke};function ut(S,P,B,oe,Te){{var $e,Me={},ke=null,It=null;B!==void 0&&(ze(B),ke=""+B),_e(P)&&(ze(P.key),ke=""+P.key),de(P)&&(It=P.ref,Fe(P,Te));for($e in P)je.call(P,$e)&&!bt.hasOwnProperty($e)&&(Me[$e]=P[$e]);if(S&&S.defaultProps){var dt=S.defaultProps;for($e in dt)Me[$e]===void 0&&(Me[$e]=dt[$e])}if(ke||It){var ht=typeof S=="function"?S.displayName||S.name||"Unknown":S;ke&&nt(Me,ht),It&&pt(Me,ht)}return Qe(S,ke,It,Te,oe,ct.current,Me)}}var mt=y.ReactCurrentOwner,$n=y.ReactDebugCurrentFrame;function zn(S){if(S){var P=S._owner,B=Je(S.type,S._source,P?P.type:null);$n.setExtraStackFrame(B)}else $n.setExtraStackFrame(null)}var Tr;Tr=!1;function Bn(S){return typeof S=="object"&&S!==null&&S.$$typeof===t}function Ft(){{if(mt.current){var S=U(mt.current.type);if(S)return`
20
+ `),dt=Te.length-1,ht=It.length-1;dt>=1&&ht>=0&&Te[dt]!==It[ht];)ht--;for(;dt>=1&&ht>=0;dt--,ht--)if(Te[dt]!==It[ht]){if(dt!==1||ht!==1)do if(dt--,ht--,ht<0||Te[dt]!==It[ht]){var Bt=`
21
+ `+Te[dt].replace(" at new "," at ");return S.displayName&&Bt.includes("<anonymous>")&&(Bt=Bt.replace("<anonymous>",S.displayName)),typeof S=="function"&&ee.set(S,Bt),Bt}while(dt>=1&&ht>=0);break}}}finally{Z=!1,ye.current=$e,ge(),Error.prepareStackTrace=ke}var Un=S?S.displayName||S.name:"",Jt=Un?L(Un):"";return typeof S=="function"&&ee.set(S,Jt),Jt}function ae(S,P,B){return se(S,!1)}function He(S){var P=S.prototype;return!!(P&&P.isReactComponent)}function Je(S,P,B){if(S==null)return"";if(typeof S=="function")return se(S,He(S));if(typeof S=="string")return L(S);switch(S){case u:return L("Suspense");case d:return L("SuspenseList")}if(typeof S=="object")switch(S.$$typeof){case l:return ae(S.render);case f:return Je(S.type,P,B);case h:{var oe=S,ke=oe._payload,$e=oe._init;try{return Je($e(ke),P,B)}catch{}}}return""}var je=Object.prototype.hasOwnProperty,Ue={},et=y.ReactDebugCurrentFrame;function Ze(S){if(S){var P=S._owner,B=Je(S.type,S._source,P?P.type:null);et.setExtraStackFrame(B)}else et.setExtraStackFrame(null)}function Pe(S,P,B,oe,ke){{var $e=Function.call.bind(je);for(var Me in S)if($e(S,Me)){var Te=void 0;try{if(typeof S[Me]!="function"){var It=Error((oe||"React class")+": "+B+" type `"+Me+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof S[Me]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw It.name="Invariant Violation",It}Te=S[Me](P,Me,oe,B,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(dt){Te=dt}Te&&!(Te instanceof Error)&&(Ze(ke),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).",oe||"React class",B,Me,typeof Te),Ze(null)),Te instanceof Error&&!(Te.message in Ue)&&(Ue[Te.message]=!0,Ze(ke),b("Failed %s type: %s",B,Te.message),Ze(null))}}}var Ct=Array.isArray;function Tt(S){return Ct(S)}function Et(S){{var P=typeof Symbol=="function"&&Symbol.toStringTag,B=P&&S[Symbol.toStringTag]||S.constructor.name||"Object";return B}}function st(S){try{return tt(S),!1}catch{return!0}}function tt(S){return""+S}function ze(S){if(st(S))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Et(S)),tt(S)}var ct=y.ReactCurrentOwner,bt={key:!0,ref:!0,__self:!0,__source:!0},X,xe;function de(S){if(je.call(S,"ref")){var P=Object.getOwnPropertyDescriptor(S,"ref").get;if(P&&P.isReactWarning)return!1}return S.ref!==void 0}function _e(S){if(je.call(S,"key")){var P=Object.getOwnPropertyDescriptor(S,"key").get;if(P&&P.isReactWarning)return!1}return S.key!==void 0}function Fe(S,P){typeof S.ref=="string"&&ct.current}function nt(S,P){{var B=function(){X||(X=!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)",P))};B.isReactWarning=!0,Object.defineProperty(S,"key",{get:B,configurable:!0})}}function pt(S,P){{var B=function(){xe||(xe=!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)",P))};B.isReactWarning=!0,Object.defineProperty(S,"ref",{get:B,configurable:!0})}}var Qe=function(S,P,B,oe,ke,$e,Me){var Te={$$typeof:t,type:S,key:P,ref:B,props:Me,_owner:$e};return Te._store={},Object.defineProperty(Te._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Te,"_self",{configurable:!1,enumerable:!1,writable:!1,value:oe}),Object.defineProperty(Te,"_source",{configurable:!1,enumerable:!1,writable:!1,value:ke}),Object.freeze&&(Object.freeze(Te.props),Object.freeze(Te)),Te};function ut(S,P,B,oe,ke){{var $e,Me={},Te=null,It=null;B!==void 0&&(ze(B),Te=""+B),_e(P)&&(ze(P.key),Te=""+P.key),de(P)&&(It=P.ref,Fe(P,ke));for($e in P)je.call(P,$e)&&!bt.hasOwnProperty($e)&&(Me[$e]=P[$e]);if(S&&S.defaultProps){var dt=S.defaultProps;for($e in dt)Me[$e]===void 0&&(Me[$e]=dt[$e])}if(Te||It){var ht=typeof S=="function"?S.displayName||S.name||"Unknown":S;Te&&nt(Me,ht),It&&pt(Me,ht)}return Qe(S,Te,It,ke,oe,ct.current,Me)}}var mt=y.ReactCurrentOwner,$n=y.ReactDebugCurrentFrame;function zn(S){if(S){var P=S._owner,B=Je(S.type,S._source,P?P.type:null);$n.setExtraStackFrame(B)}else $n.setExtraStackFrame(null)}var kr;kr=!1;function Bn(S){return typeof S=="object"&&S!==null&&S.$$typeof===t}function Ft(){{if(mt.current){var S=U(mt.current.type);if(S)return`
22
22
 
23
23
  Check the render method of \``+S+"`."}return""}}function Io(S){return""}var Hn={};function wt(S){{var P=Ft();if(!P){var B=typeof S=="string"?S:S.displayName||S.name;B&&(P=`
24
24
 
25
- Check the top-level render call using <`+B+">.")}return P}}function mn(S,P){{if(!S._store||S._store.validated||S.key!=null)return;S._store.validated=!0;var B=wt(P);if(Hn[B])return;Hn[B]=!0;var oe="";S&&S._owner&&S._owner!==mt.current&&(oe=" It was passed a child from "+U(S._owner.type)+"."),zn(S),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',B,oe),zn(null)}}function _n(S,P){{if(typeof S!="object")return;if(kt(S))for(var B=0;B<S.length;B++){var oe=S[B];Bn(oe)&&mn(oe,P)}else if(Bn(S))S._store&&(S._store.validated=!0);else if(S){var Te=g(S);if(typeof Te=="function"&&Te!==S.entries)for(var $e=Te.call(S),Me;!(Me=$e.next()).done;)Bn(Me.value)&&mn(Me.value,P)}}}function Ur(S){{var P=S.type;if(P==null||typeof P=="string")return;var B;if(typeof P=="function")B=P.propTypes;else if(typeof P=="object"&&(P.$$typeof===l||P.$$typeof===f))B=P.propTypes;else return;if(B){var oe=U(P);Pe(B,S.props,"prop",oe,S)}else if(P.PropTypes!==void 0&&!Tr){Tr=!0;var Te=U(P);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Te||"Unknown")}typeof P.getDefaultProps=="function"&&!P.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function sn(S){{for(var P=Object.keys(S.props),B=0;B<P.length;B++){var oe=P[B];if(oe!=="children"&&oe!=="key"){zn(S),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",oe),zn(null);break}}S.ref!==null&&(zn(S),b("Invalid attribute `ref` supplied to `React.Fragment`."),zn(null))}}var rr={};function gn(S,P,B,oe,Te,$e){{var Me=j(S);if(!Me){var ke="";(S===void 0||typeof S=="object"&&S!==null&&Object.keys(S).length===0)&&(ke+=" 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 It=Io();It?ke+=It:ke+=Ft();var dt;S===null?dt="null":kt(S)?dt="array":S!==void 0&&S.$$typeof===t?(dt="<"+(U(S.type)||"Unknown")+" />",ke=" Did you accidentally export a JSX literal instead of a component?"):dt=typeof S,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",dt,ke)}var ht=ut(S,P,B,Te,$e);if(ht==null)return ht;if(Me){var Bt=P.children;if(Bt!==void 0)if(oe)if(kt(Bt)){for(var Un=0;Un<Bt.length;Un++)_n(Bt[Un],S);Object.freeze&&Object.freeze(Bt)}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 _n(Bt,S)}if(je.call(P,"key")){var Jt=U(S),_t=Object.keys(P).filter(function(Tl){return Tl!=="key"}),Ao=_t.length>0?"{key: someKey, "+_t.join(": ..., ")+": ...}":"{key: someKey}";if(!rr[Jt+Ao]){var Cl=_t.length>0?"{"+_t.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+B+">.")}return P}}function mn(S,P){{if(!S._store||S._store.validated||S.key!=null)return;S._store.validated=!0;var B=wt(P);if(Hn[B])return;Hn[B]=!0;var oe="";S&&S._owner&&S._owner!==mt.current&&(oe=" It was passed a child from "+U(S._owner.type)+"."),zn(S),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',B,oe),zn(null)}}function _n(S,P){{if(typeof S!="object")return;if(Tt(S))for(var B=0;B<S.length;B++){var oe=S[B];Bn(oe)&&mn(oe,P)}else if(Bn(S))S._store&&(S._store.validated=!0);else if(S){var ke=g(S);if(typeof ke=="function"&&ke!==S.entries)for(var $e=ke.call(S),Me;!(Me=$e.next()).done;)Bn(Me.value)&&mn(Me.value,P)}}}function Ur(S){{var P=S.type;if(P==null||typeof P=="string")return;var B;if(typeof P=="function")B=P.propTypes;else if(typeof P=="object"&&(P.$$typeof===l||P.$$typeof===f))B=P.propTypes;else return;if(B){var oe=U(P);Pe(B,S.props,"prop",oe,S)}else if(P.PropTypes!==void 0&&!kr){kr=!0;var ke=U(P);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ke||"Unknown")}typeof P.getDefaultProps=="function"&&!P.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function sn(S){{for(var P=Object.keys(S.props),B=0;B<P.length;B++){var oe=P[B];if(oe!=="children"&&oe!=="key"){zn(S),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",oe),zn(null);break}}S.ref!==null&&(zn(S),b("Invalid attribute `ref` supplied to `React.Fragment`."),zn(null))}}var rr={};function gn(S,P,B,oe,ke,$e){{var Me=j(S);if(!Me){var Te="";(S===void 0||typeof S=="object"&&S!==null&&Object.keys(S).length===0)&&(Te+=" 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 It=Io();It?Te+=It:Te+=Ft();var dt;S===null?dt="null":Tt(S)?dt="array":S!==void 0&&S.$$typeof===t?(dt="<"+(U(S.type)||"Unknown")+" />",Te=" Did you accidentally export a JSX literal instead of a component?"):dt=typeof S,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",dt,Te)}var ht=ut(S,P,B,ke,$e);if(ht==null)return ht;if(Me){var Bt=P.children;if(Bt!==void 0)if(oe)if(Tt(Bt)){for(var Un=0;Un<Bt.length;Un++)_n(Bt[Un],S);Object.freeze&&Object.freeze(Bt)}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 _n(Bt,S)}if(je.call(P,"key")){var Jt=U(S),_t=Object.keys(P).filter(function(kl){return kl!=="key"}),Ao=_t.length>0?"{key: someKey, "+_t.join(": ..., ")+": ...}":"{key: someKey}";if(!rr[Jt+Ao]){var Cl=_t.length>0?"{"+_t.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} />`,Ao,Jt,Cl,Jt),rr[Jt+Ao]=!0}}return S===r?sn(ht):Ur(ht),ht}}function jn(S,P,B){return gn(S,P,B,!0)}function kr(S,P,B){return gn(S,P,B,!1)}var No=kr,Wr=jn;Kr.Fragment=r,Kr.jsx=No,Kr.jsxs=Wr}()),Kr}process.env.NODE_ENV==="production"?mi.exports=Pm():mi.exports=Om();var c=mi.exports;function _l(e,t){return function(){return e.apply(t,arguments)}}const{toString:Mm}=Object.prototype,{getPrototypeOf:gi}=Object,{iterator:Mo,toStringTag:jl}=Symbol,Do=(e=>t=>{const n=Mm.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),an=e=>(e=e.toLowerCase(),t=>Do(t)===e),Lo=e=>t=>typeof t===e,{isArray:Er}=Array,Ir=Lo("undefined");function qr(e){return e!==null&&!Ir(e)&&e.constructor!==null&&!Ir(e.constructor)&&Ht(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Rl=an("ArrayBuffer");function Dm(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Rl(e.buffer),t}const Lm=Lo("string"),Ht=Lo("function"),Pl=Lo("number"),Gr=e=>e!==null&&typeof e=="object",Fm=e=>e===!0||e===!1,Fo=e=>{if(Do(e)!=="object")return!1;const t=gi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(jl in e)&&!(Mo in e)},$m=e=>{if(!Gr(e)||qr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},zm=an("Date"),Bm=an("File"),Hm=an("Blob"),Um=an("FileList"),Wm=e=>Gr(e)&&Ht(e.pipe),Vm=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ht(e.append)&&((t=Do(e))==="formdata"||t==="object"&&Ht(e.toString)&&e.toString()==="[object FormData]"))},Km=an("URLSearchParams"),[qm,Gm,Ym,Xm]=["ReadableStream","Request","Response","Headers"].map(an),Jm=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Yr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Er(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(qr(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 Ol(e,t){if(qr(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 sr=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ml=e=>!Ir(e)&&e!==sr;function xi(){const{caseless:e,skipUndefined:t}=Ml(this)&&this||{},n={},r=(o,s)=>{const i=e&&Ol(n,s)||s;Fo(n[i])&&Fo(o)?n[i]=xi(n[i],o):Fo(o)?n[i]=xi({},o):Er(o)?n[i]=o.slice():(!t||!Ir(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Yr(arguments[o],r);return n}const Zm=(e,t,n,{allOwnKeys:r}={})=>(Yr(t,(o,s)=>{n&&Ht(o)?e[s]=_l(o,n):e[s]=o},{allOwnKeys:r}),e),Qm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),eg=(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)},tg=(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&&gi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},ng=(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},rg=e=>{if(!e)return null;if(Er(e))return e;let t=e.length;if(!Pl(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},og=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&gi(Uint8Array)),sg=(e,t)=>{const r=(e&&e[Mo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},ig=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},ag=an("HTMLFormElement"),lg=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Dl=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),cg=an("RegExp"),Ll=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Yr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},ug=e=>{Ll(e,(t,n)=>{if(Ht(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ht(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+"'")})}})},dg=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return Er(e)?r(e):r(String(e).split(t)),n},fg=()=>{},hg=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function pg(e){return!!(e&&Ht(e.append)&&e[jl]==="FormData"&&e[Mo])}const mg=e=>{const t=new Array(10),n=(r,o)=>{if(Gr(r)){if(t.indexOf(r)>=0)return;if(qr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=Er(r)?[]:{};return Yr(r,(i,a)=>{const l=n(i,o+1);!Ir(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},gg=an("AsyncFunction"),xg=e=>e&&(Gr(e)||Ht(e))&&Ht(e.then)&&Ht(e.catch),Fl=((e,t)=>e?setImmediate:t?((n,r)=>(sr.addEventListener("message",({source:o,data:s})=>{o===sr&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),sr.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ht(sr.postMessage)),yg=typeof queueMicrotask<"u"?queueMicrotask.bind(sr):typeof process<"u"&&process.nextTick||Fl,O={isArray:Er,isArrayBuffer:Rl,isBuffer:qr,isFormData:Vm,isArrayBufferView:Dm,isString:Lm,isNumber:Pl,isBoolean:Fm,isObject:Gr,isPlainObject:Fo,isEmptyObject:$m,isReadableStream:qm,isRequest:Gm,isResponse:Ym,isHeaders:Xm,isUndefined:Ir,isDate:zm,isFile:Bm,isBlob:Hm,isRegExp:cg,isFunction:Ht,isStream:Wm,isURLSearchParams:Km,isTypedArray:og,isFileList:Um,forEach:Yr,merge:xi,extend:Zm,trim:Jm,stripBOM:Qm,inherits:eg,toFlatObject:tg,kindOf:Do,kindOfTest:an,endsWith:ng,toArray:rg,forEachEntry:sg,matchAll:ig,isHTMLForm:ag,hasOwnProperty:Dl,hasOwnProp:Dl,reduceDescriptors:Ll,freezeMethods:ug,toObjectSet:dg,toCamelCase:lg,noop:fg,toFiniteNumber:hg,findKey:Ol,global:sr,isContextDefined:Ml,isSpecCompliantForm:pg,toJSONObject:mg,isAsyncFn:gg,isThenable:xg,setImmediate:Fl,asap:yg,isIterable:e=>e!=null&&Ht(e[Mo])};function Re(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)}O.inherits(Re,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:O.toJSONObject(this.config),code:this.code,status:this.status}}});const $l=Re.prototype,zl={};["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=>{zl[e]={value:e}}),Object.defineProperties(Re,zl),Object.defineProperty($l,"isAxiosError",{value:!0}),Re.from=(e,t,n,r,o,s)=>{const i=Object.create($l);O.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Re.call(i,a,l,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 vg=null;function yi(e){return O.isPlainObject(e)||O.isArray(e)}function Bl(e){return O.endsWith(e,"[]")?e.slice(0,-2):e}function Hl(e,t,n){return e?e.concat(t).map(function(o,s){return o=Bl(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function bg(e){return O.isArray(e)&&!e.some(yi)}const wg=O.toFlatObject(O,{},null,function(t){return/^is[A-Z]/.test(t)});function $o(e,t,n){if(!O.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=O.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(x,g){return!O.isUndefined(g[x])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&O.isSpecCompliantForm(t);if(!O.isFunction(o))throw new TypeError("visitor must be a function");function u(v){if(v===null)return"";if(O.isDate(v))return v.toISOString();if(O.isBoolean(v))return v.toString();if(!l&&O.isBlob(v))throw new Re("Blob is not supported. Use a Buffer instead.");return O.isArrayBuffer(v)||O.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,x,g){let y=v;if(v&&!g&&typeof v=="object"){if(O.endsWith(x,"{}"))x=r?x:x.slice(0,-2),v=JSON.stringify(v);else if(O.isArray(v)&&bg(v)||(O.isFileList(v)||O.endsWith(x,"[]"))&&(y=O.toArray(v)))return x=Bl(x),y.forEach(function(C,E){!(O.isUndefined(C)||C===null)&&t.append(i===!0?Hl([x],E,s):i===null?x:x+"[]",u(C))}),!1}return yi(v)?!0:(t.append(Hl(g,x,s),u(v)),!1)}const f=[],h=Object.assign(wg,{defaultVisitor:d,convertValue:u,isVisitable:yi});function p(v,x){if(!O.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+x.join("."));f.push(v),O.forEach(v,function(y,b){(!(O.isUndefined(y)||y===null)&&o.call(t,y,O.isString(b)?b.trim():b,x,h))===!0&&p(y,x?x.concat(b):[b])}),f.pop()}}if(!O.isObject(e))throw new TypeError("data must be an object");return p(e),t}function Ul(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function vi(e,t){this._pairs=[],e&&$o(e,this,t)}const Wl=vi.prototype;Wl.append=function(t,n){this._pairs.push([t,n])},Wl.toString=function(t){const n=t?function(r){return t.call(this,r,Ul)}:Ul;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function Sg(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Vl(e,t,n){if(!t)return e;const r=n&&n.encode||Sg;O.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=O.isURLSearchParams(t)?t.toString():new vi(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Kl{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){O.forEach(this.handlers,function(r){r!==null&&t(r)})}}const ql={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Cg={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:vi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},bi=typeof window<"u"&&typeof document<"u",wi=typeof navigator=="object"&&navigator||void 0,Tg=bi&&(!wi||["ReactNative","NativeScript","NS"].indexOf(wi.product)<0),kg=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Eg=bi&&window.location.href||"http://localhost",Ot={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:bi,hasStandardBrowserEnv:Tg,hasStandardBrowserWebWorkerEnv:kg,navigator:wi,origin:Eg},Symbol.toStringTag,{value:"Module"})),...Cg};function Ig(e,t){return $o(e,new Ot.classes.URLSearchParams,{visitor:function(n,r,o,s){return Ot.isNode&&O.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Ng(e){return O.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Ag(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 Gl(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&O.isArray(o)?o.length:i,l?(O.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!O.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&O.isArray(o[i])&&(o[i]=Ag(o[i])),!a)}if(O.isFormData(e)&&O.isFunction(e.entries)){const n={};return O.forEachEntry(e,(r,o)=>{t(Ng(r),o,n,0)}),n}return null}function _g(e,t,n){if(O.isString(e))try{return(t||JSON.parse)(e),O.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Xr={transitional:ql,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=O.isObject(t);if(s&&O.isHTMLForm(t)&&(t=new FormData(t)),O.isFormData(t))return o?JSON.stringify(Gl(t)):t;if(O.isArrayBuffer(t)||O.isBuffer(t)||O.isStream(t)||O.isFile(t)||O.isBlob(t)||O.isReadableStream(t))return t;if(O.isArrayBufferView(t))return t.buffer;if(O.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 Ig(t,this.formSerializer).toString();if((a=O.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return $o(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),_g(t)):t}],transformResponse:[function(t){const n=this.transitional||Xr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(O.isResponse(t)||O.isReadableStream(t))return t;if(t&&O.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"?Re.from(a,Re.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:Ot.classes.FormData,Blob:Ot.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};O.forEach(["delete","get","head","post","put","patch"],e=>{Xr.headers[e]={}});const jg=O.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"]),Rg=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]&&jg[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Yl=Symbol("internals");function Jr(e){return e&&String(e).trim().toLowerCase()}function zo(e){return e===!1||e==null?e:O.isArray(e)?e.map(zo):String(e)}function Pg(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 Og=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Si(e,t,n,r,o){if(O.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!O.isString(t)){if(O.isString(r))return t.indexOf(r)!==-1;if(O.isRegExp(r))return r.test(t)}}function Mg(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Dg(e,t){const n=O.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 Ut=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,u){const d=Jr(l);if(!d)throw new Error("header name must be a non-empty string");const f=O.findKey(o,d);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||l]=zo(a))}const i=(a,l)=>O.forEach(a,(u,d)=>s(u,d,l));if(O.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(O.isString(t)&&(t=t.trim())&&!Og(t))i(Rg(t),n);else if(O.isObject(t)&&O.isIterable(t)){let a={},l,u;for(const d of t){if(!O.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(l=a[u])?O.isArray(l)?[...l,d[1]]:[l,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=Jr(t),t){const r=O.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Pg(o);if(O.isFunction(n))return n.call(this,o,r);if(O.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Jr(t),t){const r=O.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Si(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Jr(i),i){const a=O.findKey(r,i);a&&(!n||Si(r,r[a],a,n))&&(delete r[a],o=!0)}}return O.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||Si(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return O.forEach(this,(o,s)=>{const i=O.findKey(r,s);if(i){n[i]=zo(o),delete n[s];return}const a=t?Mg(s):String(s).trim();a!==s&&delete n[s],n[a]=zo(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return O.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&O.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[Yl]=this[Yl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Jr(i);r[a]||(Dg(o,i),r[a]=!0)}return O.isArray(t)?t.forEach(s):s(t),this}};Ut.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),O.reduceDescriptors(Ut.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),O.freezeMethods(Ut);function Ci(e,t){const n=this||Xr,r=t||n,o=Ut.from(r.headers);let s=r.data;return O.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Xl(e){return!!(e&&e.__CANCEL__)}function Nr(e,t,n){Re.call(this,e??"canceled",Re.ERR_CANCELED,t,n),this.name="CanceledError"}O.inherits(Nr,Re,{__CANCEL__:!0});function Jl(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Re("Request failed with status code "+n.status,[Re.ERR_BAD_REQUEST,Re.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Lg(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Fg(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(l){const u=Date.now(),d=r[s];i||(i=u),n[o]=l,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 p=d&&u-d;return p?Math.round(h*1e3/p):void 0}}function $g(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 Bo=(e,t,n=3)=>{let r=0;const o=Fg(50,250);return $g(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,u=o(l),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,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)},Zl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Ql=e=>(...t)=>O.asap(()=>e(...t)),zg=Ot.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Ot.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Ot.origin),Ot.navigator&&/(msie|trident)/i.test(Ot.navigator.userAgent)):()=>!0,Bg=Ot.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];O.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),O.isString(r)&&i.push("path="+r),O.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 Hg(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Ug(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function ec(e,t,n){let r=!Hg(t);return e&&(r||n==!1)?Ug(e,t):t}const tc=e=>e instanceof Ut?{...e}:e;function ir(e,t){t=t||{};const n={};function r(u,d,f,h){return O.isPlainObject(u)&&O.isPlainObject(d)?O.merge.call({caseless:h},u,d):O.isPlainObject(d)?O.merge({},d):O.isArray(d)?d.slice():d}function o(u,d,f,h){if(O.isUndefined(d)){if(!O.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!O.isUndefined(d))return r(void 0,d)}function i(u,d){if(O.isUndefined(d)){if(!O.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 l={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(tc(u),tc(d),f,!0)};return O.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,h=f(e[d],t[d],d);O.isUndefined(h)&&f!==a||(n[d]=h)}),n}const nc=e=>{const t=ir({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ut.from(i),t.url=Vl(ec(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),O.isFormData(n)){if(Ot.hasStandardBrowserEnv||Ot.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(O.isFunction(n.getHeaders)){const l=n.getHeaders(),u=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{u.includes(d.toLowerCase())&&i.set(d,f)})}}if(Ot.hasStandardBrowserEnv&&(r&&O.isFunction(r)&&(r=r(t)),r||r!==!1&&zg(t.url))){const l=o&&s&&Bg.read(s);l&&i.set(o,l)}return t},Wg=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=nc(e);let s=o.data;const i=Ut.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=o,d,f,h,p,v;function x(){p&&p(),v&&v(),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 y(){if(!g)return;const C=Ut.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),T={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:C,config:e,request:g};Jl(function(I){n(I),x()},function(I){r(I),x()},T),g=null}"onloadend"in g?g.onloadend=y:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(y)},g.onabort=function(){g&&(r(new Re("Request aborted",Re.ECONNABORTED,e,g)),g=null)},g.onerror=function(E){const T=E&&E.message?E.message:"Network Error",k=new Re(T,Re.ERR_NETWORK,e,g);k.event=E||null,r(k),g=null},g.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const T=o.transitional||ql;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),r(new Re(E,T.clarifyTimeoutError?Re.ETIMEDOUT:Re.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&O.forEach(i.toJSON(),function(E,T){g.setRequestHeader(T,E)}),O.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,v]=Bo(u,!0),g.addEventListener("progress",h)),l&&g.upload&&([f,p]=Bo(l),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=C=>{g&&(r(!C||C.type?new Nr(null,e,g):C),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=Lg(o.url);if(b&&Ot.protocols.indexOf(b)===-1){r(new Re("Unsupported protocol "+b+":",Re.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Vg=(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 Re?d:new Nr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Re(`timeout ${t} of ms exceeded`,Re.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:l}=r;return l.unsubscribe=()=>O.asap(a),l}},Kg=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},qg=async function*(e,t){for await(const n of Gg(e))yield*Kg(n,t)},Gg=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()}},rc=(e,t,n,r)=>{const o=qg(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:u,value:d}=await o.next();if(u){a(),l.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}l.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},oc=64*1024,{isFunction:Ho}=O,Yg=(({Request:e,Response:t})=>({Request:e,Response:t}))(O.global),{ReadableStream:sc,TextEncoder:ic}=O.global,ac=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Xg=e=>{e=O.merge.call({skipUndefined:!0},Yg,e);const{fetch:t,Request:n,Response:r}=e,o=t?Ho(t):typeof fetch=="function",s=Ho(n),i=Ho(r);if(!o)return!1;const a=o&&Ho(sc),l=o&&(typeof ic=="function"?(v=>x=>v.encode(x))(new ic):async v=>new Uint8Array(await new n(v).arrayBuffer())),u=s&&a&&ac(()=>{let v=!1;const x=new n(Ot.origin,{body:new sc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!x}),d=i&&a&&ac(()=>O.isReadableStream(new r("").body)),f={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!f[v]&&(f[v]=(x,g)=>{let y=x&&x[v];if(y)return y.call(x);throw new Re(`Response type '${v}' is not supported`,Re.ERR_NOT_SUPPORT,g)})});const h=async v=>{if(v==null)return 0;if(O.isBlob(v))return v.size;if(O.isSpecCompliantForm(v))return(await new n(Ot.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(O.isArrayBufferView(v)||O.isArrayBuffer(v))return v.byteLength;if(O.isURLSearchParams(v)&&(v=v+""),O.isString(v))return(await l(v)).byteLength},p=async(v,x)=>{const g=O.toFiniteNumber(v.getContentLength());return g??h(x)};return async v=>{let{url:x,method:g,data:y,signal:b,cancelToken:C,timeout:E,onDownloadProgress:T,onUploadProgress:k,responseType:I,headers:_,withCredentials:R="same-origin",fetchOptions:j}=nc(v),H=t||fetch;I=I?(I+"").toLowerCase():"text";let F=Vg([b,C&&C.toAbortSignal()],E),U=null;const D=F&&F.unsubscribe&&(()=>{F.unsubscribe()});let G;try{if(k&&u&&g!=="get"&&g!=="head"&&(G=await p(_,y))!==0){let M=new n(x,{method:"POST",body:y,duplex:"half"}),Y;if(O.isFormData(y)&&(Y=M.headers.get("content-type"))&&_.setContentType(Y),M.body){const[ce,be]=Zl(G,Bo(Ql(k)));y=rc(M.body,oc,ce,be)}}O.isString(R)||(R=R?"include":"omit");const W=s&&"credentials"in n.prototype,ne={...j,signal:F,method:g.toUpperCase(),headers:_.normalize().toJSON(),body:y,duplex:"half",credentials:W?R:void 0};U=s&&new n(x,ne);let $=await(s?H(U,j):H(x,ne));const z=d&&(I==="stream"||I==="response");if(d&&(T||z&&D)){const M={};["status","statusText","headers"].forEach(ge=>{M[ge]=$[ge]});const Y=O.toFiniteNumber($.headers.get("content-length")),[ce,be]=T&&Zl(Y,Bo(Ql(T),!0))||[];$=new r(rc($.body,oc,ce,()=>{be&&be(),D&&D()}),M)}I=I||"text";let ie=await f[O.findKey(f,I)||"text"]($,v);return!z&&D&&D(),await new Promise((M,Y)=>{Jl(M,Y,{data:ie,headers:Ut.from($.headers),status:$.status,statusText:$.statusText,config:v,request:U})})}catch(W){throw D&&D(),W&&W.name==="TypeError"&&/Load failed|fetch/i.test(W.message)?Object.assign(new Re("Network Error",Re.ERR_NETWORK,v,U),{cause:W.cause||W}):Re.from(W,W&&W.code,v,U)}}},Jg=new Map,lc=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,u,d=Jg;for(;a--;)l=s[a],u=d.get(l),u===void 0&&d.set(l,u=a?new Map:Xg(t)),d=u;return u};lc();const Ti={http:vg,xhr:Wg,fetch:{get:lc}};O.forEach(Ti,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const cc=e=>`- ${e}`,Zg=e=>O.isFunction(e)||e===null||e===!1,uc={getAdapter:(e,t)=>{e=O.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,!Zg(r)&&(o=Ti[(a=String(r)).toLowerCase()],o===void 0))throw new Re(`Unknown adapter '${a}'`);if(o&&(O.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,u])=>`adapter ${l} `+(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} />`,Ao,Jt,Cl,Jt),rr[Jt+Ao]=!0}}return S===r?sn(ht):Ur(ht),ht}}function jn(S,P,B){return gn(S,P,B,!0)}function Tr(S,P,B){return gn(S,P,B,!1)}var No=Tr,Wr=jn;Kr.Fragment=r,Kr.jsx=No,Kr.jsxs=Wr}()),Kr}process.env.NODE_ENV==="production"?mi.exports=jm():mi.exports=Rm();var c=mi.exports;function _l(e,t){return function(){return e.apply(t,arguments)}}const{toString:Pm}=Object.prototype,{getPrototypeOf:gi}=Object,{iterator:Mo,toStringTag:jl}=Symbol,Do=(e=>t=>{const n=Pm.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),an=e=>(e=e.toLowerCase(),t=>Do(t)===e),Lo=e=>t=>typeof t===e,{isArray:Er}=Array,Ir=Lo("undefined");function qr(e){return e!==null&&!Ir(e)&&e.constructor!==null&&!Ir(e.constructor)&&Ht(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Rl=an("ArrayBuffer");function Om(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Rl(e.buffer),t}const Mm=Lo("string"),Ht=Lo("function"),Pl=Lo("number"),Gr=e=>e!==null&&typeof e=="object",Dm=e=>e===!0||e===!1,Fo=e=>{if(Do(e)!=="object")return!1;const t=gi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(jl in e)&&!(Mo in e)},Lm=e=>{if(!Gr(e)||qr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Fm=an("Date"),$m=an("File"),zm=an("Blob"),Bm=an("FileList"),Hm=e=>Gr(e)&&Ht(e.pipe),Um=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ht(e.append)&&((t=Do(e))==="formdata"||t==="object"&&Ht(e.toString)&&e.toString()==="[object FormData]"))},Wm=an("URLSearchParams"),[Vm,Km,qm,Gm]=["ReadableStream","Request","Response","Headers"].map(an),Ym=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Yr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Er(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(qr(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 Ol(e,t){if(qr(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 sr=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ml=e=>!Ir(e)&&e!==sr;function xi(){const{caseless:e,skipUndefined:t}=Ml(this)&&this||{},n={},r=(o,s)=>{const i=e&&Ol(n,s)||s;Fo(n[i])&&Fo(o)?n[i]=xi(n[i],o):Fo(o)?n[i]=xi({},o):Er(o)?n[i]=o.slice():(!t||!Ir(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Yr(arguments[o],r);return n}const Xm=(e,t,n,{allOwnKeys:r}={})=>(Yr(t,(o,s)=>{n&&Ht(o)?e[s]=_l(o,n):e[s]=o},{allOwnKeys:r}),e),Jm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Zm=(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)},Qm=(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&&gi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},eg=(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},tg=e=>{if(!e)return null;if(Er(e))return e;let t=e.length;if(!Pl(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},ng=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&gi(Uint8Array)),rg=(e,t)=>{const r=(e&&e[Mo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},og=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},sg=an("HTMLFormElement"),ig=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Dl=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),ag=an("RegExp"),Ll=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Yr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},lg=e=>{Ll(e,(t,n)=>{if(Ht(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ht(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+"'")})}})},cg=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return Er(e)?r(e):r(String(e).split(t)),n},ug=()=>{},dg=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function fg(e){return!!(e&&Ht(e.append)&&e[jl]==="FormData"&&e[Mo])}const hg=e=>{const t=new Array(10),n=(r,o)=>{if(Gr(r)){if(t.indexOf(r)>=0)return;if(qr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=Er(r)?[]:{};return Yr(r,(i,a)=>{const l=n(i,o+1);!Ir(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},pg=an("AsyncFunction"),mg=e=>e&&(Gr(e)||Ht(e))&&Ht(e.then)&&Ht(e.catch),Fl=((e,t)=>e?setImmediate:t?((n,r)=>(sr.addEventListener("message",({source:o,data:s})=>{o===sr&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),sr.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ht(sr.postMessage)),gg=typeof queueMicrotask<"u"?queueMicrotask.bind(sr):typeof process<"u"&&process.nextTick||Fl,O={isArray:Er,isArrayBuffer:Rl,isBuffer:qr,isFormData:Um,isArrayBufferView:Om,isString:Mm,isNumber:Pl,isBoolean:Dm,isObject:Gr,isPlainObject:Fo,isEmptyObject:Lm,isReadableStream:Vm,isRequest:Km,isResponse:qm,isHeaders:Gm,isUndefined:Ir,isDate:Fm,isFile:$m,isBlob:zm,isRegExp:ag,isFunction:Ht,isStream:Hm,isURLSearchParams:Wm,isTypedArray:ng,isFileList:Bm,forEach:Yr,merge:xi,extend:Xm,trim:Ym,stripBOM:Jm,inherits:Zm,toFlatObject:Qm,kindOf:Do,kindOfTest:an,endsWith:eg,toArray:tg,forEachEntry:rg,matchAll:og,isHTMLForm:sg,hasOwnProperty:Dl,hasOwnProp:Dl,reduceDescriptors:Ll,freezeMethods:lg,toObjectSet:cg,toCamelCase:ig,noop:ug,toFiniteNumber:dg,findKey:Ol,global:sr,isContextDefined:Ml,isSpecCompliantForm:fg,toJSONObject:hg,isAsyncFn:pg,isThenable:mg,setImmediate:Fl,asap:gg,isIterable:e=>e!=null&&Ht(e[Mo])};function Re(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)}O.inherits(Re,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:O.toJSONObject(this.config),code:this.code,status:this.status}}});const $l=Re.prototype,zl={};["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=>{zl[e]={value:e}}),Object.defineProperties(Re,zl),Object.defineProperty($l,"isAxiosError",{value:!0}),Re.from=(e,t,n,r,o,s)=>{const i=Object.create($l);O.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Re.call(i,a,l,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 xg=null;function yi(e){return O.isPlainObject(e)||O.isArray(e)}function Bl(e){return O.endsWith(e,"[]")?e.slice(0,-2):e}function Hl(e,t,n){return e?e.concat(t).map(function(o,s){return o=Bl(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function yg(e){return O.isArray(e)&&!e.some(yi)}const vg=O.toFlatObject(O,{},null,function(t){return/^is[A-Z]/.test(t)});function $o(e,t,n){if(!O.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=O.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(x,g){return!O.isUndefined(g[x])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&O.isSpecCompliantForm(t);if(!O.isFunction(o))throw new TypeError("visitor must be a function");function u(v){if(v===null)return"";if(O.isDate(v))return v.toISOString();if(O.isBoolean(v))return v.toString();if(!l&&O.isBlob(v))throw new Re("Blob is not supported. Use a Buffer instead.");return O.isArrayBuffer(v)||O.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,x,g){let y=v;if(v&&!g&&typeof v=="object"){if(O.endsWith(x,"{}"))x=r?x:x.slice(0,-2),v=JSON.stringify(v);else if(O.isArray(v)&&yg(v)||(O.isFileList(v)||O.endsWith(x,"[]"))&&(y=O.toArray(v)))return x=Bl(x),y.forEach(function(C,E){!(O.isUndefined(C)||C===null)&&t.append(i===!0?Hl([x],E,s):i===null?x:x+"[]",u(C))}),!1}return yi(v)?!0:(t.append(Hl(g,x,s),u(v)),!1)}const f=[],h=Object.assign(vg,{defaultVisitor:d,convertValue:u,isVisitable:yi});function p(v,x){if(!O.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+x.join("."));f.push(v),O.forEach(v,function(y,b){(!(O.isUndefined(y)||y===null)&&o.call(t,y,O.isString(b)?b.trim():b,x,h))===!0&&p(y,x?x.concat(b):[b])}),f.pop()}}if(!O.isObject(e))throw new TypeError("data must be an object");return p(e),t}function Ul(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function vi(e,t){this._pairs=[],e&&$o(e,this,t)}const Wl=vi.prototype;Wl.append=function(t,n){this._pairs.push([t,n])},Wl.toString=function(t){const n=t?function(r){return t.call(this,r,Ul)}:Ul;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function bg(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Vl(e,t,n){if(!t)return e;const r=n&&n.encode||bg;O.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=O.isURLSearchParams(t)?t.toString():new vi(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Kl{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){O.forEach(this.handlers,function(r){r!==null&&t(r)})}}const ql={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},wg={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:vi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},bi=typeof window<"u"&&typeof document<"u",wi=typeof navigator=="object"&&navigator||void 0,Sg=bi&&(!wi||["ReactNative","NativeScript","NS"].indexOf(wi.product)<0),Cg=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",kg=bi&&window.location.href||"http://localhost",Ot={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:bi,hasStandardBrowserEnv:Sg,hasStandardBrowserWebWorkerEnv:Cg,navigator:wi,origin:kg},Symbol.toStringTag,{value:"Module"})),...wg};function Tg(e,t){return $o(e,new Ot.classes.URLSearchParams,{visitor:function(n,r,o,s){return Ot.isNode&&O.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Eg(e){return O.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Ig(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 Gl(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&O.isArray(o)?o.length:i,l?(O.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!O.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&O.isArray(o[i])&&(o[i]=Ig(o[i])),!a)}if(O.isFormData(e)&&O.isFunction(e.entries)){const n={};return O.forEachEntry(e,(r,o)=>{t(Eg(r),o,n,0)}),n}return null}function Ng(e,t,n){if(O.isString(e))try{return(t||JSON.parse)(e),O.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Xr={transitional:ql,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=O.isObject(t);if(s&&O.isHTMLForm(t)&&(t=new FormData(t)),O.isFormData(t))return o?JSON.stringify(Gl(t)):t;if(O.isArrayBuffer(t)||O.isBuffer(t)||O.isStream(t)||O.isFile(t)||O.isBlob(t)||O.isReadableStream(t))return t;if(O.isArrayBufferView(t))return t.buffer;if(O.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 Tg(t,this.formSerializer).toString();if((a=O.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return $o(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Ng(t)):t}],transformResponse:[function(t){const n=this.transitional||Xr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(O.isResponse(t)||O.isReadableStream(t))return t;if(t&&O.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"?Re.from(a,Re.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:Ot.classes.FormData,Blob:Ot.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};O.forEach(["delete","get","head","post","put","patch"],e=>{Xr.headers[e]={}});const Ag=O.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"]),_g=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]&&Ag[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Yl=Symbol("internals");function Jr(e){return e&&String(e).trim().toLowerCase()}function zo(e){return e===!1||e==null?e:O.isArray(e)?e.map(zo):String(e)}function jg(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 Rg=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Si(e,t,n,r,o){if(O.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!O.isString(t)){if(O.isString(r))return t.indexOf(r)!==-1;if(O.isRegExp(r))return r.test(t)}}function Pg(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Og(e,t){const n=O.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 Ut=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,u){const d=Jr(l);if(!d)throw new Error("header name must be a non-empty string");const f=O.findKey(o,d);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||l]=zo(a))}const i=(a,l)=>O.forEach(a,(u,d)=>s(u,d,l));if(O.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(O.isString(t)&&(t=t.trim())&&!Rg(t))i(_g(t),n);else if(O.isObject(t)&&O.isIterable(t)){let a={},l,u;for(const d of t){if(!O.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(l=a[u])?O.isArray(l)?[...l,d[1]]:[l,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=Jr(t),t){const r=O.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return jg(o);if(O.isFunction(n))return n.call(this,o,r);if(O.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Jr(t),t){const r=O.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Si(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Jr(i),i){const a=O.findKey(r,i);a&&(!n||Si(r,r[a],a,n))&&(delete r[a],o=!0)}}return O.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||Si(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return O.forEach(this,(o,s)=>{const i=O.findKey(r,s);if(i){n[i]=zo(o),delete n[s];return}const a=t?Pg(s):String(s).trim();a!==s&&delete n[s],n[a]=zo(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return O.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&O.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[Yl]=this[Yl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Jr(i);r[a]||(Og(o,i),r[a]=!0)}return O.isArray(t)?t.forEach(s):s(t),this}};Ut.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),O.reduceDescriptors(Ut.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),O.freezeMethods(Ut);function Ci(e,t){const n=this||Xr,r=t||n,o=Ut.from(r.headers);let s=r.data;return O.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Xl(e){return!!(e&&e.__CANCEL__)}function Nr(e,t,n){Re.call(this,e??"canceled",Re.ERR_CANCELED,t,n),this.name="CanceledError"}O.inherits(Nr,Re,{__CANCEL__:!0});function Jl(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Re("Request failed with status code "+n.status,[Re.ERR_BAD_REQUEST,Re.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Mg(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Dg(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(l){const u=Date.now(),d=r[s];i||(i=u),n[o]=l,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 p=d&&u-d;return p?Math.round(h*1e3/p):void 0}}function Lg(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 Bo=(e,t,n=3)=>{let r=0;const o=Dg(50,250);return Lg(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,u=o(l),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,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)},Zl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Ql=e=>(...t)=>O.asap(()=>e(...t)),Fg=Ot.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Ot.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Ot.origin),Ot.navigator&&/(msie|trident)/i.test(Ot.navigator.userAgent)):()=>!0,$g=Ot.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];O.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),O.isString(r)&&i.push("path="+r),O.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 zg(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Bg(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function ec(e,t,n){let r=!zg(t);return e&&(r||n==!1)?Bg(e,t):t}const tc=e=>e instanceof Ut?{...e}:e;function ir(e,t){t=t||{};const n={};function r(u,d,f,h){return O.isPlainObject(u)&&O.isPlainObject(d)?O.merge.call({caseless:h},u,d):O.isPlainObject(d)?O.merge({},d):O.isArray(d)?d.slice():d}function o(u,d,f,h){if(O.isUndefined(d)){if(!O.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!O.isUndefined(d))return r(void 0,d)}function i(u,d){if(O.isUndefined(d)){if(!O.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 l={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(tc(u),tc(d),f,!0)};return O.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,h=f(e[d],t[d],d);O.isUndefined(h)&&f!==a||(n[d]=h)}),n}const nc=e=>{const t=ir({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ut.from(i),t.url=Vl(ec(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),O.isFormData(n)){if(Ot.hasStandardBrowserEnv||Ot.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(O.isFunction(n.getHeaders)){const l=n.getHeaders(),u=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{u.includes(d.toLowerCase())&&i.set(d,f)})}}if(Ot.hasStandardBrowserEnv&&(r&&O.isFunction(r)&&(r=r(t)),r||r!==!1&&Fg(t.url))){const l=o&&s&&$g.read(s);l&&i.set(o,l)}return t},Hg=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=nc(e);let s=o.data;const i=Ut.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=o,d,f,h,p,v;function x(){p&&p(),v&&v(),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 y(){if(!g)return;const C=Ut.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),k={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:C,config:e,request:g};Jl(function(I){n(I),x()},function(I){r(I),x()},k),g=null}"onloadend"in g?g.onloadend=y:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(y)},g.onabort=function(){g&&(r(new Re("Request aborted",Re.ECONNABORTED,e,g)),g=null)},g.onerror=function(E){const k=E&&E.message?E.message:"Network Error",T=new Re(k,Re.ERR_NETWORK,e,g);T.event=E||null,r(T),g=null},g.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const k=o.transitional||ql;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),r(new Re(E,k.clarifyTimeoutError?Re.ETIMEDOUT:Re.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&O.forEach(i.toJSON(),function(E,k){g.setRequestHeader(k,E)}),O.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,v]=Bo(u,!0),g.addEventListener("progress",h)),l&&g.upload&&([f,p]=Bo(l),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=C=>{g&&(r(!C||C.type?new Nr(null,e,g):C),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=Mg(o.url);if(b&&Ot.protocols.indexOf(b)===-1){r(new Re("Unsupported protocol "+b+":",Re.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Ug=(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 Re?d:new Nr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Re(`timeout ${t} of ms exceeded`,Re.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:l}=r;return l.unsubscribe=()=>O.asap(a),l}},Wg=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},Vg=async function*(e,t){for await(const n of Kg(e))yield*Wg(n,t)},Kg=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()}},rc=(e,t,n,r)=>{const o=Vg(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:u,value:d}=await o.next();if(u){a(),l.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}l.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},oc=64*1024,{isFunction:Ho}=O,qg=(({Request:e,Response:t})=>({Request:e,Response:t}))(O.global),{ReadableStream:sc,TextEncoder:ic}=O.global,ac=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Gg=e=>{e=O.merge.call({skipUndefined:!0},qg,e);const{fetch:t,Request:n,Response:r}=e,o=t?Ho(t):typeof fetch=="function",s=Ho(n),i=Ho(r);if(!o)return!1;const a=o&&Ho(sc),l=o&&(typeof ic=="function"?(v=>x=>v.encode(x))(new ic):async v=>new Uint8Array(await new n(v).arrayBuffer())),u=s&&a&&ac(()=>{let v=!1;const x=new n(Ot.origin,{body:new sc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!x}),d=i&&a&&ac(()=>O.isReadableStream(new r("").body)),f={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!f[v]&&(f[v]=(x,g)=>{let y=x&&x[v];if(y)return y.call(x);throw new Re(`Response type '${v}' is not supported`,Re.ERR_NOT_SUPPORT,g)})});const h=async v=>{if(v==null)return 0;if(O.isBlob(v))return v.size;if(O.isSpecCompliantForm(v))return(await new n(Ot.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(O.isArrayBufferView(v)||O.isArrayBuffer(v))return v.byteLength;if(O.isURLSearchParams(v)&&(v=v+""),O.isString(v))return(await l(v)).byteLength},p=async(v,x)=>{const g=O.toFiniteNumber(v.getContentLength());return g??h(x)};return async v=>{let{url:x,method:g,data:y,signal:b,cancelToken:C,timeout:E,onDownloadProgress:k,onUploadProgress:T,responseType:I,headers:_,withCredentials:R="same-origin",fetchOptions:j}=nc(v),H=t||fetch;I=I?(I+"").toLowerCase():"text";let F=Ug([b,C&&C.toAbortSignal()],E),U=null;const D=F&&F.unsubscribe&&(()=>{F.unsubscribe()});let G;try{if(T&&u&&g!=="get"&&g!=="head"&&(G=await p(_,y))!==0){let M=new n(x,{method:"POST",body:y,duplex:"half"}),Y;if(O.isFormData(y)&&(Y=M.headers.get("content-type"))&&_.setContentType(Y),M.body){const[ce,be]=Zl(G,Bo(Ql(T)));y=rc(M.body,oc,ce,be)}}O.isString(R)||(R=R?"include":"omit");const W=s&&"credentials"in n.prototype,ne={...j,signal:F,method:g.toUpperCase(),headers:_.normalize().toJSON(),body:y,duplex:"half",credentials:W?R:void 0};U=s&&new n(x,ne);let $=await(s?H(U,j):H(x,ne));const z=d&&(I==="stream"||I==="response");if(d&&(k||z&&D)){const M={};["status","statusText","headers"].forEach(ge=>{M[ge]=$[ge]});const Y=O.toFiniteNumber($.headers.get("content-length")),[ce,be]=k&&Zl(Y,Bo(Ql(k),!0))||[];$=new r(rc($.body,oc,ce,()=>{be&&be(),D&&D()}),M)}I=I||"text";let ie=await f[O.findKey(f,I)||"text"]($,v);return!z&&D&&D(),await new Promise((M,Y)=>{Jl(M,Y,{data:ie,headers:Ut.from($.headers),status:$.status,statusText:$.statusText,config:v,request:U})})}catch(W){throw D&&D(),W&&W.name==="TypeError"&&/Load failed|fetch/i.test(W.message)?Object.assign(new Re("Network Error",Re.ERR_NETWORK,v,U),{cause:W.cause||W}):Re.from(W,W&&W.code,v,U)}}},Yg=new Map,lc=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,u,d=Yg;for(;a--;)l=s[a],u=d.get(l),u===void 0&&d.set(l,u=a?new Map:Gg(t)),d=u;return u};lc();const ki={http:xg,xhr:Hg,fetch:{get:lc}};O.forEach(ki,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const cc=e=>`- ${e}`,Xg=e=>O.isFunction(e)||e===null||e===!1,uc={getAdapter:(e,t)=>{e=O.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,!Xg(r)&&(o=ki[(a=String(r)).toLowerCase()],o===void 0))throw new Re(`Unknown adapter '${a}'`);if(o&&(O.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,u])=>`adapter ${l} `+(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(cc).join(`
34
- `):" "+cc(i[0]):"as no adapter specified";throw new Re("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:Ti};function ki(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Nr(null,e)}function dc(e){return ki(e),e.headers=Ut.from(e.headers),e.data=Ci.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),uc.getAdapter(e.adapter||Xr.adapter,e)(e).then(function(r){return ki(e),r.data=Ci.call(e,e.transformResponse,r),r.headers=Ut.from(r.headers),r},function(r){return Xl(r)||(ki(e),r&&r.response&&(r.response.data=Ci.call(e,e.transformResponse,r.response),r.response.headers=Ut.from(r.response.headers))),Promise.reject(r)})}const fc="1.12.2",Uo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Uo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const hc={};Uo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+fc+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Re(o(i," has been removed"+(n?" in "+n:"")),Re.ERR_DEPRECATED);return n&&!hc[i]&&(hc[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}},Uo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Qg(e,t,n){if(typeof e!="object")throw new Re("options must be an object",Re.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],l=a===void 0||i(a,s,e);if(l!==!0)throw new Re("option "+s+" must be "+l,Re.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Re("Unknown option "+s,Re.ERR_BAD_OPTION)}}const Wo={assertOptions:Qg,validators:Uo},xn=Wo.validators;let ar=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Kl,response:new Kl}}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=ir(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Wo.assertOptions(r,{silentJSONParsing:xn.transitional(xn.boolean),forcedJSONParsing:xn.transitional(xn.boolean),clarifyTimeoutError:xn.transitional(xn.boolean)},!1),o!=null&&(O.isFunction(o)?n.paramsSerializer={serialize:o}:Wo.assertOptions(o,{encode:xn.function,serialize:xn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Wo.assertOptions(n,{baseUrl:xn.spelling("baseURL"),withXsrfToken:xn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&O.merge(s.common,s[n.method]);s&&O.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Ut.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(x){typeof x.runWhen=="function"&&x.runWhen(n)===!1||(l=l&&x.synchronous,a.unshift(x.fulfilled,x.rejected))});const u=[];this.interceptors.response.forEach(function(x){u.push(x.fulfilled,x.rejected)});let d,f=0,h;if(!l){const v=[dc.bind(this),void 0];for(v.unshift(...a),v.push(...u),h=v.length,d=Promise.resolve(n);f<h;)d=d.then(v[f++],v[f++]);return d}h=a.length;let p=n;for(;f<h;){const v=a[f++],x=a[f++];try{p=v(p)}catch(g){x.call(this,g);break}}try{d=dc.call(this,p)}catch(v){return Promise.reject(v)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=ir(this.defaults,t);const n=ec(t.baseURL,t.url,t.allowAbsoluteUrls);return Vl(n,t.params,t.paramsSerializer)}};O.forEach(["delete","get","head","options"],function(t){ar.prototype[t]=function(n,r){return this.request(ir(r||{},{method:t,url:n,data:(r||{}).data}))}}),O.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(ir(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}ar.prototype[t]=n(),ar.prototype[t+"Form"]=n(!0)});let ex=class _m{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 Nr(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 _m(function(o){t=o}),cancel:t}}};function tx(e){return function(n){return e.apply(null,n)}}function nx(e){return O.isObject(e)&&e.isAxiosError===!0}const Ei={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(Ei).forEach(([e,t])=>{Ei[t]=e});function pc(e){const t=new ar(e),n=_l(ar.prototype.request,t);return O.extend(n,ar.prototype,t,{allOwnKeys:!0}),O.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return pc(ir(e,o))},n}const gt=pc(Xr);gt.Axios=ar,gt.CanceledError=Nr,gt.CancelToken=ex,gt.isCancel=Xl,gt.VERSION=fc,gt.toFormData=$o,gt.AxiosError=Re,gt.Cancel=gt.CanceledError,gt.all=function(t){return Promise.all(t)},gt.spread=tx,gt.isAxiosError=nx,gt.mergeConfig=ir,gt.AxiosHeaders=Ut,gt.formToJSON=e=>Gl(O.isHTMLForm(e)?new FormData(e):e),gt.getAdapter=uc.getAdapter,gt.HttpStatusCode=Ei,gt.default=gt;const{Axios:rk,AxiosError:ok,CanceledError:sk,isCancel:ik,CancelToken:ak,VERSION:lk,all:ck,Cancel:uk,isAxiosError:dk,spread:fk,toFormData:hk,AxiosHeaders:pk,HttpStatusCode:mk,formToJSON:gk,getAdapter:xk,mergeConfig:yk}=gt,mc=typeof window<"u"?window.__API_BASE_URL__:void 0,gc=mc?Mn(mc):void 0;function Mn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Vo=null;const Ii=new Set;function xc(){return Vo}function Ni(e){Vo=e,Ii.forEach(t=>t(e))}function yc(e){return Ii.add(e),()=>Ii.delete(e)}const Zt=gt.create({...gc?{baseURL:gc}:{},timeout:3e4,withCredentials:!0});Zt.interceptors.request.use(e=>(Vo&&(e.headers.Authorization=`Bearer ${Vo}`),e)),Zt.interceptors.response.use(e=>e,e=>Promise.reject(e));async function ln(e,t){return Zt.defaults.baseURL?(await Zt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function vc(e,t,n){return Zt.defaults.baseURL?(await Zt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function bc(e,t,n){return Zt.defaults.baseURL?(await Zt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function wc(e,t){return Zt.defaults.baseURL?(await Zt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function yn(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Sc{get baseUrl(){const t=Zt.defaults.baseURL;return t?Mn(String(t)):""}updateConfig(t){t.baseUrl&&(Zt.defaults.baseURL=Mn(String(t.baseUrl))),t.authToken!==void 0&&Ni(t.authToken)}getAuthToken(){return xc()}setAuthToken(t){Ni(t)}onTokenChange(t){return yc(t)}async listThreads(){const t=await ln("/threads"),n=yn(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await vc("/threads",t?{title:t}:void 0);return yn(r)}async updateThread(t,n){const r=await bc(`/threads/${t}`,{title:n});return yn(r)}async deleteThread(t){const n=await wc(`/threads/${t}`);return yn(n)}async threadInfo(t){const n=await ln(`/threads/${t}/info`);return yn(n)}async listAgents(){const t=await ln("/agents"),n=yn(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await ln(`/agents/${t}`);return yn(n)}async getAgentSchema(t){const n=await ln(`/agents/${t}/schema`);return yn(n)}async getState(t){const n=await ln(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return yn(n)}async getStateHistory(t){const n=await ln(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return yn(n)}}const Wn=new Sc,Cc=w.createContext(null);function rx({children:e,apiConfig:t}){const n=Wn;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return c.jsx(Cc.Provider,{value:r,children:e})}function Ai(){const e=w.useContext(Cc);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function ox(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 l=0;l<a;l++)i+=String.fromCharCode(s[l]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function sx(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const u=await ox(l);a.push({filename:l.name,data:u,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const ix={human:"user",user:"user",ai:"assistant",assistant:"assistant",tool:"tool",function:"tool",system:"system"};function _i(e){if(!e||typeof e!="object")return!1;const t=e;return"values"in t&&"config"in t&&typeof t.values=="object"&&t.values!==null&&typeof t.config=="object"&&t.config!==null}function Zr(e,t){return`${e??""}::${t??""}`}function Tc(e){const t=Array.isArray(e==null?void 0:e.checkpoints)?(e==null?void 0:e.checkpoints)??[]:e!=null&&e.checkpoints?Object.values(e.checkpoints):[],n=(e==null?void 0:e.threadId)??"",r=t[0];if(!_i(r))return{threadId:n,latest:null,checkpoints:[],interrupt:null,snapshots:{}};const{orderedSnapshots:o,snapshotMap:s}=lx(t),i=kc(r,0);return{threadId:n,latest:i,checkpoints:o,interrupt:(i==null?void 0:i.interrupt)??null,snapshots:s}}function kc(e,t){if(!_i(e))return null;const n=e.values??{messages:[]},r=Array.isArray(n==null?void 0:n.messages)?n.messages:[],{messages:o,...s}=n,i=Object.keys(s).length?s:null,a=e.tasks,l=Array.isArray(a)?a.filter(R=>!!R&&typeof R=="object").map(R=>({...R})):a===null?null:void 0,u=r.map((R,j)=>gx(R,j)).filter(R=>!!R),d=Vt(e.config),f=Vt(d==null?void 0:d.configurable),h=ft(f,["checkpoint_id","checkpointId"]),p=ft(f,["checkpoint_ns","checkpointNs"]),v=Vt(e==null?void 0:e.parentConfig),x=Vt(v==null?void 0:v.configurable),g=ft(x,["checkpoint_id","checkpointId"])??null,y=ft(x,["checkpoint_ns","checkpointNs"])??null,b=e==null?void 0:e.createdAt,C=typeof b=="string"&&b.trim()?b:new Date(Date.now()-t).toISOString(),E=u[u.length-1]??null,T=Vt(e==null?void 0:e.metadata),k=ft(T,["branch_label","branchLabel"]),I=ft(x,["checkpoint_id","checkpointId"]),_=Array.isArray(e.next)?[...e.next]:(e==null?void 0:e.next)===null?null:void 0;return{messages:u,checkpointId:h??null,checkpointNs:p??null,nextCursor:g,nextCursorNs:y,interrupt:ax(a,u,t),createdAt:C,parentId:I??null,branchLabel:k??null,lastMessageId:(E==null?void 0:E.id)??null,hasMessages:u.length>0,messagesLen:u.length,metadata:T??null,config:d??null,parentConfig:v??null,next:_??null,tasks:l??null,values:i??null}}function ax(e,t,n){const r=px(e,n);return r||hx(t,n)}function lx(e){const t=new Map;e.forEach((o,s)=>{if(!_i(o))return;const i=kc(o,s);if(!(i!=null&&i.checkpointId))return;const a=Zr(i.checkpointId,i.checkpointNs??null),l=t.get(a);if(!l){t.set(a,i);return}t.set(a,cx(l,i))});const n=Array.from(t.values());n.sort((o,s)=>Ic(s.createdAt??"")-Ic(o.createdAt??""));const r={};for(const[o,s]of t.entries())r[o]=s;return{orderedSnapshots:n,snapshotMap:r}}function cx(e,t){const n=Ko(e.metadata,t.metadata),r=Ko(e.config,t.config),o=Ko(e.parentConfig,t.parentConfig),s=dx(e.next,t.next),i=fx(e.tasks,t.tasks),a=ux(e.values,t.values);return{...e,metadata:n??null,config:r??null,parentConfig:o??null,next:s??null,tasks:i??null,values:a??null}}function Ko(e,t){return t&&typeof t=="object"?{...e&&typeof e=="object"?{...e}:{},...t}:t===null?e&&typeof e=="object"?{...e}:e??null:e&&typeof e=="object"?{...e}:e??void 0}function ux(e,t){return Ko(e,t)}function dx(e,t){return Array.isArray(t)?t.slice():t===null?Array.isArray(e)?e.slice():e??null:Array.isArray(e)?e.slice():e??void 0}function fx(e,t){return Array.isArray(t)?t.map(n=>({...n})):t===null?Array.isArray(e)?e.map(n=>({...n})):e??null:Array.isArray(e)?e.map(n=>({...n})):e??void 0}function hx(e,t){var n;for(let r=e.length-1;r>=0;r--){const o=((n=e[r])==null?void 0:n.content)??[];for(let s=o.length-1;s>=0;s--){const i=o[s];if((i==null?void 0:i.type)==="interrupt"){const a=i;return{id:typeof a.id=="string"&&a.id.trim()?a.id:`interrupt-${t}-${r}-${s}`,value:a.value}}}}return null}function px(e,t){if(!Array.isArray(e)||!e.length)return null;for(let n=e.length-1;n>=0;n--){const r=mx(e[n],`task-${t}-${n}`);if(!r)continue;const o=r.id||`task-${t}-${n}`;if(Array.isArray(r.interrupts)&&r.interrupts.length)for(let s=r.interrupts.length-1;s>=0;s--){const i=Qr(r.interrupts[s],`${o}-interrupt-${s}`);if(i)return i}if(r.state!==void 0&&r.state!==null){const s=Qr(r.state,`${o}-state`);if(s)return s}}return null}function mx(e,t){if(!e)return null;if(Array.isArray(e)){const[a,l,u,,d,,f,...h]=e,p=typeof a=="string"&&a.trim()?a:t,v=typeof l=="string"&&l.trim()?l:Array.isArray(u)&&typeof u[0]=="string"?String(u[0]):"task",x=Array.isArray(d)?d:void 0,g=h.length?h[h.length-1]:void 0;return{id:p,name:v,interrupts:x,state:g!==void 0?g:f}}const n=Vt(e);if(!n)return null;const r=ft(n,["id","task_id","taskId"])??t,o=ft(n,["name"])??"task",s=Array.isArray(n.interrupts)?n.interrupts:void 0,i=Object.prototype.hasOwnProperty.call(n,"state")?n.state:void 0;return{id:r,name:o,interrupts:s,state:i}}function Qr(e,t,n=0,r=new Set){if(n>6||e==null)return null;if(typeof e=="object"){if(r.has(e))return null;r.add(e)}const o=Ec(e,t);if(o)return o;if(Array.isArray(e)){for(let s=e.length-1;s>=0;s--){const i=Qr(e[s],t,n+1,r);if(i)return i}return null}if(typeof e=="object"){const s=e,i=["interrupt","pending_interrupt","pendingInterrupt","value","data","payload","result","response"];for(const a of i)if(a in s){const l=Qr(s[a],t,n+1,r);if(l)return l}for(const[a,l]of Object.entries(s)){if(i.includes(a)||a==="messages"||a==="results")continue;const u=Qr(l,t,n+1,r);if(u)return u}}return null}function Ec(e,t){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){const n=e,r=ft(n,["type","event","kind"]),o=ft(n,["id","interrupt_id","interruptId","value_id"])??(r&&r.toLowerCase().includes("interrupt")?t:void 0);if(!(Object.prototype.hasOwnProperty.call(n,"value")||Object.prototype.hasOwnProperty.call(n,"data")||Object.prototype.hasOwnProperty.call(n,"payload"))&&!(r&&r.toLowerCase().includes("interrupt")))return null;const i=Object.prototype.hasOwnProperty.call(n,"value")?n.value:Object.prototype.hasOwnProperty.call(n,"data")?n.data:Object.prototype.hasOwnProperty.call(n,"payload")?n.payload:n,a=o&&o.trim()?o:t;return a?{id:a,value:i}:null}if(Array.isArray(e)){for(let n=e.length-1;n>=0;n--){const r=Ec(e[n],t);if(r)return r}return e.length>=2&&typeof e[0]=="string"&&e[0].trim()?{id:e[0],value:e[1]}:null}if(typeof e=="string"){const n=e.trim();return n?{id:t||n,value:n}:null}return null}function Ic(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function gx(e,t){if(!e||typeof e!="object")return null;const n=e,r=Vt(e)??{},o=Vt(n.data)??r,s=String(n.type??o.type??o.role??"").toLowerCase(),i=ix[s];if(!i)return null;const a=o.id??o.message_id??o.run_id??null,l=typeof a=="string"&&a.trim()?a:`history-${i}-${t}`,u=Vt(o.additional_kwargs)??Vt(o.additionalKwargs),d=Vt(o.response_metadata)??Vt(o.responseMetadata),f=ft(u,["createdAt","created_at"])??ft(o,["created_at","createdAt"]),h=ft(u,["checkpointId","checkpoint_id"]),p=ft(u,["checkpointNs","checkpoint_ns"]),v=xx(o.content),x={id:l,role:i,content:v};f&&(x.createdAt=f),typeof o.name=="string"&&o.name.trim()&&(x.name=o.name),typeof(d==null?void 0:d.model_name)=="string"&&(x.model=String(d.model_name)),!x.model&&typeof o.model=="string"&&(x.model=o.model),h&&(x.checkpointId=h),p&&(x.checkpointNs=p);const g=Sx(u,["createdAt","created_at","checkpointId","checkpoint_id","checkpointNs","checkpoint_ns","tool_calls"]),y=d?{...d}:void 0;g&&Object.keys(g).length&&(x.additionalKwargs=g),y&&Object.keys(y).length&&(x.responseMetadata=y);const b=yx((u==null?void 0:u.tool_calls)??o.tool_calls);if(b.length&&(x.content=[...x.content,...b]),i==="tool"){const C=bx(o,x.content);C&&(x.content=C)}return x}function xx(e){if(!e)return[];if(Array.isArray(e))return e.map(t=>Nc(t)).filter(t=>!!t);if(typeof e=="string")return e.trim()?[{type:"text",text:e.trim()}]:[];if(typeof e=="object"){const t=Nc(e);return t?[t]:[]}return[]}function Nc(e){if(!e||typeof e!="object")return typeof e=="string"&&e.trim()?{type:"text",text:e}:null;const t=e,n=String(t.type??"").toLowerCase();if(!n||n==="text"){const o=typeof t.text=="string"?t.text:typeof t.value=="string"?t.value:"";return o.trim()?{type:"text",text:o}:null}if(n==="image"||n==="image_url"){const o=ft(t,["url","src"]);if(!o)return null;const s={type:"image_url",url:o};return typeof t.mimeType=="string"&&(s.mimeType=t.mimeType),typeof t.alt=="string"&&(s.alt=t.alt),s}if(n==="file"){const o=ft(t,["url"]);if(!o)return null;const s={type:"file",url:o};return typeof t.mimeType=="string"&&(s.mimeType=t.mimeType),typeof t.name=="string"&&(s.name=t.name),typeof t.size=="number"&&(s.size=t.size),typeof t.sourceType=="string"&&(s.sourceType=t.sourceType),s}if(n==="tool_call")return vx(t)??null;if(n==="tool_end"){const o=ft(t,["tool_call_id","toolCallId","id"]);if(!o)return null;const s={type:"tool_end",toolCallId:o,output:"output"in t?t.output:t.content};return typeof t.error=="string"&&(s.error=t.error),s}if(n==="interrupt")return{type:"interrupt",value:t.value,...t};if(n==="tool"){const o=ft(t,["text","content"]);if(o)return{type:"text",text:o}}const r=typeof t.content=="string"?t.content:typeof t.value=="string"?t.value:JSON.stringify(t);return r?{type:"text",text:r}:null}function yx(e){return Array.isArray(e)?e.map((t,n)=>{if(!t||typeof t!="object")return null;const r=t,o=ft(r,["id","call_id"]),s=Vt(r.function),i=ft(s,["name"])??"tool",a=s==null?void 0:s.arguments,l=Ac(a);return{type:"tool_call",id:o??`tool_call_${n}`,name:i,args:l}}).filter(t=>!!t):[]}function vx(e){const t=ft(e,["id","call_id"]),n=ft(e,["name"]);if(!t||!n)return null;const r=Ac(e.args??e.arguments);return{type:"tool_call",id:t,name:n,args:r}}function bx(e,t){const n=ft(e,["tool_call_id","toolCallId","id"]);if(!n)return t;const r=e.content??e.output,o=typeof r=="string"?wx(r):r,s={type:"tool_end",toolCallId:n,output:o};return typeof e.error=="string"&&(s.error=e.error),[s]}function Ac(e){if(!e)return{};if(typeof e=="string")try{const t=JSON.parse(e);return typeof t=="object"&&t!==null?t:{raw:e}}catch{return{raw:e}}return typeof e=="object"&&!Array.isArray(e)?{...e}:{}}function wx(e){try{return JSON.parse(e)}catch{return e}}function Vt(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function ft(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r}}function Sx(e,t){if(!e)return;const n={};let r=!1;for(const[o,s]of Object.entries(e)){if(t.includes(o)){r=!0;continue}s!==void 0&&(n[o]=s)}return r?Object.keys(n).length?n:void 0:e}function Cx(e){return e.type!=="thread_info"&&e.type!=="token"}const Tx={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,messagesStreamMeta:{},pendingInterrupt:null};function kx(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:ji(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,pendingInterrupt:null};return console.log("[MessageReducer] 📊 After reset - messages count:",r.messages.length),r}case"seed":{const r=ji(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??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=ji(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 jc(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>jc(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 _c(e=[]){const[t,n]=w.useReducer(kx,{...Tx,messages:e}),r=w.useRef([]),o=w.useRef(null),s=w.useRef(null),i=w.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=w.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]),l=w.useCallback(d=>{r.current.push(d),a()},[a]);w.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const u=w.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:l}),[l]);return{state:t,dispatch:n,...u}}function jc(e,t){var n,r,o,s;if(t.type==="message_start"&&t.role==="assistant"){const i=t.id,a=Nx(t.model);if(e.messages.some(d=>d.id===i)){const d=e.messagesStreamMeta??{},f={...d,[i]:d[i]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:i,messagesStreamMeta:f}}const u={id:i,role:"assistant",name:a||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:i,messages:[...e.messages,u]}}if(t.type==="message_delta"){const i=e.assemblingId??Ri(e.messages);if(!i)return e;const a=e.messages,l=a.findIndex(C=>C.id===i&&C.role==="assistant");if(l===-1)return e;const u=a[l],d=e.messagesStreamMeta??{},f=d[i]??{lastSeq:null,lastText:Dc(u.content)},h=t.seq??null;if(h!==null&&typeof h=="number"&&typeof f.lastSeq=="number"&&h<=f.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:h,lastSeq:f.lastSeq}),e;const{newParts:p,newMeta:v,changed:x}=Ex(u.content,t.delta,f,h);if(!x)return e;const g={...u,content:p},y=Rc(a,l,g),b={...d,[i]:v};return{...e,messages:y,messagesStreamMeta:b}}if(t.type==="message_end"){const i=e.assemblingId??Ri(e.messages);if(!i)return{...e,assemblingId:null};const a=e.messages,l=a.findIndex(u=>u.id===i&&u.role==="assistant");if(l>=0){const u=a[l];if(!((n=u.content)==null?void 0:n.some(f=>{var h;return(f==null?void 0:f.type)==="text"&&((h=f.text)==null?void 0:h.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:u.id,contentTypes:(r=u.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=u.content)==null?void 0:o.map(h=>(h==null?void 0:h.type)==="text"?String(h.text).slice(0,100):h==null?void 0:h.type)});const f=[...a.slice(0,l),...a.slice(l+1)];return{...e,assemblingId:null,messages:f}}}return e}if(t.type==="tool_start"){const i=t.id??t.call_id,a=t.name??t.tool??"tool";if(!i)return e;const l=`tool-${i}`,u={type:"tool_call",id:i,name:a,args:t.args};if(e.messages.find(h=>h.id===l))return{...e,toolIndex:{...e.toolIndex,[i]:l}};const f={id:l,role:"tool",name:a,createdAt:new Date().toISOString(),content:[u]};return{...e,messages:[...e.messages,f],toolIndex:{...e.toolIndex,[i]:l}}}if(t.type==="tool_end"){const i=t.id??t.call_id;if(!i)return e;const a=e.toolIndex[i]??`tool-${i}`,l={type:"tool_end",toolCallId:i,output:t.output,error:t.error},u=e.messages.find(h=>h.id===a),d={id:a,role:"tool",name:t.name??((s=e.messages.find(h=>h.id===a))==null?void 0:s.name),content:[l],createdAt:new Date().toISOString()},f=u?Oc(e.messages,a,[l]):[...e.messages,d];return{...e,messages:f,toolIndex:{...e.toolIndex,[i]:a}}}if(t.type==="checkpoint"){const i=t.checkpointNs??e.lastCheckpointNs??null,a=Ix(e.messages,t.checkpointId,i);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:i,messages:a}}if(t.type==="branch"){const i=t.checkpointId??e.lastCheckpointId,a=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:i??null,lastCheckpointNs:a??null}}if(t.type==="error"){const i={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,i]}}if(t.type==="interrupt"){const i=e.assemblingId??Ri(e.messages),a={type:"interrupt",value:t.value,id:t.id};if(i)return{...e,assemblingId:null,messages:Oc(e.messages,i,[a]),pendingInterrupt:{id:t.id,value:t.value}};const l=`interrupt-${t.id}`;if(e.messages.findIndex(f=>f.id===l)!==-1)return{...e,assemblingId:null,messages:Pc(e.messages,l,f=>({...f,content:Mc(f.content??[],[a])})),pendingInterrupt:{id:t.id,value:t.value}};const d={id:l,role:"system",createdAt:new Date().toISOString(),content:[a]};return{...e,messages:[...e.messages,d],pendingInterrupt:{id:t.id,value:t.value}}}return e}function ji(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 Rc(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Ri(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function Pc(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 Oc(e,t,n){return Pc(e,t,r=>({...r,content:Mc(r.content,n)}))}function Mc(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1],s=r.text??"";if(!s)continue;if((o==null?void 0:o.type)==="text"){let i=function(p){return p.replace(/\s+/g," ").trim()};const a=o,l=a.text??"";if(console.debug("[MessageReducer] mergeParts",{incomingLength:s.length,previousLength:l.length,incomingSnippet:s.slice(0,100),previousSnippet:l.slice(-100)}),!l){a.text=s;continue}const u=i(s),d=i(l);if(u.startsWith(d)||s.startsWith(l)){console.debug("[MessageReducer] incoming startsWith previous (norm/raw) - replacing",{incomingLength:s.length,previousLength:l.length}),a.text=s;continue}if(u.includes(d)){console.debug("[MessageReducer] incoming includes previous (normalized) - replacing",{incomingLength:s.length,previousLength:l.length}),a.text=s;continue}if(d.includes(u)&&u.length<=3){console.debug("[MessageReducer] previous includes incoming (normalized) - skipping trivial incoming",{incomingLength:s.length,previousLength:l.length});continue}const h=Fc(l,s);h?(console.debug("[MessageReducer] suffix computed",{suffixLength:h.length}),a.text=l+h):(console.debug("[MessageReducer] no overlap detected - appending incoming",{incomingLength:s.length}),a.text=l+s)}else n.push({type:"text",text:s})}else n.push(r);return n}function Dc(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function Ex(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(f=>f.type==="text").map(f=>f.text??"").join(""),i=t.filter(f=>f.type!=="text"),a=o.lastText??Dc(e);let l="",u=e.slice();if(s){const f=Fc(a,s);if(f===""?l="":f===s?l=s:l=f,l){const h=u[u.length-1];if((h==null?void 0:h.type)==="text"){const p=h.text??"",v={...h,text:p+l};u=[...u.slice(0,u.length-1),v]}else u=[...u,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(u=[...u,...i]);const d=!!(l||i.length);return{newParts:u,newMeta:o,changed:d}}function Lc(e){return e.replace(/\s+/g," ").trim()}function Fc(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let i=n;i>0;i--)if(e.slice(-i)===t.slice(0,i))return t.slice(i);const r=Lc(e),o=Lc(t);if(r===o)return"";const s=Math.min(r.length,o.length);for(let i=s;i>0;i--)if(r.slice(-i)===o.slice(0,i))return t;return t}function Ix(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 Rc(e,r,s)}return e}function Nx(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function $c(e={}){const t=w.useMemo(()=>Mn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=w.useState(e.token??null),s=w.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=w.useState(!1),[u,d]=w.useState(null),[f,h]=w.useState(""),[p,v]=w.useState(null),[x,g]=w.useState(0),[y,b]=w.useState(!1),C=w.useRef(null),E=w.useRef(!0),T=w.useRef(0),k=w.useCallback(j=>{o(j)},[]),I=w.useCallback(()=>{var j;(j=C.current)==null||j.abort(),C.current=null,l(!1),b(!1),T.current=0,g(0)},[]),_=w.useCallback(()=>{h(""),v(null),d(null)},[]),R=w.useCallback((j,H,F)=>{C.current&&(C.current.abort(),C.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h("");const U=new AbortController;return C.current=U,(async()=>{var G,W,ne,$,z,ie,M,Y;const D=ce=>{var be;try{const ge=JSON.parse(JSON.stringify(ce));return(be=ge==null?void 0:ge.payload)!=null&&be.files_info&&Array.isArray(ge.payload.files_info)&&(ge.payload.files_info=ge.payload.files_info.map(ye=>({...ye,data:ye!=null&&ye.data?`<base64 ${String(ye.data).length} chars>`:ye==null?void 0:ye.data}))),ge}catch{return ce}};try{let ce={};try{if(r)ce={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ue=window.__AUTH_TOKEN__,et=((G=window.localStorage)==null?void 0:G.getItem("authToken"))||null;let Ze=null;try{const Ct=(W=window.localStorage)==null?void 0:W.getItem("chat-settings");Ct&&(Ze=((ne=JSON.parse(Ct))==null?void 0:ne.apiKey)||null)}catch{}const Pe=Ue||et||Ze||null;Pe&&(ce={Authorization:`Bearer ${Pe}`})}}catch{}console.debug("[use-chat] POST",t+n,D(j));const be=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...ce,...s.current},body:JSON.stringify(j),signal:U.signal,credentials:i});if(!be.ok||!be.body){const je=await be.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",be.status,je==null?void 0:je.slice(0,500)),new Error(`stream ${be.status}${je?": "+je:""}`)}b(!0);const ge=be.body.getReader(),ye=new TextDecoder;let K="",L=[];T.current=0,g(0);let Z=0,ee=null;const me=()=>{if(L.length){const je=L.join("");L=[],E.current&&h(Ue=>Ue+je)}ee=null},se=()=>{typeof window<"u"&&ee==null&&(ee=requestAnimationFrame(me))};let ae=Date.now();const He=setInterval(()=>{var je;if(Date.now()-ae>6e4){const Ue="Stream idle timeout";d(Ue),U.abort(),(je=F==null?void 0:F.onError)==null||je.call(F,Ue)}},5e3),Je=1024*1024;try{const je=be.headers.get("X-Thread-Id")||be.headers.get("x-thread-id"),Ue=be.headers.get("X-Thread-Created")||be.headers.get("x-thread-created"),et=je??null,Ze=String(Ue??"").toLowerCase()==="true";for(($=F==null?void 0:F.onOpen)==null||$.call(F,{threadId:et,created:Ze});;){const{value:Pe,done:Ct}=await ge.read();if(Ct)break;K+=ye.decode(Pe,{stream:!0}),K.length>Je&&(K="",console.warn("Stream buffer reset: exceeded 1MB"));let kt;for(;(kt=K.indexOf(`
34
+ `):" "+cc(i[0]):"as no adapter specified";throw new Re("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:ki};function Ti(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Nr(null,e)}function dc(e){return Ti(e),e.headers=Ut.from(e.headers),e.data=Ci.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),uc.getAdapter(e.adapter||Xr.adapter,e)(e).then(function(r){return Ti(e),r.data=Ci.call(e,e.transformResponse,r),r.headers=Ut.from(r.headers),r},function(r){return Xl(r)||(Ti(e),r&&r.response&&(r.response.data=Ci.call(e,e.transformResponse,r.response),r.response.headers=Ut.from(r.response.headers))),Promise.reject(r)})}const fc="1.12.2",Uo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Uo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const hc={};Uo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+fc+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Re(o(i," has been removed"+(n?" in "+n:"")),Re.ERR_DEPRECATED);return n&&!hc[i]&&(hc[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}},Uo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Jg(e,t,n){if(typeof e!="object")throw new Re("options must be an object",Re.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],l=a===void 0||i(a,s,e);if(l!==!0)throw new Re("option "+s+" must be "+l,Re.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Re("Unknown option "+s,Re.ERR_BAD_OPTION)}}const Wo={assertOptions:Jg,validators:Uo},xn=Wo.validators;let ar=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Kl,response:new Kl}}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=ir(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Wo.assertOptions(r,{silentJSONParsing:xn.transitional(xn.boolean),forcedJSONParsing:xn.transitional(xn.boolean),clarifyTimeoutError:xn.transitional(xn.boolean)},!1),o!=null&&(O.isFunction(o)?n.paramsSerializer={serialize:o}:Wo.assertOptions(o,{encode:xn.function,serialize:xn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Wo.assertOptions(n,{baseUrl:xn.spelling("baseURL"),withXsrfToken:xn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&O.merge(s.common,s[n.method]);s&&O.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Ut.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(x){typeof x.runWhen=="function"&&x.runWhen(n)===!1||(l=l&&x.synchronous,a.unshift(x.fulfilled,x.rejected))});const u=[];this.interceptors.response.forEach(function(x){u.push(x.fulfilled,x.rejected)});let d,f=0,h;if(!l){const v=[dc.bind(this),void 0];for(v.unshift(...a),v.push(...u),h=v.length,d=Promise.resolve(n);f<h;)d=d.then(v[f++],v[f++]);return d}h=a.length;let p=n;for(;f<h;){const v=a[f++],x=a[f++];try{p=v(p)}catch(g){x.call(this,g);break}}try{d=dc.call(this,p)}catch(v){return Promise.reject(v)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=ir(this.defaults,t);const n=ec(t.baseURL,t.url,t.allowAbsoluteUrls);return Vl(n,t.params,t.paramsSerializer)}};O.forEach(["delete","get","head","options"],function(t){ar.prototype[t]=function(n,r){return this.request(ir(r||{},{method:t,url:n,data:(r||{}).data}))}}),O.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(ir(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}ar.prototype[t]=n(),ar.prototype[t+"Form"]=n(!0)});let Zg=class Nm{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 Nr(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 Nm(function(o){t=o}),cancel:t}}};function Qg(e){return function(n){return e.apply(null,n)}}function ex(e){return O.isObject(e)&&e.isAxiosError===!0}const Ei={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(Ei).forEach(([e,t])=>{Ei[t]=e});function pc(e){const t=new ar(e),n=_l(ar.prototype.request,t);return O.extend(n,ar.prototype,t,{allOwnKeys:!0}),O.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return pc(ir(e,o))},n}const gt=pc(Xr);gt.Axios=ar,gt.CanceledError=Nr,gt.CancelToken=Zg,gt.isCancel=Xl,gt.VERSION=fc,gt.toFormData=$o,gt.AxiosError=Re,gt.Cancel=gt.CanceledError,gt.all=function(t){return Promise.all(t)},gt.spread=Qg,gt.isAxiosError=ex,gt.mergeConfig=ir,gt.AxiosHeaders=Ut,gt.formToJSON=e=>Gl(O.isHTMLForm(e)?new FormData(e):e),gt.getAdapter=uc.getAdapter,gt.HttpStatusCode=Ei,gt.default=gt;const{Axios:oT,AxiosError:sT,CanceledError:iT,isCancel:aT,CancelToken:lT,VERSION:cT,all:uT,Cancel:dT,isAxiosError:fT,spread:hT,toFormData:pT,AxiosHeaders:mT,HttpStatusCode:gT,formToJSON:xT,getAdapter:yT,mergeConfig:vT}=gt,mc=typeof window<"u"?window.__API_BASE_URL__:void 0,gc=mc?Mn(mc):void 0;function Mn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Vo=null;const Ii=new Set;function xc(){return Vo}function Ni(e){Vo=e,Ii.forEach(t=>t(e))}function yc(e){return Ii.add(e),()=>Ii.delete(e)}const Zt=gt.create({...gc?{baseURL:gc}:{},timeout:3e4,withCredentials:!0});Zt.interceptors.request.use(e=>(Vo&&(e.headers.Authorization=`Bearer ${Vo}`),e)),Zt.interceptors.response.use(e=>e,e=>Promise.reject(e));async function ln(e,t){return Zt.defaults.baseURL?(await Zt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function vc(e,t,n){return Zt.defaults.baseURL?(await Zt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function bc(e,t,n){return Zt.defaults.baseURL?(await Zt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function wc(e,t){return Zt.defaults.baseURL?(await Zt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function yn(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Sc{get baseUrl(){const t=Zt.defaults.baseURL;return t?Mn(String(t)):""}updateConfig(t){t.baseUrl&&(Zt.defaults.baseURL=Mn(String(t.baseUrl))),t.authToken!==void 0&&Ni(t.authToken)}getAuthToken(){return xc()}setAuthToken(t){Ni(t)}onTokenChange(t){return yc(t)}async listThreads(){const t=await ln("/threads"),n=yn(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await vc("/threads",t?{title:t}:void 0);return yn(r)}async updateThread(t,n){const r=await bc(`/threads/${t}`,{title:n});return yn(r)}async deleteThread(t){const n=await wc(`/threads/${t}`);return yn(n)}async threadInfo(t){const n=await ln(`/threads/${t}/info`);return yn(n)}async listAgents(){const t=await ln("/agents"),n=yn(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await ln(`/agents/${t}`);return yn(n)}async getAgentSchema(t){const n=await ln(`/agents/${t}/schema`);return yn(n)}async getState(t){const n=await ln(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return yn(n)}async getStateHistory(t){const n=await ln(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return yn(n)}}const Wn=new Sc,Cc=w.createContext(null);function tx({children:e,apiConfig:t}){const n=Wn;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return c.jsx(Cc.Provider,{value:r,children:e})}function Ai(){const e=w.useContext(Cc);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function nx(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 l=0;l<a;l++)i+=String.fromCharCode(s[l]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function rx(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const u=await nx(l);a.push({filename:l.name,data:u,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const ox={human:"user",user:"user",ai:"assistant",assistant:"assistant",tool:"tool",function:"tool",system:"system"};function _i(e){if(!e||typeof e!="object")return!1;const t=e;return"values"in t&&"config"in t&&typeof t.values=="object"&&t.values!==null&&typeof t.config=="object"&&t.config!==null}function Zr(e,t){return`${e??""}::${t??""}`}function ji(e){const t=Array.isArray(e==null?void 0:e.checkpoints)?(e==null?void 0:e.checkpoints)??[]:e!=null&&e.checkpoints?Object.values(e.checkpoints):[],n=(e==null?void 0:e.threadId)??"",r=t[0];if(!_i(r))return{threadId:n,latest:null,checkpoints:[],interrupt:null,snapshots:{}};const{orderedSnapshots:o,snapshotMap:s}=ix(t),i=kc(r,0);return{threadId:n,latest:i,checkpoints:o,interrupt:(i==null?void 0:i.interrupt)??null,snapshots:s}}function kc(e,t){if(!_i(e))return null;const n=e.values??{messages:[]},r=Array.isArray(n==null?void 0:n.messages)?n.messages:[],{messages:o,...s}=n,i=Object.keys(s).length?s:null,a=e.tasks,l=Array.isArray(a)?a.filter(R=>!!R&&typeof R=="object").map(R=>({...R})):a===null?null:void 0,u=r.map((R,j)=>px(R,j)).filter(R=>!!R),d=Vt(e.config),f=Vt(d==null?void 0:d.configurable),h=ft(f,["checkpoint_id","checkpointId"]),p=ft(f,["checkpoint_ns","checkpointNs"]),v=Vt(e==null?void 0:e.parentConfig),x=Vt(v==null?void 0:v.configurable),g=ft(x,["checkpoint_id","checkpointId"])??null,y=ft(x,["checkpoint_ns","checkpointNs"])??null,b=e==null?void 0:e.createdAt,C=typeof b=="string"&&b.trim()?b:new Date(Date.now()-t).toISOString(),E=u[u.length-1]??null,k=Vt(e==null?void 0:e.metadata),T=ft(k,["branch_label","branchLabel"]),I=ft(x,["checkpoint_id","checkpointId"]),_=Array.isArray(e.next)?[...e.next]:(e==null?void 0:e.next)===null?null:void 0;return{messages:u,checkpointId:h??null,checkpointNs:p??null,nextCursor:g,nextCursorNs:y,interrupt:sx(a,u,t),createdAt:C,parentId:I??null,branchLabel:T??null,lastMessageId:(E==null?void 0:E.id)??null,hasMessages:u.length>0,messagesLen:u.length,metadata:k??null,config:d??null,parentConfig:v??null,next:_??null,tasks:l??null,values:i??null}}function sx(e,t,n){const r=fx(e,n);return r||dx(t,n)}function ix(e){const t=new Map;e.forEach((o,s)=>{if(!_i(o))return;const i=kc(o,s);if(!(i!=null&&i.checkpointId))return;const a=Zr(i.checkpointId,i.checkpointNs??null),l=t.get(a);if(!l){t.set(a,i);return}t.set(a,ax(l,i))});const n=Array.from(t.values());n.sort((o,s)=>Ec(s.createdAt??"")-Ec(o.createdAt??""));const r={};for(const[o,s]of t.entries())r[o]=s;return{orderedSnapshots:n,snapshotMap:r}}function ax(e,t){const n=Ko(e.metadata,t.metadata),r=Ko(e.config,t.config),o=Ko(e.parentConfig,t.parentConfig),s=cx(e.next,t.next),i=ux(e.tasks,t.tasks),a=lx(e.values,t.values);return{...e,metadata:n??null,config:r??null,parentConfig:o??null,next:s??null,tasks:i??null,values:a??null}}function Ko(e,t){return t&&typeof t=="object"?{...e&&typeof e=="object"?{...e}:{},...t}:t===null?e&&typeof e=="object"?{...e}:e??null:e&&typeof e=="object"?{...e}:e??void 0}function lx(e,t){return Ko(e,t)}function cx(e,t){return Array.isArray(t)?t.slice():t===null?Array.isArray(e)?e.slice():e??null:Array.isArray(e)?e.slice():e??void 0}function ux(e,t){return Array.isArray(t)?t.map(n=>({...n})):t===null?Array.isArray(e)?e.map(n=>({...n})):e??null:Array.isArray(e)?e.map(n=>({...n})):e??void 0}function dx(e,t){var n;for(let r=e.length-1;r>=0;r--){const o=((n=e[r])==null?void 0:n.content)??[];for(let s=o.length-1;s>=0;s--){const i=o[s];if((i==null?void 0:i.type)==="interrupt"){const a=i;return{id:typeof a.id=="string"&&a.id.trim()?a.id:`interrupt-${t}-${r}-${s}`,value:a.value}}}}return null}function fx(e,t){if(!Array.isArray(e)||!e.length)return null;for(let n=e.length-1;n>=0;n--){const r=hx(e[n],`task-${t}-${n}`);if(!r)continue;const o=r.id||`task-${t}-${n}`;if(Array.isArray(r.interrupts)&&r.interrupts.length)for(let s=r.interrupts.length-1;s>=0;s--){const i=Qr(r.interrupts[s],`${o}-interrupt-${s}`);if(i)return i}if(r.state!==void 0&&r.state!==null){const s=Qr(r.state,`${o}-state`);if(s)return s}}return null}function hx(e,t){if(!e)return null;if(Array.isArray(e)){const[a,l,u,,d,,f,...h]=e,p=typeof a=="string"&&a.trim()?a:t,v=typeof l=="string"&&l.trim()?l:Array.isArray(u)&&typeof u[0]=="string"?String(u[0]):"task",x=Array.isArray(d)?d:void 0,g=h.length?h[h.length-1]:void 0;return{id:p,name:v,interrupts:x,state:g!==void 0?g:f}}const n=Vt(e);if(!n)return null;const r=ft(n,["id","task_id","taskId"])??t,o=ft(n,["name"])??"task",s=Array.isArray(n.interrupts)?n.interrupts:void 0,i=Object.prototype.hasOwnProperty.call(n,"state")?n.state:void 0;return{id:r,name:o,interrupts:s,state:i}}function Qr(e,t,n=0,r=new Set){if(n>6||e==null)return null;if(typeof e=="object"){if(r.has(e))return null;r.add(e)}const o=Tc(e,t);if(o)return o;if(Array.isArray(e)){for(let s=e.length-1;s>=0;s--){const i=Qr(e[s],t,n+1,r);if(i)return i}return null}if(typeof e=="object"){const s=e,i=["interrupt","pending_interrupt","pendingInterrupt","value","data","payload","result","response"];for(const a of i)if(a in s){const l=Qr(s[a],t,n+1,r);if(l)return l}for(const[a,l]of Object.entries(s)){if(i.includes(a)||a==="messages"||a==="results")continue;const u=Qr(l,t,n+1,r);if(u)return u}}return null}function Tc(e,t){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){const n=e,r=ft(n,["type","event","kind"]),o=ft(n,["id","interrupt_id","interruptId","value_id"])??(r&&r.toLowerCase().includes("interrupt")?t:void 0);if(!(Object.prototype.hasOwnProperty.call(n,"value")||Object.prototype.hasOwnProperty.call(n,"data")||Object.prototype.hasOwnProperty.call(n,"payload"))&&!(r&&r.toLowerCase().includes("interrupt")))return null;const i=Object.prototype.hasOwnProperty.call(n,"value")?n.value:Object.prototype.hasOwnProperty.call(n,"data")?n.data:Object.prototype.hasOwnProperty.call(n,"payload")?n.payload:n,a=o&&o.trim()?o:t;return a?{id:a,value:i}:null}if(Array.isArray(e)){for(let n=e.length-1;n>=0;n--){const r=Tc(e[n],t);if(r)return r}return e.length>=2&&typeof e[0]=="string"&&e[0].trim()?{id:e[0],value:e[1]}:null}if(typeof e=="string"){const n=e.trim();return n?{id:t||n,value:n}:null}return null}function Ec(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function px(e,t){if(!e||typeof e!="object")return null;const n=e,r=Vt(e)??{},o=Vt(n.data)??r,s=String(n.type??o.type??o.role??"").toLowerCase(),i=ox[s];if(!i)return null;const a=o.id??o.message_id??o.run_id??null,l=typeof a=="string"&&a.trim()?a:`history-${i}-${t}`,u=Vt(o.additional_kwargs)??Vt(o.additionalKwargs),d=Vt(o.response_metadata)??Vt(o.responseMetadata),f=ft(u,["createdAt","created_at"])??ft(o,["created_at","createdAt"]),h=ft(u,["checkpointId","checkpoint_id"]),p=ft(u,["checkpointNs","checkpoint_ns"]),v=mx(o.content),x={id:l,role:i,content:v};f&&(x.createdAt=f),typeof o.name=="string"&&o.name.trim()&&(x.name=o.name),typeof(d==null?void 0:d.model_name)=="string"&&(x.model=String(d.model_name)),!x.model&&typeof o.model=="string"&&(x.model=o.model),h&&(x.checkpointId=h),p&&(x.checkpointNs=p);const g=bx(u,["createdAt","created_at","checkpointId","checkpoint_id","checkpointNs","checkpoint_ns","tool_calls"]),y=d?{...d}:void 0;g&&Object.keys(g).length&&(x.additionalKwargs=g),y&&Object.keys(y).length&&(x.responseMetadata=y);const b=gx((u==null?void 0:u.tool_calls)??o.tool_calls);if(b.length&&(x.content=[...x.content,...b]),i==="tool"){const C=yx(o,x.content);C&&(x.content=C)}return x}function mx(e){if(!e)return[];if(Array.isArray(e))return e.map(t=>Ic(t)).filter(t=>!!t);if(typeof e=="string")return e.trim()?[{type:"text",text:e.trim()}]:[];if(typeof e=="object"){const t=Ic(e);return t?[t]:[]}return[]}function Ic(e){if(!e||typeof e!="object")return typeof e=="string"&&e.trim()?{type:"text",text:e}:null;const t=e,n=String(t.type??"").toLowerCase();if(!n||n==="text"){const o=typeof t.text=="string"?t.text:typeof t.value=="string"?t.value:"";return o.trim()?{type:"text",text:o}:null}if(n==="image"||n==="image_url"){const o=ft(t,["url","src"]);if(!o)return null;const s={type:"image_url",url:o};return typeof t.mimeType=="string"&&(s.mimeType=t.mimeType),typeof t.alt=="string"&&(s.alt=t.alt),s}if(n==="file"){const o=ft(t,["url"]);if(!o)return null;const s={type:"file",url:o};return typeof t.mimeType=="string"&&(s.mimeType=t.mimeType),typeof t.name=="string"&&(s.name=t.name),typeof t.size=="number"&&(s.size=t.size),typeof t.sourceType=="string"&&(s.sourceType=t.sourceType),s}if(n==="tool_call")return xx(t)??null;if(n==="tool_end"){const o=ft(t,["tool_call_id","toolCallId","id"]);if(!o)return null;const s={type:"tool_end",toolCallId:o,output:"output"in t?t.output:t.content};return typeof t.error=="string"&&(s.error=t.error),s}if(n==="interrupt")return{type:"interrupt",value:t.value,...t};if(n==="tool"){const o=ft(t,["text","content"]);if(o)return{type:"text",text:o}}const r=typeof t.content=="string"?t.content:typeof t.value=="string"?t.value:JSON.stringify(t);return r?{type:"text",text:r}:null}function gx(e){return Array.isArray(e)?e.map((t,n)=>{if(!t||typeof t!="object")return null;const r=t,o=ft(r,["id","call_id"]),s=Vt(r.function),i=ft(s,["name"])??"tool",a=s==null?void 0:s.arguments,l=Nc(a);return{type:"tool_call",id:o??`tool_call_${n}`,name:i,args:l}}).filter(t=>!!t):[]}function xx(e){const t=ft(e,["id","call_id"]),n=ft(e,["name"]);if(!t||!n)return null;const r=Nc(e.args??e.arguments);return{type:"tool_call",id:t,name:n,args:r}}function yx(e,t){const n=ft(e,["tool_call_id","toolCallId","id"]);if(!n)return t;const r=e.content??e.output,o=typeof r=="string"?vx(r):r,s={type:"tool_end",toolCallId:n,output:o};return typeof e.error=="string"&&(s.error=e.error),[s]}function Nc(e){if(!e)return{};if(typeof e=="string")try{const t=JSON.parse(e);return typeof t=="object"&&t!==null?t:{raw:e}}catch{return{raw:e}}return typeof e=="object"&&!Array.isArray(e)?{...e}:{}}function vx(e){try{return JSON.parse(e)}catch{return e}}function Vt(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function ft(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r}}function bx(e,t){if(!e)return;const n={};let r=!1;for(const[o,s]of Object.entries(e)){if(t.includes(o)){r=!0;continue}s!==void 0&&(n[o]=s)}return r?Object.keys(n).length?n:void 0:e}function wx(e){return e.type!=="thread_info"&&e.type!=="token"}const Sx={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,messagesStreamMeta:{},pendingInterrupt:null};function Cx(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:Ri(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,pendingInterrupt:null};return console.log("[MessageReducer] 📊 After reset - messages count:",r.messages.length),r}case"seed":{const r=Ri(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??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=Ri(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 _c(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>_c(o,s),e):e}case"interrupt_response":return{...e,messages:Rc(e.messages),pendingInterrupt:null};default:return e}}function Ac(e=[]){const[t,n]=w.useReducer(Cx,{...Sx,messages:e}),r=w.useRef([]),o=w.useRef(null),s=w.useRef(null),i=w.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=w.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]),l=w.useCallback(d=>{r.current.push(d),a()},[a]);w.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const u=w.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:l}),[l]);return{state:t,dispatch:n,...u}}function _c(e,t){var n,r,o,s;if(t.type==="message_start"&&t.role==="assistant"){const i=t.id,a=Ax(t.model);if(e.messages.some(d=>d.id===i)){const d=e.messagesStreamMeta??{},f={...d,[i]:d[i]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:i,messagesStreamMeta:f}}const u={id:i,role:"assistant",name:a||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:i,messages:[...e.messages,u]}}if(t.type==="message_delta"){const i=e.assemblingId??Pc(e.messages);if(!i)return e;const a=e.messages,l=a.findIndex(C=>C.id===i&&C.role==="assistant");if(l===-1)return e;const u=a[l],d=e.messagesStreamMeta??{},f=d[i]??{lastSeq:null,lastText:Oc(u.content)},h=t.seq??null;if(h!==null&&typeof h=="number"&&typeof f.lastSeq=="number"&&h<=f.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:h,lastSeq:f.lastSeq}),e;const{newParts:p,newMeta:v,changed:x}=Ix(u.content,t.delta,f,h);if(!x)return e;const g={...u,content:p},y=jc(a,l,g),b={...d,[i]:v};return{...e,messages:y,messagesStreamMeta:b}}if(t.type==="message_end"){const i=e.assemblingId??Pc(e.messages);if(!i)return{...e,assemblingId:null};const a=e.messages,l=a.findIndex(u=>u.id===i&&u.role==="assistant");if(l>=0){const u=a[l];if(!((n=u.content)==null?void 0:n.some(f=>{var h;return(f==null?void 0:f.type)==="text"&&((h=f.text)==null?void 0:h.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:u.id,contentTypes:(r=u.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=u.content)==null?void 0:o.map(h=>(h==null?void 0:h.type)==="text"?String(h.text).slice(0,100):h==null?void 0:h.type)});const f=[...a.slice(0,l),...a.slice(l+1)];return{...e,assemblingId:null,messages:f}}}return e}if(t.type==="tool_start"){const i=t.id??t.call_id,a=t.name??t.tool??"tool";if(!i)return e;const l=`tool-${i}`,u={type:"tool_call",id:i,name:a,args:t.args};if(e.messages.find(h=>h.id===l))return{...e,toolIndex:{...e.toolIndex,[i]:l}};const f={id:l,role:"tool",name:a,createdAt:new Date().toISOString(),content:[u]};return{...e,messages:[...e.messages,f],toolIndex:{...e.toolIndex,[i]:l}}}if(t.type==="tool_end"){const i=t.id??t.call_id;if(!i)return e;const a=e.toolIndex[i]??`tool-${i}`,l={type:"tool_end",toolCallId:i,output:t.output,error:t.error},u=e.messages.find(h=>h.id===a),d={id:a,role:"tool",name:t.name??((s=e.messages.find(h=>h.id===a))==null?void 0:s.name),content:[l],createdAt:new Date().toISOString()},f=u?Tx(e.messages,a,[l]):[...e.messages,d];return{...e,messages:f,toolIndex:{...e.toolIndex,[i]:a}}}if(t.type==="checkpoint"){const i=t.checkpointNs??e.lastCheckpointNs??null,a=Nx(e.messages,t.checkpointId,i);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:i,messages:a}}if(t.type==="branch"){const i=t.checkpointId??e.lastCheckpointId,a=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:i??null,lastCheckpointNs:a??null}}if(t.type==="error"){const i={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,i]}}if(t.type==="state_history"){const i=ji(t),a=i.interrupt,l=i.latest,u=a===null?Rc(e.messages):e.messages;return{...e,messages:u,pendingInterrupt:a,lastCheckpointId:(l==null?void 0:l.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(l==null?void 0:l.checkpointNs)??e.lastCheckpointNs}}return e}function Ri(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 jc(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Rc(e){let t=!1;const n=e.map(r=>{const o=(r.content??[]).filter(s=>s.type!=="interrupt");return o.length!==r.content.length?(t=!0,{...r,content:o}):r});return t?n:e}function Pc(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function kx(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 Tx(e,t,n){return kx(e,t,r=>({...r,content:Ex(r.content,n)}))}function Ex(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1],s=r.text??"";if(!s)continue;if((o==null?void 0:o.type)==="text"){let i=function(p){return p.replace(/\s+/g," ").trim()};const a=o,l=a.text??"";if(console.debug("[MessageReducer] mergeParts",{incomingLength:s.length,previousLength:l.length,incomingSnippet:s.slice(0,100),previousSnippet:l.slice(-100)}),!l){a.text=s;continue}const u=i(s),d=i(l);if(u.startsWith(d)||s.startsWith(l)){console.debug("[MessageReducer] incoming startsWith previous (norm/raw) - replacing",{incomingLength:s.length,previousLength:l.length}),a.text=s;continue}if(u.includes(d)){console.debug("[MessageReducer] incoming includes previous (normalized) - replacing",{incomingLength:s.length,previousLength:l.length}),a.text=s;continue}if(d.includes(u)&&u.length<=3){console.debug("[MessageReducer] previous includes incoming (normalized) - skipping trivial incoming",{incomingLength:s.length,previousLength:l.length});continue}const h=Dc(l,s);h?(console.debug("[MessageReducer] suffix computed",{suffixLength:h.length}),a.text=l+h):(console.debug("[MessageReducer] no overlap detected - appending incoming",{incomingLength:s.length}),a.text=l+s)}else n.push({type:"text",text:s})}else n.push(r);return n}function Oc(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function Ix(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(f=>f.type==="text").map(f=>f.text??"").join(""),i=t.filter(f=>f.type!=="text"),a=o.lastText??Oc(e);let l="",u=e.slice();if(s){const f=Dc(a,s);if(f===""?l="":f===s?l=s:l=f,l){const h=u[u.length-1];if((h==null?void 0:h.type)==="text"){const p=h.text??"",v={...h,text:p+l};u=[...u.slice(0,u.length-1),v]}else u=[...u,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(u=[...u,...i]);const d=!!(l||i.length);return{newParts:u,newMeta:o,changed:d}}function Mc(e){return e.replace(/\s+/g," ").trim()}function Dc(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let i=n;i>0;i--)if(e.slice(-i)===t.slice(0,i))return t.slice(i);const r=Mc(e),o=Mc(t);if(r===o)return"";const s=Math.min(r.length,o.length);for(let i=s;i>0;i--)if(r.slice(-i)===o.slice(0,i))return t;return t}function Nx(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 jc(e,r,s)}return e}function Ax(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Lc(e={}){const t=w.useMemo(()=>Mn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=w.useState(e.token??null),s=w.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=w.useState(!1),[u,d]=w.useState(null),[f,h]=w.useState(""),[p,v]=w.useState(null),[x,g]=w.useState(0),[y,b]=w.useState(!1),C=w.useRef(null),E=w.useRef(!0),k=w.useRef(0),T=w.useCallback(j=>{o(j)},[]),I=w.useCallback(()=>{var j;(j=C.current)==null||j.abort(),C.current=null,l(!1),b(!1),k.current=0,g(0)},[]),_=w.useCallback(()=>{h(""),v(null),d(null)},[]),R=w.useCallback((j,H,F)=>{C.current&&(C.current.abort(),C.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h("");const U=new AbortController;return C.current=U,(async()=>{var G,W,ne,$,z,ie,M,Y;const D=ce=>{var be;try{const ge=JSON.parse(JSON.stringify(ce));return(be=ge==null?void 0:ge.payload)!=null&&be.files_info&&Array.isArray(ge.payload.files_info)&&(ge.payload.files_info=ge.payload.files_info.map(ye=>({...ye,data:ye!=null&&ye.data?`<base64 ${String(ye.data).length} chars>`:ye==null?void 0:ye.data}))),ge}catch{return ce}};try{let ce={};try{if(r)ce={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ue=window.__AUTH_TOKEN__,et=((G=window.localStorage)==null?void 0:G.getItem("authToken"))||null;let Ze=null;try{const Ct=(W=window.localStorage)==null?void 0:W.getItem("chat-settings");Ct&&(Ze=((ne=JSON.parse(Ct))==null?void 0:ne.apiKey)||null)}catch{}const Pe=Ue||et||Ze||null;Pe&&(ce={Authorization:`Bearer ${Pe}`})}}catch{}console.debug("[use-chat] POST",t+n,D(j));const be=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...ce,...s.current},body:JSON.stringify(j),signal:U.signal,credentials:i});if(!be.ok||!be.body){const je=await be.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",be.status,je==null?void 0:je.slice(0,500)),new Error(`stream ${be.status}${je?": "+je:""}`)}b(!0);const ge=be.body.getReader(),ye=new TextDecoder;let K="",L=[];k.current=0,g(0);let Z=0,ee=null;const me=()=>{if(L.length){const je=L.join("");L=[],E.current&&h(Ue=>Ue+je)}ee=null},se=()=>{typeof window<"u"&&ee==null&&(ee=requestAnimationFrame(me))};let ae=Date.now();const He=setInterval(()=>{var je;if(Date.now()-ae>6e4){const Ue="Stream idle timeout";d(Ue),U.abort(),(je=F==null?void 0:F.onError)==null||je.call(F,Ue)}},5e3),Je=1024*1024;try{const je=be.headers.get("X-Thread-Id")||be.headers.get("x-thread-id"),Ue=be.headers.get("X-Thread-Created")||be.headers.get("x-thread-created"),et=je??null,Ze=String(Ue??"").toLowerCase()==="true";for(($=F==null?void 0:F.onOpen)==null||$.call(F,{threadId:et,created:Ze});;){const{value:Pe,done:Ct}=await ge.read();if(Ct)break;K+=ye.decode(Pe,{stream:!0}),K.length>Je&&(K="",console.warn("Stream buffer reset: exceeded 1MB"));let Tt;for(;(Tt=K.indexOf(`
36
36
 
37
- `))>=0;){const Et=K.slice(0,kt);K=K.slice(kt+2);const st=_x(Et);if(!st)continue;let tt;try{tt=JSON.parse(st)}catch{console.debug("[use-chat] malformed SSE:",st.slice(0,200));continue}const ze=Ax(tt)?tt.data:tt;ae=Date.now();const ct=ze.seq;if(ct!==void 0){if(ct<=Z){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:ct,lastProcessedSeq:Z,type:ze.type});continue}Z>0&&ct>Z+1&&((z=F==null?void 0:F.onGap)==null||z.call(F,{from:Z,to:ct})),Z=ct,T.current=ct,g(ct)}if(console.debug("[use-chat] received event",{seq:ze.seq,type:ze.type,preview:(()=>{var bt;try{return ze.type==="message_delta"?{deltaTypes:(bt=ze.delta)==null?void 0:bt.map(X=>X.type),textLen:(ze.delta||[]).filter(X=>X.type==="text").map(X=>String(X.text||"").length)}:ze.content||ze.delta?{hasContent:!0}:{}}catch(X){return{err:String(X)}}})()}),H==null||H(ze),ze.type==="token"&&e.autoAppendAssistant!==!1)L.push(ze.content),se();else if(ze.type==="message_delta"){const bt=ze.delta.filter(X=>X.type==="text").map(X=>X.text).join("");bt&&e.autoAppendAssistant!==!1&&(L.push(bt),se())}else ze.type==="heartbeat"?console.debug("[use-chat] heartbeat received"):(ee!==null&&cancelAnimationFrame(ee),me(),ze.type==="checkpoint"?v(ze.checkpointId):ze.type==="error"&&d(ze.message))}}me()}catch(je){if(je.name!=="AbortError"){const Ue=je.message||String(je);d(Ue),(ie=F==null?void 0:F.onError)==null||ie.call(F,Ue)}}finally{try{await ge.cancel()}catch{}finally{(M=ge.releaseLock)==null||M.call(ge)}ee!==null&&typeof window<"u"&&window.cancelAnimationFrame(ee),clearInterval(He),l(!1),b(!1),C.current=null,T.current=0,g(0)}}catch(ce){if(ce.name!=="AbortError"){const be=ce.message||String(ce);d(be),(Y=F==null?void 0:F.onError)==null||Y.call(F,be)}}finally{l(!1),b(!1),C.current=null,T.current=0,g(0)}})(),{close:()=>U.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var j;E.current=!1,(j=C.current)==null||j.abort()},[]),{isStreaming:a,error:u,assistantText:f,lastCheckpointId:p,lastSeq:x,connected:y,stream:R,stop:I,clear:_,setToken:k}}function Ax(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function _x(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
- `)}function jx({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onUnhandledEvent:r,onSequenceGap:o}){const s=w.useRef(null),i=w.useCallback(p=>{const v=p.seq??null;if(v!==null){const x=s.current;if(x!==null){if(v<=x)return;v>x+1&&(o==null||o({from:x,to:v}))}s.current=v}if(p.type==="thread_info"){console.log("[useChatStreamingService] 🎯 Received thread_info event:",p),t(p);return}if(Cx(p)){n(p);return}r==null||r(p)},[n,o,t,r]),{stream:a,stop:l,isStreaming:u,error:d,setToken:f}=$c({baseUrl:e,token:null}),h=w.useCallback((p,v)=>{s.current=null,a(p,i,{onOpen:v==null?void 0:v.onOpen,onError:x=>{var g;(g=v==null?void 0:v.onError)==null||g.call(v,x)},onGap:(v==null?void 0:v.onGap)??o})},[i,o,a]);return w.useMemo(()=>({startStream:h,stop:l,isStreaming:u,error:d,setAuthToken:f}),[h,l,u,d,f])}function Pi(e){return e==null?e:{...e}}function Rx(e){return e==null?e:{...e}}function Px(e){if(Array.isArray(e))return e.slice();if(e==null)return e}function Ox(e){if(Array.isArray(e))return e.map(t=>({...t}));if(e==null)return e}function Qt(e,t={}){const n=t.cloneMessages??!1,r=Array.isArray(e==null?void 0:e.messages)?e.messages:[],o=Pi(e==null?void 0:e.metadata),s=Pi(e==null?void 0:e.config),i=Pi(e==null?void 0:e.parentConfig),a=Px(e==null?void 0:e.next),l=Ox(e==null?void 0:e.tasks),u=Rx(e==null?void 0:e.values),d={checkpointId:(e==null?void 0:e.checkpointId)??null,checkpointNs:(e==null?void 0:e.checkpointNs)??null,createdAt:(e==null?void 0:e.createdAt)??null,parentId:(e==null?void 0:e.parentId)??null,branchLabel:(e==null?void 0:e.branchLabel)??null,lastMessageId:(e==null?void 0:e.lastMessageId)??null,messagesLen:typeof(e==null?void 0:e.messagesLen)=="number"?e.messagesLen:r.length,hasMessages:typeof(e==null?void 0:e.hasMessages)=="boolean"?e.hasMessages:r.length>0,messages:n?r.slice():r,nextCursor:(e==null?void 0:e.nextCursor)??null,nextCursorNs:(e==null?void 0:e.nextCursorNs)??null,interrupt:(e==null?void 0:e.interrupt)??null};return o!==void 0&&(d.metadata=o),s!==void 0&&(d.config=s),i!==void 0&&(d.parentConfig=i),a!==void 0&&(d.next=a),l!==void 0&&(d.tasks=l),u!==void 0&&(d.values=u),d}function Mx(e){var t;for(let n=e.length-1;n>=0;n--){const r=((t=e[n])==null?void 0:t.content)??[];for(let o=r.length-1;o>=0;o--){const s=r[o];if((s==null?void 0:s.type)==="interrupt"){const i=s.id;return{id:(typeof i=="string"?i:null)??`interrupt-${e[n].id??o}`,value:s.value}}}}return null}function zc(e,t){if(!e&&!t)return!0;if(!e||!t||e.id!==t.id)return!1;try{return JSON.stringify(e.value)===JSON.stringify(t.value)}catch{return e.value===t.value}}const qo=300;function Bc(e,t=qo){if(typeof window<"u"&&"requestIdleCallback"in window)try{window.requestIdleCallback(e,{timeout:t});return}catch{}window.setTimeout(e,t)}function lr(){return typeof window<"u"&&typeof window.localStorage<"u"}function Oi(e){if(!lr())return null;try{return window.localStorage.getItem(e)}catch{return null}}function Mi(e,t){if(!lr())return!1;try{return window.localStorage.setItem(e,t),!0}catch{return!1}}function Di(e){if(lr())try{window.localStorage.removeItem(e)}catch{}}const Dx="cachedThreads",Lx="v1",Li=200;function Fx(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(36)}function Fi(e,t){return`cachedThreads:v1:${e}:${Fx(t||"anon")}`}function $x(){const e=Oi(Dx);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>{if(!n||typeof n!="object")return!1;const r=n;return typeof r.threadId=="string"&&typeof r.title=="string"}):[]}catch{return[]}}function zx(e){const t=Oi(e);if(!t)return[];try{const n=JSON.parse(t);return Array.isArray(n)?n.filter(r=>{if(!r||typeof r!="object")return!1;const o=r;return typeof o.threadId=="string"&&typeof o.title=="string"}):[]}catch{return[]}}function $i(e,t){Mi(e,JSON.stringify(t))}function zi(e){const t=zx(e);if(t.length>0)return t;const n=$x();if(n.length>0)try{$i(e,n.slice(0,Li))}catch{}return n}function Go(e){const t={},n=[];for(const r of e)!r||typeof r.threadId!="string"||t[r.threadId]||(t[r.threadId]=r,n.push(r.threadId));return{byId:t,order:n}}function Bi(e){return e.order.map(t=>e.byId[t]).filter(Boolean)}function Hi(e,t){return`${e}${t}`}function Bx(e,t){const n=Oi(Hi(e,t));if(!n)return null;try{const r=JSON.parse(n);return typeof(r==null?void 0:r.threadId)!="string"?null:{threadId:r.threadId,snapshot:Qt(r.snapshot,{cloneMessages:!0}),updatedAt:typeof r.updatedAt=="number"?r.updatedAt:void 0}}catch{return null}}function Hx(e,t,n=100){if(!lr())return;const r=Qt(t.snapshot,{cloneMessages:!0}),o={threadId:t.threadId,snapshot:{...r,messages:r.messages.slice(-n)},updatedAt:Date.now()},s=Hi(e,t.threadId),i=JSON.stringify(o);if(!Mi(s,i))try{const a=[];for(let l=0;l<window.localStorage.length;l++){const u=window.localStorage.key(l);if(!u||u===s||!u.startsWith(e))continue;const d=window.localStorage.getItem(u);if(!d){a.push({key:u,updatedAt:0});continue}try{const f=JSON.parse(d),h=typeof(f==null?void 0:f.updatedAt)=="number"&&Number.isFinite(f.updatedAt)?f.updatedAt:0;a.push({key:u,updatedAt:h})}catch{a.push({key:u,updatedAt:0})}}a.sort((l,u)=>l.updatedAt-u.updatedAt);for(const l of a)if(window.localStorage.removeItem(l.key),Mi(s,i))break}catch{}}function Ux(e,t){Di(Hi(e,t))}function Wx(e){if(lr())try{for(let t=0;t<window.localStorage.length;t++){const n=window.localStorage.key(t);n&&n.startsWith(e)&&window.localStorage.removeItem(n)}}catch{}}const Hc=w.createContext(null),Uc=w.createContext(null),Wc=w.createContext(null),Vx=w.createContext(!1),Vc=50,Kx=750;function Kc(e,t,n){return`${e}__${t??""}__${n??""}`}function Yo(e,t){return t&&typeof t=="object"?{...e&&typeof e=="object"?{...e}:{},...t}:t===null?e&&typeof e=="object"?{...e}:e??null:e&&typeof e=="object"?{...e}:e??void 0}function qx(e,t){return Yo(e,t)}function Gx(e,t){return Array.isArray(t)?t.slice():t===null?Array.isArray(e)?e.slice():e??null:Array.isArray(e)?e.slice():e??void 0}function Yx(e,t){return Array.isArray(t)?t.map(n=>({...n})):t===null?Array.isArray(e)?e.map(n=>({...n})):e??null:Array.isArray(e)?e.map(n=>({...n})):e??void 0}function qc(e,t){const n=Yo(e.metadata,t.metadata),r=Yo(e.config,t.config),o=Yo(e.parentConfig,t.parentConfig),s=Gx(e.next,t.next),i=Yx(e.tasks,t.tasks),a=qx(e.values,t.values),l={};return n!==void 0&&(l.metadata=n??null),r!==void 0&&(l.config=r??null),o!==void 0&&(l.parentConfig=o??null),s!==void 0&&(l.next=s??null),i!==void 0&&(l.tasks=i??null),a!==void 0&&(l.values=a??null),l}function Xx({children:e,initialThreadId:t=null,autoLoadInitial:n=!0,disableAutoRestore:r=!1,enableFileAgentRouting:o=!1,fileAgentId:s="invoice_reader",onError:i,onThreadChange:a}){const{api:l,baseUrl:u}=Ai(),d=w.useMemo(()=>Mn(u),[u]),f=w.useMemo(()=>{try{return new URL(u).host}catch{return"unknown"}},[u]),h=w.useMemo(()=>`threadPayload:${Lx}:${f}:`,[f]),p=w.useCallback(N=>Bx(h,N),[h]),v=w.useCallback((N,A=100)=>{Hx(h,N,A)},[h]),x=w.useCallback(N=>{Ux(h,N)},[h]),g=w.useCallback(()=>{Wx(h)},[h]),[y,b]=w.useState(()=>{var N;return Fi(f,(N=l.getAuthToken)==null?void 0:N.call(l))}),[C,E]=w.useState(()=>{var A;const N=zi(Fi(f,(A=l.getAuthToken)==null?void 0:A.call(l)));return Go(N)}),T=w.useMemo(()=>Bi(C),[C]),[k,I]=w.useState(t),[_,R]=w.useState(!1),[j,H]=w.useState(!1),[F,U]=w.useState(null),[D,G]=w.useState(null),[W,ne]=w.useState(null),[$,z]=w.useState([]),ie=w.useCallback(()=>{const N=zi(y);w.startTransition(()=>{E(Go(N))})},[y]),[M,Y]=w.useState(!1),[ce,be]=w.useState(!1),[ge,ye]=w.useState(null),[K,L]=w.useState(void 0),[Z,ee]=w.useState(void 0),[me,se]=w.useState(void 0),{state:ae,dispatch:He,seed:Je,prepend:je,pushUser:Ue,onEvent:et,reset:Ze}=_c(),Pe=w.useRef(k);w.useEffect(()=>{Pe.current=k},[k]);const Ct=w.useRef(!1),kt=w.useRef([]),Et=w.useRef(null),st=w.useRef(null),tt=w.useRef(new Map),ze=w.useRef(k),ct=w.useRef(!1),bt=w.useRef(null),X=w.useRef(new Map),xe=w.useRef(new Map),de=w.useRef(new Map),_e=w.useRef(new Map),Fe=w.useCallback(N=>{if(!N){z([]);return}const A=X.current.get(N);if(!A||!A.length){z([]);return}z(A.map(q=>Qt(q,{cloneMessages:!0})))},[]);w.useEffect(()=>{Fe(k)},[k,Fe]);const nt=w.useCallback(()=>{var te;const N=_e.current;if(N.size<=Vc)return;const A=Array.from(N.entries()).sort((le,Q)=>le[1].timestamp-Q[1].timestamp),q=N.size-Vc;for(let le=0;le<q;le++){const Q=(te=A[le])==null?void 0:te[0];Q&&N.delete(Q)}},[]),pt=w.useCallback((N,A,q)=>{if(!N)return;const te=q==="replace"?[]:X.current.get(N)??[],le=q==="replace"?A:[...A,...te];if(!le.length){q==="replace"&&X.current.set(N,[]);return}const Q=new Map;for(const We of le){if(!(We!=null&&We.checkpointId))continue;const De=`${We.checkpointId}::${We.checkpointNs??""}`,Xe=Qt(We,{cloneMessages:!0}),yt=Q.get(De);if(!yt){Q.set(De,Xe);continue}const jt=qc(yt,Xe);Q.set(De,{...yt,...jt})}const Be=Array.from(Q.values()).sort((We,De)=>{const Xe=Number.isFinite(Date.parse(We.createdAt??""))?Date.parse(We.createdAt??""):0;return(Number.isFinite(Date.parse(De.createdAt??""))?Date.parse(De.createdAt??""):0)-Xe});X.current.set(N,Be),N===Pe.current&&Fe(N)},[Fe]),Qe=w.useCallback((N,A,q)=>{if(!N)return;const te=xe.current.get(N),le=q==="replace"||!te?new Map:new Map(te);if(A&&typeof A=="object")for(const[Q,Be]of Object.entries(A)){if(!(Be!=null&&Be.checkpointId))continue;const We=Q||Zr(Be.checkpointId,Be.checkpointNs??null);le.set(We,Qt(Be,{cloneMessages:!0}))}xe.current.set(N,le)},[]),ut=w.useCallback((N,A)=>{const{threadId:q,checkpointId:te=null,checkpointNs:le=null}=N,Q=Kc(q,te,le);if(A!=null&&A.force)de.current.delete(Q),_e.current.delete(Q);else{if(A!=null&&A.preferCache){const Xe=_e.current.get(Q);if(Xe)return Promise.resolve(Xe.payload)}const De=de.current.get(Q);if(De)return De}const We=l.getStateHistory({threadId:q,checkpointId:te??void 0,checkpointNs:le??void 0}).then(De=>(_e.current.set(Q,{payload:De,timestamp:Date.now()}),nt(),De)).finally(()=>{de.current.get(Q)===We&&de.current.delete(Q)});return de.current.set(Q,We),We},[l,nt]),mt=w.useCallback((N,A)=>new Promise((q,te)=>{const le=async()=>{Ct.current=!0;try{await N(),q()}catch(Q){te(Q)}finally{Ct.current=!1;const Q=kt.current.shift();Q&&Q().catch(()=>{})}};Ct.current?kt.current.push(le):le().catch(Q=>{te(Q)})}),[]),$n=w.useRef(T.length),[zn,Tr]=w.useState(!1),Bn=w.useRef(!1);w.useEffect(()=>{$n.current=T.length},[T.length]),w.useEffect(()=>{const N=ae.pendingInterrupt??Mx(ae.messages);zc(W,N)||ne(N??null)},[W,ae.messages,ae.pendingInterrupt]);const Ft=w.useCallback(async()=>{const N=$n.current>0;N||R(!0);try{const A=await l.listThreads();w.startTransition(()=>{E(q=>{const te=Be=>Be.map(We=>`${We.threadId}:${We.updatedAt??""}:${We.messageCount??""}`).join("|"),le=Bi(q);return te(le)===te(A)||A.length===0&&le.length>0&&!Bn.current?q:Go(A)})}),U(null),Bn.current||(Bn.current=!0,Tr(!0))}catch(A){i==null||i(String(A)),console.error("[ChatSessionProvider] Failed to refresh threads:",A),U(String(A))}finally{N||R(!1)}},[l,i]),Io=w.useRef(!1),Hn=w.useRef(null),wt=w.useRef(null),mn=w.useRef(""),_n=w.useCallback((N,A)=>{if(!lr())return;wt.current!==null&&(window.clearTimeout(wt.current),wt.current=null);const q=N.map(le=>`${le.threadId}:${le.updatedAt??""}:${le.messageCount??""}`).join("|");if(N.length===0){try{Di(y)}catch{}mn.current="";return}if(q===mn.current)return;const te=()=>{try{const le=N.slice(0,Li);$i(y,le),mn.current=q}catch{}finally{wt.current=null}};if(A!=null&&A.immediate){te();return}wt.current=window.setTimeout(()=>{Bc(te)},qo)},[y]),Ur=w.useCallback(()=>{_n(T,{immediate:!0})},[_n,T]),sn=w.useCallback((N,A,q,te)=>{var Nm;const le=q??Pe.current;if(!le)return;const Q=Qt(N),Be=le===Pe.current,We=(te==null?void 0:te.persist)!==!1;if(A==="replace"){if(We){const Nt={threadId:le,snapshot:Qt(N,{cloneMessages:!0})};tt.current.set(le,Nt),ze.current=le}if(!Be)return;Je(Q.messages,{checkpointId:Q.checkpointId??null,checkpointNs:Q.checkpointNs??null,pendingInterrupt:Q.interrupt??null}),ne(Q.interrupt??null),ye(Q.nextCursor??null),Y(!!Q.nextCursor),L(Q.checkpointId??void 0),ee(Q.checkpointNs??void 0),se(Q.nextCursorNs??void 0);return}const De=tt.current.get(le),Xe=(De==null?void 0:De.snapshot)??null,yt=Array.isArray(Xe==null?void 0:Xe.messages)?Xe.messages:[],jt=Qt(Xe),Rn=Array.isArray(N==null?void 0:N.messages)?N.messages:[],Rt=new Set,Pt=[...Rn,...yt].filter(Nt=>{const El=Nt==null?void 0:Nt.id;return El?Rt.has(El)?!1:(Rt.add(El),!0):!0}),_o=qc(jt,Q),jo={checkpointId:jt.checkpointId??Q.checkpointId??null,checkpointNs:jt.checkpointNs??Q.checkpointNs??null,createdAt:Q.createdAt??jt.createdAt??null,parentId:Q.parentId??jt.parentId??null,branchLabel:Q.branchLabel??jt.branchLabel??null,lastMessageId:((Nm=Pt[Pt.length-1])==null?void 0:Nm.id)??null,messagesLen:Pt.length,hasMessages:Pt.length>0,messages:Pt,nextCursor:Q.nextCursor??jt.nextCursor??null,nextCursorNs:Q.nextCursorNs??jt.nextCursorNs??null,interrupt:jt.interrupt??Q.interrupt??null,..._o};if(tt.current.set(le,{threadId:le,snapshot:Qt(jo,{cloneMessages:!0})}),!Be)return;Rn.length&&je(Rn);const Pn=N&&Object.prototype.hasOwnProperty.call(N,"checkpointId")?N.checkpointId:void 0,Ro=N&&Object.prototype.hasOwnProperty.call(N,"checkpointNs")?N.checkpointNs:void 0,On=N&&Object.prototype.hasOwnProperty.call(N,"nextCursor")?N.nextCursor:void 0,kl=N&&Object.prototype.hasOwnProperty.call(N,"nextCursorNs")?N.nextCursorNs:void 0;ye(Nt=>On!==void 0?On??Nt??null:Nt??null),Y(Nt=>On!==void 0?!!On:Nt),L(Nt=>Pn!==void 0?Pn??Nt??void 0:Nt??void 0),ee(Nt=>Ro!==void 0?Ro??Nt??void 0:Nt??void 0),se(Nt=>kl!==void 0?kl??void 0:Nt)},[je,Je,ne]),rr=w.useCallback(N=>{if(N.threadId!=null&&N.threadId!==Pe.current)return;const A=Qt(N.snapshot,{cloneMessages:!0});Je(A.messages,{checkpointId:A.checkpointId??null,checkpointNs:A.checkpointNs??null,pendingInterrupt:A.interrupt??null}),ne(A.interrupt??null),ye(A.nextCursor??null),Y(!!A.nextCursor),L(A.checkpointId??void 0),ee(A.checkpointNs??void 0),se(A.nextCursorNs??void 0),ze.current=N.threadId,Fe(N.threadId??Pe.current??null)},[Je,ne,Fe]),gn=w.useCallback(N=>{if(!N)return;tt.current.delete(N),x(N),X.current.delete(N),xe.current.delete(N),N===Pe.current&&z([]);const A=`${N}__`;for(const q of de.current.keys())q.startsWith(A)&&de.current.delete(q);for(const q of _e.current.keys())q.startsWith(A)&&_e.current.delete(q);ze.current===N&&(ze.current=null)},[x]),jn=w.useCallback(()=>{const N=Pe.current;N&&gn(N),Ze([]),Y(!1),be(!1),ye(null),L(void 0),ee(void 0),se(void 0)},[gn,Ze]),kr=w.useCallback(({from:N,to:A})=>{const q=Pe.current;q&&console.warn(`[ChatSessionProvider] Stream sequence gap detected (${N} -> ${A}) for thread ${q}`)},[]),No=w.useCallback(N=>{const A=N.threadId;console.log("[ChatSessionProvider] 📥 Handling thread_info event:",{threadId:A,title:N.title,created:N.created,currentThreads:T.length});const q={threadId:A,title:N.title||`Thread ${A.slice(0,8)}`,createdAt:N.createdAt||new Date().toISOString(),updatedAt:N.updatedAt||new Date().toISOString(),messageCount:N.messageCount||0};Pe.current!==A&&(!Pe.current&&ae.messages.length<=1&&(st.current=A),I(A)),w.startTransition(()=>{E(te=>{const le=te.byId[A];return le?le.title===q.title&&le.updatedAt===q.updatedAt&&le.messageCount===q.messageCount?te:{byId:{...te.byId,[A]:q},order:te.order}:{byId:{...te.byId,[A]:q},order:[A,...te.order]}})})},[ae.messages.length]),{startStream:Wr,stop:S,isStreaming:P,error:B,setAuthToken:oe}=jx({baseUrl:d,onThreadInfo:No,onMessageEvent:et,onUnhandledEvent:N=>{console.warn(`[ChatSessionProvider] Unhandled stream event: ${N.type}`,N)},onSequenceGap:kr});w.useEffect(()=>{Io.current=P},[P]),w.useEffect(()=>{if(!lr())return;wt.current!==null&&(window.clearTimeout(wt.current),wt.current=null);const N=T.map(q=>`${q.threadId}:${q.updatedAt??""}:${q.messageCount??""}`).join("|");if(T.length===0){try{Di(y)}catch{}mn.current="";return}if(N===mn.current)return;const A=()=>{try{const q=T.slice(0,Li);$i(y,q),mn.current=N}catch{}finally{wt.current=null}};return wt.current=window.setTimeout(()=>{Bc(A),wt.current=null},qo),()=>{wt.current!==null&&(window.clearTimeout(wt.current),wt.current=null)}},[T,_n]),w.useEffect(()=>{var te;const N=l.getAuthToken();oe(N);const A=le=>{const Q=Fi(f,le);bt.current!==Q&&(bt.current=Q,ct.current=!1),b(Q);const Be=zi(Q);w.startTransition(()=>{E(Go(Be))}),ct.current||(ct.current=!0,Ft().catch(()=>{}))};A(N);const q=(te=l.onTokenChange)==null?void 0:te.call(l,le=>{oe(le),g(),de.current.clear(),_e.current.clear(),A(le)});return()=>{q==null||q()}},[l,f,oe,g,Ft]);const Te=w.useCallback(async N=>{var te;const A=`Thread ${(te=crypto.randomUUID)==null?void 0:te.call(crypto)}`,q={threadId:A,title:N||"New Chat",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messageCount:0};E(le=>({byId:{...le.byId,[A]:q},order:[A,...le.order]})),I(A);try{const le=await l.createThread(N),Q=typeof le=="string"?le:le.threadId;return E(Be=>{const We=Be.byId[A];if(!We)return Be;const De={...Be.byId};delete De[A],De[Q]={...We,threadId:Q};const Xe=Be.order.map(yt=>yt===A?Q:yt);return{byId:De,order:Xe}}),I(Q),setTimeout(()=>Ft(),10),U(null),Q}catch(le){throw E(Q=>{if(!Q.byId[A])return Q;const Be={...Q.byId};delete Be[A];const We=Q.order.filter(De=>De!==A);return{byId:Be,order:We}}),I(null),U(String(le)),le}},[l,Ft]),$e=w.useCallback(async N=>{try{await l.deleteThread(N);let A=null;E(q=>{if(!q.byId[N])return q;const te={...q.byId};delete te[N];const le=q.order.filter(Be=>Be!==N),Q={byId:te,order:le};return A=Bi(Q),Q}),A&&_n(A,{immediate:!0}),gn(N),Pe.current===N&&(st.current=N,I(null),Pe.current=null,ze.current=null,jn()),await Ft(),U(null)}catch(A){throw U(String(A)),A}},[l,jn,gn,Ft,_n]),Me=w.useCallback(async(N,A)=>{try{await l.updateThread(N,A),E(q=>{const te=q.byId[N];return te?{byId:{...q.byId,[N]:{...te,title:A}},order:q.order}:q}),U(null)}catch(q){throw await Ft(),U(String(q)),q}},[l,Ft]),ke=w.useCallback(async(N,A,q,te=!1)=>{await mt(async()=>{if(st.current===N&&!te){st.current=null;return}if(Et.current===N&&!te)return;I(Rt=>Rt===N?Rt:N),Pe.current=N;const Be=Kc(N,A??null,q??null),We=_e.current.get(Be),De=!te&&!A&&!q&&We&&Date.now()-We.timestamp<Kx,Xe=!te&&!A&&!q;let yt=!1;if(Xe){const Rt=tt.current.get(N);if(Rt)rr(Rt),yt=!0;else{const Pt=p(N);Pt&&(tt.current.set(N,Pt),rr(Pt),yt=!0)}}const jt=te||!yt||!!A||!!q,Rn=async Rt=>{Rt&&H(!0),Et.current=N;try{const Pt=await ut({threadId:N,checkpointId:A,checkpointNs:q},{force:te}),{latest:_o,checkpoints:jo,snapshots:Pn}=Tc(Pt);sn(_o,"replace",N),pt(N,jo,"replace"),Qe(N,Pn,"replace"),G(null)}catch(Pt){throw(!yt||te||Rt)&&(i==null||i(String(Pt))),G(String(Pt)),Pt}finally{Et.current=null,Rt&&H(!1)}};jt?await Rn(!0):Xe&&yt&&!De&&Rn(!1).catch(Rt=>{console.warn("[ChatSessionProvider] Background refresh failed:",Rt)})},`loadThread-${N}`)},[rr,sn,mt,ut,i,pt,Qe]),It=w.useCallback(async()=>{await mt(async()=>{const N=Pe.current;N&&gn(N),st.current=null,I(null),Pe.current=null,ze.current=null,jn(),L(void 0),ee(void 0),se(void 0),z([]);try{localStorage.removeItem("lastThreadId")}catch(A){console.warn("[ChatSessionProvider] Failed to clear lastThreadId:",A)}},"clearCurrentThread")},[jn,gn,mt]),dt=w.useCallback(async(N,A)=>{var Q;const q=Pe.current;if(!q)throw new Error("No active thread");const te=Zr(N,A??null),le=(Q=xe.current.get(q))==null?void 0:Q.get(te);if(le){await mt(async()=>{sn(le,"replace",q,{persist:!1})},`navigateToCheckpoint-${q}-${te}`);return}await ke(q,N,A??void 0,!0)},[sn,mt,ke]),ht=w.useCallback(async()=>{if(!Pe.current)throw new Error("No active thread");await ke(Pe.current,void 0,void 0,!0)},[ke]),Bt=w.useCallback(async()=>{if(!Pe.current)throw new Error("No active thread");if(ce||!M)return;const N=ge;if(N){be(!0);try{const A=Pe.current,q=await ut({threadId:A,checkpointId:N??K??null,checkpointNs:me??Z??null}),{latest:te,checkpoints:le,snapshots:Q}=Tc(q),Be=A?xe.current.get(A):null;let We=le.length>0;if(We&&Be&&Be.size>0&&(We=le.some(De=>{if(!(De!=null&&De.checkpointId))return!1;const Xe=Zr(De.checkpointId,De.checkpointNs??null);return!Be.has(Xe)})),!We){ye(null),se(void 0),Y(!1),G(null);return}sn(te,"prepend",A??void 0),A&&(pt(A,le,"prepend"),Qe(A,Q,"prepend")),G(null)}catch(A){throw G(String(A)),A}finally{be(!1)}}},[sn,ut,M,K,Z,me,ge,ce,pt,Qe]),Un=w.useCallback(N=>{if(N!=null&&N.threadId){if(N.checkpointId){const A=Zr(N.checkpointId,N.checkpointNs??null),q=Qt({...N,interrupt:N.interrupt??null},{cloneMessages:!0});Qe(N.threadId,{[A]:q},"prepend")}sn(N,"replace",N.threadId)}},[sn,Qe]),Jt=w.useCallback(async(N,A)=>{var Ro;const q=Pe.current,te=(N==null?void 0:N.text)??"",le=(N==null?void 0:N.attachments)??[],Q=le.length?le:(A==null?void 0:A.attachments)??[],Be={...(A==null?void 0:A.payloadExtras)??{},...(N==null?void 0:N.payload)??{}};if(!q&&!Object.keys(Be).length&&Q.length===0&&!te.trim()){console.warn("[ChatSessionProvider] Nothing to submit - skipping");return}!q&&!Be.messages&&console.warn("[ChatSessionProvider] No thread ID - message will create new thread");const{contentParts:We,filesInfo:De}=await sx(l,Q),Xe=[...We];te&&te.trim()&&Xe.push({type:"text",text:te.trim()});const yt=!!q,jt=yt?(A==null?void 0:A.checkpointId)??ae.lastCheckpointId??void 0:void 0,Rn=yt?(A==null?void 0:A.checkpointNs)??ae.lastCheckpointNs??void 0:void 0,Rt={id:((Ro=crypto.randomUUID)==null?void 0:Ro.call(crypto))||`user-${Date.now()}`,role:"user",content:Xe,createdAt:new Date().toISOString(),...jt!=null?{checkpointId:jt}:{},...Rn!=null?{checkpointNs:Rn}:{}};Xe.length>0&&Ue(Rt);const Pt={...Rt,content:Xe},_o=Q.length>0,jo={messages:Xe.length>0?[Pt]:[],files_info:De,...o&&_o&&s?{active_agent:s}:{},...Be},Pn={threadId:q??null,payload:jo,checkpointId:jt??null,checkpointNs:Rn??null,nodeFilter:(A==null?void 0:A.nodeFilter)??null,config:A==null?void 0:A.config,command:(A==null?void 0:A.command)??null};Pn.threadId||delete Pn.threadId,Pn.command||delete Pn.command,Wr(Pn,{onError:On=>{console.warn("[ChatSessionProvider] Stream error:",On)},onOpen:({threadId:On})=>{!Pe.current&&On&&(ae.messages.length<=1&&(st.current=On),I(On))},onGap:kr})},[l,o,s,kr,ae.lastCheckpointId,ae.lastCheckpointNs,ae.messages.length,Ue,Wr]),_t=w.useCallback(async(N,A,q)=>{if(!Pe.current)throw new Error("No active thread to handle interrupt");const le=A?q??!0:!1;try{try{He({type:"interrupt_response",payload:{interruptId:N}})}catch(Q){console.warn("[ChatSessionProvider] optimistic interrupt_response dispatch failed:",Q)}await Jt({payload:{}},{checkpointId:ae.lastCheckpointId??void 0,checkpointNs:ae.lastCheckpointNs??void 0,command:{kind:"resume",value:le}}),ne(null)}catch(Q){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${N}:`,Q),Q}},[He,ae.lastCheckpointId,ae.lastCheckpointNs,Jt]);w.useEffect(()=>{if(a==null||a(k),k)try{localStorage.setItem("lastThreadId",k)}catch(N){console.warn("[ChatSessionProvider] Failed to persist lastThreadId:",N)}},[k,a]),w.useEffect(()=>((async()=>{try{if(Ft().catch(A=>{console.error("[ChatSessionProvider] Failed to refresh threads (background):",A),i==null||i(String(A))}),!r&&!t)try{const A=localStorage.getItem("lastThreadId");A&&(I(A),n&&await ke(A))}catch(A){console.warn("[ChatSessionProvider] Failed to restore last thread:",A)}else t&&n&&await ke(t)}catch(A){console.error("[ChatSessionProvider] Initialization failed:",A),i==null||i(String(A))}})(),()=>{}),[]),w.useEffect(()=>{const N=Pe.current;if(!N||ze.current!==N)return;ae.messages.length&&ae.messages[ae.messages.length-1];const A=Qt({checkpointId:ae.lastCheckpointId??null,checkpointNs:ae.lastCheckpointNs??null,messages:ae.messages.slice(),nextCursor:ge??null,nextCursorNs:me??null,interrupt:ae.pendingInterrupt??W??null}),q=tt.current.get(N),te=q==null?void 0:q.snapshot,le=!te||te.messages.length!==A.messages.length||te.messages.some((De,Xe)=>{var yt;return(De==null?void 0:De.id)!==((yt=A.messages[Xe])==null?void 0:yt.id)}),Q=((te==null?void 0:te.checkpointId)??null)!==A.checkpointId||((te==null?void 0:te.checkpointNs)??null)!==A.checkpointNs,Be=((te==null?void 0:te.nextCursor)??null)!==A.nextCursor||((te==null?void 0:te.nextCursorNs)??null)!==A.nextCursorNs,We=!zc((te==null?void 0:te.interrupt)??null,A.interrupt??null);if(le||Q||Be||We){const De={threadId:N,snapshot:A};tt.current.set(N,De),Hn.current&&window.clearTimeout(Hn.current),Hn.current=window.setTimeout(()=>{try{v(De,100)}catch(Xe){console.warn("[ChatSessionProvider] Failed to persist thread payload:",Xe)}},qo)}},[ge,me,ae.lastCheckpointId,ae.lastCheckpointNs,ae.messages,ae.pendingInterrupt,W,v]);const Ao=w.useMemo(()=>({threads:T,currentThreadId:k,setCurrentThreadId:I,isLoading:_,error:F,actions:{createThread:Te,deleteThread:$e,renameThread:Me,refreshThreads:()=>Ft()},persistThreadsCache:Ur,hydrateFromCache:ie}),[T,k,_,F,Te,$e,Me,Ft,Ur,ie,I]),Cl=w.useMemo(()=>{const N=ae.lastBranch??null,A=ae.assemblingId??null,q=N||A?{branchLabel:(N==null?void 0:N.branchLabel)??null,lastBranch:N,assemblingMessageId:A}:null;return{threadId:k,messages:ae.messages,interrupt:W,checkpoint:{id:ae.lastCheckpointId??null,namespace:ae.lastCheckpointNs??null},checkpoints:$,metadata:q,isLoading:j,isHistoryLoading:ce,error:D,hasMore:M,loadOlder:Bt,seedFromSnapshot:Un,clearState:jn,navigateToCheckpoint:dt,returnToLatest:ht,loadThread:ke,clearThread:It,respondToInterrupt:_t}},[It,jn,k,W,M,ce,j,Bt,ke,ae.assemblingId,ae.lastBranch,ae.lastCheckpointId,ae.lastCheckpointNs,ae.messages,dt,_t,ht,Un,D,$]),Tl=w.useMemo(()=>({isStreaming:P,error:B,submit:Jt,send:Jt,stop:S,setAuthToken:oe}),[P,B,Jt,S,oe]);return c.jsx(Vx.Provider,{value:!0,children:c.jsx(Wc.Provider,{value:Tl,children:c.jsx(Hc.Provider,{value:Ao,children:c.jsx(Uc.Provider,{value:Cl,children:e})})})})}function Xo(){const e=w.useContext(Hc);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Jo(){const e=w.useContext(Uc);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function Gc(){const e=w.useContext(Wc);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function Zo({children:e,apiConfig:t,initialThreadId:n=null,autoLoadInitial:r=!0,disableAutoRestore:o=!1,enableFileAgentRouting:s=!1,fileAgentId:i="invoice_reader",onError:a,onThreadChange:l}){return c.jsx(rx,{apiConfig:t,children:c.jsx(Xx,{initialThreadId:n,autoLoadInitial:r,disableAutoRestore:o,enableFileAgentRouting:s,fileAgentId:i,onError:a,onThreadChange:l,children:e})})}function re(...e){return Rm.twMerge(jm.clsx(e))}const Jx=Po.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"}}),qe=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?or.Slot:"button";return c.jsx(i,{className:re(Jx({variant:t,size:n,className:e})),ref:s,...o})});qe.displayName="Button";const Yc=m.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:re("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}));Yc.displayName="Textarea";function Zx({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,onSend:i,onCancelEdit:a,onStop:l,className:u="",textareaClassName:d="",allowEmptySend:f=!1}){const[h,p]=w.useState(e),[v,x]=w.useTransition(),g=w.useRef(null),y=w.useRef(0),b=w.useRef(null);w.useEffect(()=>{p(e??""),b.current=null,g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const C=w.useCallback(()=>{const j=g.current;j&&(j.style.height="auto",j.style.height=`${j.scrollHeight}px`)},[]);w.useEffect(()=>{C()},[C]);const E=w.useCallback(async j=>{j&&j.preventDefault();const H=(h??"").trim();if(!H&&!f)return;const F=++y.current;b.current={id:F,shouldClear:!0},x(()=>{var U,D,G;try{const W=i(H);W&&typeof W.then=="function"?W.then(()=>{var ne,$;((ne=b.current)==null?void 0:ne.id)===F&&b.current.shouldClear&&(p(""),g.current&&(g.current.style.height="auto")),(($=b.current)==null?void 0:$.id)===F&&(b.current=null)}).catch(()=>{var ne;((ne=b.current)==null?void 0:ne.id)===F&&(b.current=null)}):(((U=b.current)==null?void 0:U.id)===F&&b.current.shouldClear&&(p(""),g.current&&(g.current.style.height="auto")),((D=b.current)==null?void 0:D.id)===F&&(b.current=null))}catch{((G=b.current)==null?void 0:G.id)===F&&(b.current=null)}})},[h,i,f]),T=w.useCallback(j=>{p(j.target.value),b.current&&(b.current.shouldClear=!1),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),k=w.useCallback(j=>{j.key==="Enter"&&!j.shiftKey?(j.preventDefault(),E()):j.key==="Escape"&&t&&(j.preventDefault(),a==null||a())},[E,t,a]),R=`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 c.jsx("form",{onSubmit:j=>void E(j),className:`w-full ${u}`,children:c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsx("div",{className:"flex-1",children:c.jsx(Yc,{ref:g,value:h,onChange:T,onKeyDown:k,placeholder:t?"Edit your message...":n,className:R,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),c.jsx("div",{children:r?c.jsx(qe,{type:"button",onClick:()=>{l==null||l()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!l,children:c.jsx(ue.Square,{size:16})}):c.jsx(qe,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||v,children:c.jsx(ue.Send,{size:16})})})]})})}const Qx=w.memo(Zx),Qo=0,Vn=1,Ar=2,Xc=4;function Jc(e){return()=>e}function ey(e){e()}function Zc(e,t){return n=>e(t(n))}function Qc(e,t){return()=>e(t)}function ty(e,t){return n=>e(t,n)}function Ui(e){return e!==void 0}function ny(...e){return()=>{e.map(ey)}}function _r(){}function es(e,t){return t(e),e}function ry(e,t){return t(e)}function it(...e){return e}function Ye(e,t){return e(Vn,t)}function Oe(e,t){e(Qo,t)}function Wi(e){e(Ar)}function xt(e){return e(Xc)}function ve(e,t){return Ye(e,ty(t,Qo))}function cn(e,t){const n=e(Vn,r=>{n(),t(r)});return n}function eu(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function tu(e,t){return e===t}function at(e=tu){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ee(e){return t=>n=>{e(n)&&t(n)}}function fe(e){return t=>Zc(t,e)}function vn(e){return t=>()=>{t(e)}}function V(e,...t){const n=oy(...t);return(r,o)=>{switch(r){case Ar:Wi(e);return;case Vn:return Ye(e,n(o))}}}function bn(e,t){return n=>r=>{n(t=e(t,r))}}function cr(e){return t=>n=>{e>0?e--:t(n)}}function Dn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Le(...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);Ye(s,l=>{const u=n;n=n|a,t[i]=l,u!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function oy(...e){return t=>e.reduceRight(ry,t)}function sy(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Vn:return s?n===s?void 0:(r(),n=s,t=Ye(e,s),t):(r(),_r);case Ar:r(),n=null;return}}}function J(e){let t=e;const n=Ke();return(r,o)=>{switch(r){case Qo:t=o;break;case Vn:{o(t);break}case Xc:return t}return n(r,o)}}function Mt(e,t){return es(J(t),n=>ve(e,n))}function Ke(){const e=[];return(t,n)=>{switch(t){case Qo:e.slice().forEach(r=>{r(n)});return;case Ar:e.splice(0,e.length);return;case Vn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Kt(e){return es(Ke(),t=>ve(e,t))}function Ge(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:iy(),singleton:n}}const iy=()=>Symbol();function ay(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(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function vt(...e){const t=Ke(),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);Ye(s,l=>{n[i]=l,r=r|a,r===o&&Oe(t,n)})}),function(s,i){switch(s){case Ar:{Wi(t);return}case Vn:return r===o&&i(n),Ye(t,i)}}}function Ce(e,t=tu){return V(e,at(t))}function Vi(...e){return function(t,n){switch(t){case Ar:return;case Vn:return ny(...e.map(r=>Ye(r,n)))}}}var Wt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Wt||{});const ly={0:"debug",3:"error",1:"log",2:"warn"},cy=()=>typeof globalThis>"u"?window:globalThis,Kn=Ge(()=>{const e=J(3);return{log:J((t,n,r=1)=>{var o;const s=(o=cy().VIRTUOSO_LOG_LEVEL)!=null?o:xt(e);r>=s&&console[ly[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function ur(e,t,n){return Ki(e,t,n).callbackRef}function Ki(e,t,n){const r=w.useRef(null);let o=i=>{};const s=w.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};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 uy(e,t,n,r,o,s,i,a,l){const u=w.useCallback(d=>{const f=dy(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const p=h.lastElementChild.dataset.viewportType==="window";let v;p&&(v=h.ownerDocument.defaultView);const x=i?a?i.scrollLeft:i.scrollTop:p?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:p?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:p?a?v.innerWidth:v.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(x,0),viewportHeight:y}),s==null||s(a?nu("column-gap",getComputedStyle(d).columnGap,o):nu("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return Ki(u,n,l)}function dy(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 l=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},Wt.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function nu(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Wt.WARN),t==="normal"?0:parseInt(t??"0",10)}function ru(e,t,n){const r=w.useRef(null),o=w.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const u=l.getBoundingClientRect(),d=u.width;let f,h;if(t){const p=t.getBoundingClientRect(),v=u.top-p.top;h=p.height-Math.max(0,v),f=v+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;h=p.innerHeight-Math.max(0,u.top),f=u.top+p.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Ki(o,!0,n),a=w.useCallback(()=>{o(i.current)},[o,i]);return w.useEffect(()=>{var l;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=(l=i.current)==null?void 0:l.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 $t=Ge(()=>{const e=Ke(),t=Ke(),n=J(0),r=Ke(),o=J(0),s=Ke(),i=Ke(),a=J(0),l=J(0),u=J(0),d=J(0),f=Ke(),h=Ke(),p=J(!1),v=J(!1),x=J(!1);return ve(V(e,fe(({scrollTop:g})=>g)),t),ve(V(e,fe(({scrollHeight:g})=>g)),i),ve(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:x,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),eo={lvl:0};function ou(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:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function rt(e){return e===eo}function to(e,t){if(!rt(e))return t===e.k?e.v:t<e.k?to(e.l,t):to(e.r,t)}function un(e,t,n="k"){if(rt(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=un(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return un(e.l,t,n)}function qt(e,t,n){return rt(e)?au(t,n,1):t===e.k?St(e,{k:t,v:n}):t<e.k?lu(St(e,{l:qt(e.l,t,n)})):lu(St(e,{r:qt(e.r,t,n)}))}function jr(){return eo}function ts(e,t,n){if(rt(e))return[];const r=un(e,t)[0];return fy(Gi(e,r,n))}function qi(e,t){if(rt(e))return eo;const{k:n,l:r,r:o}=e;if(t===n){if(rt(r))return o;if(rt(o))return r;{const[s,i]=iu(r);return ns(St(e,{k:s,l:su(r),v:i}))}}else return t<n?ns(St(e,{l:qi(r,t)})):ns(St(e,{r:qi(o,t)}))}function dr(e){return rt(e)?[]:[...dr(e.l),{k:e.k,v:e.v},...dr(e.r)]}function Gi(e,t,n){if(rt(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Gi(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Gi(s,t,n))),a}function ns(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(Yi(t))return cu(St(e,{lvl:n-1}));if(!rt(t)&&!rt(t.r))return St(t.r,{l:St(t,{r:t.r.l}),lvl:n,r:St(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Yi(e))return Xi(St(e,{lvl:n-1}));if(!rt(r)&&!rt(r.l)){const o=r.l,s=Yi(o)?r.lvl-1:r.lvl;return St(o,{l:St(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Xi(St(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function St(e,t){return au(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 su(e){return rt(e.r)?e.l:ns(St(e,{r:su(e.r)}))}function Yi(e){return rt(e)||e.lvl>e.r.lvl}function iu(e){return rt(e.r)?[e.k,e.v]:iu(e.r)}function au(e,t,n,r=eo,o=eo){return{k:e,l:r,lvl:n,r:o,v:t}}function lu(e){return Xi(cu(e))}function cu(e){const{l:t}=e;return!rt(t)&&t.lvl===e.lvl?St(t,{r:St(e,{l:t.r})}):e}function Xi(e){const{lvl:t,r:n}=e;return!rt(n)&&!rt(n.r)&&n.lvl===t&&n.r.lvl===t?St(n,{l:St(e,{r:n.l}),lvl:t+1}):e}function fy(e){return ou(e,({k:t,v:n})=>({index:t,value:n}))}function uu(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function no(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ji=Ge(()=>({recalcInProgress:J(!1)}),[],{singleton:!0});function du(e,t,n){return e[rs(e,t,n)]}function rs(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 hy(e,t,n,r){const o=rs(e,t,r),s=rs(e,n,r,o);return e.slice(o,s+1)}function qn(e,t){return Math.round(e.getBoundingClientRect()[t])}function os(e){return!rt(e.groupOffsetTree)}function Zi({index:e},t){return t===e?0:t<e?-1:1}function py(){return{groupIndices:[],groupOffsetTree:jr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:jr()}}function my(e,t){let n=rt(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),rt(e)){e=qt(e,0,s);continue}const a=ts(e,i-1,o+1);if(a.some(Sy(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=qi(e,f)):(u=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=qt(e,o+1,h));u&&(e=qt(e,i,s))}return[e,n]}function gy(e){return typeof e.groupIndex<"u"}function xy({offset:e},t){return t===e?0:t<e?-1:1}function ro(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=du(t,e,Zi),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function fu(e,t){if(!os(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function hu(e,t,n){if(gy(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=fu(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function yy(e,t,n,r=0){return r>0&&(t=Math.max(t,du(e,r,Zi).offset)),ou(hy(e,t,n,xy),wy)}function vy(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Wt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&rt(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((v,x)=>qt(qt(v,x,h),x+1,p),i)}else[i,a]=my(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=Qi(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>qt(h,p,ro(p,f,o)),jr()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function by(e){return dr(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 pu(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 Qi(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=rs(o,t-1,Zi),a=o[l].offset;const u=un(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===un(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:u,value:d}of ts(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 wy(e){return{index:e.index,value:e}}function Sy(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 Cy={offsetHeight:"height",offsetWidth:"width"},wn=Ge(([{log:e},{recalcInProgress:t}])=>{const n=Ke(),r=Ke(),o=Mt(r,0),s=Ke(),i=Ke(),a=J(0),l=J([]),u=J(void 0),d=J(void 0),f=J((T,k)=>qn(T,Cy[k])),h=J(void 0),p=J(0),v=py(),x=Mt(V(n,Le(l,e,p),bn(vy,v),at()),v),g=Mt(V(l,at(),bn((T,k)=>({current:k,prev:T.current}),{current:[],prev:[]}),fe(({prev:T})=>T)),[]);ve(V(l,Ee(T=>T.length>0),Le(x,p),fe(([T,k,I])=>{const _=T.reduce((R,j,H)=>qt(R,j,ro(j,k.offsetTree,I)||H),jr());return{...k,groupIndices:T,groupOffsetTree:_}})),x),ve(V(r,Le(x),Ee(([T,{lastIndex:k}])=>T<k),fe(([T,{lastIndex:k,lastSize:I}])=>[{endIndex:k,size:I,startIndex:T}])),n),ve(u,d);const y=Mt(V(u,fe(T=>T===void 0)),!0);ve(V(d,Ee(T=>T!==void 0&&rt(xt(x).sizeTree)),fe(T=>[{endIndex:0,size:T,startIndex:0}])),n);const b=Kt(V(n,Le(x),bn(({sizes:T},[k,I])=>({changed:I!==T,sizes:I}),{changed:!1,sizes:v}),fe(T=>T.changed)));Ye(V(a,bn((T,k)=>({diff:T.prev-k,prev:k}),{diff:0,prev:0}),fe(T=>T.diff)),T=>{const{groupIndices:k}=xt(x);if(T>0)Oe(t,!0),Oe(s,T+pu(T,k));else if(T<0){const I=xt(g);I.length>0&&(T-=pu(-T,I)),Oe(i,T)}}),Ye(V(a,Le(e)),([T,k])=>{T<0&&k("`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},Wt.ERROR)});const C=Kt(s);ve(V(s,Le(x),fe(([T,k])=>{const I=k.groupIndices.length>0,_=[],R=k.lastSize;if(I){const j=to(k.sizeTree,0);let H=0,F=0;for(;H<T;){const D=k.groupIndices[F],G=k.groupIndices.length===F+1?1/0:k.groupIndices[F+1]-D-1;_.push({endIndex:D,size:j,startIndex:D}),_.push({endIndex:D+1+G-1,size:R,startIndex:D+1}),F++,H+=G+1}const U=dr(k.sizeTree);return H!==T&&U.shift(),U.reduce((D,{k:G,v:W})=>{let ne=D.ranges;return D.prevSize!==0&&(ne=[...D.ranges,{endIndex:G+T-1,size:D.prevSize,startIndex:D.prevIndex}]),{prevIndex:G+T,prevSize:W,ranges:ne}},{prevIndex:T,prevSize:0,ranges:_}).ranges}return dr(k.sizeTree).reduce((j,{k:H,v:F})=>({prevIndex:H+T,prevSize:F,ranges:[...j.ranges,{endIndex:H+T-1,size:j.prevSize,startIndex:j.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),n);const E=Kt(V(i,Le(x,p),fe(([T,{offsetTree:k},I])=>{const _=-T;return ro(_,k,I)})));return ve(V(i,Le(x,p),fe(([T,k,I])=>{if(k.groupIndices.length>0){if(rt(k.sizeTree))return k;let _=jr();const R=xt(g);let j=0,H=0,F=0;for(;j<-T;){F=R[H];const U=R[H+1]-F-1;H++,j+=U+1}if(_=dr(k.sizeTree).reduce((U,{k:D,v:G})=>qt(U,Math.max(0,D+T),G),_),j!==-T){const U=to(k.sizeTree,F);_=qt(_,0,U);const D=un(k.sizeTree,-T+1)[1];_=qt(_,1,D)}return{...k,sizeTree:_,...Qi(k.offsetTree,0,_,I)}}else{const _=dr(k.sizeTree).reduce((R,{k:j,v:H})=>qt(R,Math.max(0,j+T),H),jr());return{...k,sizeTree:_,...Qi(k.offsetTree,0,_,I)}}})),x),{beforeUnshiftWith:C,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:x,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},it(Kn,Ji),{singleton:!0});function Ty(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const mu=Ge(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Ke(),i=Ke(),a=Kt(V(s,fe(Ty)));return ve(V(a,fe(l=>l.totalCount)),n),ve(V(a,fe(l=>l.groupIndices)),e),ve(V(vt(o,t,r),Ee(([l,u])=>os(u)),fe(([l,u,d])=>un(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),at(),fe(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},it(wn,$t)),Gn=Ge(([{log:e}])=>{const t=J(!1),n=Kt(V(t,Ee(r=>r),at()));return Ye(t,r=>{r&&xt(e)("props updated",{},Wt.DEBUG)}),{didMount:n,propsReady:t}},it(Kn),{singleton:!0}),ky=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function gu(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!ky)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const oo=Ge(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const p=Ke(),v=Ke(),x=J(0);let g=null,y=null,b=null;function C(){g&&(g(),g=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),Oe(l,!1)}return ve(V(p,Le(n,f,r,x,a,i,h),Le(e,s,o),fe(([[E,T,k,I,_,R,j,H],F,U,D])=>{const G=gu(E),{align:W,behavior:ne,offset:$}=G,z=I-1,ie=hu(G,T,z);let M=ro(ie,T.offsetTree,F)+R;W==="end"?(M+=U+un(T.sizeTree,ie)[1]-k+D,ie===z&&(M+=j)):W==="center"?M+=(U+un(T.sizeTree,ie)[1]-k+D)/2:M-=_,$&&(M+=$);const Y=ce=>{C(),ce?(H("retrying to scroll to",{location:E},Wt.DEBUG),Oe(p,E)):(Oe(v,!0),H("list did not change, scroll successful",{},Wt.DEBUG))};if(C(),ne==="smooth"){let ce=!1;b=Ye(t,be=>{ce=ce||be}),g=cn(d,()=>{Y(ce)})}else g=cn(V(t,Ey(150)),Y);return y=setTimeout(()=>{C()},1200),Oe(l,!0),H("scrolling from index to",{behavior:ne,index:ie,top:M},Wt.DEBUG),{behavior:ne,top:M}})),u),{scrollTargetReached:v,scrollToIndex:p,topListHeight:x}},it(wn,$t,Kn),{singleton:!0});function Ey(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function ea(e,t){e==0?t():requestAnimationFrame(()=>{ea(e-1,t)})}function ta(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const so=Ge(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=J(!0),l=J(0),u=J(!0);return ve(V(i,Le(l),Ee(([d,f])=>!!f),vn(!1)),a),ve(V(i,Le(l),Ee(([d,f])=>!!f),vn(!1)),u),Ye(V(vt(t,i),Le(a,n,e,u),Ee(([[,d],f,{sizeTree:h},p,v])=>d&&(!rt(h)||Ui(p))&&!f&&!v),Le(l)),([,d])=>{cn(o,()=>{Oe(u,!0)}),ea(4,()=>{cn(r,()=>{Oe(a,!0)}),Oe(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},it(wn,$t,oo,Gn),{singleton:!0});function xu(e,t){return Math.abs(e-t)<1.01}const io="up",ao="down",Iy="none",Ny={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Ay=0,lo=Ge(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=J(!1),a=J(!0),l=Ke(),u=Ke(),d=J(4),f=J(Ay),h=Mt(V(Vi(V(Ce(o),cr(1),vn(!0)),V(Ce(o),cr(1),vn(!1),eu(100))),at()),!1),p=Mt(V(Vi(V(n,vn(!0)),V(n,vn(!1),eu(200))),at()),!1);ve(V(vt(Ce(o),Ce(f)),fe(([b,C])=>b<=C),at()),a),ve(V(a,Dn(50)),u);const v=Kt(V(vt(r,Ce(s),Ce(t),Ce(e),Ce(d)),bn((b,[{scrollHeight:C,scrollTop:E},T,k,I,_])=>{const R=E+T-C>-_,j={scrollHeight:C,scrollTop:E,viewportHeight:T};if(R){let F,U;return E>b.state.scrollTop?(F="SCROLLED_DOWN",U=b.state.scrollTop-E):(F="SIZE_DECREASED",U=b.state.scrollTop-E||b.scrollTopDelta),{atBottom:!0,atBottomBecause:F,scrollTopDelta:U,state:j}}let H;return j.scrollHeight>b.state.scrollHeight?H="SIZE_INCREASED":T<b.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":E<b.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:j}},Ny),at((b,C)=>b&&b.atBottom===C.atBottom))),x=Mt(V(r,bn((b,{scrollHeight:C,scrollTop:E,viewportHeight:T})=>{if(xu(b.scrollHeight,C))return{changed:!1,jump:0,scrollHeight:C,scrollTop:E};{const k=C-(E+T)<1;return b.scrollTop!==E&&k?{changed:!0,jump:b.scrollTop-E,scrollHeight:C,scrollTop:E}:{changed:!0,jump:0,scrollHeight:C,scrollTop:E}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ee(b=>b.changed),fe(b=>b.jump)),0);ve(V(v,fe(b=>b.atBottom)),i),ve(V(i,Dn(50)),l);const g=J(ao);ve(V(r,fe(({scrollTop:b})=>b),at(),bn((b,C)=>xt(p)?{direction:b.direction,prevScrollTop:C}:{direction:C<b.prevScrollTop?io:ao,prevScrollTop:C},{direction:ao,prevScrollTop:0}),fe(b=>b.direction)),g),ve(V(r,Dn(50),vn(Iy)),g);const y=J(0);return ve(V(h,Ee(b=>!b),vn(0)),y),ve(V(o,Dn(100),Le(h),Ee(([b,C])=>!!C),bn(([b,C],[E])=>[C,E],[0,0]),fe(([b,C])=>C-b)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:x,scrollDirection:g,scrollVelocity:y}},it($t)),ss="top",is="bottom",yu="none";function vu(e,t,n){return typeof e=="number"?n===io&&t===ss||n===ao&&t===is?e:0:n===io?t===ss?e.main:e.reverse:t===is?e.main:e.reverse}function bu(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const na=Ge(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Ke(),i=J(0),a=J(0),l=J(0),u=Mt(V(vt(Ce(r),Ce(o),Ce(n),Ce(s,no),Ce(l),Ce(i),Ce(t),Ce(e),Ce(a)),fe(([d,f,h,[p,v],x,g,y,b,C])=>{const E=d-b,T=g+y,k=Math.max(h-E,0);let I=yu;const _=bu(C,ss),R=bu(C,is);return p-=b,p+=h+y,v+=h+y,v-=b,p>d+T-_&&(I=io),v<d-k+f+R&&(I=ao),I!==yu?[Math.max(E-h-vu(x,ss,I)-_,0),E-k-y+f+vu(x,is,I)+R]:null}),Ee(d=>d!=null),at(no)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},it($t),{singleton:!0});function _y(e,t,n){if(os(t)){const r=fu(e,t);return[{index:un(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 ra={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function as(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const x=e[e.length-1];d=x.offset+x.size}const f=n-i,h=a+f*l+(f-1)*r,p=u,v=h-d;return{bottom:d,firstItemIndex:s,items:Su(e,o,s),offsetBottom:v,offsetTop:u,top:p,topItems:Su(t,o,s),topListHeight:t.reduce((x,g)=>g.size+x,0),totalCount:n}}function wu(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,l=ta(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return as(u,[],a,o,n,r)}function Su(e,t,n){if(e.length===0)return[];if(!os(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=ts(t.groupOffsetTree,r,o);let a,l=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:u.index-(l+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const fr=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:p},{recalcInProgress:v}])=>{const x=J([]),g=J(0),y=Ke();ve(s.topItemsIndexes,x);const b=Mt(V(vt(p,v,Ce(l,no),Ce(o),Ce(r),Ce(u),d,Ce(x),Ce(t),Ce(n),e),Ee(([k,I,,_,,,,,,,R])=>{const j=R&&R.length!==_;return k&&!I&&!j}),fe(([,,[k,I],_,R,j,H,F,U,D,G])=>{const W=R,{offsetTree:ne,sizeTree:$}=W,z=xt(g);if(_===0)return{...ra,totalCount:_};if(k===0&&I===0)return z===0?{...ra,totalCount:_}:wu(z,j,R,U,D,G||[]);if(rt($))return z>0?null:as(_y(ta(j,_),W,G),[],_,D,W,U);const ie=[];if(F.length>0){const ge=F[0],ye=F[F.length-1];let K=0;for(const L of ts($,ge,ye)){const Z=L.value,ee=Math.max(L.start,ge),me=Math.min(L.end,ye);for(let se=ee;se<=me;se++)ie.push({data:G==null?void 0:G[se],index:se,offset:K,size:Z}),K+=Z}}if(!H)return as([],ie,_,D,W,U);const M=F.length>0?F[F.length-1]+1:0,Y=yy(ne,k,I,M);if(Y.length===0)return null;const ce=_-1,be=es([],ge=>{for(const ye of Y){const K=ye.value;let L=K.offset,Z=ye.start;const ee=K.size;if(K.offset<k){Z+=Math.floor((k-K.offset+D)/(ee+D));const se=Z-ye.start;L+=se*ee+se*D}Z<M&&(L+=(M-Z)*ee,Z=M);const me=Math.min(ye.end,ce);for(let se=Z;se<=me&&!(L>=I);se++)ge.push({data:G==null?void 0:G[se],index:se,offset:L,size:ee}),L+=ee+D}});return as(be,ie,_,D,W,U)}),Ee(k=>k!==null),at()),ra);ve(V(e,Ee(Ui),fe(k=>k==null?void 0:k.length)),o),ve(V(b,fe(k=>k.topListHeight)),f),ve(f,a),ve(V(b,fe(k=>[k.top,k.bottom])),i),ve(V(b,fe(k=>k.items)),y);const C=Kt(V(b,Ee(({items:k})=>k.length>0),Le(o,e),Ee(([{items:k},I])=>k[k.length-1].originalIndex===I-1),fe(([,k,I])=>[k-1,I]),at(no),fe(([k])=>k))),E=Kt(V(b,Dn(200),Ee(({items:k,topItems:I})=>k.length>0&&k[0].originalIndex===I.length),fe(({items:k})=>k[0].index),at())),T=Kt(V(b,Ee(({items:k})=>k.length>0),fe(({items:k})=>{let I=0,_=k.length-1;for(;k[I].type==="group"&&I<_;)I++;for(;k[_].type==="group"&&_>I;)_--;return{endIndex:k[_].index,startIndex:k[I].index}}),at(uu)));return{endReached:C,initialItemCount:g,itemsRendered:y,listState:b,rangeChanged:T,startReached:E,topItemsIndexes:x,...h}},it(wn,mu,na,so,oo,lo,Gn,Ji),{singleton:!0}),Cu=Ge(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Ke(),i=Mt(V(vt(n,e,r,t,o),fe(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return ve(Ce(i),s),{totalListHeight:i,totalListHeightChanged:s}},it($t,fr),{singleton:!0}),jy=Ge(([{viewportHeight:e},{totalListHeight:t}])=>{const n=J(!1),r=Mt(V(vt(n,e,t),Ee(([o])=>o),fe(([,o,s])=>Math.max(0,o-s)),Dn(0),at()),0);return{alignToBottom:n,paddingTopAddition:r}},it($t,Cu),{singleton:!0}),Tu=Ge(()=>({context:J(null)})),Ry=({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,ku=Ge(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:u}])=>{const d=Ke();return ve(V(d,Le(t,l,n,s,o,r,a),Le(e),fe(([[f,h,p,v,x,g,y,b],C])=>{const{align:E,behavior:T,calculateViewLocation:k=Ry,done:I,..._}=f,R=hu(f,h,v-1),j=ro(R,h.offsetTree,C)+x+g,H=j+un(h.sizeTree,R)[1],F=b+g,U=b+p-y,D=k({itemBottom:H,itemTop:j,locationParams:{align:E,behavior:T,..._},viewportBottom:U,viewportTop:F});return D?I&&cn(V(i,Ee(G=>!G),cr(xt(i)?1:2)),I):I&&I(),D}),Ee(f=>f!==null)),u),{scrollIntoView:d}},it(wn,$t,oo,fr,Kn),{singleton:!0});function Eu(e){return e?e==="smooth"?"smooth":"auto":!1}const Py=(e,t)=>typeof e=="function"?Eu(e(t)):t&&Eu(e),Oy=Ge(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:u},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:p}])=>{const v=J(!1),x=Ke();let g=null;function y(T){Oe(i,{align:"end",behavior:T,index:"LAST"})}Ye(V(vt(V(Ce(t),cr(1)),l),Le(Ce(v),s,a,f),fe(([[T,k],I,_,R,j])=>{let H=k&&R,F="auto";return H&&(F=Py(I,_||j),H=H&&!!F),{followOutputBehavior:F,shouldFollow:H,totalCount:T}}),Ee(({shouldFollow:T})=>T)),({followOutputBehavior:T,totalCount:k})=>{g&&(g(),g=null),xt(n)?requestAnimationFrame(()=>{xt(d)("following output to ",{totalCount:k},Wt.DEBUG),y(T)}):g=cn(e,()=>{xt(d)("following output to ",{totalCount:k},Wt.DEBUG),y(T),g=null})});function b(T){const k=cn(o,I=>{T&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(xt(d)("scrolling to bottom due to increased size",{},Wt.DEBUG),y("auto"))});setTimeout(k,100)}Ye(V(vt(Ce(v),t,u),Ee(([T,,k])=>T&&k),bn(({value:T},[,k])=>({refreshed:T===k,value:k}),{refreshed:!1,value:0}),Ee(({refreshed:T})=>T),Le(v,t)),([,T])=>{xt(a)&&b(T!==!1)}),Ye(x,()=>{b(xt(v)!==!1)}),Ye(vt(Ce(v),o),([T,k])=>{T&&!k.atBottom&&k.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const C=J(null),E=Ke();return ve(Vi(V(Ce(r),fe(T=>{var k;return(k=T==null?void 0:T.length)!=null?k:0})),V(Ce(t))),E),Ye(V(vt(V(E,cr(1)),l),Le(Ce(C),a,f,h),fe(([[T,k],I,_,R,j])=>k&&_&&(I==null?void 0:I({context:j,totalCount:T,scrollingInProgress:R}))),Ee(T=>!!T),Dn(0)),T=>{g&&(g(),g=null),xt(n)?requestAnimationFrame(()=>{xt(d)("scrolling into view",{}),Oe(p,T)}):g=cn(e,()=>{xt(d)("scrolling into view",{}),Oe(p,T),g=null})}),{autoscrollToBottom:x,followOutput:v,scrollIntoViewOnChange:C}},it(wn,lo,oo,so,Gn,Kn,$t,Tu,ku)),My=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ve(V(a,Le(s),Ee(([,l])=>l!==0),Le(o,r,t,n,e),fe(([[,l],u,d,f,h,p=[]])=>wu(l,u,d,f,h,p))),i),{}),it(wn,so,fr,Gn),{singleton:!0}),Dy=Ge(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=J(0);return Ye(V(e,Le(r),Ee(([,o])=>o!==0),fe(([,o])=>({top:o}))),o=>{cn(V(n,cr(1),Ee(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Oe(t,o)})})}),{initialScrollTop:r}},it(Gn,$t,fr),{singleton:!0}),Iu=Ge(([{scrollVelocity:e}])=>{const t=J(!1),n=Ke(),r=J(!1);return ve(V(e,Le(r,t,n),Ee(([o,s])=>!!s),fe(([o,s,i,a])=>{const{enter:l,exit:u}=s;if(i){if(u(o,a))return!1}else if(l(o,a))return!0;return i}),at()),t),Ye(V(vt(t,e,n),Le(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},it(lo),{singleton:!0}),oa=Ge(([{scrollContainerState:e,scrollTo:t}])=>{const n=Ke(),r=Ke(),o=Ke(),s=J(!1),i=J(void 0);return ve(V(vt(n,r),fe(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),ve(V(t,Le(r),fe(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},it($t)),Ly=Ge(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=Ke(),d=J(void 0),f=J(null),h=J(null);return ve(a,f),ve(l,h),Ye(V(u,Le(t,r,i,f,h,n)),([p,v,x,g,y,b,C])=>{const E=by(v.sizeTree);g&&y!==null&&b!==null&&(x=y.scrollTop-b.offsetTop),x-=C,p({ranges:E,scrollTop:x})}),ve(V(d,Ee(Ui),fe(Fy)),o),ve(V(s,Le(d),Ee(([,p])=>p!==void 0),at(),fe(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},it(wn,$t,so,Gn,oa));function Fy(e){return{align:"start",index:0,offset:e.scrollTop}}const $y=Ge(([{topItemsIndexes:e}])=>{const t=J(0);return ve(V(t,Ee(n=>n>=0),fe(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},it(fr));function Nu(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const zy=Nu(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),By=Ge(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:h},{log:p},{recalcInProgress:v}])=>{const x=Kt(V(l,Le(i),bn(([,y,b,C],[{bottom:E,items:T,offsetBottom:k,totalCount:I},_])=>{const R=E+k;let j=0;return b===I&&y.length>0&&T.length>0&&(T[0].originalIndex===0&&y[0].originalIndex===0||(j=R-C,j!==0&&(j+=_))),[j,T,I,R]},[0,[],0,0]),Ee(([y])=>y!==0),Le(r,a,n,o,p,v),Ee(([,y,b,C,,,E])=>!E&&!C&&y!==0&&b===io),fe(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},Wt.DEBUG),y))));function g(y){y>0?(Oe(t,{behavior:"auto",top:-y}),Oe(e,0)):(Oe(e,0),Oe(t,{behavior:"auto",top:-y}))}return Ye(V(x,Le(e,s)),([y,b,C])=>{C&&zy()?Oe(e,b-y):g(-y)}),Ye(V(vt(Mt(s,!1),e,v),Ee(([y,b,C])=>!y&&!C&&b!==0),fe(([y,b])=>b),Dn(1)),g),ve(V(f,fe(y=>({top:-y}))),t),Ye(V(u,Le(h,d),fe(([y,{groupIndices:b,lastSize:C,sizeTree:E},T])=>{function k(I){return I*(C+T)}if(b.length===0)return k(y);{let I=0;const _=to(E,0);let R=0,j=0;for(;R<y;){R++,I+=_;let H=b.length===j+1?1/0:b[j+1]-b[j]-1;R+H>y&&(I-=_,H=y-R+1),R+=H,I+=k(H),j++}return I}})),y=>{Oe(e,y),requestAnimationFrame(()=>{Oe(t,{top:y}),requestAnimationFrame(()=>{Oe(e,0),Oe(v,!1)})})}),{deviation:e}},it($t,lo,fr,wn,Kn,Ji)),Hy=Ge(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),it(na,My,Gn,Iu,Cu,Dy,jy,oa,ku,Kn,Tu)),Au=Ge(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:v},x,g,y,{listState:b,topItemsIndexes:C,...E},{scrollToIndex:T},k,{topItemCount:I},{groupCounts:_},R])=>(ve(E.rangeChanged,R.scrollSeekRangeChanged),ve(V(R.windowViewportRect,fe(j=>j.visibleHeight)),x.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:_,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:v,sizeRanges:a,topItemCount:I,topItemsIndexes:C,totalCount:d,...y,groupIndices:s,itemSize:i,listState:b,scrollToIndex:T,statefulTotalCount:u,trackItemSizes:f,...E,...R,...x,sizes:l,...g}),it(wn,so,$t,Ly,Oy,fr,oo,By,$y,mu,Hy));function Uy(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 ls=typeof document<"u"?w.useLayoutEffect:w.useEffect;function _u(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=w.createContext({});function l(g,y){g.propsReady&&Oe(g.propsReady,!1);for(const b of r){const C=g[t.required[b]];Oe(C,y[b])}for(const b of o)if(b in y){const C=g[t.optional[b]];Oe(C,y[b])}g.propsReady&&Oe(g.propsReady,!0)}function u(g){return s.reduce((y,b)=>(y[b]=C=>{const E=g[t.methods[b]];Oe(E,C)},y),{})}function d(g){return i.reduce((y,b)=>(y[b]=sy(g[t.events[b]]),y),{})}const f=w.forwardRef((g,y)=>{const{children:b,...C}=g,[E]=w.useState(()=>es(ay(e),I=>{l(I,C)})),[T]=w.useState(Qc(d,E));ls(()=>{for(const I of i)I in C&&Ye(T[I],C[I]);return()=>{Object.values(T).map(Wi)}},[C,T,E]),ls(()=>{l(E,C)}),w.useImperativeHandle(y,Jc(u(E)));const k=n;return c.jsx(a.Provider,{value:E,children:n?c.jsx(k,{...Uy([...r,...o,...i],C),children:b}):b})}),h=g=>{const y=w.useContext(a);return w.useCallback(b=>{Oe(y[g],b)},[y,g])},p=g=>{const y=w.useContext(a)[g],b=w.useCallback(C=>Ye(y,C),[y]);return w.useSyncExternalStore(b,()=>xt(y),()=>xt(y))},v=g=>{const y=w.useContext(a)[g],[b,C]=w.useState(Qc(xt,y));return ls(()=>Ye(y,E=>{E!==b&&C(Jc(E))}),[y,b]),b},x=w.version.startsWith("18")?p:v;return{Component:f,useEmitter:(g,y)=>{const b=w.useContext(a)[g];ls(()=>Ye(b,y),[y,b])},useEmitterValue:x,usePublisher:h}}const ju=w.createContext(void 0),Ru=w.createContext(void 0),Pu=typeof document<"u"?w.useLayoutEffect:w.useEffect;function sa(e){return"self"in e}function Wy(e){return"body"in e}function Ou(e,t,n,r=_r,o,s){const i=w.useRef(null),a=w.useRef(null),l=w.useRef(null),u=w.useCallback(h=>{let p,v,x;const g=h.target;if(Wy(g)||sa(g)){const b=sa(g)?g:g.defaultView;x=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,v=s?b.innerWidth:b.innerHeight}else x=s?g.scrollLeft:g.scrollTop,p=s?g.scrollWidth:g.scrollHeight,v=s?g.offsetWidth:g.offsetHeight;const y=()=>{e({scrollHeight:p,scrollTop:Math.max(x,0),viewportHeight:v})};h.suppressFlushSync?y():pi.flushSync(y),a.current!==null&&(x===a.current||x<=0||x===p-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);w.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 p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const v=h.behavior==="smooth";let x,g,y;sa(p)?(g=Math.max(qn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),x=s?p.innerWidth:p.innerHeight,y=s?window.scrollX:window.scrollY):(g=p[s?"scrollWidth":"scrollHeight"],x=qn(p,s?"width":"height"),y=p[s?"scrollLeft":"scrollTop"]);const b=g-x;if(h.top=Math.ceil(Math.max(Math.min(b,h.top),0)),xu(x,g)||h.top===y){e({scrollHeight:g,scrollTop:y,viewportHeight:x}),v&&t(!0);return}v?(a.current=h.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(h={behavior:h.behavior,left:h.top}),p.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 ia="-webkit-sticky",Mu="sticky",aa=Nu(()=>{if(typeof document>"u")return Mu;const e=document.createElement("div");return e.style.position=ia,e.style.position===ia?ia:Mu});function la(e){return e}const Vy=Ge(()=>{const e=J(a=>`Item ${a}`),t=J(a=>`Group ${a}`),n=J({}),r=J(la),o=J("div"),s=J(_r),i=(a,l=null)=>Mt(V(n,fe(u=>u[a]),at()),l);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")}}),Ky=Ge(([e,t])=>({...e,...t}),it(Au,Vy)),qy=({height:e})=>c.jsx("div",{style:{height:e}}),Gy={overflowAnchor:"none",position:aa(),zIndex:1},Du={overflowAnchor:"none"},Yy={...Du,display:"inline-block",height:"100%"},Lu=w.memo(function({showTopList:e=!1}){const t=Ae("listState"),n=en("sizeRanges"),r=Ae("useWindowScroll"),o=Ae("customScrollParent"),s=en("windowScrollContainerState"),i=en("scrollContainerState"),a=o||r?s:i,l=Ae("itemContent"),u=Ae("context"),d=Ae("groupContent"),f=Ae("trackItemSizes"),h=Ae("itemSize"),p=Ae("log"),v=en("gap"),x=Ae("horizontalDirection"),{callbackRef:g}=uy(n,h,f,e?_r:a,p,v,o,x,Ae("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);ca("deviation",D=>{y!==D&&b(D)});const C=Ae("EmptyPlaceholder"),E=Ae("ScrollSeekPlaceholder")||qy,T=Ae("ListComponent"),k=Ae("ItemComponent"),I=Ae("GroupComponent"),_=Ae("computeItemKey"),R=Ae("isSeeking"),j=Ae("groupIndices").length>0,H=Ae("alignToBottom"),F=Ae("initialItemFinalLocationReached"),U=e?{}:{boxSizing:"border-box",...x?{display:"inline-block",height:"100%",marginLeft:y!==0?y:H?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:H?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...F?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?c.jsx(C,{...Dt(C,u)}):c.jsx(T,{...Dt(T,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:U,children:(e?t.topItems:t.items).map(D=>{const G=D.originalIndex,W=_(G+t.firstItemIndex,D.data,u);return R?w.createElement(E,{...Dt(E,u),height:D.size,index:D.index,key:W,type:D.type||"item",...D.type==="group"?{}:{groupIndex:D.groupIndex}}):D.type==="group"?w.createElement(I,{...Dt(I,u),"data-index":G,"data-item-index":D.index,"data-known-size":D.size,key:W,style:Gy},d(D.index,u)):w.createElement(k,{...Dt(k,u),...Qy(k,D.data),"data-index":G,"data-item-group-index":D.groupIndex,"data-item-index":D.index,"data-known-size":D.size,key:W,style:x?Yy:Du},j?l(D.index,D.groupIndex,D.data,u):l(D.index,D.data,u))})})}),Xy={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Jy={outline:"none",overflowX:"auto",position:"relative"},cs=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Zy={position:aa(),top:0,width:"100%",zIndex:1};function Dt(e,t){if(typeof e!="string")return{context:t}}function Qy(e,t){return{item:typeof e=="string"?void 0:t}}const ev=w.memo(function(){const e=Ae("HeaderComponent"),t=en("headerHeight"),n=Ae("HeaderFooterTag"),r=ur(w.useMemo(()=>s=>{t(qn(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Dt(e,o)})}):null}),tv=w.memo(function(){const e=Ae("FooterComponent"),t=en("footerHeight"),n=Ae("HeaderFooterTag"),r=ur(w.useMemo(()=>s=>{t(qn(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Dt(e,o)})}):null});function Fu({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:v}=Ou(a,u,l,d,void 0,f);return e("scrollTo",v),e("scrollBy",h),c.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?Jy:Xy,...o},tabIndex:0,...i,...Dt(l,s),children:r})})}function $u({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=w.useRef(null),v=t("scrollerRef"),{scrollByCallback:x,scrollerRef:g,scrollToCallback:y}=Ou(a,u,l,v,h);return Pu(()=>{var b;return g.current=h||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",y),e("scrollBy",x),c.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Dt(l,s),children:r})})}const nv=({children:e})=>{const t=w.useContext(ju),n=en("viewportHeight"),r=en("fixedItemHeight"),o=Ae("alignToBottom"),s=Ae("horizontalDirection"),i=w.useMemo(()=>Zc(n,l=>qn(l,s?"width":"height")),[n,s]),a=ur(i,!0,Ae("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),c.jsx("div",{"data-viewport-type":"element",ref:a,style:cs(o),children:e})},rv=({children:e})=>{const t=w.useContext(ju),n=en("windowViewportRect"),r=en("fixedItemHeight"),o=Ae("customScrollParent"),s=ru(n,o,Ae("skipAnimationFrameInResizeObserver")),i=Ae("alignToBottom");return w.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),c.jsx("div",{"data-viewport-type":"window",ref:s,style:cs(i),children:e})},ov=({children:e})=>{const t=Ae("TopItemListComponent")||"div",n=Ae("headerHeight"),r={...Zy,marginTop:`${n}px`},o=Ae("context");return c.jsx(t,{style:r,...Dt(t,o),children:e})},sv=w.memo(function(e){const t=Ae("useWindowScroll"),n=Ae("topItemsIndexes").length>0,r=Ae("customScrollParent"),o=Ae("context");return c.jsxs(r||t?lv:av,{...e,context:o,children:[n&&c.jsx(ov,{children:c.jsx(Lu,{showTopList:!0})}),c.jsxs(r||t?rv:nv,{children:[c.jsx(ev,{}),c.jsx(Lu,{}),c.jsx(tv,{})]})]})}),{Component:iv,useEmitter:ca,useEmitterValue:Ae,usePublisher:en}=_u(Ky,{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"}},sv),av=Fu({useEmitter:ca,useEmitterValue:Ae,usePublisher:en}),lv=$u({useEmitter:ca,useEmitterValue:Ae,usePublisher:en}),cv=iv;it(Au,Ge(()=>{const e=J(u=>c.jsxs("td",{children:["Item $",u]})),t=J(null),n=J(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=J(null),o=J(null),s=J({}),i=J(la),a=J(_r),l=(u,d=null)=>Mt(V(s,fe(f=>f[u]),at()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),aa();const zu={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},uv={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Bu,floor:us,max:co,min:ua,round:Hu}=Math;function Uu(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function dv(e){return{...uv,items:e}}function ds(e,t){return e&&e.width===t.width&&e.height===t.height}function fv(e,t){return e&&e.column===t.column&&e.row===t.row}const hv=Ge(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},h,p,{didMount:v,propsReady:x},{customScrollParent:g,useWindowScroll:y,windowScrollContainerState:b,windowScrollTo:C,windowViewportRect:E},T])=>{const k=J(0),I=J(0),_=J(zu),R=J({height:0,width:0}),j=J({height:0,width:0}),H=Ke(),F=Ke(),U=J(0),D=J(null),G=J({column:0,row:0}),W=Ke(),ne=Ke(),$=J(!1),z=J(0),ie=J(!0),M=J(!1),Y=J(!1);Ye(V(v,Le(z),Ee(([L,Z])=>!!Z)),()=>{Oe(ie,!1)}),Ye(V(vt(v,ie,j,R,z,M),Ee(([L,Z,ee,me,,se])=>L&&!Z&&ee.height!==0&&me.height!==0&&!se)),([,,,,L])=>{Oe(M,!0),ea(1,()=>{Oe(H,L)}),cn(V(u),()=>{Oe(t,[0,0]),Oe(ie,!0)})}),ve(V(ne,Ee(L=>L!=null&&L.scrollTop>0),vn(0)),I),Ye(V(v,Le(ne),Ee(([,L])=>L!=null)),([,L])=>{L&&(Oe(R,L.viewport),Oe(j,L.item),Oe(G,L.gap),L.scrollTop>0&&(Oe($,!0),cn(V(u,cr(1)),Z=>{Oe($,!1)}),Oe(l,{top:L.scrollTop})))}),ve(V(R,fe(({height:L})=>L)),f),ve(V(vt(Ce(R,ds),Ce(j,ds),Ce(G,(L,Z)=>L&&L.column===Z.column&&L.row===Z.row),Ce(u)),fe(([L,Z,ee,me])=>({gap:ee,item:Z,scrollTop:me,viewport:L}))),W),ve(V(vt(Ce(k),r,Ce(G,fv),Ce(j,ds),Ce(R,ds),Ce(D),Ce(I),Ce($),Ce(ie),Ce(z)),Ee(([,,,,,,,L])=>!L),fe(([L,[Z,ee],me,se,ae,He,Je,,je,Ue])=>{const{column:et,row:Ze}=me,{height:Pe,width:Ct}=se,{width:kt}=ae;if(Je===0&&(L===0||kt===0))return zu;if(Ct===0){const de=ta(Ue,L),_e=de+Math.max(Je-1,0);return dv(Uu(de,_e,He))}const Et=Wu(kt,Ct,et);let st,tt;je?Z===0&&ee===0&&Je>0?(st=0,tt=Je-1):(st=Et*us((Z+Ze)/(Pe+Ze)),tt=Et*Bu((ee+Ze)/(Pe+Ze))-1,tt=ua(L-1,co(tt,Et-1)),st=ua(tt,co(0,st))):(st=0,tt=-1);const ze=Uu(st,tt,He),{bottom:ct,top:bt}=Vu(ae,me,se,ze),X=Bu(L/Et),xe=X*Pe+(X-1)*Ze-ct;return{bottom:ct,itemHeight:Pe,items:ze,itemWidth:Ct,offsetBottom:xe,offsetTop:bt,top:bt}})),_),ve(V(D,Ee(L=>L!==null),fe(L=>L.length)),k),ve(V(vt(R,j,_,G),Ee(([L,Z,{items:ee}])=>ee.length>0&&Z.height!==0&&L.height!==0),fe(([L,Z,{items:ee},me])=>{const{bottom:se,top:ae}=Vu(L,me,Z,ee);return[ae,se]}),at(no)),t);const ce=J(!1);ve(V(u,Le(ce),fe(([L,Z])=>Z||L!==0)),ce);const be=Kt(V(vt(_,k),Ee(([{items:L}])=>L.length>0),Le(ce),Ee(([[L,Z],ee])=>{const me=L.items[L.items.length-1].index===Z-1;return(ee||L.bottom>0&&L.itemHeight>0&&L.offsetBottom===0&&L.items.length===Z)&&me}),fe(([[,L]])=>L-1),at())),ge=Kt(V(Ce(_),Ee(({items:L})=>L.length>0&&L[0].index===0),vn(0),at())),ye=Kt(V(Ce(_),Le($),Ee(([{items:L},Z])=>L.length>0&&!Z),fe(([{items:L}])=>({endIndex:L[L.length-1].index,startIndex:L[0].index})),at(uu),Dn(0)));ve(ye,p.scrollSeekRangeChanged),ve(V(H,Le(R,j,k,G),fe(([L,Z,ee,me,se])=>{const ae=gu(L),{align:He,behavior:Je,offset:je}=ae;let Ue=ae.index;Ue==="LAST"&&(Ue=me-1),Ue=co(0,Ue,ua(me-1,Ue));let et=da(Z,se,ee,Ue);return He==="end"?et=Hu(et-Z.height+ee.height):He==="center"&&(et=Hu(et-Z.height/2+ee.height/2)),je&&(et+=je),{behavior:Je,top:et}})),l);const K=Mt(V(_,fe(L=>L.offsetBottom+L.bottom)),0);return ve(V(E,fe(L=>({height:L.visibleHeight,width:L.visibleWidth}))),R),{customScrollParent:g,data:D,deviation:U,footerHeight:o,gap:G,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:j,overscan:n,restoreStateFrom:ne,scrollBy:i,scrollContainerState:a,scrollHeight:F,scrollTo:l,scrollToIndex:H,scrollTop:u,smoothScrollTargetReached:d,totalCount:k,useWindowScroll:y,viewportDimensions:R,windowScrollContainerState:b,windowScrollTo:C,windowViewportRect:E,...p,gridState:_,horizontalDirection:Y,initialTopMostItemIndex:z,totalListHeight:K,...h,endReached:be,propsReady:x,rangeChanged:ye,startReached:ge,stateChanged:W,stateRestoreInProgress:$,...T}},it(na,$t,lo,Iu,Gn,oa,Kn));function Wu(e,t,n){return co(1,us((e+n)/(us(t)+n)))}function Vu(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=da(e,t,n,r[0].index);return{bottom:da(e,t,n,r[r.length-1].index)+o,top:s}}function da(e,t,n,r){const o=Wu(e.width,n.width,t.column),s=us(r/o),i=s*n.height+co(0,s-1)*t.row;return i>0?i+t.row:i}const pv=Ge(()=>{const e=J(f=>`Item ${f}`),t=J({}),n=J(null),r=J("virtuoso-grid-item"),o=J("virtuoso-grid-list"),s=J(la),i=J("div"),a=J(_r),l=(f,h=null)=>Mt(V(t,fe(p=>p[f]),at()),h),u=J(!1),d=J(!1);return ve(Ce(d),u),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:u,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),mv=Ge(([e,t])=>({...e,...t}),it(hv,pv)),gv=w.memo(function(){const e=lt("gridState"),t=lt("listClassName"),n=lt("itemClassName"),r=lt("itemContent"),o=lt("computeItemKey"),s=lt("isSeeking"),i=tn("scrollHeight"),a=lt("ItemComponent"),l=lt("ListComponent"),u=lt("ScrollSeekPlaceholder"),d=lt("context"),f=tn("itemDimensions"),h=tn("gap"),p=lt("log"),v=lt("stateRestoreInProgress"),x=tn("reportReadyState"),g=ur(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);const C=y.firstChild;if(C){const{height:E,width:T}=C.getBoundingClientRect();f({height:E,width:T})}h({column:qu("column-gap",getComputedStyle(y).columnGap,p),row:qu("row-gap",getComputedStyle(y).rowGap,p)})},[i,f,h,p]),!0,!1);return Pu(()=>{e.itemHeight>0&&e.itemWidth>0&&x(!0)},[e]),v?null:c.jsx(l,{className:t,ref:g,...Dt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const b=o(y.index,y.data,d);return s?c.jsx(u,{...Dt(u,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{...Dt(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),xv=w.memo(function(){const e=lt("HeaderComponent"),t=tn("headerHeight"),n=lt("headerFooterTag"),r=ur(w.useMemo(()=>s=>{t(qn(s,"height"))},[t]),!0,!1),o=lt("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Dt(e,o)})}):null}),yv=w.memo(function(){const e=lt("FooterComponent"),t=tn("footerHeight"),n=lt("headerFooterTag"),r=ur(w.useMemo(()=>s=>{t(qn(s,"height"))},[t]),!0,!1),o=lt("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Dt(e,o)})}):null}),vv=({children:e})=>{const t=w.useContext(Ru),n=tn("itemDimensions"),r=tn("viewportDimensions"),o=ur(w.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return w.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),c.jsx("div",{ref:o,style:cs(!1),children:e})},bv=({children:e})=>{const t=w.useContext(Ru),n=tn("windowViewportRect"),r=tn("itemDimensions"),o=lt("customScrollParent"),s=ru(n,o,!1);return w.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),c.jsx("div",{ref:s,style:cs(!1),children:e})},wv=w.memo(function({...e}){const t=lt("useWindowScroll"),n=lt("customScrollParent"),r=n||t?Cv:Sv,o=n||t?bv:vv,s=lt("context");return c.jsx(r,{...e,...Dt(r,s),children:c.jsxs(o,{children:[c.jsx(xv,{}),c.jsx(gv,{}),c.jsx(yv,{})]})})}),{useEmitter:Ku,useEmitterValue:lt,usePublisher:tn}=_u(mv,{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"}},wv),Sv=Fu({useEmitter:Ku,useEmitterValue:lt,usePublisher:tn}),Cv=$u({useEmitter:Ku,useEmitterValue:lt,usePublisher:tn});function qu(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Wt.WARN),t==="normal"?0:parseInt(t??"0",10)}const Tv=Po.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 fa({className:e,variant:t,...n}){return c.jsx("div",{className:re(Tv({variant:t}),e),...n})}function pe(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 kv(e,t){const n=m.createContext(t),r=s=>{const{children:i,...a}=s,l=m.useMemo(()=>a,Object.values(a));return c.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=m.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 Sn(e,t=[]){let n=[];function r(s,i){const a=m.createContext(i),l=n.length;n=[...n,i];const u=f=>{var y;const{scope:h,children:p,...v}=f,x=((y=h==null?void 0:h[e])==null?void 0:y[l])||a,g=m.useMemo(()=>v,Object.values(v));return c.jsx(x.Provider,{value:g,children:p})};u.displayName=s+"Provider";function d(f,h){var x;const p=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,v=m.useContext(p);if(v)return v;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=>m.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Ev(o,...t)]}function Ev(...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:l,scopeName:u})=>{const f=l(s)[`__scope${u}`];return{...a,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Tt=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},Iv=m[" useInsertionEffect ".trim().toString()]||Tt;function hr({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Nv({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=m.useRef(e!==void 0);m.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=m.useCallback(d=>{var f;if(a){const h=Av(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[l,u]}function Nv({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return Iv(()=>{s.current=t},[t]),m.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Av(e){return typeof e=="function"}function Gu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function ha(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Gu(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():Gu(e[o],null)}}}}function Ve(...e){return m.useCallback(ha(...e),e)}var _v=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ie=_v.reduce((e,t)=>{const n=or.createSlot(`Primitive.${t}`),r=m.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Yu(e,t){e&&Oo.flushSync(()=>e.dispatchEvent(t))}function jv(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Gt=e=>{const{present:t,children:n}=e,r=Rv(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=Ve(r.ref,Pv(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};Gt.displayName="Presence";function Rv(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=jv(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=fs(r.current);s.current=a==="mounted"?u:"none"},[a]),Tt(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,p=fs(u);e?l("MOUNT"):p==="none"||(u==null?void 0:u.display)==="none"?l("UNMOUNT"):l(d&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),Tt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const x=fs(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&x&&(l("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=p=>{p.target===t&&(s.current=fs(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 l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function fs(e){return(e==null?void 0:e.animationName)||"none"}function Pv(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 Ov=m[" useId ".trim().toString()]||(()=>{}),Mv=0;function Cn(e){const[t,n]=m.useState(Ov());return Tt(()=>{n(r=>r??String(Mv++))},[e]),e||(t?`radix-${t}`:"")}var hs="Collapsible",[Dv,bk]=Sn(hs),[Lv,pa]=Dv(hs),Xu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,u]=hr({prop:r,defaultProp:o??!1,onChange:i,caller:hs});return c.jsx(Lv,{scope:n,disabled:s,contentId:Cn(),open:l,onOpenToggle:m.useCallback(()=>u(d=>!d),[u]),children:c.jsx(Ie.div,{"data-state":ga(l),"data-disabled":s?"":void 0,...a,ref:t})})});Xu.displayName=hs;var Ju="CollapsibleTrigger",Zu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=pa(Ju,n);return c.jsx(Ie.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":ga(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:pe(e.onClick,o.onOpenToggle)})});Zu.displayName=Ju;var ma="CollapsibleContent",Fv=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=pa(ma,e.__scopeCollapsible);return c.jsx(Gt,{present:n||o.open,children:({present:s})=>c.jsx($v,{...r,ref:t,present:s})})});Fv.displayName=ma;var $v=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=pa(ma,n),[a,l]=m.useState(r),u=m.useRef(null),d=Ve(t,u),f=m.useRef(0),h=f.current,p=m.useRef(0),v=p.current,x=i.open||a,g=m.useRef(x),y=m.useRef(void 0);return m.useEffect(()=>{const b=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(b)},[]),Tt(()=>{const b=u.current;if(b){y.current=y.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const C=b.getBoundingClientRect();f.current=C.height,p.current=C.width,g.current||(b.style.transitionDuration=y.current.transitionDuration,b.style.animationName=y.current.animationName),l(r)}},[i.open,r]),c.jsx(Ie.div,{"data-state":ga(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!x,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style},children:x&&o})});function ga(e){return e?"open":"closed"}var zv=Xu;const Qu=zv,ed=Zu,uo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:re("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));uo.displayName="Card";const fo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:re("flex flex-col space-y-1.5 p-6",e),...t}));fo.displayName="CardHeader";const ho=m.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:re("text-2xl font-semibold leading-none tracking-tight",e),...t}));ho.displayName="CardTitle";const td=m.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:re("text-sm text-muted-foreground",e),...t}));td.displayName="CardDescription";const po=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:re("p-6 pt-0",e),...t}));po.displayName="CardContent";const nd=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:re("flex items-center p-6 pt-0",e),...t}));nd.displayName="CardFooter";function rd(){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 pr=rd();function Bv(e){pr=e}const od=/[&<>"']/,Hv=new RegExp(od.source,"g"),sd=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Uv=new RegExp(sd.source,"g"),Wv={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},id=e=>Wv[e];function Lt(e,t){if(t){if(od.test(e))return e.replace(Hv,id)}else if(sd.test(e))return e.replace(Uv,id);return e}const Vv=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function ad(e){return e.replace(Vv,(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 Kv=/(^|[^\[])\^/g;function ot(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(Kv,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const qv=/[^\w:]/g,Gv=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function ld(e,t,n){if(e){let r;try{r=decodeURIComponent(ad(n)).replace(qv,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!Gv.test(n)&&(n=Zv(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const ps={},Yv=/^[^:]+:\/*[^/]*$/,Xv=/^([^:]+:)[\s\S]*$/,Jv=/^([^:]+:\/*[^/]*)[\s\S]*$/;function Zv(e,t){ps[" "+e]||(Yv.test(e)?ps[" "+e]=e+"/":ps[" "+e]=gs(e,"/",!0)),e=ps[" "+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(Jv,"$1")+t:e+t}const ms={exec:function(){}};function cd(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,u=i;for(;--u>=0&&a[u]==="\\";)l=!l;return l?"|":" |"}),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 gs(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 Qv(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 eb(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 ud(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function dd(e,t,n,r){const o=t.href,s=t.title?Lt(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:Lt(i)}}function tb(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
37
+ `))>=0;){const Et=K.slice(0,Tt);K=K.slice(Tt+2);const st=jx(Et);if(!st)continue;let tt;try{tt=JSON.parse(st)}catch{console.debug("[use-chat] malformed SSE:",st.slice(0,200));continue}const ze=_x(tt)?tt.data:tt;ae=Date.now();const ct=ze.seq;if(ct!==void 0){if(ct<=Z){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:ct,lastProcessedSeq:Z,type:ze.type});continue}Z>0&&ct>Z+1&&((z=F==null?void 0:F.onGap)==null||z.call(F,{from:Z,to:ct})),Z=ct,k.current=ct,g(ct)}if(console.debug("[use-chat] received event",{seq:ze.seq,type:ze.type,preview:(()=>{var bt;try{return ze.type==="message_delta"?{deltaTypes:(bt=ze.delta)==null?void 0:bt.map(X=>X.type),textLen:(ze.delta||[]).filter(X=>X.type==="text").map(X=>String(X.text||"").length)}:ze.content||ze.delta?{hasContent:!0}:{}}catch(X){return{err:String(X)}}})()}),H==null||H(ze),ze.type==="token"&&e.autoAppendAssistant!==!1)L.push(ze.content),se();else if(ze.type==="message_delta"){const bt=ze.delta.filter(X=>X.type==="text").map(X=>X.text).join("");bt&&e.autoAppendAssistant!==!1&&(L.push(bt),se())}else ze.type==="heartbeat"?console.debug("[use-chat] heartbeat received"):(ee!==null&&cancelAnimationFrame(ee),me(),ze.type==="checkpoint"?v(ze.checkpointId):ze.type==="error"&&d(ze.message))}}me()}catch(je){if(je.name!=="AbortError"){const Ue=je.message||String(je);d(Ue),(ie=F==null?void 0:F.onError)==null||ie.call(F,Ue)}}finally{try{await ge.cancel()}catch{}finally{(M=ge.releaseLock)==null||M.call(ge)}ee!==null&&typeof window<"u"&&window.cancelAnimationFrame(ee),clearInterval(He),l(!1),b(!1),C.current=null,k.current=0,g(0)}}catch(ce){if(ce.name!=="AbortError"){const be=ce.message||String(ce);d(be),(Y=F==null?void 0:F.onError)==null||Y.call(F,be)}}finally{l(!1),b(!1),C.current=null,k.current=0,g(0)}})(),{close:()=>U.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var j;E.current=!1,(j=C.current)==null||j.abort()},[]),{isStreaming:a,error:u,assistantText:f,lastCheckpointId:p,lastSeq:x,connected:y,stream:R,stop:I,clear:_,setToken:T}}function _x(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function jx(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
+ `)}function Rx({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onUnhandledEvent:r,onSequenceGap:o}){const s=w.useRef(null),i=w.useCallback(p=>{const v=p.seq??null;if(v!==null){const x=s.current;if(x!==null){if(v<=x)return;v>x+1&&(o==null||o({from:x,to:v}))}s.current=v}if(p.type==="thread_info"){console.log("[useChatStreamingService] 🎯 Received thread_info event:",p),t(p);return}if(wx(p)){n(p);return}r==null||r(p)},[n,o,t,r]),{stream:a,stop:l,isStreaming:u,error:d,setToken:f}=Lc({baseUrl:e,token:null}),h=w.useCallback((p,v)=>{s.current=null,a(p,i,{onOpen:v==null?void 0:v.onOpen,onError:x=>{var g;(g=v==null?void 0:v.onError)==null||g.call(v,x)},onGap:(v==null?void 0:v.onGap)??o})},[i,o,a]);return w.useMemo(()=>({startStream:h,stop:l,isStreaming:u,error:d,setAuthToken:f}),[h,l,u,d,f])}function Pi(e){return e==null?e:{...e}}function Px(e){return e==null?e:{...e}}function Ox(e){if(Array.isArray(e))return e.slice();if(e==null)return e}function Mx(e){if(Array.isArray(e))return e.map(t=>({...t}));if(e==null)return e}function Qt(e,t={}){const n=t.cloneMessages??!1,r=Array.isArray(e==null?void 0:e.messages)?e.messages:[],o=Pi(e==null?void 0:e.metadata),s=Pi(e==null?void 0:e.config),i=Pi(e==null?void 0:e.parentConfig),a=Ox(e==null?void 0:e.next),l=Mx(e==null?void 0:e.tasks),u=Px(e==null?void 0:e.values),d={checkpointId:(e==null?void 0:e.checkpointId)??null,checkpointNs:(e==null?void 0:e.checkpointNs)??null,createdAt:(e==null?void 0:e.createdAt)??null,parentId:(e==null?void 0:e.parentId)??null,branchLabel:(e==null?void 0:e.branchLabel)??null,lastMessageId:(e==null?void 0:e.lastMessageId)??null,messagesLen:typeof(e==null?void 0:e.messagesLen)=="number"?e.messagesLen:r.length,hasMessages:typeof(e==null?void 0:e.hasMessages)=="boolean"?e.hasMessages:r.length>0,messages:n?r.slice():r,nextCursor:(e==null?void 0:e.nextCursor)??null,nextCursorNs:(e==null?void 0:e.nextCursorNs)??null,interrupt:(e==null?void 0:e.interrupt)??null};return o!==void 0&&(d.metadata=o),s!==void 0&&(d.config=s),i!==void 0&&(d.parentConfig=i),a!==void 0&&(d.next=a),l!==void 0&&(d.tasks=l),u!==void 0&&(d.values=u),d}function Dx(e){var t;for(let n=e.length-1;n>=0;n--){const r=((t=e[n])==null?void 0:t.content)??[];for(let o=r.length-1;o>=0;o--){const s=r[o];if((s==null?void 0:s.type)==="interrupt"){const i=s.id;return{id:(typeof i=="string"?i:null)??`interrupt-${e[n].id??o}`,value:s.value}}}}return null}function Fc(e,t){if(!e&&!t)return!0;if(!e||!t||e.id!==t.id)return!1;try{return JSON.stringify(e.value)===JSON.stringify(t.value)}catch{return e.value===t.value}}const qo=300;function $c(e,t=qo){if(typeof window<"u"&&"requestIdleCallback"in window)try{window.requestIdleCallback(e,{timeout:t});return}catch{}window.setTimeout(e,t)}function lr(){return typeof window<"u"&&typeof window.localStorage<"u"}function Oi(e){if(!lr())return null;try{return window.localStorage.getItem(e)}catch{return null}}function Mi(e,t){if(!lr())return!1;try{return window.localStorage.setItem(e,t),!0}catch{return!1}}function Di(e){if(lr())try{window.localStorage.removeItem(e)}catch{}}const Lx="cachedThreads",Fx="v1",Li=200;function $x(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(36)}function Fi(e,t){return`cachedThreads:v1:${e}:${$x(t||"anon")}`}function zx(){const e=Oi(Lx);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>{if(!n||typeof n!="object")return!1;const r=n;return typeof r.threadId=="string"&&typeof r.title=="string"}):[]}catch{return[]}}function Bx(e){const t=Oi(e);if(!t)return[];try{const n=JSON.parse(t);return Array.isArray(n)?n.filter(r=>{if(!r||typeof r!="object")return!1;const o=r;return typeof o.threadId=="string"&&typeof o.title=="string"}):[]}catch{return[]}}function $i(e,t){Mi(e,JSON.stringify(t))}function zi(e){const t=Bx(e);if(t.length>0)return t;const n=zx();if(n.length>0)try{$i(e,n.slice(0,Li))}catch{}return n}function Go(e){const t={},n=[];for(const r of e)!r||typeof r.threadId!="string"||t[r.threadId]||(t[r.threadId]=r,n.push(r.threadId));return{byId:t,order:n}}function Bi(e){return e.order.map(t=>e.byId[t]).filter(Boolean)}function Hi(e,t){return`${e}${t}`}function Hx(e,t){const n=Oi(Hi(e,t));if(!n)return null;try{const r=JSON.parse(n);return typeof(r==null?void 0:r.threadId)!="string"?null:{threadId:r.threadId,snapshot:Qt(r.snapshot,{cloneMessages:!0}),updatedAt:typeof r.updatedAt=="number"?r.updatedAt:void 0}}catch{return null}}function Ux(e,t,n=100){if(!lr())return;const r=Qt(t.snapshot,{cloneMessages:!0}),o={threadId:t.threadId,snapshot:{...r,messages:r.messages.slice(-n)},updatedAt:Date.now()},s=Hi(e,t.threadId),i=JSON.stringify(o);if(!Mi(s,i))try{const a=[];for(let l=0;l<window.localStorage.length;l++){const u=window.localStorage.key(l);if(!u||u===s||!u.startsWith(e))continue;const d=window.localStorage.getItem(u);if(!d){a.push({key:u,updatedAt:0});continue}try{const f=JSON.parse(d),h=typeof(f==null?void 0:f.updatedAt)=="number"&&Number.isFinite(f.updatedAt)?f.updatedAt:0;a.push({key:u,updatedAt:h})}catch{a.push({key:u,updatedAt:0})}}a.sort((l,u)=>l.updatedAt-u.updatedAt);for(const l of a)if(window.localStorage.removeItem(l.key),Mi(s,i))break}catch{}}function Wx(e,t){Di(Hi(e,t))}function Vx(e){if(lr())try{for(let t=0;t<window.localStorage.length;t++){const n=window.localStorage.key(t);n&&n.startsWith(e)&&window.localStorage.removeItem(n)}}catch{}}const zc=w.createContext(null),Bc=w.createContext(null),Hc=w.createContext(null),Kx=w.createContext(!1),Uc=50,qx=750;function Wc(e,t,n){return`${e}__${t??""}__${n??""}`}function Yo(e,t){return t&&typeof t=="object"?{...e&&typeof e=="object"?{...e}:{},...t}:t===null?e&&typeof e=="object"?{...e}:e??null:e&&typeof e=="object"?{...e}:e??void 0}function Gx(e,t){return Yo(e,t)}function Yx(e,t){return Array.isArray(t)?t.slice():t===null?Array.isArray(e)?e.slice():e??null:Array.isArray(e)?e.slice():e??void 0}function Xx(e,t){return Array.isArray(t)?t.map(n=>({...n})):t===null?Array.isArray(e)?e.map(n=>({...n})):e??null:Array.isArray(e)?e.map(n=>({...n})):e??void 0}function Vc(e,t){const n=Yo(e.metadata,t.metadata),r=Yo(e.config,t.config),o=Yo(e.parentConfig,t.parentConfig),s=Yx(e.next,t.next),i=Xx(e.tasks,t.tasks),a=Gx(e.values,t.values),l={};return n!==void 0&&(l.metadata=n??null),r!==void 0&&(l.config=r??null),o!==void 0&&(l.parentConfig=o??null),s!==void 0&&(l.next=s??null),i!==void 0&&(l.tasks=i??null),a!==void 0&&(l.values=a??null),l}function Jx({children:e,initialThreadId:t=null,autoLoadInitial:n=!0,disableAutoRestore:r=!1,enableFileAgentRouting:o=!1,fileAgentId:s="invoice_reader",onError:i,onThreadChange:a}){const{api:l,baseUrl:u}=Ai(),d=w.useMemo(()=>Mn(u),[u]),f=w.useMemo(()=>{try{return new URL(u).host}catch{return"unknown"}},[u]),h=w.useMemo(()=>`threadPayload:${Fx}:${f}:`,[f]),p=w.useCallback(N=>Hx(h,N),[h]),v=w.useCallback((N,A=100)=>{Ux(h,N,A)},[h]),x=w.useCallback(N=>{Wx(h,N)},[h]),g=w.useCallback(()=>{Vx(h)},[h]),[y,b]=w.useState(()=>{var N;return Fi(f,(N=l.getAuthToken)==null?void 0:N.call(l))}),[C,E]=w.useState(()=>{var A;const N=zi(Fi(f,(A=l.getAuthToken)==null?void 0:A.call(l)));return Go(N)}),k=w.useMemo(()=>Bi(C),[C]),[T,I]=w.useState(t),[_,R]=w.useState(!1),[j,H]=w.useState(!1),[F,U]=w.useState(null),[D,G]=w.useState(null),[W,ne]=w.useState(null),[$,z]=w.useState([]),ie=w.useCallback(()=>{const N=zi(y);w.startTransition(()=>{E(Go(N))})},[y]),[M,Y]=w.useState(!1),[ce,be]=w.useState(!1),[ge,ye]=w.useState(null),[K,L]=w.useState(void 0),[Z,ee]=w.useState(void 0),[me,se]=w.useState(void 0),{state:ae,dispatch:He,seed:Je,prepend:je,pushUser:Ue,onEvent:et,reset:Ze}=Ac(),Pe=w.useRef(T);w.useEffect(()=>{Pe.current=T},[T]);const Ct=w.useRef(!1),Tt=w.useRef([]),Et=w.useRef(null),st=w.useRef(null),tt=w.useRef(new Map),ze=w.useRef(T),ct=w.useRef(!1),bt=w.useRef(null),X=w.useRef(new Map),xe=w.useRef(new Map),de=w.useRef(new Map),_e=w.useRef(new Map),Fe=w.useCallback(N=>{if(!N){z([]);return}const A=X.current.get(N);if(!A||!A.length){z([]);return}z(A.map(q=>Qt(q,{cloneMessages:!0})))},[]);w.useEffect(()=>{Fe(T)},[T,Fe]);const nt=w.useCallback(()=>{var te;const N=_e.current;if(N.size<=Uc)return;const A=Array.from(N.entries()).sort((le,Q)=>le[1].timestamp-Q[1].timestamp),q=N.size-Uc;for(let le=0;le<q;le++){const Q=(te=A[le])==null?void 0:te[0];Q&&N.delete(Q)}},[]),pt=w.useCallback((N,A,q)=>{if(!N)return;const te=q==="replace"?[]:X.current.get(N)??[],le=q==="replace"?A:[...A,...te];if(!le.length){q==="replace"&&X.current.set(N,[]);return}const Q=new Map;for(const We of le){if(!(We!=null&&We.checkpointId))continue;const De=`${We.checkpointId}::${We.checkpointNs??""}`,Xe=Qt(We,{cloneMessages:!0}),yt=Q.get(De);if(!yt){Q.set(De,Xe);continue}const jt=Vc(yt,Xe);Q.set(De,{...yt,...jt})}const Be=Array.from(Q.values()).sort((We,De)=>{const Xe=Number.isFinite(Date.parse(We.createdAt??""))?Date.parse(We.createdAt??""):0;return(Number.isFinite(Date.parse(De.createdAt??""))?Date.parse(De.createdAt??""):0)-Xe});X.current.set(N,Be),N===Pe.current&&Fe(N)},[Fe]),Qe=w.useCallback((N,A,q)=>{if(!N)return;const te=xe.current.get(N),le=q==="replace"||!te?new Map:new Map(te);if(A&&typeof A=="object")for(const[Q,Be]of Object.entries(A)){if(!(Be!=null&&Be.checkpointId))continue;const We=Q||Zr(Be.checkpointId,Be.checkpointNs??null);le.set(We,Qt(Be,{cloneMessages:!0}))}xe.current.set(N,le)},[]),ut=w.useCallback((N,A)=>{const{threadId:q,checkpointId:te=null,checkpointNs:le=null}=N,Q=Wc(q,te,le);if(A!=null&&A.force)de.current.delete(Q),_e.current.delete(Q);else{if(A!=null&&A.preferCache){const Xe=_e.current.get(Q);if(Xe)return Promise.resolve(Xe.payload)}const De=de.current.get(Q);if(De)return De}const We=l.getStateHistory({threadId:q,checkpointId:te??void 0,checkpointNs:le??void 0}).then(De=>(_e.current.set(Q,{payload:De,timestamp:Date.now()}),nt(),De)).finally(()=>{de.current.get(Q)===We&&de.current.delete(Q)});return de.current.set(Q,We),We},[l,nt]),mt=w.useCallback((N,A)=>new Promise((q,te)=>{const le=async()=>{Ct.current=!0;try{await N(),q()}catch(Q){te(Q)}finally{Ct.current=!1;const Q=Tt.current.shift();Q&&Q().catch(()=>{})}};Ct.current?Tt.current.push(le):le().catch(Q=>{te(Q)})}),[]),$n=w.useRef(k.length),[zn,kr]=w.useState(!1),Bn=w.useRef(!1);w.useEffect(()=>{$n.current=k.length},[k.length]),w.useEffect(()=>{const N=ae.pendingInterrupt??Dx(ae.messages);Fc(W,N)||ne(N??null)},[W,ae.messages,ae.pendingInterrupt]);const Ft=w.useCallback(async()=>{const N=$n.current>0;N||R(!0);try{const A=await l.listThreads();w.startTransition(()=>{E(q=>{const te=Be=>Be.map(We=>`${We.threadId}:${We.updatedAt??""}:${We.messageCount??""}`).join("|"),le=Bi(q);return te(le)===te(A)||A.length===0&&le.length>0&&!Bn.current?q:Go(A)})}),U(null),Bn.current||(Bn.current=!0,kr(!0))}catch(A){i==null||i(String(A)),console.error("[ChatSessionProvider] Failed to refresh threads:",A),U(String(A))}finally{N||R(!1)}},[l,i]),Io=w.useRef(!1),Hn=w.useRef(null),wt=w.useRef(null),mn=w.useRef(""),_n=w.useCallback((N,A)=>{if(!lr())return;wt.current!==null&&(window.clearTimeout(wt.current),wt.current=null);const q=N.map(le=>`${le.threadId}:${le.updatedAt??""}:${le.messageCount??""}`).join("|");if(N.length===0){try{Di(y)}catch{}mn.current="";return}if(q===mn.current)return;const te=()=>{try{const le=N.slice(0,Li);$i(y,le),mn.current=q}catch{}finally{wt.current=null}};if(A!=null&&A.immediate){te();return}wt.current=window.setTimeout(()=>{$c(te)},qo)},[y]),Ur=w.useCallback(()=>{_n(k,{immediate:!0})},[_n,k]),sn=w.useCallback((N,A,q,te)=>{var Em;const le=q??Pe.current;if(!le)return;const Q=Qt(N),Be=le===Pe.current,We=(te==null?void 0:te.persist)!==!1;if(A==="replace"){if(We){const Nt={threadId:le,snapshot:Qt(N,{cloneMessages:!0})};tt.current.set(le,Nt),ze.current=le}if(!Be)return;Je(Q.messages,{checkpointId:Q.checkpointId??null,checkpointNs:Q.checkpointNs??null,pendingInterrupt:Q.interrupt??null}),ne(Q.interrupt??null),ye(Q.nextCursor??null),Y(!!Q.nextCursor),L(Q.checkpointId??void 0),ee(Q.checkpointNs??void 0),se(Q.nextCursorNs??void 0);return}const De=tt.current.get(le),Xe=(De==null?void 0:De.snapshot)??null,yt=Array.isArray(Xe==null?void 0:Xe.messages)?Xe.messages:[],jt=Qt(Xe),Rn=Array.isArray(N==null?void 0:N.messages)?N.messages:[],Rt=new Set,Pt=[...Rn,...yt].filter(Nt=>{const El=Nt==null?void 0:Nt.id;return El?Rt.has(El)?!1:(Rt.add(El),!0):!0}),_o=Vc(jt,Q),jo={checkpointId:jt.checkpointId??Q.checkpointId??null,checkpointNs:jt.checkpointNs??Q.checkpointNs??null,createdAt:Q.createdAt??jt.createdAt??null,parentId:Q.parentId??jt.parentId??null,branchLabel:Q.branchLabel??jt.branchLabel??null,lastMessageId:((Em=Pt[Pt.length-1])==null?void 0:Em.id)??null,messagesLen:Pt.length,hasMessages:Pt.length>0,messages:Pt,nextCursor:Q.nextCursor??jt.nextCursor??null,nextCursorNs:Q.nextCursorNs??jt.nextCursorNs??null,interrupt:jt.interrupt??Q.interrupt??null,..._o};if(tt.current.set(le,{threadId:le,snapshot:Qt(jo,{cloneMessages:!0})}),!Be)return;Rn.length&&je(Rn);const Pn=N&&Object.prototype.hasOwnProperty.call(N,"checkpointId")?N.checkpointId:void 0,Ro=N&&Object.prototype.hasOwnProperty.call(N,"checkpointNs")?N.checkpointNs:void 0,On=N&&Object.prototype.hasOwnProperty.call(N,"nextCursor")?N.nextCursor:void 0,Tl=N&&Object.prototype.hasOwnProperty.call(N,"nextCursorNs")?N.nextCursorNs:void 0;ye(Nt=>On!==void 0?On??Nt??null:Nt??null),Y(Nt=>On!==void 0?!!On:Nt),L(Nt=>Pn!==void 0?Pn??Nt??void 0:Nt??void 0),ee(Nt=>Ro!==void 0?Ro??Nt??void 0:Nt??void 0),se(Nt=>Tl!==void 0?Tl??void 0:Nt)},[je,Je,ne]),rr=w.useCallback(N=>{if(N.threadId!=null&&N.threadId!==Pe.current)return;const A=Qt(N.snapshot,{cloneMessages:!0});Je(A.messages,{checkpointId:A.checkpointId??null,checkpointNs:A.checkpointNs??null,pendingInterrupt:A.interrupt??null}),ne(A.interrupt??null),ye(A.nextCursor??null),Y(!!A.nextCursor),L(A.checkpointId??void 0),ee(A.checkpointNs??void 0),se(A.nextCursorNs??void 0),ze.current=N.threadId,Fe(N.threadId??Pe.current??null)},[Je,ne,Fe]),gn=w.useCallback(N=>{if(!N)return;tt.current.delete(N),x(N),X.current.delete(N),xe.current.delete(N),N===Pe.current&&z([]);const A=`${N}__`;for(const q of de.current.keys())q.startsWith(A)&&de.current.delete(q);for(const q of _e.current.keys())q.startsWith(A)&&_e.current.delete(q);ze.current===N&&(ze.current=null)},[x]),jn=w.useCallback(()=>{const N=Pe.current;N&&gn(N),Ze([]),Y(!1),be(!1),ye(null),L(void 0),ee(void 0),se(void 0)},[gn,Ze]),Tr=w.useCallback(({from:N,to:A})=>{const q=Pe.current;q&&console.warn(`[ChatSessionProvider] Stream sequence gap detected (${N} -> ${A}) for thread ${q}`)},[]),No=w.useCallback(N=>{const A=N.threadId;console.log("[ChatSessionProvider] 📥 Handling thread_info event:",{threadId:A,title:N.title,created:N.created,currentThreads:k.length});const q={threadId:A,title:N.title||`Thread ${A.slice(0,8)}`,createdAt:N.createdAt||new Date().toISOString(),updatedAt:N.updatedAt||new Date().toISOString(),messageCount:N.messageCount||0};Pe.current!==A&&(!Pe.current&&ae.messages.length<=1&&(st.current=A),I(A)),w.startTransition(()=>{E(te=>{const le=te.byId[A];return le?le.title===q.title&&le.updatedAt===q.updatedAt&&le.messageCount===q.messageCount?te:{byId:{...te.byId,[A]:q},order:te.order}:{byId:{...te.byId,[A]:q},order:[A,...te.order]}})})},[ae.messages.length]),{startStream:Wr,stop:S,isStreaming:P,error:B,setAuthToken:oe}=Rx({baseUrl:d,onThreadInfo:No,onMessageEvent:et,onUnhandledEvent:N=>{console.warn(`[ChatSessionProvider] Unhandled stream event: ${N.type}`,N)},onSequenceGap:Tr});w.useEffect(()=>{Io.current=P},[P]),w.useEffect(()=>{if(!lr())return;wt.current!==null&&(window.clearTimeout(wt.current),wt.current=null);const N=k.map(q=>`${q.threadId}:${q.updatedAt??""}:${q.messageCount??""}`).join("|");if(k.length===0){try{Di(y)}catch{}mn.current="";return}if(N===mn.current)return;const A=()=>{try{const q=k.slice(0,Li);$i(y,q),mn.current=N}catch{}finally{wt.current=null}};return wt.current=window.setTimeout(()=>{$c(A),wt.current=null},qo),()=>{wt.current!==null&&(window.clearTimeout(wt.current),wt.current=null)}},[k,_n]),w.useEffect(()=>{var te;const N=l.getAuthToken();oe(N);const A=le=>{const Q=Fi(f,le);bt.current!==Q&&(bt.current=Q,ct.current=!1),b(Q);const Be=zi(Q);w.startTransition(()=>{E(Go(Be))}),ct.current||(ct.current=!0,Ft().catch(()=>{}))};A(N);const q=(te=l.onTokenChange)==null?void 0:te.call(l,le=>{oe(le),g(),de.current.clear(),_e.current.clear(),A(le)});return()=>{q==null||q()}},[l,f,oe,g,Ft]);const ke=w.useCallback(async N=>{var te;const A=`Thread ${(te=crypto.randomUUID)==null?void 0:te.call(crypto)}`,q={threadId:A,title:N||"New Chat",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messageCount:0};E(le=>({byId:{...le.byId,[A]:q},order:[A,...le.order]})),I(A);try{const le=await l.createThread(N),Q=typeof le=="string"?le:le.threadId;return E(Be=>{const We=Be.byId[A];if(!We)return Be;const De={...Be.byId};delete De[A],De[Q]={...We,threadId:Q};const Xe=Be.order.map(yt=>yt===A?Q:yt);return{byId:De,order:Xe}}),I(Q),setTimeout(()=>Ft(),10),U(null),Q}catch(le){throw E(Q=>{if(!Q.byId[A])return Q;const Be={...Q.byId};delete Be[A];const We=Q.order.filter(De=>De!==A);return{byId:Be,order:We}}),I(null),U(String(le)),le}},[l,Ft]),$e=w.useCallback(async N=>{try{await l.deleteThread(N);let A=null;E(q=>{if(!q.byId[N])return q;const te={...q.byId};delete te[N];const le=q.order.filter(Be=>Be!==N),Q={byId:te,order:le};return A=Bi(Q),Q}),A&&_n(A,{immediate:!0}),gn(N),Pe.current===N&&(st.current=N,I(null),Pe.current=null,ze.current=null,jn()),await Ft(),U(null)}catch(A){throw U(String(A)),A}},[l,jn,gn,Ft,_n]),Me=w.useCallback(async(N,A)=>{try{await l.updateThread(N,A),E(q=>{const te=q.byId[N];return te?{byId:{...q.byId,[N]:{...te,title:A}},order:q.order}:q}),U(null)}catch(q){throw await Ft(),U(String(q)),q}},[l,Ft]),Te=w.useCallback(async(N,A,q,te=!1)=>{await mt(async()=>{if(st.current===N&&!te){st.current=null;return}if(Et.current===N&&!te)return;I(Rt=>Rt===N?Rt:N),Pe.current=N;const Be=Wc(N,A??null,q??null),We=_e.current.get(Be),De=!te&&!A&&!q&&We&&Date.now()-We.timestamp<qx,Xe=!te&&!A&&!q;let yt=!1;if(Xe){const Rt=tt.current.get(N);if(Rt)rr(Rt),yt=!0;else{const Pt=p(N);Pt&&(tt.current.set(N,Pt),rr(Pt),yt=!0)}}const jt=te||!yt||!!A||!!q,Rn=async Rt=>{Rt&&H(!0),Et.current=N;try{const Pt=await ut({threadId:N,checkpointId:A,checkpointNs:q},{force:te}),{latest:_o,checkpoints:jo,snapshots:Pn}=ji(Pt);sn(_o,"replace",N),pt(N,jo,"replace"),Qe(N,Pn,"replace"),G(null)}catch(Pt){throw(!yt||te||Rt)&&(i==null||i(String(Pt))),G(String(Pt)),Pt}finally{Et.current=null,Rt&&H(!1)}};jt?await Rn(!0):Xe&&yt&&!De&&Rn(!1).catch(Rt=>{console.warn("[ChatSessionProvider] Background refresh failed:",Rt)})},`loadThread-${N}`)},[rr,sn,mt,ut,i,pt,Qe]),It=w.useCallback(async()=>{await mt(async()=>{const N=Pe.current;N&&gn(N),st.current=null,I(null),Pe.current=null,ze.current=null,jn(),L(void 0),ee(void 0),se(void 0),z([]);try{localStorage.removeItem("lastThreadId")}catch(A){console.warn("[ChatSessionProvider] Failed to clear lastThreadId:",A)}},"clearCurrentThread")},[jn,gn,mt]),dt=w.useCallback(async(N,A)=>{var Q;const q=Pe.current;if(!q)throw new Error("No active thread");const te=Zr(N,A??null),le=(Q=xe.current.get(q))==null?void 0:Q.get(te);if(le){await mt(async()=>{sn(le,"replace",q,{persist:!1})},`navigateToCheckpoint-${q}-${te}`);return}await Te(q,N,A??void 0,!0)},[sn,mt,Te]),ht=w.useCallback(async()=>{if(!Pe.current)throw new Error("No active thread");await Te(Pe.current,void 0,void 0,!0)},[Te]),Bt=w.useCallback(async()=>{if(!Pe.current)throw new Error("No active thread");if(ce||!M)return;const N=ge;if(N){be(!0);try{const A=Pe.current,q=await ut({threadId:A,checkpointId:N??K??null,checkpointNs:me??Z??null}),{latest:te,checkpoints:le,snapshots:Q}=ji(q),Be=A?xe.current.get(A):null;let We=le.length>0;if(We&&Be&&Be.size>0&&(We=le.some(De=>{if(!(De!=null&&De.checkpointId))return!1;const Xe=Zr(De.checkpointId,De.checkpointNs??null);return!Be.has(Xe)})),!We){ye(null),se(void 0),Y(!1),G(null);return}sn(te,"prepend",A??void 0),A&&(pt(A,le,"prepend"),Qe(A,Q,"prepend")),G(null)}catch(A){throw G(String(A)),A}finally{be(!1)}}},[sn,ut,M,K,Z,me,ge,ce,pt,Qe]),Un=w.useCallback(N=>{if(N!=null&&N.threadId){if(N.checkpointId){const A=Zr(N.checkpointId,N.checkpointNs??null),q=Qt({...N,interrupt:N.interrupt??null},{cloneMessages:!0});Qe(N.threadId,{[A]:q},"prepend")}sn(N,"replace",N.threadId)}},[sn,Qe]),Jt=w.useCallback(async(N,A)=>{var Ro;const q=Pe.current,te=(N==null?void 0:N.text)??"",le=(N==null?void 0:N.attachments)??[],Q=le.length?le:(A==null?void 0:A.attachments)??[],Be={...(A==null?void 0:A.payloadExtras)??{},...(N==null?void 0:N.payload)??{}};if(!q&&!Object.keys(Be).length&&Q.length===0&&!te.trim()){console.warn("[ChatSessionProvider] Nothing to submit - skipping");return}!q&&!Be.messages&&console.warn("[ChatSessionProvider] No thread ID - message will create new thread");const{contentParts:We,filesInfo:De}=await rx(l,Q),Xe=[...We];te&&te.trim()&&Xe.push({type:"text",text:te.trim()});const yt=!!q,jt=yt?(A==null?void 0:A.checkpointId)??ae.lastCheckpointId??void 0:void 0,Rn=yt?(A==null?void 0:A.checkpointNs)??ae.lastCheckpointNs??void 0:void 0,Rt={id:((Ro=crypto.randomUUID)==null?void 0:Ro.call(crypto))||`user-${Date.now()}`,role:"user",content:Xe,createdAt:new Date().toISOString(),...jt!=null?{checkpointId:jt}:{},...Rn!=null?{checkpointNs:Rn}:{}};Xe.length>0&&Ue(Rt);const Pt={...Rt,content:Xe},_o=Q.length>0,jo={messages:Xe.length>0?[Pt]:[],files_info:De,...o&&_o&&s?{active_agent:s}:{},...Be},Pn={threadId:q??null,payload:jo,checkpointId:jt??null,checkpointNs:Rn??null,nodeFilter:(A==null?void 0:A.nodeFilter)??null,config:A==null?void 0:A.config,command:(A==null?void 0:A.command)??null};Pn.threadId||delete Pn.threadId,Pn.command||delete Pn.command,Wr(Pn,{onError:On=>{console.warn("[ChatSessionProvider] Stream error:",On)},onOpen:({threadId:On})=>{!Pe.current&&On&&(ae.messages.length<=1&&(st.current=On),I(On))},onGap:Tr})},[l,o,s,Tr,ae.lastCheckpointId,ae.lastCheckpointNs,ae.messages.length,Ue,Wr]),_t=w.useCallback(async(N,A,q)=>{if(!Pe.current)throw new Error("No active thread to handle interrupt");const le=A?q??!0:!1;try{try{He({type:"interrupt_response",payload:{interruptId:N}})}catch(Q){console.warn("[ChatSessionProvider] optimistic interrupt_response dispatch failed:",Q)}await Jt({payload:{}},{checkpointId:ae.lastCheckpointId??void 0,checkpointNs:ae.lastCheckpointNs??void 0,command:{kind:"resume",value:le}}),ne(null)}catch(Q){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${N}:`,Q),Q}},[He,ae.lastCheckpointId,ae.lastCheckpointNs,Jt]);w.useEffect(()=>{if(a==null||a(T),T)try{localStorage.setItem("lastThreadId",T)}catch(N){console.warn("[ChatSessionProvider] Failed to persist lastThreadId:",N)}},[T,a]),w.useEffect(()=>((async()=>{try{if(Ft().catch(A=>{console.error("[ChatSessionProvider] Failed to refresh threads (background):",A),i==null||i(String(A))}),!r&&!t)try{const A=localStorage.getItem("lastThreadId");A&&(I(A),n&&await Te(A))}catch(A){console.warn("[ChatSessionProvider] Failed to restore last thread:",A)}else t&&n&&await Te(t)}catch(A){console.error("[ChatSessionProvider] Initialization failed:",A),i==null||i(String(A))}})(),()=>{}),[]),w.useEffect(()=>{const N=Pe.current;if(!N||ze.current!==N)return;ae.messages.length&&ae.messages[ae.messages.length-1];const A=Qt({checkpointId:ae.lastCheckpointId??null,checkpointNs:ae.lastCheckpointNs??null,messages:ae.messages.slice(),nextCursor:ge??null,nextCursorNs:me??null,interrupt:ae.pendingInterrupt??W??null}),q=tt.current.get(N),te=q==null?void 0:q.snapshot,le=!te||te.messages.length!==A.messages.length||te.messages.some((De,Xe)=>{var yt;return(De==null?void 0:De.id)!==((yt=A.messages[Xe])==null?void 0:yt.id)}),Q=((te==null?void 0:te.checkpointId)??null)!==A.checkpointId||((te==null?void 0:te.checkpointNs)??null)!==A.checkpointNs,Be=((te==null?void 0:te.nextCursor)??null)!==A.nextCursor||((te==null?void 0:te.nextCursorNs)??null)!==A.nextCursorNs,We=!Fc((te==null?void 0:te.interrupt)??null,A.interrupt??null);if(le||Q||Be||We){const De={threadId:N,snapshot:A};tt.current.set(N,De),Hn.current&&window.clearTimeout(Hn.current),Hn.current=window.setTimeout(()=>{try{v(De,100)}catch(Xe){console.warn("[ChatSessionProvider] Failed to persist thread payload:",Xe)}},qo)}},[ge,me,ae.lastCheckpointId,ae.lastCheckpointNs,ae.messages,ae.pendingInterrupt,W,v]);const Ao=w.useMemo(()=>({threads:k,currentThreadId:T,setCurrentThreadId:I,isLoading:_,error:F,actions:{createThread:ke,deleteThread:$e,renameThread:Me,refreshThreads:()=>Ft()},persistThreadsCache:Ur,hydrateFromCache:ie}),[k,T,_,F,ke,$e,Me,Ft,Ur,ie,I]),Cl=w.useMemo(()=>{const N=ae.lastBranch??null,A=ae.assemblingId??null,q=N||A?{branchLabel:(N==null?void 0:N.branchLabel)??null,lastBranch:N,assemblingMessageId:A}:null;return{threadId:T,messages:ae.messages,interrupt:W,checkpoint:{id:ae.lastCheckpointId??null,namespace:ae.lastCheckpointNs??null},checkpoints:$,metadata:q,isLoading:j,isHistoryLoading:ce,error:D,hasMore:M,loadOlder:Bt,seedFromSnapshot:Un,clearState:jn,navigateToCheckpoint:dt,returnToLatest:ht,loadThread:Te,clearThread:It,respondToInterrupt:_t}},[It,jn,T,W,M,ce,j,Bt,Te,ae.assemblingId,ae.lastBranch,ae.lastCheckpointId,ae.lastCheckpointNs,ae.messages,dt,_t,ht,Un,D,$]),kl=w.useMemo(()=>({isStreaming:P,error:B,submit:Jt,send:Jt,stop:S,setAuthToken:oe}),[P,B,Jt,S,oe]);return c.jsx(Kx.Provider,{value:!0,children:c.jsx(Hc.Provider,{value:kl,children:c.jsx(zc.Provider,{value:Ao,children:c.jsx(Bc.Provider,{value:Cl,children:e})})})})}function Xo(){const e=w.useContext(zc);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Jo(){const e=w.useContext(Bc);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function Kc(){const e=w.useContext(Hc);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function Zo({children:e,apiConfig:t,initialThreadId:n=null,autoLoadInitial:r=!0,disableAutoRestore:o=!1,enableFileAgentRouting:s=!1,fileAgentId:i="invoice_reader",onError:a,onThreadChange:l}){return c.jsx(tx,{apiConfig:t,children:c.jsx(Jx,{initialThreadId:n,autoLoadInitial:r,disableAutoRestore:o,enableFileAgentRouting:s,fileAgentId:i,onError:a,onThreadChange:l,children:e})})}function re(...e){return _m.twMerge(Am.clsx(e))}const Zx=Po.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"}}),qe=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?or.Slot:"button";return c.jsx(i,{className:re(Zx({variant:t,size:n,className:e})),ref:s,...o})});qe.displayName="Button";const qc=m.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:re("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}));qc.displayName="Textarea";function Qx({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,onSend:i,onCancelEdit:a,onStop:l,className:u="",textareaClassName:d="",allowEmptySend:f=!1}){const[h,p]=w.useState(e),[v,x]=w.useTransition(),g=w.useRef(null),y=w.useRef(0),b=w.useRef(null);w.useEffect(()=>{p(e??""),b.current=null,g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const C=w.useCallback(()=>{const j=g.current;j&&(j.style.height="auto",j.style.height=`${j.scrollHeight}px`)},[]);w.useEffect(()=>{C()},[C]);const E=w.useCallback(async j=>{j&&j.preventDefault();const H=(h??"").trim();if(!H&&!f)return;const F=++y.current;b.current={id:F,shouldClear:!0},x(()=>{var U,D,G;try{const W=i(H);W&&typeof W.then=="function"?W.then(()=>{var ne,$;((ne=b.current)==null?void 0:ne.id)===F&&b.current.shouldClear&&(p(""),g.current&&(g.current.style.height="auto")),(($=b.current)==null?void 0:$.id)===F&&(b.current=null)}).catch(()=>{var ne;((ne=b.current)==null?void 0:ne.id)===F&&(b.current=null)}):(((U=b.current)==null?void 0:U.id)===F&&b.current.shouldClear&&(p(""),g.current&&(g.current.style.height="auto")),((D=b.current)==null?void 0:D.id)===F&&(b.current=null))}catch{((G=b.current)==null?void 0:G.id)===F&&(b.current=null)}})},[h,i,f]),k=w.useCallback(j=>{p(j.target.value),b.current&&(b.current.shouldClear=!1),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),T=w.useCallback(j=>{j.key==="Enter"&&!j.shiftKey?(j.preventDefault(),E()):j.key==="Escape"&&t&&(j.preventDefault(),a==null||a())},[E,t,a]),R=`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 c.jsx("form",{onSubmit:j=>void E(j),className:`w-full ${u}`,children:c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsx("div",{className:"flex-1",children:c.jsx(qc,{ref:g,value:h,onChange:k,onKeyDown:T,placeholder:t?"Edit your message...":n,className:R,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),c.jsx("div",{children:r?c.jsx(qe,{type:"button",onClick:()=>{l==null||l()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!l,children:c.jsx(ue.Square,{size:16})}):c.jsx(qe,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||v,children:c.jsx(ue.Send,{size:16})})})]})})}const ey=w.memo(Qx),Qo=0,Vn=1,Ar=2,Gc=4;function Yc(e){return()=>e}function ty(e){e()}function Xc(e,t){return n=>e(t(n))}function Jc(e,t){return()=>e(t)}function ny(e,t){return n=>e(t,n)}function Ui(e){return e!==void 0}function ry(...e){return()=>{e.map(ty)}}function _r(){}function es(e,t){return t(e),e}function oy(e,t){return t(e)}function it(...e){return e}function Ye(e,t){return e(Vn,t)}function Oe(e,t){e(Qo,t)}function Wi(e){e(Ar)}function xt(e){return e(Gc)}function ve(e,t){return Ye(e,ny(t,Qo))}function cn(e,t){const n=e(Vn,r=>{n(),t(r)});return n}function Zc(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Qc(e,t){return e===t}function at(e=Qc){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ee(e){return t=>n=>{e(n)&&t(n)}}function fe(e){return t=>Xc(t,e)}function vn(e){return t=>()=>{t(e)}}function V(e,...t){const n=sy(...t);return(r,o)=>{switch(r){case Ar:Wi(e);return;case Vn:return Ye(e,n(o))}}}function bn(e,t){return n=>r=>{n(t=e(t,r))}}function cr(e){return t=>n=>{e>0?e--:t(n)}}function Dn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Le(...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);Ye(s,l=>{const u=n;n=n|a,t[i]=l,u!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function sy(...e){return t=>e.reduceRight(oy,t)}function iy(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Vn:return s?n===s?void 0:(r(),n=s,t=Ye(e,s),t):(r(),_r);case Ar:r(),n=null;return}}}function J(e){let t=e;const n=Ke();return(r,o)=>{switch(r){case Qo:t=o;break;case Vn:{o(t);break}case Gc:return t}return n(r,o)}}function Mt(e,t){return es(J(t),n=>ve(e,n))}function Ke(){const e=[];return(t,n)=>{switch(t){case Qo:e.slice().forEach(r=>{r(n)});return;case Ar:e.splice(0,e.length);return;case Vn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Kt(e){return es(Ke(),t=>ve(e,t))}function Ge(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:ay(),singleton:n}}const ay=()=>Symbol();function ly(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(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function vt(...e){const t=Ke(),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);Ye(s,l=>{n[i]=l,r=r|a,r===o&&Oe(t,n)})}),function(s,i){switch(s){case Ar:{Wi(t);return}case Vn:return r===o&&i(n),Ye(t,i)}}}function Ce(e,t=Qc){return V(e,at(t))}function Vi(...e){return function(t,n){switch(t){case Ar:return;case Vn:return ry(...e.map(r=>Ye(r,n)))}}}var Wt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Wt||{});const cy={0:"debug",3:"error",1:"log",2:"warn"},uy=()=>typeof globalThis>"u"?window:globalThis,Kn=Ge(()=>{const e=J(3);return{log:J((t,n,r=1)=>{var o;const s=(o=uy().VIRTUOSO_LOG_LEVEL)!=null?o:xt(e);r>=s&&console[cy[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function ur(e,t,n){return Ki(e,t,n).callbackRef}function Ki(e,t,n){const r=w.useRef(null);let o=i=>{};const s=w.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};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 dy(e,t,n,r,o,s,i,a,l){const u=w.useCallback(d=>{const f=fy(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const p=h.lastElementChild.dataset.viewportType==="window";let v;p&&(v=h.ownerDocument.defaultView);const x=i?a?i.scrollLeft:i.scrollTop:p?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:p?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:p?a?v.innerWidth:v.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(x,0),viewportHeight:y}),s==null||s(a?eu("column-gap",getComputedStyle(d).columnGap,o):eu("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return Ki(u,n,l)}function fy(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 l=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},Wt.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function eu(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Wt.WARN),t==="normal"?0:parseInt(t??"0",10)}function tu(e,t,n){const r=w.useRef(null),o=w.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const u=l.getBoundingClientRect(),d=u.width;let f,h;if(t){const p=t.getBoundingClientRect(),v=u.top-p.top;h=p.height-Math.max(0,v),f=v+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;h=p.innerHeight-Math.max(0,u.top),f=u.top+p.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Ki(o,!0,n),a=w.useCallback(()=>{o(i.current)},[o,i]);return w.useEffect(()=>{var l;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=(l=i.current)==null?void 0:l.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 $t=Ge(()=>{const e=Ke(),t=Ke(),n=J(0),r=Ke(),o=J(0),s=Ke(),i=Ke(),a=J(0),l=J(0),u=J(0),d=J(0),f=Ke(),h=Ke(),p=J(!1),v=J(!1),x=J(!1);return ve(V(e,fe(({scrollTop:g})=>g)),t),ve(V(e,fe(({scrollHeight:g})=>g)),i),ve(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:x,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),eo={lvl:0};function nu(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:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function rt(e){return e===eo}function to(e,t){if(!rt(e))return t===e.k?e.v:t<e.k?to(e.l,t):to(e.r,t)}function un(e,t,n="k"){if(rt(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=un(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return un(e.l,t,n)}function qt(e,t,n){return rt(e)?su(t,n,1):t===e.k?St(e,{k:t,v:n}):t<e.k?iu(St(e,{l:qt(e.l,t,n)})):iu(St(e,{r:qt(e.r,t,n)}))}function jr(){return eo}function ts(e,t,n){if(rt(e))return[];const r=un(e,t)[0];return hy(Gi(e,r,n))}function qi(e,t){if(rt(e))return eo;const{k:n,l:r,r:o}=e;if(t===n){if(rt(r))return o;if(rt(o))return r;{const[s,i]=ou(r);return ns(St(e,{k:s,l:ru(r),v:i}))}}else return t<n?ns(St(e,{l:qi(r,t)})):ns(St(e,{r:qi(o,t)}))}function dr(e){return rt(e)?[]:[...dr(e.l),{k:e.k,v:e.v},...dr(e.r)]}function Gi(e,t,n){if(rt(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Gi(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Gi(s,t,n))),a}function ns(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(Yi(t))return au(St(e,{lvl:n-1}));if(!rt(t)&&!rt(t.r))return St(t.r,{l:St(t,{r:t.r.l}),lvl:n,r:St(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Yi(e))return Xi(St(e,{lvl:n-1}));if(!rt(r)&&!rt(r.l)){const o=r.l,s=Yi(o)?r.lvl-1:r.lvl;return St(o,{l:St(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Xi(St(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function St(e,t){return su(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 ru(e){return rt(e.r)?e.l:ns(St(e,{r:ru(e.r)}))}function Yi(e){return rt(e)||e.lvl>e.r.lvl}function ou(e){return rt(e.r)?[e.k,e.v]:ou(e.r)}function su(e,t,n,r=eo,o=eo){return{k:e,l:r,lvl:n,r:o,v:t}}function iu(e){return Xi(au(e))}function au(e){const{l:t}=e;return!rt(t)&&t.lvl===e.lvl?St(t,{r:St(e,{l:t.r})}):e}function Xi(e){const{lvl:t,r:n}=e;return!rt(n)&&!rt(n.r)&&n.lvl===t&&n.r.lvl===t?St(n,{l:St(e,{r:n.l}),lvl:t+1}):e}function hy(e){return nu(e,({k:t,v:n})=>({index:t,value:n}))}function lu(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function no(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ji=Ge(()=>({recalcInProgress:J(!1)}),[],{singleton:!0});function cu(e,t,n){return e[rs(e,t,n)]}function rs(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 py(e,t,n,r){const o=rs(e,t,r),s=rs(e,n,r,o);return e.slice(o,s+1)}function qn(e,t){return Math.round(e.getBoundingClientRect()[t])}function os(e){return!rt(e.groupOffsetTree)}function Zi({index:e},t){return t===e?0:t<e?-1:1}function my(){return{groupIndices:[],groupOffsetTree:jr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:jr()}}function gy(e,t){let n=rt(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),rt(e)){e=qt(e,0,s);continue}const a=ts(e,i-1,o+1);if(a.some(Cy(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=qi(e,f)):(u=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=qt(e,o+1,h));u&&(e=qt(e,i,s))}return[e,n]}function xy(e){return typeof e.groupIndex<"u"}function yy({offset:e},t){return t===e?0:t<e?-1:1}function ro(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=cu(t,e,Zi),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function uu(e,t){if(!os(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function du(e,t,n){if(xy(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=uu(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function vy(e,t,n,r=0){return r>0&&(t=Math.max(t,cu(e,r,Zi).offset)),nu(py(e,t,n,yy),Sy)}function by(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Wt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&rt(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((v,x)=>qt(qt(v,x,h),x+1,p),i)}else[i,a]=gy(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=Qi(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>qt(h,p,ro(p,f,o)),jr()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function wy(e){return dr(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 fu(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 Qi(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=rs(o,t-1,Zi),a=o[l].offset;const u=un(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===un(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:u,value:d}of ts(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 Sy(e){return{index:e.index,value:e}}function Cy(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 ky={offsetHeight:"height",offsetWidth:"width"},wn=Ge(([{log:e},{recalcInProgress:t}])=>{const n=Ke(),r=Ke(),o=Mt(r,0),s=Ke(),i=Ke(),a=J(0),l=J([]),u=J(void 0),d=J(void 0),f=J((k,T)=>qn(k,ky[T])),h=J(void 0),p=J(0),v=my(),x=Mt(V(n,Le(l,e,p),bn(by,v),at()),v),g=Mt(V(l,at(),bn((k,T)=>({current:T,prev:k.current}),{current:[],prev:[]}),fe(({prev:k})=>k)),[]);ve(V(l,Ee(k=>k.length>0),Le(x,p),fe(([k,T,I])=>{const _=k.reduce((R,j,H)=>qt(R,j,ro(j,T.offsetTree,I)||H),jr());return{...T,groupIndices:k,groupOffsetTree:_}})),x),ve(V(r,Le(x),Ee(([k,{lastIndex:T}])=>k<T),fe(([k,{lastIndex:T,lastSize:I}])=>[{endIndex:T,size:I,startIndex:k}])),n),ve(u,d);const y=Mt(V(u,fe(k=>k===void 0)),!0);ve(V(d,Ee(k=>k!==void 0&&rt(xt(x).sizeTree)),fe(k=>[{endIndex:0,size:k,startIndex:0}])),n);const b=Kt(V(n,Le(x),bn(({sizes:k},[T,I])=>({changed:I!==k,sizes:I}),{changed:!1,sizes:v}),fe(k=>k.changed)));Ye(V(a,bn((k,T)=>({diff:k.prev-T,prev:T}),{diff:0,prev:0}),fe(k=>k.diff)),k=>{const{groupIndices:T}=xt(x);if(k>0)Oe(t,!0),Oe(s,k+fu(k,T));else if(k<0){const I=xt(g);I.length>0&&(k-=fu(-k,I)),Oe(i,k)}}),Ye(V(a,Le(e)),([k,T])=>{k<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},Wt.ERROR)});const C=Kt(s);ve(V(s,Le(x),fe(([k,T])=>{const I=T.groupIndices.length>0,_=[],R=T.lastSize;if(I){const j=to(T.sizeTree,0);let H=0,F=0;for(;H<k;){const D=T.groupIndices[F],G=T.groupIndices.length===F+1?1/0:T.groupIndices[F+1]-D-1;_.push({endIndex:D,size:j,startIndex:D}),_.push({endIndex:D+1+G-1,size:R,startIndex:D+1}),F++,H+=G+1}const U=dr(T.sizeTree);return H!==k&&U.shift(),U.reduce((D,{k:G,v:W})=>{let ne=D.ranges;return D.prevSize!==0&&(ne=[...D.ranges,{endIndex:G+k-1,size:D.prevSize,startIndex:D.prevIndex}]),{prevIndex:G+k,prevSize:W,ranges:ne}},{prevIndex:k,prevSize:0,ranges:_}).ranges}return dr(T.sizeTree).reduce((j,{k:H,v:F})=>({prevIndex:H+k,prevSize:F,ranges:[...j.ranges,{endIndex:H+k-1,size:j.prevSize,startIndex:j.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),n);const E=Kt(V(i,Le(x,p),fe(([k,{offsetTree:T},I])=>{const _=-k;return ro(_,T,I)})));return ve(V(i,Le(x,p),fe(([k,T,I])=>{if(T.groupIndices.length>0){if(rt(T.sizeTree))return T;let _=jr();const R=xt(g);let j=0,H=0,F=0;for(;j<-k;){F=R[H];const U=R[H+1]-F-1;H++,j+=U+1}if(_=dr(T.sizeTree).reduce((U,{k:D,v:G})=>qt(U,Math.max(0,D+k),G),_),j!==-k){const U=to(T.sizeTree,F);_=qt(_,0,U);const D=un(T.sizeTree,-k+1)[1];_=qt(_,1,D)}return{...T,sizeTree:_,...Qi(T.offsetTree,0,_,I)}}else{const _=dr(T.sizeTree).reduce((R,{k:j,v:H})=>qt(R,Math.max(0,j+k),H),jr());return{...T,sizeTree:_,...Qi(T.offsetTree,0,_,I)}}})),x),{beforeUnshiftWith:C,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:x,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},it(Kn,Ji),{singleton:!0});function Ty(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const hu=Ge(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Ke(),i=Ke(),a=Kt(V(s,fe(Ty)));return ve(V(a,fe(l=>l.totalCount)),n),ve(V(a,fe(l=>l.groupIndices)),e),ve(V(vt(o,t,r),Ee(([l,u])=>os(u)),fe(([l,u,d])=>un(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),at(),fe(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},it(wn,$t)),Gn=Ge(([{log:e}])=>{const t=J(!1),n=Kt(V(t,Ee(r=>r),at()));return Ye(t,r=>{r&&xt(e)("props updated",{},Wt.DEBUG)}),{didMount:n,propsReady:t}},it(Kn),{singleton:!0}),Ey=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function pu(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Ey)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const oo=Ge(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const p=Ke(),v=Ke(),x=J(0);let g=null,y=null,b=null;function C(){g&&(g(),g=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),Oe(l,!1)}return ve(V(p,Le(n,f,r,x,a,i,h),Le(e,s,o),fe(([[E,k,T,I,_,R,j,H],F,U,D])=>{const G=pu(E),{align:W,behavior:ne,offset:$}=G,z=I-1,ie=du(G,k,z);let M=ro(ie,k.offsetTree,F)+R;W==="end"?(M+=U+un(k.sizeTree,ie)[1]-T+D,ie===z&&(M+=j)):W==="center"?M+=(U+un(k.sizeTree,ie)[1]-T+D)/2:M-=_,$&&(M+=$);const Y=ce=>{C(),ce?(H("retrying to scroll to",{location:E},Wt.DEBUG),Oe(p,E)):(Oe(v,!0),H("list did not change, scroll successful",{},Wt.DEBUG))};if(C(),ne==="smooth"){let ce=!1;b=Ye(t,be=>{ce=ce||be}),g=cn(d,()=>{Y(ce)})}else g=cn(V(t,Iy(150)),Y);return y=setTimeout(()=>{C()},1200),Oe(l,!0),H("scrolling from index to",{behavior:ne,index:ie,top:M},Wt.DEBUG),{behavior:ne,top:M}})),u),{scrollTargetReached:v,scrollToIndex:p,topListHeight:x}},it(wn,$t,Kn),{singleton:!0});function Iy(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function ea(e,t){e==0?t():requestAnimationFrame(()=>{ea(e-1,t)})}function ta(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const so=Ge(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=J(!0),l=J(0),u=J(!0);return ve(V(i,Le(l),Ee(([d,f])=>!!f),vn(!1)),a),ve(V(i,Le(l),Ee(([d,f])=>!!f),vn(!1)),u),Ye(V(vt(t,i),Le(a,n,e,u),Ee(([[,d],f,{sizeTree:h},p,v])=>d&&(!rt(h)||Ui(p))&&!f&&!v),Le(l)),([,d])=>{cn(o,()=>{Oe(u,!0)}),ea(4,()=>{cn(r,()=>{Oe(a,!0)}),Oe(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},it(wn,$t,oo,Gn),{singleton:!0});function mu(e,t){return Math.abs(e-t)<1.01}const io="up",ao="down",Ny="none",Ay={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},_y=0,lo=Ge(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=J(!1),a=J(!0),l=Ke(),u=Ke(),d=J(4),f=J(_y),h=Mt(V(Vi(V(Ce(o),cr(1),vn(!0)),V(Ce(o),cr(1),vn(!1),Zc(100))),at()),!1),p=Mt(V(Vi(V(n,vn(!0)),V(n,vn(!1),Zc(200))),at()),!1);ve(V(vt(Ce(o),Ce(f)),fe(([b,C])=>b<=C),at()),a),ve(V(a,Dn(50)),u);const v=Kt(V(vt(r,Ce(s),Ce(t),Ce(e),Ce(d)),bn((b,[{scrollHeight:C,scrollTop:E},k,T,I,_])=>{const R=E+k-C>-_,j={scrollHeight:C,scrollTop:E,viewportHeight:k};if(R){let F,U;return E>b.state.scrollTop?(F="SCROLLED_DOWN",U=b.state.scrollTop-E):(F="SIZE_DECREASED",U=b.state.scrollTop-E||b.scrollTopDelta),{atBottom:!0,atBottomBecause:F,scrollTopDelta:U,state:j}}let H;return j.scrollHeight>b.state.scrollHeight?H="SIZE_INCREASED":k<b.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":E<b.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:j}},Ay),at((b,C)=>b&&b.atBottom===C.atBottom))),x=Mt(V(r,bn((b,{scrollHeight:C,scrollTop:E,viewportHeight:k})=>{if(mu(b.scrollHeight,C))return{changed:!1,jump:0,scrollHeight:C,scrollTop:E};{const T=C-(E+k)<1;return b.scrollTop!==E&&T?{changed:!0,jump:b.scrollTop-E,scrollHeight:C,scrollTop:E}:{changed:!0,jump:0,scrollHeight:C,scrollTop:E}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ee(b=>b.changed),fe(b=>b.jump)),0);ve(V(v,fe(b=>b.atBottom)),i),ve(V(i,Dn(50)),l);const g=J(ao);ve(V(r,fe(({scrollTop:b})=>b),at(),bn((b,C)=>xt(p)?{direction:b.direction,prevScrollTop:C}:{direction:C<b.prevScrollTop?io:ao,prevScrollTop:C},{direction:ao,prevScrollTop:0}),fe(b=>b.direction)),g),ve(V(r,Dn(50),vn(Ny)),g);const y=J(0);return ve(V(h,Ee(b=>!b),vn(0)),y),ve(V(o,Dn(100),Le(h),Ee(([b,C])=>!!C),bn(([b,C],[E])=>[C,E],[0,0]),fe(([b,C])=>C-b)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:x,scrollDirection:g,scrollVelocity:y}},it($t)),ss="top",is="bottom",gu="none";function xu(e,t,n){return typeof e=="number"?n===io&&t===ss||n===ao&&t===is?e:0:n===io?t===ss?e.main:e.reverse:t===is?e.main:e.reverse}function yu(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const na=Ge(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Ke(),i=J(0),a=J(0),l=J(0),u=Mt(V(vt(Ce(r),Ce(o),Ce(n),Ce(s,no),Ce(l),Ce(i),Ce(t),Ce(e),Ce(a)),fe(([d,f,h,[p,v],x,g,y,b,C])=>{const E=d-b,k=g+y,T=Math.max(h-E,0);let I=gu;const _=yu(C,ss),R=yu(C,is);return p-=b,p+=h+y,v+=h+y,v-=b,p>d+k-_&&(I=io),v<d-T+f+R&&(I=ao),I!==gu?[Math.max(E-h-xu(x,ss,I)-_,0),E-T-y+f+xu(x,is,I)+R]:null}),Ee(d=>d!=null),at(no)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},it($t),{singleton:!0});function jy(e,t,n){if(os(t)){const r=uu(e,t);return[{index:un(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 ra={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function as(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const x=e[e.length-1];d=x.offset+x.size}const f=n-i,h=a+f*l+(f-1)*r,p=u,v=h-d;return{bottom:d,firstItemIndex:s,items:bu(e,o,s),offsetBottom:v,offsetTop:u,top:p,topItems:bu(t,o,s),topListHeight:t.reduce((x,g)=>g.size+x,0),totalCount:n}}function vu(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,l=ta(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return as(u,[],a,o,n,r)}function bu(e,t,n){if(e.length===0)return[];if(!os(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=ts(t.groupOffsetTree,r,o);let a,l=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:u.index-(l+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const fr=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:p},{recalcInProgress:v}])=>{const x=J([]),g=J(0),y=Ke();ve(s.topItemsIndexes,x);const b=Mt(V(vt(p,v,Ce(l,no),Ce(o),Ce(r),Ce(u),d,Ce(x),Ce(t),Ce(n),e),Ee(([T,I,,_,,,,,,,R])=>{const j=R&&R.length!==_;return T&&!I&&!j}),fe(([,,[T,I],_,R,j,H,F,U,D,G])=>{const W=R,{offsetTree:ne,sizeTree:$}=W,z=xt(g);if(_===0)return{...ra,totalCount:_};if(T===0&&I===0)return z===0?{...ra,totalCount:_}:vu(z,j,R,U,D,G||[]);if(rt($))return z>0?null:as(jy(ta(j,_),W,G),[],_,D,W,U);const ie=[];if(F.length>0){const ge=F[0],ye=F[F.length-1];let K=0;for(const L of ts($,ge,ye)){const Z=L.value,ee=Math.max(L.start,ge),me=Math.min(L.end,ye);for(let se=ee;se<=me;se++)ie.push({data:G==null?void 0:G[se],index:se,offset:K,size:Z}),K+=Z}}if(!H)return as([],ie,_,D,W,U);const M=F.length>0?F[F.length-1]+1:0,Y=vy(ne,T,I,M);if(Y.length===0)return null;const ce=_-1,be=es([],ge=>{for(const ye of Y){const K=ye.value;let L=K.offset,Z=ye.start;const ee=K.size;if(K.offset<T){Z+=Math.floor((T-K.offset+D)/(ee+D));const se=Z-ye.start;L+=se*ee+se*D}Z<M&&(L+=(M-Z)*ee,Z=M);const me=Math.min(ye.end,ce);for(let se=Z;se<=me&&!(L>=I);se++)ge.push({data:G==null?void 0:G[se],index:se,offset:L,size:ee}),L+=ee+D}});return as(be,ie,_,D,W,U)}),Ee(T=>T!==null),at()),ra);ve(V(e,Ee(Ui),fe(T=>T==null?void 0:T.length)),o),ve(V(b,fe(T=>T.topListHeight)),f),ve(f,a),ve(V(b,fe(T=>[T.top,T.bottom])),i),ve(V(b,fe(T=>T.items)),y);const C=Kt(V(b,Ee(({items:T})=>T.length>0),Le(o,e),Ee(([{items:T},I])=>T[T.length-1].originalIndex===I-1),fe(([,T,I])=>[T-1,I]),at(no),fe(([T])=>T))),E=Kt(V(b,Dn(200),Ee(({items:T,topItems:I})=>T.length>0&&T[0].originalIndex===I.length),fe(({items:T})=>T[0].index),at())),k=Kt(V(b,Ee(({items:T})=>T.length>0),fe(({items:T})=>{let I=0,_=T.length-1;for(;T[I].type==="group"&&I<_;)I++;for(;T[_].type==="group"&&_>I;)_--;return{endIndex:T[_].index,startIndex:T[I].index}}),at(lu)));return{endReached:C,initialItemCount:g,itemsRendered:y,listState:b,rangeChanged:k,startReached:E,topItemsIndexes:x,...h}},it(wn,hu,na,so,oo,lo,Gn,Ji),{singleton:!0}),wu=Ge(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Ke(),i=Mt(V(vt(n,e,r,t,o),fe(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return ve(Ce(i),s),{totalListHeight:i,totalListHeightChanged:s}},it($t,fr),{singleton:!0}),Ry=Ge(([{viewportHeight:e},{totalListHeight:t}])=>{const n=J(!1),r=Mt(V(vt(n,e,t),Ee(([o])=>o),fe(([,o,s])=>Math.max(0,o-s)),Dn(0),at()),0);return{alignToBottom:n,paddingTopAddition:r}},it($t,wu),{singleton:!0}),Su=Ge(()=>({context:J(null)})),Py=({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,Cu=Ge(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:u}])=>{const d=Ke();return ve(V(d,Le(t,l,n,s,o,r,a),Le(e),fe(([[f,h,p,v,x,g,y,b],C])=>{const{align:E,behavior:k,calculateViewLocation:T=Py,done:I,..._}=f,R=du(f,h,v-1),j=ro(R,h.offsetTree,C)+x+g,H=j+un(h.sizeTree,R)[1],F=b+g,U=b+p-y,D=T({itemBottom:H,itemTop:j,locationParams:{align:E,behavior:k,..._},viewportBottom:U,viewportTop:F});return D?I&&cn(V(i,Ee(G=>!G),cr(xt(i)?1:2)),I):I&&I(),D}),Ee(f=>f!==null)),u),{scrollIntoView:d}},it(wn,$t,oo,fr,Kn),{singleton:!0});function ku(e){return e?e==="smooth"?"smooth":"auto":!1}const Oy=(e,t)=>typeof e=="function"?ku(e(t)):t&&ku(e),My=Ge(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:u},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:p}])=>{const v=J(!1),x=Ke();let g=null;function y(k){Oe(i,{align:"end",behavior:k,index:"LAST"})}Ye(V(vt(V(Ce(t),cr(1)),l),Le(Ce(v),s,a,f),fe(([[k,T],I,_,R,j])=>{let H=T&&R,F="auto";return H&&(F=Oy(I,_||j),H=H&&!!F),{followOutputBehavior:F,shouldFollow:H,totalCount:k}}),Ee(({shouldFollow:k})=>k)),({followOutputBehavior:k,totalCount:T})=>{g&&(g(),g=null),xt(n)?requestAnimationFrame(()=>{xt(d)("following output to ",{totalCount:T},Wt.DEBUG),y(k)}):g=cn(e,()=>{xt(d)("following output to ",{totalCount:T},Wt.DEBUG),y(k),g=null})});function b(k){const T=cn(o,I=>{k&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(xt(d)("scrolling to bottom due to increased size",{},Wt.DEBUG),y("auto"))});setTimeout(T,100)}Ye(V(vt(Ce(v),t,u),Ee(([k,,T])=>k&&T),bn(({value:k},[,T])=>({refreshed:k===T,value:T}),{refreshed:!1,value:0}),Ee(({refreshed:k})=>k),Le(v,t)),([,k])=>{xt(a)&&b(k!==!1)}),Ye(x,()=>{b(xt(v)!==!1)}),Ye(vt(Ce(v),o),([k,T])=>{k&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const C=J(null),E=Ke();return ve(Vi(V(Ce(r),fe(k=>{var T;return(T=k==null?void 0:k.length)!=null?T:0})),V(Ce(t))),E),Ye(V(vt(V(E,cr(1)),l),Le(Ce(C),a,f,h),fe(([[k,T],I,_,R,j])=>T&&_&&(I==null?void 0:I({context:j,totalCount:k,scrollingInProgress:R}))),Ee(k=>!!k),Dn(0)),k=>{g&&(g(),g=null),xt(n)?requestAnimationFrame(()=>{xt(d)("scrolling into view",{}),Oe(p,k)}):g=cn(e,()=>{xt(d)("scrolling into view",{}),Oe(p,k),g=null})}),{autoscrollToBottom:x,followOutput:v,scrollIntoViewOnChange:C}},it(wn,lo,oo,so,Gn,Kn,$t,Su,Cu)),Dy=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ve(V(a,Le(s),Ee(([,l])=>l!==0),Le(o,r,t,n,e),fe(([[,l],u,d,f,h,p=[]])=>vu(l,u,d,f,h,p))),i),{}),it(wn,so,fr,Gn),{singleton:!0}),Ly=Ge(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=J(0);return Ye(V(e,Le(r),Ee(([,o])=>o!==0),fe(([,o])=>({top:o}))),o=>{cn(V(n,cr(1),Ee(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Oe(t,o)})})}),{initialScrollTop:r}},it(Gn,$t,fr),{singleton:!0}),Tu=Ge(([{scrollVelocity:e}])=>{const t=J(!1),n=Ke(),r=J(!1);return ve(V(e,Le(r,t,n),Ee(([o,s])=>!!s),fe(([o,s,i,a])=>{const{enter:l,exit:u}=s;if(i){if(u(o,a))return!1}else if(l(o,a))return!0;return i}),at()),t),Ye(V(vt(t,e,n),Le(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},it(lo),{singleton:!0}),oa=Ge(([{scrollContainerState:e,scrollTo:t}])=>{const n=Ke(),r=Ke(),o=Ke(),s=J(!1),i=J(void 0);return ve(V(vt(n,r),fe(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),ve(V(t,Le(r),fe(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},it($t)),Fy=Ge(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=Ke(),d=J(void 0),f=J(null),h=J(null);return ve(a,f),ve(l,h),Ye(V(u,Le(t,r,i,f,h,n)),([p,v,x,g,y,b,C])=>{const E=wy(v.sizeTree);g&&y!==null&&b!==null&&(x=y.scrollTop-b.offsetTop),x-=C,p({ranges:E,scrollTop:x})}),ve(V(d,Ee(Ui),fe($y)),o),ve(V(s,Le(d),Ee(([,p])=>p!==void 0),at(),fe(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},it(wn,$t,so,Gn,oa));function $y(e){return{align:"start",index:0,offset:e.scrollTop}}const zy=Ge(([{topItemsIndexes:e}])=>{const t=J(0);return ve(V(t,Ee(n=>n>=0),fe(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},it(fr));function Eu(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const By=Eu(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Hy=Ge(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:h},{log:p},{recalcInProgress:v}])=>{const x=Kt(V(l,Le(i),bn(([,y,b,C],[{bottom:E,items:k,offsetBottom:T,totalCount:I},_])=>{const R=E+T;let j=0;return b===I&&y.length>0&&k.length>0&&(k[0].originalIndex===0&&y[0].originalIndex===0||(j=R-C,j!==0&&(j+=_))),[j,k,I,R]},[0,[],0,0]),Ee(([y])=>y!==0),Le(r,a,n,o,p,v),Ee(([,y,b,C,,,E])=>!E&&!C&&y!==0&&b===io),fe(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},Wt.DEBUG),y))));function g(y){y>0?(Oe(t,{behavior:"auto",top:-y}),Oe(e,0)):(Oe(e,0),Oe(t,{behavior:"auto",top:-y}))}return Ye(V(x,Le(e,s)),([y,b,C])=>{C&&By()?Oe(e,b-y):g(-y)}),Ye(V(vt(Mt(s,!1),e,v),Ee(([y,b,C])=>!y&&!C&&b!==0),fe(([y,b])=>b),Dn(1)),g),ve(V(f,fe(y=>({top:-y}))),t),Ye(V(u,Le(h,d),fe(([y,{groupIndices:b,lastSize:C,sizeTree:E},k])=>{function T(I){return I*(C+k)}if(b.length===0)return T(y);{let I=0;const _=to(E,0);let R=0,j=0;for(;R<y;){R++,I+=_;let H=b.length===j+1?1/0:b[j+1]-b[j]-1;R+H>y&&(I-=_,H=y-R+1),R+=H,I+=T(H),j++}return I}})),y=>{Oe(e,y),requestAnimationFrame(()=>{Oe(t,{top:y}),requestAnimationFrame(()=>{Oe(e,0),Oe(v,!1)})})}),{deviation:e}},it($t,lo,fr,wn,Kn,Ji)),Uy=Ge(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),it(na,Dy,Gn,Tu,wu,Ly,Ry,oa,Cu,Kn,Su)),Iu=Ge(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:v},x,g,y,{listState:b,topItemsIndexes:C,...E},{scrollToIndex:k},T,{topItemCount:I},{groupCounts:_},R])=>(ve(E.rangeChanged,R.scrollSeekRangeChanged),ve(V(R.windowViewportRect,fe(j=>j.visibleHeight)),x.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:_,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:v,sizeRanges:a,topItemCount:I,topItemsIndexes:C,totalCount:d,...y,groupIndices:s,itemSize:i,listState:b,scrollToIndex:k,statefulTotalCount:u,trackItemSizes:f,...E,...R,...x,sizes:l,...g}),it(wn,so,$t,Fy,My,fr,oo,Hy,zy,hu,Uy));function Wy(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 ls=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Nu(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=w.createContext({});function l(g,y){g.propsReady&&Oe(g.propsReady,!1);for(const b of r){const C=g[t.required[b]];Oe(C,y[b])}for(const b of o)if(b in y){const C=g[t.optional[b]];Oe(C,y[b])}g.propsReady&&Oe(g.propsReady,!0)}function u(g){return s.reduce((y,b)=>(y[b]=C=>{const E=g[t.methods[b]];Oe(E,C)},y),{})}function d(g){return i.reduce((y,b)=>(y[b]=iy(g[t.events[b]]),y),{})}const f=w.forwardRef((g,y)=>{const{children:b,...C}=g,[E]=w.useState(()=>es(ly(e),I=>{l(I,C)})),[k]=w.useState(Jc(d,E));ls(()=>{for(const I of i)I in C&&Ye(k[I],C[I]);return()=>{Object.values(k).map(Wi)}},[C,k,E]),ls(()=>{l(E,C)}),w.useImperativeHandle(y,Yc(u(E)));const T=n;return c.jsx(a.Provider,{value:E,children:n?c.jsx(T,{...Wy([...r,...o,...i],C),children:b}):b})}),h=g=>{const y=w.useContext(a);return w.useCallback(b=>{Oe(y[g],b)},[y,g])},p=g=>{const y=w.useContext(a)[g],b=w.useCallback(C=>Ye(y,C),[y]);return w.useSyncExternalStore(b,()=>xt(y),()=>xt(y))},v=g=>{const y=w.useContext(a)[g],[b,C]=w.useState(Jc(xt,y));return ls(()=>Ye(y,E=>{E!==b&&C(Yc(E))}),[y,b]),b},x=w.version.startsWith("18")?p:v;return{Component:f,useEmitter:(g,y)=>{const b=w.useContext(a)[g];ls(()=>Ye(b,y),[y,b])},useEmitterValue:x,usePublisher:h}}const Au=w.createContext(void 0),_u=w.createContext(void 0),ju=typeof document<"u"?w.useLayoutEffect:w.useEffect;function sa(e){return"self"in e}function Vy(e){return"body"in e}function Ru(e,t,n,r=_r,o,s){const i=w.useRef(null),a=w.useRef(null),l=w.useRef(null),u=w.useCallback(h=>{let p,v,x;const g=h.target;if(Vy(g)||sa(g)){const b=sa(g)?g:g.defaultView;x=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,v=s?b.innerWidth:b.innerHeight}else x=s?g.scrollLeft:g.scrollTop,p=s?g.scrollWidth:g.scrollHeight,v=s?g.offsetWidth:g.offsetHeight;const y=()=>{e({scrollHeight:p,scrollTop:Math.max(x,0),viewportHeight:v})};h.suppressFlushSync?y():pi.flushSync(y),a.current!==null&&(x===a.current||x<=0||x===p-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);w.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 p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const v=h.behavior==="smooth";let x,g,y;sa(p)?(g=Math.max(qn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),x=s?p.innerWidth:p.innerHeight,y=s?window.scrollX:window.scrollY):(g=p[s?"scrollWidth":"scrollHeight"],x=qn(p,s?"width":"height"),y=p[s?"scrollLeft":"scrollTop"]);const b=g-x;if(h.top=Math.ceil(Math.max(Math.min(b,h.top),0)),mu(x,g)||h.top===y){e({scrollHeight:g,scrollTop:y,viewportHeight:x}),v&&t(!0);return}v?(a.current=h.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(h={behavior:h.behavior,left:h.top}),p.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 ia="-webkit-sticky",Pu="sticky",aa=Eu(()=>{if(typeof document>"u")return Pu;const e=document.createElement("div");return e.style.position=ia,e.style.position===ia?ia:Pu});function la(e){return e}const Ky=Ge(()=>{const e=J(a=>`Item ${a}`),t=J(a=>`Group ${a}`),n=J({}),r=J(la),o=J("div"),s=J(_r),i=(a,l=null)=>Mt(V(n,fe(u=>u[a]),at()),l);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")}}),qy=Ge(([e,t])=>({...e,...t}),it(Iu,Ky)),Gy=({height:e})=>c.jsx("div",{style:{height:e}}),Yy={overflowAnchor:"none",position:aa(),zIndex:1},Ou={overflowAnchor:"none"},Xy={...Ou,display:"inline-block",height:"100%"},Mu=w.memo(function({showTopList:e=!1}){const t=Ae("listState"),n=en("sizeRanges"),r=Ae("useWindowScroll"),o=Ae("customScrollParent"),s=en("windowScrollContainerState"),i=en("scrollContainerState"),a=o||r?s:i,l=Ae("itemContent"),u=Ae("context"),d=Ae("groupContent"),f=Ae("trackItemSizes"),h=Ae("itemSize"),p=Ae("log"),v=en("gap"),x=Ae("horizontalDirection"),{callbackRef:g}=dy(n,h,f,e?_r:a,p,v,o,x,Ae("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);ca("deviation",D=>{y!==D&&b(D)});const C=Ae("EmptyPlaceholder"),E=Ae("ScrollSeekPlaceholder")||Gy,k=Ae("ListComponent"),T=Ae("ItemComponent"),I=Ae("GroupComponent"),_=Ae("computeItemKey"),R=Ae("isSeeking"),j=Ae("groupIndices").length>0,H=Ae("alignToBottom"),F=Ae("initialItemFinalLocationReached"),U=e?{}:{boxSizing:"border-box",...x?{display:"inline-block",height:"100%",marginLeft:y!==0?y:H?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:H?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...F?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?c.jsx(C,{...Dt(C,u)}):c.jsx(k,{...Dt(k,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:U,children:(e?t.topItems:t.items).map(D=>{const G=D.originalIndex,W=_(G+t.firstItemIndex,D.data,u);return R?w.createElement(E,{...Dt(E,u),height:D.size,index:D.index,key:W,type:D.type||"item",...D.type==="group"?{}:{groupIndex:D.groupIndex}}):D.type==="group"?w.createElement(I,{...Dt(I,u),"data-index":G,"data-item-index":D.index,"data-known-size":D.size,key:W,style:Yy},d(D.index,u)):w.createElement(T,{...Dt(T,u),...ev(T,D.data),"data-index":G,"data-item-group-index":D.groupIndex,"data-item-index":D.index,"data-known-size":D.size,key:W,style:x?Xy:Ou},j?l(D.index,D.groupIndex,D.data,u):l(D.index,D.data,u))})})}),Jy={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Zy={outline:"none",overflowX:"auto",position:"relative"},cs=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Qy={position:aa(),top:0,width:"100%",zIndex:1};function Dt(e,t){if(typeof e!="string")return{context:t}}function ev(e,t){return{item:typeof e=="string"?void 0:t}}const tv=w.memo(function(){const e=Ae("HeaderComponent"),t=en("headerHeight"),n=Ae("HeaderFooterTag"),r=ur(w.useMemo(()=>s=>{t(qn(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Dt(e,o)})}):null}),nv=w.memo(function(){const e=Ae("FooterComponent"),t=en("footerHeight"),n=Ae("HeaderFooterTag"),r=ur(w.useMemo(()=>s=>{t(qn(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Dt(e,o)})}):null});function Du({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:v}=Ru(a,u,l,d,void 0,f);return e("scrollTo",v),e("scrollBy",h),c.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?Zy:Jy,...o},tabIndex:0,...i,...Dt(l,s),children:r})})}function Lu({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=w.useRef(null),v=t("scrollerRef"),{scrollByCallback:x,scrollerRef:g,scrollToCallback:y}=Ru(a,u,l,v,h);return ju(()=>{var b;return g.current=h||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",y),e("scrollBy",x),c.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Dt(l,s),children:r})})}const rv=({children:e})=>{const t=w.useContext(Au),n=en("viewportHeight"),r=en("fixedItemHeight"),o=Ae("alignToBottom"),s=Ae("horizontalDirection"),i=w.useMemo(()=>Xc(n,l=>qn(l,s?"width":"height")),[n,s]),a=ur(i,!0,Ae("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),c.jsx("div",{"data-viewport-type":"element",ref:a,style:cs(o),children:e})},ov=({children:e})=>{const t=w.useContext(Au),n=en("windowViewportRect"),r=en("fixedItemHeight"),o=Ae("customScrollParent"),s=tu(n,o,Ae("skipAnimationFrameInResizeObserver")),i=Ae("alignToBottom");return w.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),c.jsx("div",{"data-viewport-type":"window",ref:s,style:cs(i),children:e})},sv=({children:e})=>{const t=Ae("TopItemListComponent")||"div",n=Ae("headerHeight"),r={...Qy,marginTop:`${n}px`},o=Ae("context");return c.jsx(t,{style:r,...Dt(t,o),children:e})},iv=w.memo(function(e){const t=Ae("useWindowScroll"),n=Ae("topItemsIndexes").length>0,r=Ae("customScrollParent"),o=Ae("context");return c.jsxs(r||t?cv:lv,{...e,context:o,children:[n&&c.jsx(sv,{children:c.jsx(Mu,{showTopList:!0})}),c.jsxs(r||t?ov:rv,{children:[c.jsx(tv,{}),c.jsx(Mu,{}),c.jsx(nv,{})]})]})}),{Component:av,useEmitter:ca,useEmitterValue:Ae,usePublisher:en}=Nu(qy,{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"}},iv),lv=Du({useEmitter:ca,useEmitterValue:Ae,usePublisher:en}),cv=Lu({useEmitter:ca,useEmitterValue:Ae,usePublisher:en}),uv=av;it(Iu,Ge(()=>{const e=J(u=>c.jsxs("td",{children:["Item $",u]})),t=J(null),n=J(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=J(null),o=J(null),s=J({}),i=J(la),a=J(_r),l=(u,d=null)=>Mt(V(s,fe(f=>f[u]),at()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),aa();const Fu={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},dv={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:$u,floor:us,max:co,min:ua,round:zu}=Math;function Bu(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function fv(e){return{...dv,items:e}}function ds(e,t){return e&&e.width===t.width&&e.height===t.height}function hv(e,t){return e&&e.column===t.column&&e.row===t.row}const pv=Ge(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},h,p,{didMount:v,propsReady:x},{customScrollParent:g,useWindowScroll:y,windowScrollContainerState:b,windowScrollTo:C,windowViewportRect:E},k])=>{const T=J(0),I=J(0),_=J(Fu),R=J({height:0,width:0}),j=J({height:0,width:0}),H=Ke(),F=Ke(),U=J(0),D=J(null),G=J({column:0,row:0}),W=Ke(),ne=Ke(),$=J(!1),z=J(0),ie=J(!0),M=J(!1),Y=J(!1);Ye(V(v,Le(z),Ee(([L,Z])=>!!Z)),()=>{Oe(ie,!1)}),Ye(V(vt(v,ie,j,R,z,M),Ee(([L,Z,ee,me,,se])=>L&&!Z&&ee.height!==0&&me.height!==0&&!se)),([,,,,L])=>{Oe(M,!0),ea(1,()=>{Oe(H,L)}),cn(V(u),()=>{Oe(t,[0,0]),Oe(ie,!0)})}),ve(V(ne,Ee(L=>L!=null&&L.scrollTop>0),vn(0)),I),Ye(V(v,Le(ne),Ee(([,L])=>L!=null)),([,L])=>{L&&(Oe(R,L.viewport),Oe(j,L.item),Oe(G,L.gap),L.scrollTop>0&&(Oe($,!0),cn(V(u,cr(1)),Z=>{Oe($,!1)}),Oe(l,{top:L.scrollTop})))}),ve(V(R,fe(({height:L})=>L)),f),ve(V(vt(Ce(R,ds),Ce(j,ds),Ce(G,(L,Z)=>L&&L.column===Z.column&&L.row===Z.row),Ce(u)),fe(([L,Z,ee,me])=>({gap:ee,item:Z,scrollTop:me,viewport:L}))),W),ve(V(vt(Ce(T),r,Ce(G,hv),Ce(j,ds),Ce(R,ds),Ce(D),Ce(I),Ce($),Ce(ie),Ce(z)),Ee(([,,,,,,,L])=>!L),fe(([L,[Z,ee],me,se,ae,He,Je,,je,Ue])=>{const{column:et,row:Ze}=me,{height:Pe,width:Ct}=se,{width:Tt}=ae;if(Je===0&&(L===0||Tt===0))return Fu;if(Ct===0){const de=ta(Ue,L),_e=de+Math.max(Je-1,0);return fv(Bu(de,_e,He))}const Et=Hu(Tt,Ct,et);let st,tt;je?Z===0&&ee===0&&Je>0?(st=0,tt=Je-1):(st=Et*us((Z+Ze)/(Pe+Ze)),tt=Et*$u((ee+Ze)/(Pe+Ze))-1,tt=ua(L-1,co(tt,Et-1)),st=ua(tt,co(0,st))):(st=0,tt=-1);const ze=Bu(st,tt,He),{bottom:ct,top:bt}=Uu(ae,me,se,ze),X=$u(L/Et),xe=X*Pe+(X-1)*Ze-ct;return{bottom:ct,itemHeight:Pe,items:ze,itemWidth:Ct,offsetBottom:xe,offsetTop:bt,top:bt}})),_),ve(V(D,Ee(L=>L!==null),fe(L=>L.length)),T),ve(V(vt(R,j,_,G),Ee(([L,Z,{items:ee}])=>ee.length>0&&Z.height!==0&&L.height!==0),fe(([L,Z,{items:ee},me])=>{const{bottom:se,top:ae}=Uu(L,me,Z,ee);return[ae,se]}),at(no)),t);const ce=J(!1);ve(V(u,Le(ce),fe(([L,Z])=>Z||L!==0)),ce);const be=Kt(V(vt(_,T),Ee(([{items:L}])=>L.length>0),Le(ce),Ee(([[L,Z],ee])=>{const me=L.items[L.items.length-1].index===Z-1;return(ee||L.bottom>0&&L.itemHeight>0&&L.offsetBottom===0&&L.items.length===Z)&&me}),fe(([[,L]])=>L-1),at())),ge=Kt(V(Ce(_),Ee(({items:L})=>L.length>0&&L[0].index===0),vn(0),at())),ye=Kt(V(Ce(_),Le($),Ee(([{items:L},Z])=>L.length>0&&!Z),fe(([{items:L}])=>({endIndex:L[L.length-1].index,startIndex:L[0].index})),at(lu),Dn(0)));ve(ye,p.scrollSeekRangeChanged),ve(V(H,Le(R,j,T,G),fe(([L,Z,ee,me,se])=>{const ae=pu(L),{align:He,behavior:Je,offset:je}=ae;let Ue=ae.index;Ue==="LAST"&&(Ue=me-1),Ue=co(0,Ue,ua(me-1,Ue));let et=da(Z,se,ee,Ue);return He==="end"?et=zu(et-Z.height+ee.height):He==="center"&&(et=zu(et-Z.height/2+ee.height/2)),je&&(et+=je),{behavior:Je,top:et}})),l);const K=Mt(V(_,fe(L=>L.offsetBottom+L.bottom)),0);return ve(V(E,fe(L=>({height:L.visibleHeight,width:L.visibleWidth}))),R),{customScrollParent:g,data:D,deviation:U,footerHeight:o,gap:G,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:j,overscan:n,restoreStateFrom:ne,scrollBy:i,scrollContainerState:a,scrollHeight:F,scrollTo:l,scrollToIndex:H,scrollTop:u,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:R,windowScrollContainerState:b,windowScrollTo:C,windowViewportRect:E,...p,gridState:_,horizontalDirection:Y,initialTopMostItemIndex:z,totalListHeight:K,...h,endReached:be,propsReady:x,rangeChanged:ye,startReached:ge,stateChanged:W,stateRestoreInProgress:$,...k}},it(na,$t,lo,Tu,Gn,oa,Kn));function Hu(e,t,n){return co(1,us((e+n)/(us(t)+n)))}function Uu(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=da(e,t,n,r[0].index);return{bottom:da(e,t,n,r[r.length-1].index)+o,top:s}}function da(e,t,n,r){const o=Hu(e.width,n.width,t.column),s=us(r/o),i=s*n.height+co(0,s-1)*t.row;return i>0?i+t.row:i}const mv=Ge(()=>{const e=J(f=>`Item ${f}`),t=J({}),n=J(null),r=J("virtuoso-grid-item"),o=J("virtuoso-grid-list"),s=J(la),i=J("div"),a=J(_r),l=(f,h=null)=>Mt(V(t,fe(p=>p[f]),at()),h),u=J(!1),d=J(!1);return ve(Ce(d),u),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:u,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),gv=Ge(([e,t])=>({...e,...t}),it(pv,mv)),xv=w.memo(function(){const e=lt("gridState"),t=lt("listClassName"),n=lt("itemClassName"),r=lt("itemContent"),o=lt("computeItemKey"),s=lt("isSeeking"),i=tn("scrollHeight"),a=lt("ItemComponent"),l=lt("ListComponent"),u=lt("ScrollSeekPlaceholder"),d=lt("context"),f=tn("itemDimensions"),h=tn("gap"),p=lt("log"),v=lt("stateRestoreInProgress"),x=tn("reportReadyState"),g=ur(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);const C=y.firstChild;if(C){const{height:E,width:k}=C.getBoundingClientRect();f({height:E,width:k})}h({column:Vu("column-gap",getComputedStyle(y).columnGap,p),row:Vu("row-gap",getComputedStyle(y).rowGap,p)})},[i,f,h,p]),!0,!1);return ju(()=>{e.itemHeight>0&&e.itemWidth>0&&x(!0)},[e]),v?null:c.jsx(l,{className:t,ref:g,...Dt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const b=o(y.index,y.data,d);return s?c.jsx(u,{...Dt(u,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{...Dt(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),yv=w.memo(function(){const e=lt("HeaderComponent"),t=tn("headerHeight"),n=lt("headerFooterTag"),r=ur(w.useMemo(()=>s=>{t(qn(s,"height"))},[t]),!0,!1),o=lt("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Dt(e,o)})}):null}),vv=w.memo(function(){const e=lt("FooterComponent"),t=tn("footerHeight"),n=lt("headerFooterTag"),r=ur(w.useMemo(()=>s=>{t(qn(s,"height"))},[t]),!0,!1),o=lt("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Dt(e,o)})}):null}),bv=({children:e})=>{const t=w.useContext(_u),n=tn("itemDimensions"),r=tn("viewportDimensions"),o=ur(w.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return w.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),c.jsx("div",{ref:o,style:cs(!1),children:e})},wv=({children:e})=>{const t=w.useContext(_u),n=tn("windowViewportRect"),r=tn("itemDimensions"),o=lt("customScrollParent"),s=tu(n,o,!1);return w.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),c.jsx("div",{ref:s,style:cs(!1),children:e})},Sv=w.memo(function({...e}){const t=lt("useWindowScroll"),n=lt("customScrollParent"),r=n||t?kv:Cv,o=n||t?wv:bv,s=lt("context");return c.jsx(r,{...e,...Dt(r,s),children:c.jsxs(o,{children:[c.jsx(yv,{}),c.jsx(xv,{}),c.jsx(vv,{})]})})}),{useEmitter:Wu,useEmitterValue:lt,usePublisher:tn}=Nu(gv,{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"}},Sv),Cv=Du({useEmitter:Wu,useEmitterValue:lt,usePublisher:tn}),kv=Lu({useEmitter:Wu,useEmitterValue:lt,usePublisher:tn});function Vu(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Wt.WARN),t==="normal"?0:parseInt(t??"0",10)}const Tv=Po.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 fa({className:e,variant:t,...n}){return c.jsx("div",{className:re(Tv({variant:t}),e),...n})}function pe(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 Ev(e,t){const n=m.createContext(t),r=s=>{const{children:i,...a}=s,l=m.useMemo(()=>a,Object.values(a));return c.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=m.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 Sn(e,t=[]){let n=[];function r(s,i){const a=m.createContext(i),l=n.length;n=[...n,i];const u=f=>{var y;const{scope:h,children:p,...v}=f,x=((y=h==null?void 0:h[e])==null?void 0:y[l])||a,g=m.useMemo(()=>v,Object.values(v));return c.jsx(x.Provider,{value:g,children:p})};u.displayName=s+"Provider";function d(f,h){var x;const p=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,v=m.useContext(p);if(v)return v;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=>m.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Iv(o,...t)]}function Iv(...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:l,scopeName:u})=>{const f=l(s)[`__scope${u}`];return{...a,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var kt=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},Nv=m[" useInsertionEffect ".trim().toString()]||kt;function hr({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Av({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=m.useRef(e!==void 0);m.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=m.useCallback(d=>{var f;if(a){const h=_v(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[l,u]}function Av({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return Nv(()=>{s.current=t},[t]),m.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function _v(e){return typeof e=="function"}function Ku(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function ha(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Ku(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():Ku(e[o],null)}}}}function Ve(...e){return m.useCallback(ha(...e),e)}var jv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ie=jv.reduce((e,t)=>{const n=or.createSlot(`Primitive.${t}`),r=m.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function qu(e,t){e&&Oo.flushSync(()=>e.dispatchEvent(t))}function Rv(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Gt=e=>{const{present:t,children:n}=e,r=Pv(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=Ve(r.ref,Ov(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};Gt.displayName="Presence";function Pv(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Rv(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=fs(r.current);s.current=a==="mounted"?u:"none"},[a]),kt(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,p=fs(u);e?l("MOUNT"):p==="none"||(u==null?void 0:u.display)==="none"?l("UNMOUNT"):l(d&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),kt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const x=fs(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&x&&(l("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=p=>{p.target===t&&(s.current=fs(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 l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function fs(e){return(e==null?void 0:e.animationName)||"none"}function Ov(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 Mv=m[" useId ".trim().toString()]||(()=>{}),Dv=0;function Cn(e){const[t,n]=m.useState(Mv());return kt(()=>{n(r=>r??String(Dv++))},[e]),e||(t?`radix-${t}`:"")}var hs="Collapsible",[Lv,wT]=Sn(hs),[Fv,pa]=Lv(hs),Gu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,u]=hr({prop:r,defaultProp:o??!1,onChange:i,caller:hs});return c.jsx(Fv,{scope:n,disabled:s,contentId:Cn(),open:l,onOpenToggle:m.useCallback(()=>u(d=>!d),[u]),children:c.jsx(Ie.div,{"data-state":ga(l),"data-disabled":s?"":void 0,...a,ref:t})})});Gu.displayName=hs;var Yu="CollapsibleTrigger",Xu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=pa(Yu,n);return c.jsx(Ie.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":ga(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:pe(e.onClick,o.onOpenToggle)})});Xu.displayName=Yu;var ma="CollapsibleContent",$v=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=pa(ma,e.__scopeCollapsible);return c.jsx(Gt,{present:n||o.open,children:({present:s})=>c.jsx(zv,{...r,ref:t,present:s})})});$v.displayName=ma;var zv=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=pa(ma,n),[a,l]=m.useState(r),u=m.useRef(null),d=Ve(t,u),f=m.useRef(0),h=f.current,p=m.useRef(0),v=p.current,x=i.open||a,g=m.useRef(x),y=m.useRef(void 0);return m.useEffect(()=>{const b=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(b)},[]),kt(()=>{const b=u.current;if(b){y.current=y.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const C=b.getBoundingClientRect();f.current=C.height,p.current=C.width,g.current||(b.style.transitionDuration=y.current.transitionDuration,b.style.animationName=y.current.animationName),l(r)}},[i.open,r]),c.jsx(Ie.div,{"data-state":ga(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!x,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style},children:x&&o})});function ga(e){return e?"open":"closed"}var Bv=Gu;const Ju=Bv,Zu=Xu,uo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:re("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));uo.displayName="Card";const fo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:re("flex flex-col space-y-1.5 p-6",e),...t}));fo.displayName="CardHeader";const ho=m.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:re("text-2xl font-semibold leading-none tracking-tight",e),...t}));ho.displayName="CardTitle";const Qu=m.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:re("text-sm text-muted-foreground",e),...t}));Qu.displayName="CardDescription";const po=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:re("p-6 pt-0",e),...t}));po.displayName="CardContent";const ed=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:re("flex items-center p-6 pt-0",e),...t}));ed.displayName="CardFooter";function td(){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 pr=td();function Hv(e){pr=e}const nd=/[&<>"']/,Uv=new RegExp(nd.source,"g"),rd=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Wv=new RegExp(rd.source,"g"),Vv={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},od=e=>Vv[e];function Lt(e,t){if(t){if(nd.test(e))return e.replace(Uv,od)}else if(rd.test(e))return e.replace(Wv,od);return e}const Kv=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function sd(e){return e.replace(Kv,(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 qv=/(^|[^\[])\^/g;function ot(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(qv,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const Gv=/[^\w:]/g,Yv=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function id(e,t,n){if(e){let r;try{r=decodeURIComponent(sd(n)).replace(Gv,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!Yv.test(n)&&(n=Qv(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const ps={},Xv=/^[^:]+:\/*[^/]*$/,Jv=/^([^:]+:)[\s\S]*$/,Zv=/^([^:]+:\/*[^/]*)[\s\S]*$/;function Qv(e,t){ps[" "+e]||(Xv.test(e)?ps[" "+e]=e+"/":ps[" "+e]=gs(e,"/",!0)),e=ps[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(Jv,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(Zv,"$1")+t:e+t}const ms={exec:function(){}};function ad(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,u=i;for(;--u>=0&&a[u]==="\\";)l=!l;return l?"|":" |"}),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 gs(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 eb(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 tb(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 ld(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function cd(e,t,n,r){const o=t.href,s=t.title?Lt(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:Lt(i)}}function nb(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 xa{constructor(t){this.options=t||pr}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:gs(r,`
41
- `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=tb(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=gs(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,l,u,d,f,h,p,v,x=n[1].trim();const g=x.length>1,y={type:"list",raw:"",ordered:g,start:g?+x.slice(0,-1):"",loose:!1,items:[]};x=g?`\\d{1,9}\\${x.slice(-1)}`:`\\${x}`,this.options.pedantic&&(x=g?x:"[*+-]");const b=new RegExp(`^( {0,3}${x})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(v=!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=nb(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=gs(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,l,u,d,f,h,p,v,x=n[1].trim();const g=x.length>1,y={type:"list",raw:"",ordered:g,start:g?+x.slice(0,-1):"",loose:!1,items:[]};x=g?`\\d{1,9}\\${x.slice(-1)}`:`\\${x}`,this.options.pedantic&&(x=g?x:"[*+-]");const b=new RegExp(`^( {0,3}${x})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(v=!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+/,E=>" ".repeat(3*E.length)),f=t.split(`
43
43
  `,1)[0],this.options.pedantic?(i=2,p=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,p=d.slice(i),i+=n[1].length),l=!1,!d&&/^ *$/.test(f)&&(r+=f+`
44
- `,t=t.substring(f.length+1),v=!0),!v){const E=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),I=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(h=t.split(`
45
- `,1)[0],f=h,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(k.test(f)||I.test(f)||E.test(f)||T.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())p+=`
46
- `+f.slice(i);else{if(l||d.search(/[^ ]/)>=4||k.test(d)||I.test(d)||T.test(d))break;p+=`
44
+ `,t=t.substring(f.length+1),v=!0),!v){const E=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),k=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
+ `,1)[0],f=h,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(T.test(f)||I.test(f)||E.test(f)||k.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())p+=`
46
+ `+f.slice(i);else{if(l||d.search(/[^ ]/)>=4||T.test(d)||I.test(d)||k.test(d))break;p+=`
47
47
  `+f}!l&&!f.trim()&&(l=!0),r+=h+`
48
- `,t=t.substring(h.length+1),d=f.slice(i)}}y.loose||(u?y.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),y.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),y.raw+=r}y.items[y.items.length-1].raw=r.trimRight(),y.items[y.items.length-1].text=p.trimRight(),y.raw=y.raw.trimRight();const C=y.items.length;for(a=0;a<C;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const E=y.items[a].tokens.filter(k=>k.type==="space"),T=E.length>0&&E.some(k=>/\n.*\n/.test(k.raw));y.loose=T}if(y.loose)for(a=0;a<C;a++)y.items[a].loose=!0;return y}}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]):Lt(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:cd(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,l;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]=cd(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(l=r.rows[i],a=0;a<l.length;a++)l[a].tokens=this.lexer.inline(l[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:Lt(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]):Lt(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=gs(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=Qv(n[2],"()");if(i>-1){const l=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,l).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)),dd(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 dd(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,l,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(l=a.length,o[3]||o[4]){u+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(u-=l,u>0)continue;l=Math.min(l,l+u+d);const h=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const v=h.slice(1,-1);return{type:"em",raw:h,text:v,tokens:this.lexer.inlineTokens(v)}}const p=h.slice(2,-2);return{type:"strong",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}}}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=Lt(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=Lt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Lt(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=Lt(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=Lt(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]):Lt(r[0]):r[0]:o=Lt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const we={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:ms,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};we._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,we._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,we.def=ot(we.def).replace("label",we._label).replace("title",we._title).getRegex(),we.bullet=/(?:[*+-]|\d{1,9}[.)])/,we.listItemStart=ot(/^( *)(bull) */).replace("bull",we.bullet).getRegex(),we.list=ot(we.list).replace(/bull/g,we.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+we.def.source+")").getRegex(),we._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",we._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,we.html=ot(we.html,"i").replace("comment",we._comment).replace("tag",we._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),we.paragraph=ot(we._paragraph).replace("hr",we.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",we._tag).getRegex(),we.blockquote=ot(we.blockquote).replace("paragraph",we.paragraph).getRegex(),we.normal={...we},we.gfm={...we.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},we.gfm.table=ot(we.gfm.table).replace("hr",we.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",we._tag).getRegex(),we.gfm.paragraph=ot(we._paragraph).replace("hr",we.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",we.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",we._tag).getRegex(),we.pedantic={...we.normal,html:ot(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",we._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:ms,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ot(we.normal._paragraph).replace("hr",we.hr).replace("heading",` *#{1,6} *[^
51
- ]`).replace("lheading",we.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const he={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:ms,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:ms,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};he._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",he.punctuation=ot(he.punctuation).replace(/punctuation/g,he._punctuation).getRegex(),he.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,he.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,he._comment=ot(we._comment).replace("(?:-->|$)","-->").getRegex(),he.emStrong.lDelim=ot(he.emStrong.lDelim).replace(/punct/g,he._punctuation).getRegex(),he.emStrong.rDelimAst=ot(he.emStrong.rDelimAst,"g").replace(/punct/g,he._punctuation).getRegex(),he.emStrong.rDelimUnd=ot(he.emStrong.rDelimUnd,"g").replace(/punct/g,he._punctuation).getRegex(),he._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,he._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,he._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])?)+(?![-_])/,he.autolink=ot(he.autolink).replace("scheme",he._scheme).replace("email",he._email).getRegex(),he._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,he.tag=ot(he.tag).replace("comment",he._comment).replace("attribute",he._attribute).getRegex(),he._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,he._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,he._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,he.link=ot(he.link).replace("label",he._label).replace("href",he._href).replace("title",he._title).getRegex(),he.reflink=ot(he.reflink).replace("label",he._label).replace("ref",we._label).getRegex(),he.nolink=ot(he.nolink).replace("ref",we._label).getRegex(),he.reflinkSearch=ot(he.reflinkSearch,"g").replace("reflink",he.reflink).replace("nolink",he.nolink).getRegex(),he.normal={...he},he.pedantic={...he.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:ot(/^!?\[(label)\]\((.*?)\)/).replace("label",he._label).getRegex(),reflink:ot(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",he._label).getRegex()},he.gfm={...he.normal,escape:ot(he.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},he.gfm.url=ot(he.gfm.url,"i").replace("email",he.gfm._extended_email).getRegex(),he.breaks={...he.gfm,br:ot(he.br).replace("{2,}","*").getRegex(),text:ot(he.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function nb(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 fd(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 Yn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||pr,this.options.tokenizer=this.options.tokenizer||new xa,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:we.normal,inline:he.normal};this.options.pedantic?(n.block=we.pedantic,n.inline=he.pedantic):this.options.gfm&&(n.block=we.gfm,this.options.breaks?n.inline=he.breaks:n.inline=he.gfm),this.tokenizer.rules=n}static get rules(){return{block:we,inline:he}}static lex(t,n){return new Yn(n).lex(t)}static lexInline(t,n){return new Yn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
48
+ `,t=t.substring(h.length+1),d=f.slice(i)}}y.loose||(u?y.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),y.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),y.raw+=r}y.items[y.items.length-1].raw=r.trimRight(),y.items[y.items.length-1].text=p.trimRight(),y.raw=y.raw.trimRight();const C=y.items.length;for(a=0;a<C;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const E=y.items[a].tokens.filter(T=>T.type==="space"),k=E.length>0&&E.some(T=>/\n.*\n/.test(T.raw));y.loose=k}if(y.loose)for(a=0;a<C;a++)y.items[a].loose=!0;return y}}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]):Lt(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:ad(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,l;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]=ad(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(l=r.rows[i],a=0;a<l.length;a++)l[a].tokens=this.lexer.inline(l[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:Lt(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]):Lt(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=gs(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=eb(n[2],"()");if(i>-1){const l=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,l).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)),cd(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 cd(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,l,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(l=a.length,o[3]||o[4]){u+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(u-=l,u>0)continue;l=Math.min(l,l+u+d);const h=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const v=h.slice(1,-1);return{type:"em",raw:h,text:v,tokens:this.lexer.inlineTokens(v)}}const p=h.slice(2,-2);return{type:"strong",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}}}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=Lt(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=Lt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Lt(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=Lt(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=Lt(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]):Lt(r[0]):r[0]:o=Lt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const we={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:ms,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};we._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,we._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,we.def=ot(we.def).replace("label",we._label).replace("title",we._title).getRegex(),we.bullet=/(?:[*+-]|\d{1,9}[.)])/,we.listItemStart=ot(/^( *)(bull) */).replace("bull",we.bullet).getRegex(),we.list=ot(we.list).replace(/bull/g,we.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+we.def.source+")").getRegex(),we._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",we._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,we.html=ot(we.html,"i").replace("comment",we._comment).replace("tag",we._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),we.paragraph=ot(we._paragraph).replace("hr",we.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",we._tag).getRegex(),we.blockquote=ot(we.blockquote).replace("paragraph",we.paragraph).getRegex(),we.normal={...we},we.gfm={...we.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},we.gfm.table=ot(we.gfm.table).replace("hr",we.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",we._tag).getRegex(),we.gfm.paragraph=ot(we._paragraph).replace("hr",we.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",we.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",we._tag).getRegex(),we.pedantic={...we.normal,html:ot(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",we._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:ms,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ot(we.normal._paragraph).replace("hr",we.hr).replace("heading",` *#{1,6} *[^
51
+ ]`).replace("lheading",we.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const he={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:ms,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:ms,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};he._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",he.punctuation=ot(he.punctuation).replace(/punctuation/g,he._punctuation).getRegex(),he.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,he.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,he._comment=ot(we._comment).replace("(?:-->|$)","-->").getRegex(),he.emStrong.lDelim=ot(he.emStrong.lDelim).replace(/punct/g,he._punctuation).getRegex(),he.emStrong.rDelimAst=ot(he.emStrong.rDelimAst,"g").replace(/punct/g,he._punctuation).getRegex(),he.emStrong.rDelimUnd=ot(he.emStrong.rDelimUnd,"g").replace(/punct/g,he._punctuation).getRegex(),he._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,he._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,he._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])?)+(?![-_])/,he.autolink=ot(he.autolink).replace("scheme",he._scheme).replace("email",he._email).getRegex(),he._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,he.tag=ot(he.tag).replace("comment",he._comment).replace("attribute",he._attribute).getRegex(),he._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,he._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,he._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,he.link=ot(he.link).replace("label",he._label).replace("href",he._href).replace("title",he._title).getRegex(),he.reflink=ot(he.reflink).replace("label",he._label).replace("ref",we._label).getRegex(),he.nolink=ot(he.nolink).replace("ref",we._label).getRegex(),he.reflinkSearch=ot(he.reflinkSearch,"g").replace("reflink",he.reflink).replace("nolink",he.nolink).getRegex(),he.normal={...he},he.pedantic={...he.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:ot(/^!?\[(label)\]\((.*?)\)/).replace("label",he._label).getRegex(),reflink:ot(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",he._label).getRegex()},he.gfm={...he.normal,escape:ot(he.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},he.gfm.url=ot(he.gfm.url,"i").replace("email",he.gfm._extended_email).getRegex(),he.breaks={...he.gfm,br:ot(he.br).replace("{2,}","*").getRegex(),text:ot(he.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function rb(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 ud(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 Yn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||pr,this.options.tokenizer=this.options.tokenizer||new xa,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:we.normal,inline:he.normal};this.options.pedantic?(n.block=we.pedantic,n.inline=he.pedantic):this.options.gfm&&(n.block=we.gfm,this.options.breaks?n.inline=he.breaks:n.inline=he.gfm),this.tokenizer.rules=n}static get rules(){return{block:we,inline:he}}static lex(t,n){return new Yn(n).lex(t)}static lexInline(t,n){return new Yn(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,l,u)=>l+" ".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,l,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)+"["+ud("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)+"["+ud("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(l||(u=""),l=!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,fd)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,fd))){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(p){h=p.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,nb)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(u=r.raw.slice(-1)),l=!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 ya{constructor(t){this.options=t||pr}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,l,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)+"["+ld("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)+"["+ld("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(l||(u=""),l=!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,ud)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,ud))){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(p){h=p.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,rb)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(u=r.raw.slice(-1)),l=!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 ya{constructor(t){this.options=t||pr}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+Lt(o)+'">'+(r?t:Lt(t,!0))+`</code></pre>
63
63
  `:"<pre><code>"+(r?t:Lt(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=ld(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=ld(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 hd{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 pd{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 Xn{constructor(t){this.options=t||pr,this.options.renderer=this.options.renderer||new ya,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new hd,this.slugger=new pd}static parse(t,n){return new Xn(n).parse(t)}static parseInline(t,n){return new Xn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,u,d,f,h,p,v,x,g,y,b,C,E,T,k;const I=t.length;for(o=0;o<I;o++){if(p=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[p.type]&&(k=this.options.extensions.renderers[p.type].call({parser:this},p),k!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type))){r+=k||"";continue}switch(p.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(p.tokens),p.depth,ad(this.parseInline(p.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(p.text,p.lang,p.escaped);continue}case"table":{for(f="",d="",a=p.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(p.header[s].tokens),{header:!0,align:p.align[s]});for(f+=this.renderer.tablerow(d),h="",a=p.rows.length,s=0;s<a;s++){for(u=p.rows[s],d="",l=u.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(u[i].tokens),{header:!1,align:p.align[i]});h+=this.renderer.tablerow(d)}r+=this.renderer.table(f,h);continue}case"blockquote":{h=this.parse(p.tokens),r+=this.renderer.blockquote(h);continue}case"list":{for(v=p.ordered,x=p.start,g=p.loose,a=p.items.length,h="",s=0;s<a;s++)b=p.items[s],C=b.checked,E=b.task,y="",b.task&&(T=this.renderer.checkbox(C),g?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=T+" "+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=T+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:T}):y+=T),y+=this.parse(b.tokens,g),h+=this.renderer.listitem(y,E,C);r+=this.renderer.list(h,v,x);continue}case"html":{r+=this.renderer.html(p.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(p.tokens));continue}case"text":{for(h=p.tokens?this.parseInline(p.tokens):p.text;o+1<I&&t[o+1].type==="text";)p=t[++o],h+=`
82
- `+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const _='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(_);return}else throw new Error(_)}}}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 l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class xs{constructor(t){this.options=t||pr}preprocess(t){return t}postprocess(t){return t}}Am(xs,"passThroughHooks",new Set(["preprocess","postprocess"]));function rb(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>"+Lt(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 md(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...Se.defaults,...s};const i=rb(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(eb(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(f){return i(f)}const u=function(f){let h;if(!f)try{r.walkTokens&&Se.walkTokens(l,r.walkTokens),h=t(l,r),r.hooks&&(h=r.hooks.postprocess(h))}catch(p){f=p}return r.highlight=a,f?i(f):o(null,h)};if(!a||a.length<3||(delete r.highlight,!l.length))return u();let d=0;Se.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(h,p){if(h)return u(h);p!=null&&p!==f.text&&(f.text=p,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(Se.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&&Se.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function Se(e,t,n){return md(Yn.lex,Xn.parse)(e,t,n)}Se.options=Se.setOptions=function(e){return Se.defaults={...Se.defaults,...e},Bv(Se.defaults),Se},Se.getDefaults=rd,Se.defaults=pr,Se.use=function(...e){const t=Se.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=Se.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=Se.defaults.renderer||new ya;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=Se.defaults.tokenizer||new xa;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=Se.defaults.hooks||new xs;for(const s in n.hooks){const i=o[s];xs.passThroughHooks.has(s)?o[s]=a=>{if(Se.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(u=>i.call(o,u));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=Se.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}}Se.setOptions(r)})},Se.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(Se,r)),r.type){case"table":{for(const o of r.header)n=n.concat(Se.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(Se.walkTokens(s.tokens,t));break}case"list":{n=n.concat(Se.walkTokens(r.items,t));break}default:Se.defaults.extensions&&Se.defaults.extensions.childTokens&&Se.defaults.extensions.childTokens[r.type]?Se.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(Se.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(Se.walkTokens(r.tokens,t)))}return n},Se.parseInline=md(Yn.lexInline,Xn.parseInline),Se.Parser=Xn,Se.parser=Xn.parse,Se.Renderer=ya,Se.TextRenderer=hd,Se.Lexer=Yn,Se.lexer=Yn.lex,Se.Tokenizer=xa,Se.Slugger=pd,Se.Hooks=xs,Se.parse=Se,Se.options,Se.setOptions,Se.use,Se.walkTokens,Se.parseInline,Xn.parse,Yn.lex;function va({content:e,className:t="",allowHtml:n=!1,style:r}){const o=w.useMemo(()=>{try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return Se.parse(i)}return Se.parse(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre>Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=w.useMemo(()=>{if(r&&r.color){const i=r.color;return{...r,"--tw-prose-body":i,"--tw-prose-headings":i,"--tw-prose-links":i,"--tw-prose-bold":i,"--tw-prose-counters":i,"--tw-prose-bullets":i,"--tw-prose-hr":i,"--tw-prose-quotes":i,"--tw-prose-quote-borders":i,"--tw-prose-captions":i,"--tw-prose-code":i,"--tw-prose-pre-code":i,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":i,"--tw-prose-td-borders":i}}return r},[r]);return c.jsx("div",{className:re("markdown prose max-w-none break-words dark:prose-invert",t),style:s,dangerouslySetInnerHTML:{__html:o}})}async function gd(e,t){return await ln(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function xd(e,t){return await(await gd(`/files/${e}/view`,t)).text()}async function ob(e,t){const n=await gd(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await ln(`/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 sb(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await ln("/files",{params:r})}const ib=1,ab=1e6;let ba=0;function lb(){return ba=(ba+1)%Number.MAX_SAFE_INTEGER,ba.toString()}const wa=new Map,yd=e=>{if(wa.has(e))return;const t=setTimeout(()=>{wa.delete(e),mo({type:"REMOVE_TOAST",toastId:e})},ab);wa.set(e,t)},cb=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,ib)};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?yd(n):e.toasts.forEach(r=>{yd(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)}}},ys=[];let vs={toasts:[]};function mo(e){vs=cb(vs,e),ys.forEach(t=>{t(vs)})}function ub({...e}){const t=lb(),n=o=>mo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>mo({type:"DISMISS_TOAST",toastId:t});return mo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Sa(){const[e,t]=m.useState(vs);return m.useEffect(()=>(ys.push(t),()=>{const n=ys.indexOf(t);n>-1&&ys.splice(n,1)}),[e]),{...e,toast:ub,dismiss:n=>mo({type:"DISMISS_TOAST",toastId:n})}}function At(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function db(e,t=globalThis==null?void 0:globalThis.document){const n=At(e);m.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 fb="DismissableLayer",Ca="dismissableLayer.update",hb="dismissableLayer.pointerDownOutside",pb="dismissableLayer.focusOutside",vd,bd=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),bs=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=m.useContext(bd),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),v=Ve(t,I=>f(I)),x=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=x.indexOf(g),b=d?x.indexOf(d):-1,C=u.layersWithOutsidePointerEventsDisabled.size>0,E=b>=y,T=xb(I=>{const _=I.target,R=[...u.branches].some(j=>j.contains(_));!E||R||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},h),k=yb(I=>{const _=I.target;[...u.branches].some(j=>j.contains(_))||(s==null||s(I),i==null||i(I),I.defaultPrevented||a==null||a())},h);return db(I=>{b===u.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},h),m.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(vd=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),wd(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=vd)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),wd())},[d,u]),m.useEffect(()=>{const I=()=>p({});return document.addEventListener(Ca,I),()=>document.removeEventListener(Ca,I)},[]),c.jsx(Ie.div,{...l,ref:v,style:{pointerEvents:C?E?"auto":"none":void 0,...e.style},onFocusCapture:pe(e.onFocusCapture,k.onFocusCapture),onBlurCapture:pe(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:pe(e.onPointerDownCapture,T.onPointerDownCapture)})});bs.displayName=fb;var mb="DismissableLayerBranch",gb=m.forwardRef((e,t)=>{const n=m.useContext(bd),r=m.useRef(null),o=Ve(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(Ie.div,{...e,ref:o})});gb.displayName=mb;function xb(e,t=globalThis==null?void 0:globalThis.document){const n=At(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Sd(hb,n,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}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 yb(e,t=globalThis==null?void 0:globalThis.document){const n=At(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&Sd(pb,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 wd(){const e=new CustomEvent(Ca);document.dispatchEvent(e)}function Sd(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?Yu(o,s):o.dispatchEvent(s)}var Ta="focusScope.autoFocusOnMount",ka="focusScope.autoFocusOnUnmount",Cd={bubbles:!1,cancelable:!0},vb="FocusScope",ws=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=m.useState(null),u=At(o),d=At(s),f=m.useRef(null),h=Ve(t,x=>l(x)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let x=function(C){if(p.paused||!a)return;const E=C.target;a.contains(E)?f.current=E:Jn(f.current,{select:!0})},g=function(C){if(p.paused||!a)return;const E=C.relatedTarget;E!==null&&(a.contains(E)||Jn(f.current,{select:!0}))},y=function(C){if(document.activeElement===document.body)for(const T of C)T.removedNodes.length>0&&Jn(a)};document.addEventListener("focusin",x),document.addEventListener("focusout",g);const b=new MutationObserver(y);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",g),b.disconnect()}}},[r,a,p.paused]),m.useEffect(()=>{if(a){Ed.add(p);const x=document.activeElement;if(!a.contains(x)){const y=new CustomEvent(Ta,Cd);a.addEventListener(Ta,u),a.dispatchEvent(y),y.defaultPrevented||(bb(kb(Td(a)),{select:!0}),document.activeElement===x&&Jn(a))}return()=>{a.removeEventListener(Ta,u),setTimeout(()=>{const y=new CustomEvent(ka,Cd);a.addEventListener(ka,d),a.dispatchEvent(y),y.defaultPrevented||Jn(x??document.body,{select:!0}),a.removeEventListener(ka,d),Ed.remove(p)},0)}}},[a,u,d,p]);const v=m.useCallback(x=>{if(!n&&!r||p.paused)return;const g=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,y=document.activeElement;if(g&&y){const b=x.currentTarget,[C,E]=wb(b);C&&E?!x.shiftKey&&y===E?(x.preventDefault(),n&&Jn(C,{select:!0})):x.shiftKey&&y===C&&(x.preventDefault(),n&&Jn(E,{select:!0})):y===b&&x.preventDefault()}},[n,r,p.paused]);return c.jsx(Ie.div,{tabIndex:-1,...i,ref:h,onKeyDown:v})});ws.displayName=vb;function bb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Jn(r,{select:t}),document.activeElement!==n)return}function wb(e){const t=Td(e),n=kd(t,e),r=kd(t.reverse(),e);return[n,r]}function Td(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 kd(e,t){for(const n of e)if(!Sb(n,{upTo:t}))return n}function Sb(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 Cb(e){return e instanceof HTMLInputElement&&"select"in e}function Jn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Cb(e)&&t&&e.select()}}var Ed=Tb();function Tb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Id(e,t),e.unshift(t)},remove(t){var n;e=Id(e,t),(n=e[0])==null||n.resume()}}}function Id(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function kb(e){return e.filter(t=>t.tagName!=="A")}var Eb="Portal",Ss=m.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=m.useState(!1);Tt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?pi.createPortal(c.jsx(Ie.div,{...r,ref:t}),i):null});Ss.displayName=Eb;var Ea=0;function Ia(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Nd()),document.body.insertAdjacentElement("beforeend",e[1]??Nd()),Ea++,()=>{Ea===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Ea--}},[])}function Nd(){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 Tn=function(){return Tn=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},Tn.apply(this,arguments)};function Ad(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 Ib(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 Cs="right-scroll-bar-position",Ts="width-before-scroll-bar",Nb="with-scroll-bars-hidden",Ab="--removed-body-scroll-bar-size";function Na(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function _b(e,t){var n=w.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 jb=typeof window<"u"?m.useLayoutEffect:m.useEffect,_d=new WeakMap;function Rb(e,t){var n=_b(null,function(r){return e.forEach(function(o){return Na(o,r)})});return jb(function(){var r=_d.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Na(a,null)}),s.forEach(function(a){o.has(a)||Na(a,i)})}_d.set(n,e)},[e]),n}function Pb(e){return e}function Ob(e,t){t===void 0&&(t=Pb);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 l=function(){var d=i;i=[],d.forEach(s)},u=function(){return Promise.resolve().then(l)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return o}function Mb(e){e===void 0&&(e={});var t=Ob(null);return t.options=Tn({async:!0,ssr:!1},e),t}var jd=function(e){var t=e.sideCar,n=Ad(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 m.createElement(r,Tn({},n))};jd.isSideCarExport=!0;function Db(e,t){return e.useMedium(t),jd}var Rd=Mb(),Aa=function(){},ks=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:Aa,onWheelCapture:Aa,onTouchMoveCapture:Aa}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,p=e.noRelative,v=e.noIsolation,x=e.inert,g=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,C=e.gapMode,E=Ad(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),T=h,k=Rb([n,t]),I=Tn(Tn({},E),o);return m.createElement(m.Fragment,null,d&&m.createElement(T,{sideCar:Rd,removeScrollBar:u,shards:f,noRelative:p,noIsolation:v,inert:x,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:C}),i?m.cloneElement(m.Children.only(a),Tn(Tn({},I),{ref:k})):m.createElement(b,Tn({},I,{className:l,ref:k}),a))});ks.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ks.classNames={fullWidth:Ts,zeroRight:Cs};var Lb=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Fb(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Lb();return t&&e.setAttribute("nonce",t),e}function $b(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function zb(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Bb=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Fb())&&($b(t,n),zb(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Hb=function(){var e=Bb();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Pd=function(){var e=Hb(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Ub={left:0,top:0,right:0,gap:0},_a=function(e){return parseInt(e||"",10)||0},Wb=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[_a(n),_a(r),_a(o)]},Vb=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Ub;var t=Wb(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])}},Kb=Pd(),Rr="data-scroll-locked",qb=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(Nb,` {
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=id(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=id(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 dd{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 fd{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 Xn{constructor(t){this.options=t||pr,this.options.renderer=this.options.renderer||new ya,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new dd,this.slugger=new fd}static parse(t,n){return new Xn(n).parse(t)}static parseInline(t,n){return new Xn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,u,d,f,h,p,v,x,g,y,b,C,E,k,T;const I=t.length;for(o=0;o<I;o++){if(p=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[p.type]&&(T=this.options.extensions.renderers[p.type].call({parser:this},p),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type))){r+=T||"";continue}switch(p.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(p.tokens),p.depth,sd(this.parseInline(p.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(p.text,p.lang,p.escaped);continue}case"table":{for(f="",d="",a=p.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(p.header[s].tokens),{header:!0,align:p.align[s]});for(f+=this.renderer.tablerow(d),h="",a=p.rows.length,s=0;s<a;s++){for(u=p.rows[s],d="",l=u.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(u[i].tokens),{header:!1,align:p.align[i]});h+=this.renderer.tablerow(d)}r+=this.renderer.table(f,h);continue}case"blockquote":{h=this.parse(p.tokens),r+=this.renderer.blockquote(h);continue}case"list":{for(v=p.ordered,x=p.start,g=p.loose,a=p.items.length,h="",s=0;s<a;s++)b=p.items[s],C=b.checked,E=b.task,y="",b.task&&(k=this.renderer.checkbox(C),g?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=k+" "+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=k+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:k}):y+=k),y+=this.parse(b.tokens,g),h+=this.renderer.listitem(y,E,C);r+=this.renderer.list(h,v,x);continue}case"html":{r+=this.renderer.html(p.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(p.tokens));continue}case"text":{for(h=p.tokens?this.parseInline(p.tokens):p.text;o+1<I&&t[o+1].type==="text";)p=t[++o],h+=`
82
+ `+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const _='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(_);return}else throw new Error(_)}}}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 l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class xs{constructor(t){this.options=t||pr}preprocess(t){return t}postprocess(t){return t}}Im(xs,"passThroughHooks",new Set(["preprocess","postprocess"]));function ob(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>"+Lt(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 hd(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...Se.defaults,...s};const i=ob(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(tb(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(f){return i(f)}const u=function(f){let h;if(!f)try{r.walkTokens&&Se.walkTokens(l,r.walkTokens),h=t(l,r),r.hooks&&(h=r.hooks.postprocess(h))}catch(p){f=p}return r.highlight=a,f?i(f):o(null,h)};if(!a||a.length<3||(delete r.highlight,!l.length))return u();let d=0;Se.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(h,p){if(h)return u(h);p!=null&&p!==f.text&&(f.text=p,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(Se.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&&Se.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function Se(e,t,n){return hd(Yn.lex,Xn.parse)(e,t,n)}Se.options=Se.setOptions=function(e){return Se.defaults={...Se.defaults,...e},Hv(Se.defaults),Se},Se.getDefaults=td,Se.defaults=pr,Se.use=function(...e){const t=Se.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=Se.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=Se.defaults.renderer||new ya;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=Se.defaults.tokenizer||new xa;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=Se.defaults.hooks||new xs;for(const s in n.hooks){const i=o[s];xs.passThroughHooks.has(s)?o[s]=a=>{if(Se.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(u=>i.call(o,u));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=Se.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}}Se.setOptions(r)})},Se.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(Se,r)),r.type){case"table":{for(const o of r.header)n=n.concat(Se.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(Se.walkTokens(s.tokens,t));break}case"list":{n=n.concat(Se.walkTokens(r.items,t));break}default:Se.defaults.extensions&&Se.defaults.extensions.childTokens&&Se.defaults.extensions.childTokens[r.type]?Se.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(Se.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(Se.walkTokens(r.tokens,t)))}return n},Se.parseInline=hd(Yn.lexInline,Xn.parseInline),Se.Parser=Xn,Se.parser=Xn.parse,Se.Renderer=ya,Se.TextRenderer=dd,Se.Lexer=Yn,Se.lexer=Yn.lex,Se.Tokenizer=xa,Se.Slugger=fd,Se.Hooks=xs,Se.parse=Se,Se.options,Se.setOptions,Se.use,Se.walkTokens,Se.parseInline,Xn.parse,Yn.lex;function va({content:e,className:t="",allowHtml:n=!1,style:r}){const o=w.useMemo(()=>{try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return Se.parse(i)}return Se.parse(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre>Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=w.useMemo(()=>{if(r&&r.color){const i=r.color;return{...r,"--tw-prose-body":i,"--tw-prose-headings":i,"--tw-prose-links":i,"--tw-prose-bold":i,"--tw-prose-counters":i,"--tw-prose-bullets":i,"--tw-prose-hr":i,"--tw-prose-quotes":i,"--tw-prose-quote-borders":i,"--tw-prose-captions":i,"--tw-prose-code":i,"--tw-prose-pre-code":i,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":i,"--tw-prose-td-borders":i}}return r},[r]);return c.jsx("div",{className:re("markdown prose max-w-none break-words dark:prose-invert",t),style:s,dangerouslySetInnerHTML:{__html:o}})}async function pd(e,t){return await ln(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function md(e,t){return await(await pd(`/files/${e}/view`,t)).text()}async function sb(e,t){const n=await pd(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await ln(`/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 ib(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await ln("/files",{params:r})}const ab=1,lb=1e6;let ba=0;function cb(){return ba=(ba+1)%Number.MAX_SAFE_INTEGER,ba.toString()}const wa=new Map,gd=e=>{if(wa.has(e))return;const t=setTimeout(()=>{wa.delete(e),mo({type:"REMOVE_TOAST",toastId:e})},lb);wa.set(e,t)},ub=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,ab)};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?gd(n):e.toasts.forEach(r=>{gd(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)}}},ys=[];let vs={toasts:[]};function mo(e){vs=ub(vs,e),ys.forEach(t=>{t(vs)})}function db({...e}){const t=cb(),n=o=>mo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>mo({type:"DISMISS_TOAST",toastId:t});return mo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Sa(){const[e,t]=m.useState(vs);return m.useEffect(()=>(ys.push(t),()=>{const n=ys.indexOf(t);n>-1&&ys.splice(n,1)}),[e]),{...e,toast:db,dismiss:n=>mo({type:"DISMISS_TOAST",toastId:n})}}function At(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function fb(e,t=globalThis==null?void 0:globalThis.document){const n=At(e);m.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 hb="DismissableLayer",Ca="dismissableLayer.update",pb="dismissableLayer.pointerDownOutside",mb="dismissableLayer.focusOutside",xd,yd=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),bs=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=m.useContext(yd),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),v=Ve(t,I=>f(I)),x=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=x.indexOf(g),b=d?x.indexOf(d):-1,C=u.layersWithOutsidePointerEventsDisabled.size>0,E=b>=y,k=yb(I=>{const _=I.target,R=[...u.branches].some(j=>j.contains(_));!E||R||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},h),T=vb(I=>{const _=I.target;[...u.branches].some(j=>j.contains(_))||(s==null||s(I),i==null||i(I),I.defaultPrevented||a==null||a())},h);return fb(I=>{b===u.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},h),m.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(xd=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),vd(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=xd)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),vd())},[d,u]),m.useEffect(()=>{const I=()=>p({});return document.addEventListener(Ca,I),()=>document.removeEventListener(Ca,I)},[]),c.jsx(Ie.div,{...l,ref:v,style:{pointerEvents:C?E?"auto":"none":void 0,...e.style},onFocusCapture:pe(e.onFocusCapture,T.onFocusCapture),onBlurCapture:pe(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:pe(e.onPointerDownCapture,k.onPointerDownCapture)})});bs.displayName=hb;var gb="DismissableLayerBranch",xb=m.forwardRef((e,t)=>{const n=m.useContext(yd),r=m.useRef(null),o=Ve(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(Ie.div,{...e,ref:o})});xb.displayName=gb;function yb(e,t=globalThis==null?void 0:globalThis.document){const n=At(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){bd(pb,n,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}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 vb(e,t=globalThis==null?void 0:globalThis.document){const n=At(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&bd(mb,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 vd(){const e=new CustomEvent(Ca);document.dispatchEvent(e)}function bd(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?qu(o,s):o.dispatchEvent(s)}var ka="focusScope.autoFocusOnMount",Ta="focusScope.autoFocusOnUnmount",wd={bubbles:!1,cancelable:!0},bb="FocusScope",ws=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=m.useState(null),u=At(o),d=At(s),f=m.useRef(null),h=Ve(t,x=>l(x)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let x=function(C){if(p.paused||!a)return;const E=C.target;a.contains(E)?f.current=E:Jn(f.current,{select:!0})},g=function(C){if(p.paused||!a)return;const E=C.relatedTarget;E!==null&&(a.contains(E)||Jn(f.current,{select:!0}))},y=function(C){if(document.activeElement===document.body)for(const k of C)k.removedNodes.length>0&&Jn(a)};document.addEventListener("focusin",x),document.addEventListener("focusout",g);const b=new MutationObserver(y);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",g),b.disconnect()}}},[r,a,p.paused]),m.useEffect(()=>{if(a){kd.add(p);const x=document.activeElement;if(!a.contains(x)){const y=new CustomEvent(ka,wd);a.addEventListener(ka,u),a.dispatchEvent(y),y.defaultPrevented||(wb(Eb(Sd(a)),{select:!0}),document.activeElement===x&&Jn(a))}return()=>{a.removeEventListener(ka,u),setTimeout(()=>{const y=new CustomEvent(Ta,wd);a.addEventListener(Ta,d),a.dispatchEvent(y),y.defaultPrevented||Jn(x??document.body,{select:!0}),a.removeEventListener(Ta,d),kd.remove(p)},0)}}},[a,u,d,p]);const v=m.useCallback(x=>{if(!n&&!r||p.paused)return;const g=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,y=document.activeElement;if(g&&y){const b=x.currentTarget,[C,E]=Sb(b);C&&E?!x.shiftKey&&y===E?(x.preventDefault(),n&&Jn(C,{select:!0})):x.shiftKey&&y===C&&(x.preventDefault(),n&&Jn(E,{select:!0})):y===b&&x.preventDefault()}},[n,r,p.paused]);return c.jsx(Ie.div,{tabIndex:-1,...i,ref:h,onKeyDown:v})});ws.displayName=bb;function wb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Jn(r,{select:t}),document.activeElement!==n)return}function Sb(e){const t=Sd(e),n=Cd(t,e),r=Cd(t.reverse(),e);return[n,r]}function Sd(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 Cd(e,t){for(const n of e)if(!Cb(n,{upTo:t}))return n}function Cb(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 kb(e){return e instanceof HTMLInputElement&&"select"in e}function Jn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&kb(e)&&t&&e.select()}}var kd=Tb();function Tb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Td(e,t),e.unshift(t)},remove(t){var n;e=Td(e,t),(n=e[0])==null||n.resume()}}}function Td(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Eb(e){return e.filter(t=>t.tagName!=="A")}var Ib="Portal",Ss=m.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=m.useState(!1);kt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?pi.createPortal(c.jsx(Ie.div,{...r,ref:t}),i):null});Ss.displayName=Ib;var Ea=0;function Ia(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ed()),document.body.insertAdjacentElement("beforeend",e[1]??Ed()),Ea++,()=>{Ea===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Ea--}},[])}function Ed(){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 kn=function(){return kn=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},kn.apply(this,arguments)};function Id(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 Nb(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 Cs="right-scroll-bar-position",ks="width-before-scroll-bar",Ab="with-scroll-bars-hidden",_b="--removed-body-scroll-bar-size";function Na(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function jb(e,t){var n=w.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 Rb=typeof window<"u"?m.useLayoutEffect:m.useEffect,Nd=new WeakMap;function Pb(e,t){var n=jb(null,function(r){return e.forEach(function(o){return Na(o,r)})});return Rb(function(){var r=Nd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Na(a,null)}),s.forEach(function(a){o.has(a)||Na(a,i)})}Nd.set(n,e)},[e]),n}function Ob(e){return e}function Mb(e,t){t===void 0&&(t=Ob);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 l=function(){var d=i;i=[],d.forEach(s)},u=function(){return Promise.resolve().then(l)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return o}function Db(e){e===void 0&&(e={});var t=Mb(null);return t.options=kn({async:!0,ssr:!1},e),t}var Ad=function(e){var t=e.sideCar,n=Id(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 m.createElement(r,kn({},n))};Ad.isSideCarExport=!0;function Lb(e,t){return e.useMedium(t),Ad}var _d=Db(),Aa=function(){},Ts=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:Aa,onWheelCapture:Aa,onTouchMoveCapture:Aa}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,p=e.noRelative,v=e.noIsolation,x=e.inert,g=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,C=e.gapMode,E=Id(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=h,T=Pb([n,t]),I=kn(kn({},E),o);return m.createElement(m.Fragment,null,d&&m.createElement(k,{sideCar:_d,removeScrollBar:u,shards:f,noRelative:p,noIsolation:v,inert:x,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:C}),i?m.cloneElement(m.Children.only(a),kn(kn({},I),{ref:T})):m.createElement(b,kn({},I,{className:l,ref:T}),a))});Ts.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Ts.classNames={fullWidth:ks,zeroRight:Cs};var Fb=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function $b(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Fb();return t&&e.setAttribute("nonce",t),e}function zb(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Bb(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Hb=function(){var e=0,t=null;return{add:function(n){e==0&&(t=$b())&&(zb(t,n),Bb(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Ub=function(){var e=Hb();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},jd=function(){var e=Ub(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Wb={left:0,top:0,right:0,gap:0},_a=function(e){return parseInt(e||"",10)||0},Vb=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[_a(n),_a(r),_a(o)]},Kb=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Wb;var t=Vb(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])}},qb=jd(),Rr="data-scroll-locked",Gb=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(Ab,` {
85
85
  overflow: hidden `).concat(r,`;
86
86
  padding-right: `).concat(a,"px ").concat(r,`;
87
87
  }
@@ -102,7 +102,7 @@ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An err
102
102
  right: `).concat(a,"px ").concat(r,`;
103
103
  }
104
104
 
105
- .`).concat(Ts,` {
105
+ .`).concat(ks,` {
106
106
  margin-right: `).concat(a,"px ").concat(r,`;
107
107
  }
108
108
 
@@ -110,25 +110,25 @@ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An err
110
110
  right: 0 `).concat(r,`;
111
111
  }
112
112
 
113
- .`).concat(Ts," .").concat(Ts,` {
113
+ .`).concat(ks," .").concat(ks,` {
114
114
  margin-right: 0 `).concat(r,`;
115
115
  }
116
116
 
117
117
  body[`).concat(Rr,`] {
118
- `).concat(Ab,": ").concat(a,`px;
118
+ `).concat(_b,": ").concat(a,`px;
119
119
  }
120
- `)},Od=function(){var e=parseInt(document.body.getAttribute(Rr)||"0",10);return isFinite(e)?e:0},Gb=function(){m.useEffect(function(){return document.body.setAttribute(Rr,(Od()+1).toString()),function(){var e=Od()-1;e<=0?document.body.removeAttribute(Rr):document.body.setAttribute(Rr,e.toString())}},[])},Yb=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Gb();var s=m.useMemo(function(){return Vb(o)},[o]);return m.createElement(Kb,{styles:qb(s,!t,o,n?"":"!important")})},ja=!1;if(typeof window<"u")try{var Es=Object.defineProperty({},"passive",{get:function(){return ja=!0,!0}});window.addEventListener("test",Es,Es),window.removeEventListener("test",Es,Es)}catch{ja=!1}var Pr=ja?{passive:!1}:!1,Xb=function(e){return e.tagName==="TEXTAREA"},Md=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Xb(e)&&n[t]==="visible")},Jb=function(e){return Md(e,"overflowY")},Zb=function(e){return Md(e,"overflowX")},Dd=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Ld(e,r);if(o){var s=Fd(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Qb=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},ew=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Ld=function(e,t){return e==="v"?Jb(t):Zb(t)},Fd=function(e,t){return e==="v"?Qb(t):ew(t)},tw=function(e,t){return e==="h"&&t==="rtl"?-1:1},nw=function(e,t,n,r,o){var s=tw(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),u=!1,d=i>0,f=0,h=0;do{if(!a)break;var p=Fd(e,a),v=p[0],x=p[1],g=p[2],y=x-g-s*v;(v||y)&&Ld(e,a)&&(f+=y,h+=v);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},Is=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},$d=function(e){return[e.deltaX,e.deltaY]},zd=function(e){return e&&"current"in e?e.current:e},rw=function(e,t){return e[0]===t[0]&&e[1]===t[1]},ow=function(e){return`
120
+ `)},Rd=function(){var e=parseInt(document.body.getAttribute(Rr)||"0",10);return isFinite(e)?e:0},Yb=function(){m.useEffect(function(){return document.body.setAttribute(Rr,(Rd()+1).toString()),function(){var e=Rd()-1;e<=0?document.body.removeAttribute(Rr):document.body.setAttribute(Rr,e.toString())}},[])},Xb=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Yb();var s=m.useMemo(function(){return Kb(o)},[o]);return m.createElement(qb,{styles:Gb(s,!t,o,n?"":"!important")})},ja=!1;if(typeof window<"u")try{var Es=Object.defineProperty({},"passive",{get:function(){return ja=!0,!0}});window.addEventListener("test",Es,Es),window.removeEventListener("test",Es,Es)}catch{ja=!1}var Pr=ja?{passive:!1}:!1,Jb=function(e){return e.tagName==="TEXTAREA"},Pd=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Jb(e)&&n[t]==="visible")},Zb=function(e){return Pd(e,"overflowY")},Qb=function(e){return Pd(e,"overflowX")},Od=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Md(e,r);if(o){var s=Dd(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},ew=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},tw=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Md=function(e,t){return e==="v"?Zb(t):Qb(t)},Dd=function(e,t){return e==="v"?ew(t):tw(t)},nw=function(e,t){return e==="h"&&t==="rtl"?-1:1},rw=function(e,t,n,r,o){var s=nw(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),u=!1,d=i>0,f=0,h=0;do{if(!a)break;var p=Dd(e,a),v=p[0],x=p[1],g=p[2],y=x-g-s*v;(v||y)&&Md(e,a)&&(f+=y,h+=v);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},Is=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Ld=function(e){return[e.deltaX,e.deltaY]},Fd=function(e){return e&&"current"in e?e.current:e},ow=function(e,t){return e[0]===t[0]&&e[1]===t[1]},sw=function(e){return`
121
121
  .block-interactivity-`.concat(e,` {pointer-events: none;}
122
122
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
123
- `)},sw=0,Or=[];function iw(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(sw++)[0],s=m.useState(Pd)[0],i=m.useRef(e);m.useEffect(function(){i.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var x=Ib([e.lockRef.current],(e.shards||[]).map(zd),!0).filter(Boolean);return x.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),x.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=m.useCallback(function(x,g){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var y=Is(x),b=n.current,C="deltaX"in x?x.deltaX:b[0]-y[0],E="deltaY"in x?x.deltaY:b[1]-y[1],T,k=x.target,I=Math.abs(C)>Math.abs(E)?"h":"v";if("touches"in x&&I==="h"&&k.type==="range")return!1;var _=Dd(I,k);if(!_)return!0;if(_?T=I:(T=I==="v"?"h":"v",_=Dd(I,k)),!_)return!1;if(!r.current&&"changedTouches"in x&&(C||E)&&(r.current=T),!T)return!0;var R=r.current||T;return nw(R,g,x,R==="h"?C:E)},[]),l=m.useCallback(function(x){var g=x;if(!(!Or.length||Or[Or.length-1]!==s)){var y="deltaY"in g?$d(g):Is(g),b=t.current.filter(function(T){return T.name===g.type&&(T.target===g.target||g.target===T.shadowParent)&&rw(T.delta,y)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}if(!b){var C=(i.current.shards||[]).map(zd).filter(Boolean).filter(function(T){return T.contains(g.target)}),E=C.length>0?a(g,C[0]):!i.current.noIsolation;E&&g.cancelable&&g.preventDefault()}}},[]),u=m.useCallback(function(x,g,y,b){var C={name:x,delta:g,target:y,should:b,shadowParent:aw(y)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(E){return E!==C})},1)},[]),d=m.useCallback(function(x){n.current=Is(x),r.current=void 0},[]),f=m.useCallback(function(x){u(x.type,$d(x),x.target,a(x,e.lockRef.current))},[]),h=m.useCallback(function(x){u(x.type,Is(x),x.target,a(x,e.lockRef.current))},[]);m.useEffect(function(){return Or.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,Pr),document.addEventListener("touchmove",l,Pr),document.addEventListener("touchstart",d,Pr),function(){Or=Or.filter(function(x){return x!==s}),document.removeEventListener("wheel",l,Pr),document.removeEventListener("touchmove",l,Pr),document.removeEventListener("touchstart",d,Pr)}},[]);var p=e.removeScrollBar,v=e.inert;return m.createElement(m.Fragment,null,v?m.createElement(s,{styles:ow(o)}):null,p?m.createElement(Yb,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function aw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const lw=Db(Rd,iw);var Ns=m.forwardRef(function(e,t){return m.createElement(ks,Tn({},e,{ref:t,sideCar:lw}))});Ns.classNames=ks.classNames;var cw=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Mr=new WeakMap,As=new WeakMap,_s={},Ra=0,Bd=function(e){return e&&(e.host||Bd(e.parentNode))},uw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Bd(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})},dw=function(e,t,n,r){var o=uw(t,Array.isArray(e)?e:[e]);_s[n]||(_s[n]=new WeakMap);var s=_s[n],i=[],a=new Set,l=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var d=function(f){!f||l.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))d(h);else try{var p=h.getAttribute(r),v=p!==null&&p!=="false",x=(Mr.get(h)||0)+1,g=(s.get(h)||0)+1;Mr.set(h,x),s.set(h,g),i.push(h),x===1&&v&&As.set(h,!0),g===1&&h.setAttribute(n,"true"),v||h.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",h,y)}})};return d(t),a.clear(),Ra++,function(){i.forEach(function(f){var h=Mr.get(f)-1,p=s.get(f)-1;Mr.set(f,h),s.set(f,p),h||(As.has(f)||f.removeAttribute(r),As.delete(f)),p||f.removeAttribute(n)}),Ra--,Ra||(Mr=new WeakMap,Mr=new WeakMap,As=new WeakMap,_s={})}},Pa=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=cw(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),dw(r,o,n,"aria-hidden")):function(){return null}},js="Dialog",[Hd,wk]=Sn(js),[fw,dn]=Hd(js),Ud=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=m.useRef(null),l=m.useRef(null),[u,d]=hr({prop:r,defaultProp:o??!1,onChange:s,caller:js});return c.jsx(fw,{scope:t,triggerRef:a,contentRef:l,contentId:Cn(),titleId:Cn(),descriptionId:Cn(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Ud.displayName=js;var Wd="DialogTrigger",Vd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Wd,n),s=Ve(t,o.triggerRef);return c.jsx(Ie.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Da(o.open),...r,ref:s,onClick:pe(e.onClick,o.onOpenToggle)})});Vd.displayName=Wd;var Oa="DialogPortal",[hw,Kd]=Hd(Oa,{forceMount:void 0}),qd=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=dn(Oa,t);return c.jsx(hw,{scope:t,forceMount:n,children:m.Children.map(r,i=>c.jsx(Gt,{present:n||s.open,children:c.jsx(Ss,{asChild:!0,container:o,children:i})}))})};qd.displayName=Oa;var Rs="DialogOverlay",Gd=m.forwardRef((e,t)=>{const n=Kd(Rs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=dn(Rs,e.__scopeDialog);return s.modal?c.jsx(Gt,{present:r||s.open,children:c.jsx(mw,{...o,ref:t})}):null});Gd.displayName=Rs;var pw=or.createSlot("DialogOverlay.RemoveScroll"),mw=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Rs,n);return c.jsx(Ns,{as:pw,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(Ie.div,{"data-state":Da(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),mr="DialogContent",Yd=m.forwardRef((e,t)=>{const n=Kd(mr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=dn(mr,e.__scopeDialog);return c.jsx(Gt,{present:r||s.open,children:s.modal?c.jsx(gw,{...o,ref:t}):c.jsx(xw,{...o,ref:t})})});Yd.displayName=mr;var gw=m.forwardRef((e,t)=>{const n=dn(mr,e.__scopeDialog),r=m.useRef(null),o=Ve(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return Pa(s)},[]),c.jsx(Xd,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:pe(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:pe(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:pe(e.onFocusOutside,s=>s.preventDefault())})}),xw=m.forwardRef((e,t)=>{const n=dn(mr,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return c.jsx(Xd,{...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 l,u;(l=e.onInteractOutside)==null||l.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()}})}),Xd=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=dn(mr,n),l=m.useRef(null),u=Ve(t,l);return Ia(),c.jsxs(c.Fragment,{children:[c.jsx(ws,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(bs,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Da(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(yw,{titleId:a.titleId}),c.jsx(bw,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ma="DialogTitle",Jd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Ma,n);return c.jsx(Ie.h2,{id:o.titleId,...r,ref:t})});Jd.displayName=Ma;var Zd="DialogDescription",Qd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Zd,n);return c.jsx(Ie.p,{id:o.descriptionId,...r,ref:t})});Qd.displayName=Zd;var ef="DialogClose",tf=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(ef,n);return c.jsx(Ie.button,{type:"button",...r,ref:t,onClick:pe(e.onClick,()=>o.onOpenChange(!1))})});tf.displayName=ef;function Da(e){return e?"open":"closed"}var nf="DialogTitleWarning",[Sk,rf]=kv(nf,{contentName:mr,titleName:Ma,docsSlug:"dialog"}),yw=({titleId:e})=>{const t=rf(nf),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
123
+ `)},iw=0,Or=[];function aw(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(iw++)[0],s=m.useState(jd)[0],i=m.useRef(e);m.useEffect(function(){i.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var x=Nb([e.lockRef.current],(e.shards||[]).map(Fd),!0).filter(Boolean);return x.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),x.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=m.useCallback(function(x,g){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var y=Is(x),b=n.current,C="deltaX"in x?x.deltaX:b[0]-y[0],E="deltaY"in x?x.deltaY:b[1]-y[1],k,T=x.target,I=Math.abs(C)>Math.abs(E)?"h":"v";if("touches"in x&&I==="h"&&T.type==="range")return!1;var _=Od(I,T);if(!_)return!0;if(_?k=I:(k=I==="v"?"h":"v",_=Od(I,T)),!_)return!1;if(!r.current&&"changedTouches"in x&&(C||E)&&(r.current=k),!k)return!0;var R=r.current||k;return rw(R,g,x,R==="h"?C:E)},[]),l=m.useCallback(function(x){var g=x;if(!(!Or.length||Or[Or.length-1]!==s)){var y="deltaY"in g?Ld(g):Is(g),b=t.current.filter(function(k){return k.name===g.type&&(k.target===g.target||g.target===k.shadowParent)&&ow(k.delta,y)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}if(!b){var C=(i.current.shards||[]).map(Fd).filter(Boolean).filter(function(k){return k.contains(g.target)}),E=C.length>0?a(g,C[0]):!i.current.noIsolation;E&&g.cancelable&&g.preventDefault()}}},[]),u=m.useCallback(function(x,g,y,b){var C={name:x,delta:g,target:y,should:b,shadowParent:lw(y)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(E){return E!==C})},1)},[]),d=m.useCallback(function(x){n.current=Is(x),r.current=void 0},[]),f=m.useCallback(function(x){u(x.type,Ld(x),x.target,a(x,e.lockRef.current))},[]),h=m.useCallback(function(x){u(x.type,Is(x),x.target,a(x,e.lockRef.current))},[]);m.useEffect(function(){return Or.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,Pr),document.addEventListener("touchmove",l,Pr),document.addEventListener("touchstart",d,Pr),function(){Or=Or.filter(function(x){return x!==s}),document.removeEventListener("wheel",l,Pr),document.removeEventListener("touchmove",l,Pr),document.removeEventListener("touchstart",d,Pr)}},[]);var p=e.removeScrollBar,v=e.inert;return m.createElement(m.Fragment,null,v?m.createElement(s,{styles:sw(o)}):null,p?m.createElement(Xb,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function lw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const cw=Lb(_d,aw);var Ns=m.forwardRef(function(e,t){return m.createElement(Ts,kn({},e,{ref:t,sideCar:cw}))});Ns.classNames=Ts.classNames;var uw=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Mr=new WeakMap,As=new WeakMap,_s={},Ra=0,$d=function(e){return e&&(e.host||$d(e.parentNode))},dw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=$d(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})},fw=function(e,t,n,r){var o=dw(t,Array.isArray(e)?e:[e]);_s[n]||(_s[n]=new WeakMap);var s=_s[n],i=[],a=new Set,l=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var d=function(f){!f||l.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))d(h);else try{var p=h.getAttribute(r),v=p!==null&&p!=="false",x=(Mr.get(h)||0)+1,g=(s.get(h)||0)+1;Mr.set(h,x),s.set(h,g),i.push(h),x===1&&v&&As.set(h,!0),g===1&&h.setAttribute(n,"true"),v||h.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",h,y)}})};return d(t),a.clear(),Ra++,function(){i.forEach(function(f){var h=Mr.get(f)-1,p=s.get(f)-1;Mr.set(f,h),s.set(f,p),h||(As.has(f)||f.removeAttribute(r),As.delete(f)),p||f.removeAttribute(n)}),Ra--,Ra||(Mr=new WeakMap,Mr=new WeakMap,As=new WeakMap,_s={})}},Pa=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=uw(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),fw(r,o,n,"aria-hidden")):function(){return null}},js="Dialog",[zd,ST]=Sn(js),[hw,dn]=zd(js),Bd=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=m.useRef(null),l=m.useRef(null),[u,d]=hr({prop:r,defaultProp:o??!1,onChange:s,caller:js});return c.jsx(hw,{scope:t,triggerRef:a,contentRef:l,contentId:Cn(),titleId:Cn(),descriptionId:Cn(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Bd.displayName=js;var Hd="DialogTrigger",Ud=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Hd,n),s=Ve(t,o.triggerRef);return c.jsx(Ie.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Da(o.open),...r,ref:s,onClick:pe(e.onClick,o.onOpenToggle)})});Ud.displayName=Hd;var Oa="DialogPortal",[pw,Wd]=zd(Oa,{forceMount:void 0}),Vd=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=dn(Oa,t);return c.jsx(pw,{scope:t,forceMount:n,children:m.Children.map(r,i=>c.jsx(Gt,{present:n||s.open,children:c.jsx(Ss,{asChild:!0,container:o,children:i})}))})};Vd.displayName=Oa;var Rs="DialogOverlay",Kd=m.forwardRef((e,t)=>{const n=Wd(Rs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=dn(Rs,e.__scopeDialog);return s.modal?c.jsx(Gt,{present:r||s.open,children:c.jsx(gw,{...o,ref:t})}):null});Kd.displayName=Rs;var mw=or.createSlot("DialogOverlay.RemoveScroll"),gw=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Rs,n);return c.jsx(Ns,{as:mw,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(Ie.div,{"data-state":Da(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),mr="DialogContent",qd=m.forwardRef((e,t)=>{const n=Wd(mr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=dn(mr,e.__scopeDialog);return c.jsx(Gt,{present:r||s.open,children:s.modal?c.jsx(xw,{...o,ref:t}):c.jsx(yw,{...o,ref:t})})});qd.displayName=mr;var xw=m.forwardRef((e,t)=>{const n=dn(mr,e.__scopeDialog),r=m.useRef(null),o=Ve(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return Pa(s)},[]),c.jsx(Gd,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:pe(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:pe(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:pe(e.onFocusOutside,s=>s.preventDefault())})}),yw=m.forwardRef((e,t)=>{const n=dn(mr,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return c.jsx(Gd,{...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 l,u;(l=e.onInteractOutside)==null||l.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()}})}),Gd=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=dn(mr,n),l=m.useRef(null),u=Ve(t,l);return Ia(),c.jsxs(c.Fragment,{children:[c.jsx(ws,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(bs,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Da(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(vw,{titleId:a.titleId}),c.jsx(ww,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ma="DialogTitle",Yd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Ma,n);return c.jsx(Ie.h2,{id:o.titleId,...r,ref:t})});Yd.displayName=Ma;var Xd="DialogDescription",Jd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Xd,n);return c.jsx(Ie.p,{id:o.descriptionId,...r,ref:t})});Jd.displayName=Xd;var Zd="DialogClose",Qd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Zd,n);return c.jsx(Ie.button,{type:"button",...r,ref:t,onClick:pe(e.onClick,()=>o.onOpenChange(!1))})});Qd.displayName=Zd;function Da(e){return e?"open":"closed"}var ef="DialogTitleWarning",[CT,tf]=Ev(ef,{contentName:mr,titleName:Ma,docsSlug:"dialog"}),vw=({titleId:e})=>{const t=tf(ef),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 m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},vw="DialogDescriptionWarning",bw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${rf(vw).contentName}}.`;return m.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},of=Ud,ww=Vd,sf=qd,Ps=Gd,Os=Yd,gr=Jd,Ms=Qd,af=tf;const Sw=of,Cw=sf,lf=m.forwardRef(({className:e,...t},n)=>c.jsx(Ps,{ref:n,className:re("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}));lf.displayName=Ps.displayName;const cf=m.forwardRef(({className:e,children:t,...n},r)=>{const o=m.useMemo(()=>{let s=!1;function i(a){m.Children.forEach(a,l=>{if(s||!m.isValidElement(l))return;const u=l.type;if(u===gr||(u==null?void 0:u.displayName)===gr.displayName||(u==null?void 0:u.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return c.jsxs(Cw,{children:[c.jsx(lf,{}),c.jsxs(Os,{ref:r,className:re("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&&c.jsx(gr,{className:"sr-only",children:"Dialog"}),t,c.jsxs(af,{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:[c.jsx(ue.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});cf.displayName=Os.displayName;const uf=({className:e,...t})=>c.jsx("div",{className:re("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});uf.displayName="DialogHeader";const df=m.forwardRef(({className:e,...t},n)=>c.jsx(gr,{ref:n,className:re("text-lg font-semibold leading-none tracking-tight",e),...t}));df.displayName=gr.displayName;const Tw=m.forwardRef(({className:e,...t},n)=>c.jsx(Ms,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));Tw.displayName=Ms.displayName;function kw({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=w.useState(!1),[a,l]=w.useState(null),[u,d]=w.useState(null),{toast:f}=Sa(),h=w.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await xd(n);l(y)}catch(y){console.error("Failed to load file:",y),d(y instanceof Error?y.message:"Failed to load file")}finally{i(!1)}}},[n]);w.useEffect(()=>{e&&n&&h()},[e,n,h]);const p=async()=>{if(n)try{await ob(n),f({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),f({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await xd(n),b=new Blob([y],{type:o}),C=URL.createObjectURL(b);window.open(C,"_blank"),URL.revokeObjectURL(C)}catch(y){console.error("Failed to open file externally:",y),f({title:"Failed to open file",description:String(y),variant:"destructive"})}},x=()=>s?c.jsxs("div",{className:"flex items-center justify-center py-12",children:[c.jsx(ue.Loader,{className:"h-8 w-8 animate-spin mr-3"}),c.jsx("span",{children:"Loading file..."})]}):u?c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),c.jsx("p",{className:"text-red-600 mb-4",children:u}),c.jsx(qe,{onClick:h,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?c.jsx("div",{className:"flex justify-center",children:c.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?c.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:c.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?c.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:c.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx(ue.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),c.jsx("p",{className:"text-lg font-medium mb-2",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),g=()=>o.startsWith("image/")?c.jsx(ue.Image,{className:"h-5 w-5"}):c.jsx(ue.FileText,{className:"h-5 w-5"});return c.jsx(Sw,{open:e,onOpenChange:t,children:c.jsxs(cf,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[c.jsx(uf,{children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[g(),c.jsxs("div",{children:[c.jsx(df,{className:"text-left",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(qe,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[c.jsx(ue.ExternalLink,{className:"h-4 w-4"}),"External"]}),c.jsxs(qe,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[c.jsx(ue.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),c.jsx("div",{className:"flex-1 overflow-hidden",children:x()})]})})}function ff(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 hf(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function go(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(go).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(hf(e)){try{console.debug("[message-utils] sanitizeForDisplay - dropping file-like object",{sampleFilename:e&&(e.filename||e.name)?e.filename||e.name:void 0,keys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - dropped file-like (unable to inspect)",{err:String(n)})}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=go(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function Ds(e){if(typeof e=="string")return e;if(hf(e))return"";try{const t=go(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function pf(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 pf(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 l=new RegExp(i+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(r);if(!l)continue;const u=l[1],d=/Issue\(([\s\S]*?)\)(?:,|$)/g;let f=null;for(;(f=d.exec(u))!==null;){const h=f[1],p=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(h),v=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(h),x=p?p[2].trim():"",g=v?v[2].trim():"";n[i].push({title:x,description:g})}}return Object.values(n).some(i=>i.length>0)?n:null}const Ls="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",xr=1e5;function Ew(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Iw(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 Nw(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 Fs(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function Aw(e){const t=(r,o=xr)=>{try{const s=go(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 _w(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 mf(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 Rw({className:e}){const[t,n]=w.useState(0);return w.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),c.jsxs("span",{"aria-live":"polite",className:re("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const gf=w.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateToolMessages:u=!0,toolMessagePreviewLength:d=200,truncateUserMessages:f=!0,userMessagePreviewLength:h=200,customStyles:p={},onEdit:v,onRegenerate:x,onCancelEdit:g,onCopy:y,activeInterrupt:b,disableInterruptActions:C=!1,onInterruptActionStart:E,onInterruptActionEnd:T}){const[k,I]=w.useState(!1),[_,R]=w.useState("collapsed"),[j,H]=w.useState(!1),{currentThreadId:F}=Xo(),{respondToInterrupt:U}=Jo(),{toast:D}=Sa(),[G,W]=w.useState({}),[ne,$]=w.useState(!1),[z,ie]=w.useState(null),M=l==="phone"||l==="half-screen",Y=t.role,ce=Y==="tool",be=!(r&&Y!=="user"),ge=w.useMemo(()=>{switch(Y){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))]"}},[Y]),ye=w.useMemo(()=>Ew(t.content),[t.content]),K=w.useMemo(()=>Iw(t.content),[t.content]),L=w.useMemo(()=>t.content.filter(X=>X.type==="image_url"),[t.content]),Z=w.useMemo(()=>t.content.filter(X=>X.type==="file"),[t.content]),ee=w.useMemo(()=>t.content.filter(X=>X.type==="interrupt"),[t.content]),me=(b==null?void 0:b.id)??(b==null?void 0:b.interrupt_id),se=Fs(me),ae=b==null?void 0:b.value,He=w.useMemo(()=>Aw(t.content),[t.content]);w.useMemo(()=>_w(t.content),[t.content]);const Je=w.useMemo(()=>He.length<=xr?He:`${He.slice(0,xr)}
129
- … [truncated ${He.length-xr} chars]`,[He]),je=w.useCallback(async(X="all")=>{const de=X==="visible"&&ce?Je:ce?He:ye;async function _e(Fe){try{await navigator.clipboard.writeText(Fe)}catch{try{const nt=document.createElement("textarea");nt.value=Fe,nt.setAttribute("readonly",""),nt.style.position="absolute",nt.style.left="-9999px",document.body.appendChild(nt),nt.select(),document.execCommand("copy"),document.body.removeChild(nt)}catch(nt){throw console.error("Failed to copy:",nt),nt}}}try{await _e(de),I(!0),setTimeout(()=>I(!1),2e3),y==null||y(de)}catch(Fe){console.error("Failed to copy:",Fe)}},[ce,He,ye,Je,y]),Ue=w.useCallback(()=>{if(!v)return;const X=ce?He:ye;v(t.id,X)},[v,t.id,ce,He,ye]),et=w.useCallback(()=>{x==null||x(n)},[x,n]),Ze=w.useCallback(async(X,xe,de)=>{if(!be){X.preventDefault();return}if(G[de]){X.preventDefault();return}try{const _e=String(xe.url??""),Fe=_e.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(Fe){X.preventDefault();const nt=Fe[1],pt=xe.name||`file_${nt}`,Qe=xe.mimeType||"application/octet-stream";ie({id:nt,name:pt,mimeType:Qe}),$(!0);return}if(_e.startsWith("data:")){X.preventDefault(),W(Qe=>({...Qe,[de]:!0}));const nt=`${xe.name}_${xe.size}_${Date.now()}`,pt=D({title:"Fetching file...",description:"",open:!0});try{const Qe=await sb(F??void 0);if(!Qe||!Array.isArray(Qe))throw new Error("Invalid file list response");const ut=Qe.find(mt=>!mt||typeof mt!="object"||!((mt.filename??"")===(xe.name??""))?!1:typeof xe.size=="number"&&typeof mt.size=="number"?mt.size===xe.size:!0);if(!(ut!=null&&ut.id))throw new Error(`File "${xe.name}" is not yet available on the server`);if(!ut.id||!ut.filename)throw new Error("Invalid file data received from server");ie({id:ut.id,name:xe.name||ut.filename||`file_${ut.id}`,mimeType:xe.mimeType||ut.mime_type||"application/octet-stream"}),$(!0),pt.update({id:pt.id,title:"Success",description:`Opened ${xe.name}`,open:!0})}catch(Qe){console.error("Failed to fetch server file:",Qe);const ut=Qe instanceof Error?Qe.message:"Unknown error occurred";pt.update({id:pt.id,title:"Failed",description:ut}),D({title:"Failed to fetch file",description:ut,open:!0})}finally{W(Qe=>({...Qe,[de]:!1}))}}}catch(_e){console.error("File click error:",_e),W(Fe=>({...Fe,[de]:!1}))}},[be,G,D,F]),Pe=w.useCallback(()=>{const xe=re(M?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",ge);switch(Y){case"user":return c.jsx(ue.User,{className:xe});case"assistant":return c.jsx(ue.Bot,{className:xe});case"tool":return c.jsx(ue.Wrench,{className:xe});default:return c.jsx(ue.Bot,{className:xe})}},[M,ge,Y]),Ct=w.useCallback(()=>{const X="group relative mb-4 flex w-full";switch(Y){case"user":return re(X,"justify-end");case"assistant":case"tool":case"system":return re(X,"justify-start");default:return X}},[Y]),kt=w.useCallback(()=>{const X=re("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",M&&"px-3 py-2 text-sm");switch(Y){case"user":return re(X,"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 re(X,"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 re(X,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return re(X,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return re(X,"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")}},[M,Y]),Et=w.useCallback(async X=>{if(C)return;const xe=Fs((X==null?void 0:X.id)??(X==null?void 0:X.interrupt_id));if(!xe){console.warn("Interrupt part missing id",X);return}try{E==null||E(),await U(xe,!0)}catch(de){console.error("Failed to approve interrupt:",de)}finally{T==null||T()}},[C,T,E,U]),st=w.useCallback(async X=>{if(C)return;const xe=Fs((X==null?void 0:X.id)??(X==null?void 0:X.interrupt_id));if(!xe){console.warn("Interrupt part missing id",X);return}try{E==null||E(),await U(xe,!1)}catch(de){console.error("Failed to reject interrupt:",de)}finally{T==null||T()}},[C,T,E,U]),tt=w.useCallback(({part:X,i:xe})=>{if(X.type==="text"){const de=X.text??"",_e=de.trim(),Fe=ff(_e);return Fe&&Y!=="tool"?c.jsx(Pw,{data:Fe},xe):Y==="user"&&f&&_e.length>h?c.jsxs(Qu,{open:j,onOpenChange:H,children:[c.jsx("div",{className:re("text-sm text-[hsl(var(--chat-bubble-user-text))]",M&&"text-xs"),children:j?c.jsx(va,{content:_e,allowHtml:!1}):c.jsxs("pre",{className:re("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",M&&"text-xs"),children:[_e.substring(0,h),"..."]})}),c.jsx(ed,{asChild:!0,children:c.jsx(qe,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:j?c.jsxs(c.Fragment,{children:[c.jsx(ue.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ue.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",_e.length-h," chars)"]})})})]},xe):c.jsx(va,{content:de,allowHtml:!1},xe)}if(X.type==="image_url"){const de=X;return c.jsx("div",{className:"my-2",children:c.jsx("img",{src:de.url,alt:de.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},xe)}if(X.type==="file"){const de=X,_e=de.name||"file";return c.jsxs("a",{href:de.url,onClick:Fe=>Ze(Fe,de,xe),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:[G[xe]?c.jsx(ue.Loader,{className:"h-4 w-4 animate-spin"}):null,c.jsxs("span",{className:"truncate max-w-[180px]",children:[_e,G[xe]?" (processing)":""]})]},xe)}if(X.type==="interrupt"){const de=X,_e=Fs((de==null?void 0:de.id)??(de==null?void 0:de.interrupt_id)),Fe=!!(se&&_e&&_e===se),nt=Fe?ae??(de==null?void 0:de.value):de==null?void 0:de.value,pt=_e?{...de,id:_e,interrupt_id:_e}:de;return c.jsx(Mw,{interruptPart:pt,onApprove:Et,onReject:st,disabled:C,isActive:Fe,payload:nt},xe)}return null},[Ze,G,Et,st,Y,f,h,j,M,se,ae,b,C,ee]),ze=w.useCallback(()=>c.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[c.jsx(ue.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),ct=w.useCallback(()=>{const X=ye.trim().length>0||L.length>0||Z.length>0||ee.length>0;if(!ce&&!X&&!r)return ze();if(t.model==="reflection"){const xe=ye.trim(),de=ff(xe);if(de&&typeof de=="object")return c.jsx(Dw,{data:de})}if(ce&&K.name==="get_issues"){const xe=t.content.find(Fe=>Fe.type==="tool_end"),de=(xe==null?void 0:xe.output)??He,_e=pf(de);if(_e)return c.jsx(Lw,{issues:_e})}if(ce){const xe=Nw(t.content);if(xe.length>0)return c.jsx("div",{className:"space-y-2",children:xe.map((de,_e)=>{const Fe=typeof de.output=="string"?de.output:Ds(de.output),nt=Fe.length>xr?`${Fe.slice(0,xr)}
131
- … [truncated ${Fe.length-xr} chars]`:Fe,pt=_==="expanded";return c.jsxs(Qu,{open:pt,onOpenChange:Qe=>R(Qe?"expanded":"preview"),children:[c.jsx("div",{className:"flex items-center gap-2 text-xs",children:c.jsx(fa,{variant:"outline",children:(de.name??"tool")+(de.toolCallId?` • ${de.toolCallId.slice(0,8)}`:"")})}),c.jsx("div",{className:"font-mono text-sm mt-1",children:c.jsx("pre",{className:"whitespace-pre-wrap break-words",children:pt?nt:nt.slice(0,d)+(nt.length>d?"...":"")})}),c.jsx(ed,{asChild:!0,children:c.jsx(qe,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:pt?c.jsxs(c.Fragment,{children:[" ",c.jsx(ue.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ue.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},de.toolCallId??_e)})})}if(!ce){const xe=c.jsx("div",{className:"space-y-2",children:t.content.map((de,_e)=>c.jsx(tt,{part:de,i:_e},_e))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[xe,c.jsx(Rw,{className:ge})]}):xe}},[ye,L.length,Z.length,ee.length,r,t.model,ce,K.name,He,_,u,ze,ge]),bt=w.useMemo(()=>jw(t),[t]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:re(Ct(),p.container),children:c.jsxs("div",{className:re(kt(),p.content),children:[(i||a||ce)&&c.jsxs("div",{className:re("flex items-center justify-between mb-2 pb-2 border-b border-current/10",M&&"mb-1 pb-1",ge,p.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[Pe(),a&&bt&&c.jsx("span",{className:re("font-medium",M?"text-xs":"text-sm"),children:bt}),ce&&K.name&&c.jsxs(fa,{variant:"outline",className:re("text-xs flex items-center gap-1 cursor-pointer",ge,"border border-current/40",M&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":_!=="collapsed",onKeyDown:X=>{(X.key==="Enter"||X.key===" ")&&(X.preventDefault(),R(xe=>xe==="collapsed"?"preview":"collapsed"))},onClick:()=>R(X=>X==="collapsed"?"preview":"collapsed"),children:[c.jsx("span",{children:K.name}),c.jsx("span",{className:"inline-flex items-center",children:_!=="collapsed"?c.jsx(ue.ChevronUp,{className:"h-3 w-3"}):c.jsx(ue.ChevronDown,{className:"h-3 w-3"})})]}),ce&&!K.name&&c.jsx(qe,{variant:"ghost",size:"sm",className:re("h-6 px-1",ge,"hover:bg-foreground/10"),onClick:()=>R(X=>X==="collapsed"?"preview":"collapsed"),children:c.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",_!=="collapsed"?c.jsx(ue.ChevronUp,{className:"h-3 w-3"}):c.jsx(ue.ChevronDown,{className:"h-3 w-3"})]})})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.createdAt&&c.jsx("time",{className:re("text-xs opacity-60",ge,M&&"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&&c.jsxs("div",{className:re("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsxs("div",{className:"relative",children:[c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>je(ce?"visible":"all"),className:re("h-6 w-6 p-0 hover:bg-foreground/10",ge,M&&"h-5 w-5"),"aria-label":ce?"Copy visible":"Copy message",title:ce?"Copy visible portion":"Copy message",children:c.jsx(ue.Copy,{className:re(k?"text-success":ge,M?"h-3 w-3":"h-4 w-4")})}),ce&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>je("all"),className:re("h-6 px-1 text-xs hover:bg-foreground/10",ge),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),Y==="user"&&v&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:Ue,className:re("h-6 w-6 p-0 hover:bg-foreground/10",ge,M&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(ue.Edit,{className:re(ge,M?"h-3 w-3":"h-4 w-4")})}),Y==="assistant"&&x&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:et,className:re("h-6 w-6 p-0 hover:bg-foreground/10",ge,M&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(ue.RotateCcw,{className:re(ge,M?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsx("div",{className:"relative",children:ct()}),ce&&_==="expanded"&&(K.toolCallId||K.name)&&c.jsxs("div",{className:re("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",M&&"text-xs"),children:[K.name&&c.jsxs("div",{children:["Function: ",K.name]}),K.toolCallId&&c.jsxs("div",{children:["Call ID: ",K.toolCallId]})]}),!(i||a||ce)&&s&&!o&&c.jsxs("div",{className:re("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>je(),className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:c.jsx(ue.Copy,{className:re(k?"text-success":"text-current",M?"h-3 w-3":"h-4 w-4")})}),Y==="user"&&v&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:Ue,className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:c.jsx(ue.Edit,{className:re("text-current",M?"h-3 w-3":"h-4 w-4")})}),Y==="assistant"&&x&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:et,className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:c.jsx(ue.RotateCcw,{className:re("text-current",M?"h-3 w-3":"h-4 w-4")})})]})]})}),z&&c.jsx(kw,{isOpen:ne,onClose:()=>{$(!1),ie(null)},fileId:z.id,fileName:z.name,mimeType:z.mimeType})]})},(e,t)=>{var i,a,l,u,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&mf(e.message)===mf(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(v=>e[v]===t[v]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((l=e.customStyles)==null?void 0:l.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)===((p=t.customStyles)==null?void 0:p.header);return o&&s});function Pw({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?c.jsx("div",{className:Ls,children:c.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>c.jsx("li",{children:String(n)},r))})}):c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Ds(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 c.jsxs("div",{className:Ls,children:[typeof r=="boolean"&&c.jsxs("p",{children:[c.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Follow-up queries:"})}),c.jsx("ul",{className:"list-disc pl-5",children:n.map((s,i)=>c.jsx("li",{children:String(s)},i))})]}),t&&t.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Facts:"})}),c.jsx("ul",{className:"list-disc pl-5",children:t.map((s,i)=>c.jsx("li",{children:String(s)},i))})]})]});const o=Object.entries(e);return c.jsx("div",{className:Ls,children:c.jsx("dl",{className:"mt-0",children:o.map(([s,i])=>c.jsxs("div",{className:"mb-1",children:[c.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),c.jsx("dd",{className:"inline",children:Ow(i)})]},s))})})}return c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Ds(e)})}function Ow(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 c.jsx("code",{className:"text-xs",children:JSON.stringify(go(e))})}catch{return String(e)}}function Mw({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=c.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const u=Ds(s);a=c.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:u})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return c.jsxs(uo,{className:re("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[c.jsxs(fo,{className:"pb-3",children:[c.jsx(ho,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),c.jsx(td,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&c.jsx(po,{className:"pt-0 pb-3",children:a}),c.jsx(nd,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(qe,{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",disabled:r||!o,children:"Reject"}),c.jsx(qe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}function Dw({data:e}){return c.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>c.jsxs("div",{className:"flex",children:[c.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),c.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>c.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function Lw({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return c.jsx("div",{className:Ls,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:c.jsxs("div",{className:"mb-4",children:[c.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),c.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>c.jsxs("li",{children:[c.jsx("div",{className:"font-medium",children:o.title}),c.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const xf=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,La=w.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:v=!0,isNavigatingCheckpoint:x=!1,onScrollAway:g,onAtBottom:y,activeInterrupt:b,disableInterruptActions:C=!1,onInterruptActionStart:E,onInterruptActionEnd:T},k)=>{const I=w.useRef(null),_=w.useRef(null),R=w.useRef(!1),[j,H]=w.useState(!0),F=w.useMemo(()=>b?e.some($=>Array.isArray($==null?void 0:$.content)&&$.content.some(z=>z&&z.type==="interrupt"&&(z.id??z.interrupt_id)===b.id)):!1,[b,e]),U=w.useMemo(()=>{if(!b||F)return null;const $=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let z;const ie=b.value;if(ie&&typeof ie=="object"&&!Array.isArray(ie)){const M=ie.title;typeof M=="string"&&M.trim()&&(z=M.trim())}return{id:`interrupt-${$}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:$,value:ie,title:z}]}},[b,F]),D=w.useMemo(()=>U?[...e,U]:e,[e,U]),G=w.useCallback($=>{H($),g&&g(!$),y&&y($)},[g,y]),W=w.useMemo(()=>{if(a)return async()=>{if(!R.current){R.current=!0;try{await a()}finally{R.current=!1}}}},[a]),ne=w.useMemo(()=>!v||x?!1:j?"auto":!1,[j,v,x]);return D.length===0?c.jsx("div",{className:f,style:h,children:c.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:p||"No messages yet. Start a conversation!"})}):c.jsx("div",{className:f,style:h,children:c.jsx(cv,{ref:$=>{I.current=$},scrollerRef:$=>{_.current=$ instanceof HTMLDivElement?$:null},data:D,followOutput:ne,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{W&&W()},atBottomStateChange:G,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:($,z)=>xf(z,$),itemContent:($,z)=>{const ie=xf(z,$);return c.jsx("div",{className:"mb-4 last:mb-0","data-message-id":ie,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(gf,{message:z,messageIndex:$,isStreamingMessage:t&&n===z.id,streamingDebounceMs:r,isEditing:i===z.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:l,onRegenerate:()=>u($),onCancelEdit:d,activeInterrupt:b,disableInterruptActions:C,onInterruptActionStart:E,onInterruptActionEnd:T})})}})})});La.displayName="MessageList";const $s=1e4;function Fw(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 m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},bw="DialogDescriptionWarning",ww=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${tf(bw).contentName}}.`;return m.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},nf=Bd,Sw=Ud,rf=Vd,Ps=Kd,Os=qd,gr=Yd,Ms=Jd,of=Qd;const Cw=nf,kw=rf,sf=m.forwardRef(({className:e,...t},n)=>c.jsx(Ps,{ref:n,className:re("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}));sf.displayName=Ps.displayName;const af=m.forwardRef(({className:e,children:t,...n},r)=>{const o=m.useMemo(()=>{let s=!1;function i(a){m.Children.forEach(a,l=>{if(s||!m.isValidElement(l))return;const u=l.type;if(u===gr||(u==null?void 0:u.displayName)===gr.displayName||(u==null?void 0:u.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return c.jsxs(kw,{children:[c.jsx(sf,{}),c.jsxs(Os,{ref:r,className:re("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&&c.jsx(gr,{className:"sr-only",children:"Dialog"}),t,c.jsxs(of,{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:[c.jsx(ue.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});af.displayName=Os.displayName;const lf=({className:e,...t})=>c.jsx("div",{className:re("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});lf.displayName="DialogHeader";const cf=m.forwardRef(({className:e,...t},n)=>c.jsx(gr,{ref:n,className:re("text-lg font-semibold leading-none tracking-tight",e),...t}));cf.displayName=gr.displayName;const Tw=m.forwardRef(({className:e,...t},n)=>c.jsx(Ms,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));Tw.displayName=Ms.displayName;function Ew({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=w.useState(!1),[a,l]=w.useState(null),[u,d]=w.useState(null),{toast:f}=Sa(),h=w.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await md(n);l(y)}catch(y){console.error("Failed to load file:",y),d(y instanceof Error?y.message:"Failed to load file")}finally{i(!1)}}},[n]);w.useEffect(()=>{e&&n&&h()},[e,n,h]);const p=async()=>{if(n)try{await sb(n),f({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),f({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await md(n),b=new Blob([y],{type:o}),C=URL.createObjectURL(b);window.open(C,"_blank"),URL.revokeObjectURL(C)}catch(y){console.error("Failed to open file externally:",y),f({title:"Failed to open file",description:String(y),variant:"destructive"})}},x=()=>s?c.jsxs("div",{className:"flex items-center justify-center py-12",children:[c.jsx(ue.Loader,{className:"h-8 w-8 animate-spin mr-3"}),c.jsx("span",{children:"Loading file..."})]}):u?c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),c.jsx("p",{className:"text-red-600 mb-4",children:u}),c.jsx(qe,{onClick:h,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?c.jsx("div",{className:"flex justify-center",children:c.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?c.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:c.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?c.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:c.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx(ue.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),c.jsx("p",{className:"text-lg font-medium mb-2",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),g=()=>o.startsWith("image/")?c.jsx(ue.Image,{className:"h-5 w-5"}):c.jsx(ue.FileText,{className:"h-5 w-5"});return c.jsx(Cw,{open:e,onOpenChange:t,children:c.jsxs(af,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[c.jsx(lf,{children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[g(),c.jsxs("div",{children:[c.jsx(cf,{className:"text-left",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(qe,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[c.jsx(ue.ExternalLink,{className:"h-4 w-4"}),"External"]}),c.jsxs(qe,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[c.jsx(ue.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),c.jsx("div",{className:"flex-1 overflow-hidden",children:x()})]})})}function uf(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 df(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function go(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(go).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(df(e)){try{console.debug("[message-utils] sanitizeForDisplay - dropping file-like object",{sampleFilename:e&&(e.filename||e.name)?e.filename||e.name:void 0,keys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - dropped file-like (unable to inspect)",{err:String(n)})}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=go(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function Ds(e){if(typeof e=="string")return e;if(df(e))return"";try{const t=go(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function ff(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 ff(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 l=new RegExp(i+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(r);if(!l)continue;const u=l[1],d=/Issue\(([\s\S]*?)\)(?:,|$)/g;let f=null;for(;(f=d.exec(u))!==null;){const h=f[1],p=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(h),v=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(h),x=p?p[2].trim():"",g=v?v[2].trim():"";n[i].push({title:x,description:g})}}return Object.values(n).some(i=>i.length>0)?n:null}const Ls="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",xr=1e5;function Iw(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Nw(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 Aw(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 Fs(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function _w(e){const t=(r,o=xr)=>{try{const s=go(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 Rw(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function hf(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 Pw({className:e}){const[t,n]=w.useState(0);return w.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),c.jsxs("span",{"aria-live":"polite",className:re("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const pf=w.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateToolMessages:u=!0,toolMessagePreviewLength:d=200,truncateUserMessages:f=!0,userMessagePreviewLength:h=200,customStyles:p={},onEdit:v,onRegenerate:x,onCancelEdit:g,onCopy:y,activeInterrupt:b,disableInterruptActions:C=!1,onInterruptActionStart:E,onInterruptActionEnd:k}){const[T,I]=w.useState(!1),[_,R]=w.useState("collapsed"),[j,H]=w.useState(!1),{currentThreadId:F}=Xo(),{respondToInterrupt:U}=Jo(),{toast:D}=Sa(),[G,W]=w.useState({}),[ne,$]=w.useState(!1),[z,ie]=w.useState(null),M=l==="phone"||l==="half-screen",Y=t.role,ce=Y==="tool",be=!(r&&Y!=="user"),ge=w.useMemo(()=>{switch(Y){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))]"}},[Y]),ye=w.useMemo(()=>Iw(t.content),[t.content]),K=w.useMemo(()=>Nw(t.content),[t.content]),L=w.useMemo(()=>t.content.filter(X=>X.type==="image_url"),[t.content]),Z=w.useMemo(()=>t.content.filter(X=>X.type==="file"),[t.content]),ee=w.useMemo(()=>t.content.filter(X=>X.type==="interrupt"),[t.content]),me=(b==null?void 0:b.id)??(b==null?void 0:b.interrupt_id),se=Fs(me),ae=b==null?void 0:b.value,He=w.useMemo(()=>_w(t.content),[t.content]);w.useMemo(()=>jw(t.content),[t.content]);const Je=w.useMemo(()=>He.length<=xr?He:`${He.slice(0,xr)}
129
+ … [truncated ${He.length-xr} chars]`,[He]),je=w.useCallback(async(X="all")=>{const de=X==="visible"&&ce?Je:ce?He:ye;async function _e(Fe){try{await navigator.clipboard.writeText(Fe)}catch{try{const nt=document.createElement("textarea");nt.value=Fe,nt.setAttribute("readonly",""),nt.style.position="absolute",nt.style.left="-9999px",document.body.appendChild(nt),nt.select(),document.execCommand("copy"),document.body.removeChild(nt)}catch(nt){throw console.error("Failed to copy:",nt),nt}}}try{await _e(de),I(!0),setTimeout(()=>I(!1),2e3),y==null||y(de)}catch(Fe){console.error("Failed to copy:",Fe)}},[ce,He,ye,Je,y]),Ue=w.useCallback(()=>{if(!v)return;const X=ce?He:ye;v(t.id,X)},[v,t.id,ce,He,ye]),et=w.useCallback(()=>{x==null||x(n)},[x,n]),Ze=w.useCallback(async(X,xe,de)=>{if(!be){X.preventDefault();return}if(G[de]){X.preventDefault();return}try{const _e=String(xe.url??""),Fe=_e.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(Fe){X.preventDefault();const nt=Fe[1],pt=xe.name||`file_${nt}`,Qe=xe.mimeType||"application/octet-stream";ie({id:nt,name:pt,mimeType:Qe}),$(!0);return}if(_e.startsWith("data:")){X.preventDefault(),W(Qe=>({...Qe,[de]:!0}));const nt=`${xe.name}_${xe.size}_${Date.now()}`,pt=D({title:"Fetching file...",description:"",open:!0});try{const Qe=await ib(F??void 0);if(!Qe||!Array.isArray(Qe))throw new Error("Invalid file list response");const ut=Qe.find(mt=>!mt||typeof mt!="object"||!((mt.filename??"")===(xe.name??""))?!1:typeof xe.size=="number"&&typeof mt.size=="number"?mt.size===xe.size:!0);if(!(ut!=null&&ut.id))throw new Error(`File "${xe.name}" is not yet available on the server`);if(!ut.id||!ut.filename)throw new Error("Invalid file data received from server");ie({id:ut.id,name:xe.name||ut.filename||`file_${ut.id}`,mimeType:xe.mimeType||ut.mime_type||"application/octet-stream"}),$(!0),pt.update({id:pt.id,title:"Success",description:`Opened ${xe.name}`,open:!0})}catch(Qe){console.error("Failed to fetch server file:",Qe);const ut=Qe instanceof Error?Qe.message:"Unknown error occurred";pt.update({id:pt.id,title:"Failed",description:ut}),D({title:"Failed to fetch file",description:ut,open:!0})}finally{W(Qe=>({...Qe,[de]:!1}))}}}catch(_e){console.error("File click error:",_e),W(Fe=>({...Fe,[de]:!1}))}},[be,G,D,F]),Pe=w.useCallback(()=>{const xe=re(M?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",ge);switch(Y){case"user":return c.jsx(ue.User,{className:xe});case"assistant":return c.jsx(ue.Bot,{className:xe});case"tool":return c.jsx(ue.Wrench,{className:xe});default:return c.jsx(ue.Bot,{className:xe})}},[M,ge,Y]),Ct=w.useCallback(()=>{const X="group relative mb-4 flex w-full";switch(Y){case"user":return re(X,"justify-end");case"assistant":case"tool":case"system":return re(X,"justify-start");default:return X}},[Y]),Tt=w.useCallback(()=>{const X=re("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",M&&"px-3 py-2 text-sm");switch(Y){case"user":return re(X,"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 re(X,"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 re(X,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return re(X,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return re(X,"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")}},[M,Y]),Et=w.useCallback(async X=>{if(C)return;const xe=Fs((X==null?void 0:X.id)??(X==null?void 0:X.interrupt_id));if(!xe){console.warn("Interrupt part missing id",X);return}try{E==null||E(),await U(xe,!0)}catch(de){console.error("Failed to approve interrupt:",de)}finally{k==null||k()}},[C,k,E,U]),st=w.useCallback(async X=>{if(C)return;const xe=Fs((X==null?void 0:X.id)??(X==null?void 0:X.interrupt_id));if(!xe){console.warn("Interrupt part missing id",X);return}try{E==null||E(),await U(xe,!1)}catch(de){console.error("Failed to reject interrupt:",de)}finally{k==null||k()}},[C,k,E,U]),tt=w.useCallback(({part:X,i:xe})=>{if(X.type==="text"){const de=X.text??"",_e=de.trim(),Fe=uf(_e);return Fe&&Y!=="tool"?c.jsx(Ow,{data:Fe},xe):Y==="user"&&f&&_e.length>h?c.jsxs(Ju,{open:j,onOpenChange:H,children:[c.jsx("div",{className:re("text-sm text-[hsl(var(--chat-bubble-user-text))]",M&&"text-xs"),children:j?c.jsx(va,{content:_e,allowHtml:!1}):c.jsxs("pre",{className:re("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",M&&"text-xs"),children:[_e.substring(0,h),"..."]})}),c.jsx(Zu,{asChild:!0,children:c.jsx(qe,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:j?c.jsxs(c.Fragment,{children:[c.jsx(ue.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ue.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",_e.length-h," chars)"]})})})]},xe):c.jsx(va,{content:de,allowHtml:!1},xe)}if(X.type==="image_url"){const de=X;return c.jsx("div",{className:"my-2",children:c.jsx("img",{src:de.url,alt:de.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},xe)}if(X.type==="file"){const de=X,_e=de.name||"file";return c.jsxs("a",{href:de.url,onClick:Fe=>Ze(Fe,de,xe),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:[G[xe]?c.jsx(ue.Loader,{className:"h-4 w-4 animate-spin"}):null,c.jsxs("span",{className:"truncate max-w-[180px]",children:[_e,G[xe]?" (processing)":""]})]},xe)}if(X.type==="interrupt"){const de=X,_e=Fs((de==null?void 0:de.id)??(de==null?void 0:de.interrupt_id)),Fe=!!(se&&_e&&_e===se),nt=Fe?ae??(de==null?void 0:de.value):de==null?void 0:de.value,pt=_e?{...de,id:_e,interrupt_id:_e}:de;return c.jsx(Dw,{interruptPart:pt,onApprove:Et,onReject:st,disabled:C,isActive:Fe,payload:nt},xe)}return null},[Ze,G,Et,st,Y,f,h,j,M,se,ae,b,C,ee]),ze=w.useCallback(()=>c.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[c.jsx(ue.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),ct=w.useCallback(()=>{const X=ye.trim().length>0||L.length>0||Z.length>0||ee.length>0;if(!ce&&!X&&!r)return ze();if(t.model==="reflection"){const xe=ye.trim(),de=uf(xe);if(de&&typeof de=="object")return c.jsx(Lw,{data:de})}if(ce&&K.name==="get_issues"){const xe=t.content.find(Fe=>Fe.type==="tool_end"),de=(xe==null?void 0:xe.output)??He,_e=ff(de);if(_e)return c.jsx(Fw,{issues:_e})}if(ce){const xe=Aw(t.content);if(xe.length>0)return c.jsx("div",{className:"space-y-2",children:xe.map((de,_e)=>{const Fe=typeof de.output=="string"?de.output:Ds(de.output),nt=Fe.length>xr?`${Fe.slice(0,xr)}
131
+ … [truncated ${Fe.length-xr} chars]`:Fe,pt=_==="expanded";return c.jsxs(Ju,{open:pt,onOpenChange:Qe=>R(Qe?"expanded":"preview"),children:[c.jsx("div",{className:"flex items-center gap-2 text-xs",children:c.jsx(fa,{variant:"outline",children:(de.name??"tool")+(de.toolCallId?` • ${de.toolCallId.slice(0,8)}`:"")})}),c.jsx("div",{className:"font-mono text-sm mt-1",children:c.jsx("pre",{className:"whitespace-pre-wrap break-words",children:pt?nt:nt.slice(0,d)+(nt.length>d?"...":"")})}),c.jsx(Zu,{asChild:!0,children:c.jsx(qe,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:pt?c.jsxs(c.Fragment,{children:[" ",c.jsx(ue.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ue.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},de.toolCallId??_e)})})}if(!ce){const xe=c.jsx("div",{className:"space-y-2",children:t.content.map((de,_e)=>c.jsx(tt,{part:de,i:_e},_e))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[xe,c.jsx(Pw,{className:ge})]}):xe}},[ye,L.length,Z.length,ee.length,r,t.model,ce,K.name,He,_,u,ze,ge]),bt=w.useMemo(()=>Rw(t),[t]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:re(Ct(),p.container),children:c.jsxs("div",{className:re(Tt(),p.content),children:[(i||a||ce)&&c.jsxs("div",{className:re("flex items-center justify-between mb-2 pb-2 border-b border-current/10",M&&"mb-1 pb-1",ge,p.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[Pe(),a&&bt&&c.jsx("span",{className:re("font-medium",M?"text-xs":"text-sm"),children:bt}),ce&&K.name&&c.jsxs(fa,{variant:"outline",className:re("text-xs flex items-center gap-1 cursor-pointer",ge,"border border-current/40",M&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":_!=="collapsed",onKeyDown:X=>{(X.key==="Enter"||X.key===" ")&&(X.preventDefault(),R(xe=>xe==="collapsed"?"preview":"collapsed"))},onClick:()=>R(X=>X==="collapsed"?"preview":"collapsed"),children:[c.jsx("span",{children:K.name}),c.jsx("span",{className:"inline-flex items-center",children:_!=="collapsed"?c.jsx(ue.ChevronUp,{className:"h-3 w-3"}):c.jsx(ue.ChevronDown,{className:"h-3 w-3"})})]}),ce&&!K.name&&c.jsx(qe,{variant:"ghost",size:"sm",className:re("h-6 px-1",ge,"hover:bg-foreground/10"),onClick:()=>R(X=>X==="collapsed"?"preview":"collapsed"),children:c.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",_!=="collapsed"?c.jsx(ue.ChevronUp,{className:"h-3 w-3"}):c.jsx(ue.ChevronDown,{className:"h-3 w-3"})]})})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.createdAt&&c.jsx("time",{className:re("text-xs opacity-60",ge,M&&"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&&c.jsxs("div",{className:re("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsxs("div",{className:"relative",children:[c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>je(ce?"visible":"all"),className:re("h-6 w-6 p-0 hover:bg-foreground/10",ge,M&&"h-5 w-5"),"aria-label":ce?"Copy visible":"Copy message",title:ce?"Copy visible portion":"Copy message",children:c.jsx(ue.Copy,{className:re(T?"text-success":ge,M?"h-3 w-3":"h-4 w-4")})}),ce&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>je("all"),className:re("h-6 px-1 text-xs hover:bg-foreground/10",ge),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),Y==="user"&&v&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:Ue,className:re("h-6 w-6 p-0 hover:bg-foreground/10",ge,M&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(ue.Edit,{className:re(ge,M?"h-3 w-3":"h-4 w-4")})}),Y==="assistant"&&x&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:et,className:re("h-6 w-6 p-0 hover:bg-foreground/10",ge,M&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(ue.RotateCcw,{className:re(ge,M?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsx("div",{className:"relative",children:ct()}),ce&&_==="expanded"&&(K.toolCallId||K.name)&&c.jsxs("div",{className:re("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",M&&"text-xs"),children:[K.name&&c.jsxs("div",{children:["Function: ",K.name]}),K.toolCallId&&c.jsxs("div",{children:["Call ID: ",K.toolCallId]})]}),!(i||a||ce)&&s&&!o&&c.jsxs("div",{className:re("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>je(),className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:c.jsx(ue.Copy,{className:re(T?"text-success":"text-current",M?"h-3 w-3":"h-4 w-4")})}),Y==="user"&&v&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:Ue,className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:c.jsx(ue.Edit,{className:re("text-current",M?"h-3 w-3":"h-4 w-4")})}),Y==="assistant"&&x&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:et,className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:c.jsx(ue.RotateCcw,{className:re("text-current",M?"h-3 w-3":"h-4 w-4")})})]})]})}),z&&c.jsx(Ew,{isOpen:ne,onClose:()=>{$(!1),ie(null)},fileId:z.id,fileName:z.name,mimeType:z.mimeType})]})},(e,t)=>{var i,a,l,u,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&hf(e.message)===hf(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(v=>e[v]===t[v]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((l=e.customStyles)==null?void 0:l.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)===((p=t.customStyles)==null?void 0:p.header);return o&&s});function Ow({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?c.jsx("div",{className:Ls,children:c.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>c.jsx("li",{children:String(n)},r))})}):c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Ds(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 c.jsxs("div",{className:Ls,children:[typeof r=="boolean"&&c.jsxs("p",{children:[c.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Follow-up queries:"})}),c.jsx("ul",{className:"list-disc pl-5",children:n.map((s,i)=>c.jsx("li",{children:String(s)},i))})]}),t&&t.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Facts:"})}),c.jsx("ul",{className:"list-disc pl-5",children:t.map((s,i)=>c.jsx("li",{children:String(s)},i))})]})]});const o=Object.entries(e);return c.jsx("div",{className:Ls,children:c.jsx("dl",{className:"mt-0",children:o.map(([s,i])=>c.jsxs("div",{className:"mb-1",children:[c.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),c.jsx("dd",{className:"inline",children:Mw(i)})]},s))})})}return c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Ds(e)})}function Mw(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 c.jsx("code",{className:"text-xs",children:JSON.stringify(go(e))})}catch{return String(e)}}function Dw({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=c.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const u=Ds(s);a=c.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:u})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return c.jsxs(uo,{className:re("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[c.jsxs(fo,{className:"pb-3",children:[c.jsx(ho,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),c.jsx(Qu,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&c.jsx(po,{className:"pt-0 pb-3",children:a}),c.jsx(ed,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(qe,{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",disabled:r||!o,children:"Reject"}),c.jsx(qe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}function Lw({data:e}){return c.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>c.jsxs("div",{className:"flex",children:[c.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),c.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>c.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function Fw({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return c.jsx("div",{className:Ls,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:c.jsxs("div",{className:"mb-4",children:[c.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),c.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>c.jsxs("li",{children:[c.jsx("div",{className:"font-medium",children:o.title}),c.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const mf=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,La=w.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:v=!0,isNavigatingCheckpoint:x=!1,onScrollAway:g,onAtBottom:y,activeInterrupt:b,disableInterruptActions:C=!1,onInterruptActionStart:E,onInterruptActionEnd:k},T)=>{const I=w.useRef(null),_=w.useRef(null),R=w.useRef(!1),[j,H]=w.useState(!0),F=w.useMemo(()=>b?e.some($=>Array.isArray($==null?void 0:$.content)&&$.content.some(z=>z&&z.type==="interrupt"&&(z.id??z.interrupt_id)===b.id)):!1,[b,e]),U=w.useMemo(()=>{if(!b||F)return null;const $=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let z;const ie=b.value;if(ie&&typeof ie=="object"&&!Array.isArray(ie)){const M=ie.title;typeof M=="string"&&M.trim()&&(z=M.trim())}return{id:`interrupt-${$}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:$,value:ie,title:z}]}},[b,F]),D=w.useMemo(()=>U?[...e,U]:e,[e,U]),G=w.useCallback($=>{H($),g&&g(!$),y&&y($)},[g,y]),W=w.useMemo(()=>{if(a)return async()=>{if(!R.current){R.current=!0;try{await a()}finally{R.current=!1}}}},[a]),ne=w.useMemo(()=>!v||x?!1:j?"auto":!1,[j,v,x]);return D.length===0?c.jsx("div",{className:f,style:h,children:c.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:p||"No messages yet. Start a conversation!"})}):c.jsx("div",{className:f,style:h,children:c.jsx(uv,{ref:$=>{I.current=$},scrollerRef:$=>{_.current=$ instanceof HTMLDivElement?$:null},data:D,followOutput:ne,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{W&&W()},atBottomStateChange:G,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:($,z)=>mf(z,$),itemContent:($,z)=>{const ie=mf(z,$);return c.jsx("div",{className:"mb-4 last:mb-0","data-message-id":ie,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(pf,{message:z,messageIndex:$,isStreamingMessage:t&&n===z.id,streamingDebounceMs:r,isEditing:i===z.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:l,onRegenerate:()=>u($),onCancelEdit:d,activeInterrupt:b,disableInterruptActions:C,onInterruptActionStart:E,onInterruptActionEnd:k})})}})})});La.displayName="MessageList";const $s=1e4;function $w(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 $w(e,t=$s){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 zw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),$w(t),Fw(t)}function Fa(e){const t=e+"CollectionProvider",[n,r]=Sn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=x=>{const{scope:g,children:y}=x,b=w.useRef(null),C=w.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:C,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=or.createSlot(a),u=w.forwardRef((x,g)=>{const{scope:y,children:b}=x,C=s(a,y),E=Ve(g,C.collectionRef);return c.jsx(l,{ref:E,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=or.createSlot(d),p=w.forwardRef((x,g)=>{const{scope:y,children:b,...C}=x,E=w.useRef(null),T=Ve(g,E),k=s(d,y);return w.useEffect(()=>(k.itemMap.set(E,{ref:E,...C}),()=>void k.itemMap.delete(E))),c.jsx(h,{[f]:"",ref:T,children:b})});p.displayName=d;function v(x){const g=s(e+"CollectionConsumer",x);return w.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const C=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((k,I)=>C.indexOf(k.ref.current)-C.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},v,r]}var Bw=m.createContext(void 0);function zs(e){const t=m.useContext(Bw);return e||t||"ltr"}const Hw=["top","right","bottom","left"],Zn=Math.min,Yt=Math.max,Bs=Math.round,Hs=Math.floor,kn=e=>({x:e,y:e}),Uw={left:"right",right:"left",bottom:"top",top:"bottom"},Ww={start:"end",end:"start"};function $a(e,t,n){return Yt(e,Zn(t,n))}function Ln(e,t){return typeof e=="function"?e(t):e}function Fn(e){return e.split("-")[0]}function Dr(e){return e.split("-")[1]}function za(e){return e==="x"?"y":"x"}function Ba(e){return e==="y"?"height":"width"}const Vw=new Set(["top","bottom"]);function En(e){return Vw.has(Fn(e))?"y":"x"}function Ha(e){return za(En(e))}function Kw(e,t,n){n===void 0&&(n=!1);const r=Dr(e),o=Ha(e),s=Ba(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Us(i)),[i,Us(i)]}function qw(e){const t=Us(e);return[Ua(e),t,Ua(t)]}function Ua(e){return e.replace(/start|end/g,t=>Ww[t])}const yf=["left","right"],vf=["right","left"],Gw=["top","bottom"],Yw=["bottom","top"];function Xw(e,t,n){switch(e){case"top":case"bottom":return n?t?vf:yf:t?yf:vf;case"left":case"right":return t?Gw:Yw;default:return[]}}function Jw(e,t,n,r){const o=Dr(e);let s=Xw(Fn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ua)))),s}function Us(e){return e.replace(/left|right|bottom|top/g,t=>Uw[t])}function Zw(e){return{top:0,right:0,bottom:0,left:0,...e}}function bf(e){return typeof e!="number"?Zw(e):{top:e,right:e,bottom:e,left:e}}function Ws(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 wf(e,t,n){let{reference:r,floating:o}=e;const s=En(t),i=Ha(t),a=Ba(i),l=Fn(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 p;switch(l){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(Dr(t)){case"start":p[i]-=h*(n&&u?-1:1);break;case"end":p[i]+=h*(n&&u?-1:1);break}return p}const Qw=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=wf(u,r,l),h=r,p={},v=0;for(let x=0;x<a.length;x++){const{name:g,fn:y}=a[x],{x:b,y:C,data:E,reset:T}=await y({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});d=b??d,f=C??f,p={...p,[g]:{...p[g],...E}},T&&v<=50&&(v++,typeof T=="object"&&(T.placement&&(h=T.placement),T.rects&&(u=T.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:d,y:f}=wf(u,h,l)),x=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function xo(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=Ln(t,e),v=bf(p),g=a[h?f==="floating"?"reference":"floating":f],y=Ws(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:l})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},T=Ws(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:C,strategy:l}):b);return{top:(y.top-T.top+v.top)/E.y,bottom:(T.bottom-y.bottom+v.bottom)/E.y,left:(y.left-T.left+v.left)/E.x,right:(T.right-y.right+v.right)/E.x}}const e0=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:u,padding:d=0}=Ln(e,t)||{};if(u==null)return{};const f=bf(d),h={x:n,y:r},p=Ha(o),v=Ba(p),x=await i.getDimensions(u),g=p==="y",y=g?"top":"left",b=g?"bottom":"right",C=g?"clientHeight":"clientWidth",E=s.reference[v]+s.reference[p]-h[p]-s.floating[v],T=h[p]-s.reference[p],k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let I=k?k[C]:0;(!I||!await(i.isElement==null?void 0:i.isElement(k)))&&(I=a.floating[C]||s.floating[v]);const _=E/2-T/2,R=I/2-x[v]/2-1,j=Zn(f[y],R),H=Zn(f[b],R),F=j,U=I-x[v]-H,D=I/2-x[v]/2+_,G=$a(F,D,U),W=!l.arrow&&Dr(o)!=null&&D!==G&&s.reference[v]/2-(D<F?j:H)-x[v]/2<0,ne=W?D<F?D-F:D-U:0;return{[p]:h[p]+ne,data:{[p]:G,centerOffset:D-G-ne,...W&&{alignmentOffset:ne}},reset:W}}}),t0=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:l,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:x=!0,...g}=Ln(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=Fn(o),b=En(a),C=Fn(a)===a,E=await(l.isRTL==null?void 0:l.isRTL(u.floating)),T=h||(C||!x?[Us(a)]:qw(a)),k=v!=="none";!h&&k&&T.push(...Jw(a,x,v,E));const I=[a,...T],_=await xo(t,g),R=[];let j=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&R.push(_[y]),f){const D=Kw(o,i,E);R.push(_[D[0]],_[D[1]])}if(j=[...j,{placement:o,overflows:R}],!R.every(D=>D<=0)){var H,F;const D=(((H=s.flip)==null?void 0:H.index)||0)+1,G=I[D];if(G&&(!(f==="alignment"?b!==En(G):!1)||j.every($=>En($.placement)===b?$.overflows[0]>0:!0)))return{data:{index:D,overflows:j},reset:{placement:G}};let W=(F=j.filter(ne=>ne.overflows[0]<=0).sort((ne,$)=>ne.overflows[1]-$.overflows[1])[0])==null?void 0:F.placement;if(!W)switch(p){case"bestFit":{var U;const ne=(U=j.filter($=>{if(k){const z=En($.placement);return z===b||z==="y"}return!0}).map($=>[$.placement,$.overflows.filter(z=>z>0).reduce((z,ie)=>z+ie,0)]).sort(($,z)=>$[1]-z[1])[0])==null?void 0:U[0];ne&&(W=ne);break}case"initialPlacement":W=a;break}if(o!==W)return{reset:{placement:W}}}return{}}}};function Sf(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Cf(e){return Hw.some(t=>e[t]>=0)}const n0=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Ln(e,t);switch(r){case"referenceHidden":{const s=await xo(t,{...o,elementContext:"reference"}),i=Sf(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Cf(i)}}}case"escaped":{const s=await xo(t,{...o,altBoundary:!0}),i=Sf(s,n.floating);return{data:{escapedOffsets:i,escaped:Cf(i)}}}default:return{}}}}},Tf=new Set(["left","top"]);async function r0(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Fn(n),a=Dr(n),l=En(n)==="y",u=Tf.has(i)?-1:1,d=s&&l?-1:1,f=Ln(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof v=="number"&&(p=a==="end"?v*-1:v),l?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const o0=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,l=await r0(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},s0=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,y:b}=g;return{x:y,y:b}}},...l}=Ln(e,t),u={x:n,y:r},d=await xo(t,l),f=En(Fn(o)),h=za(f);let p=u[h],v=u[f];if(s){const g=h==="y"?"top":"left",y=h==="y"?"bottom":"right",b=p+d[g],C=p-d[y];p=$a(b,p,C)}if(i){const g=f==="y"?"top":"left",y=f==="y"?"bottom":"right",b=v+d[g],C=v-d[y];v=$a(b,v,C)}const x=a.fn({...t,[h]:p,[f]:v});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[h]:s,[f]:i}}}}}},i0=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:l=!0,crossAxis:u=!0}=Ln(e,t),d={x:n,y:r},f=En(o),h=za(f);let p=d[h],v=d[f];const x=Ln(a,t),g=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(l){const C=h==="y"?"height":"width",E=s.reference[h]-s.floating[C]+g.mainAxis,T=s.reference[h]+s.reference[C]-g.mainAxis;p<E?p=E:p>T&&(p=T)}if(u){var y,b;const C=h==="y"?"width":"height",E=Tf.has(Fn(o)),T=s.reference[f]-s.floating[C]+(E&&((y=i.offset)==null?void 0:y[f])||0)+(E?0:g.crossAxis),k=s.reference[f]+s.reference[C]+(E?0:((b=i.offset)==null?void 0:b[f])||0)-(E?g.crossAxis:0);v<T?v=T:v>k&&(v=k)}return{[h]:p,[f]:v}}}},a0=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:l=()=>{},...u}=Ln(e,t),d=await xo(t,u),f=Fn(o),h=Dr(o),p=En(o)==="y",{width:v,height:x}=s.floating;let g,y;f==="top"||f==="bottom"?(g=f,y=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=f,g=h==="end"?"top":"bottom");const b=x-d.top-d.bottom,C=v-d.left-d.right,E=Zn(x-d[g],b),T=Zn(v-d[y],C),k=!t.middlewareData.shift;let I=E,_=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(_=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=b),k&&!h){const j=Yt(d.left,0),H=Yt(d.right,0),F=Yt(d.top,0),U=Yt(d.bottom,0);p?_=v-2*(j!==0||H!==0?j+H:Yt(d.left,d.right)):I=x-2*(F!==0||U!==0?F+U:Yt(d.top,d.bottom))}await l({...t,availableWidth:_,availableHeight:I});const R=await i.getDimensions(a.floating);return v!==R.width||x!==R.height?{reset:{rects:!0}}:{}}}};function Vs(){return typeof window<"u"}function Lr(e){return kf(e)?(e.nodeName||"").toLowerCase():"#document"}function Xt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function In(e){var t;return(t=(kf(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function kf(e){return Vs()?e instanceof Node||e instanceof Xt(e).Node:!1}function fn(e){return Vs()?e instanceof Element||e instanceof Xt(e).Element:!1}function Nn(e){return Vs()?e instanceof HTMLElement||e instanceof Xt(e).HTMLElement:!1}function Ef(e){return!Vs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Xt(e).ShadowRoot}const l0=new Set(["inline","contents"]);function yo(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=hn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!l0.has(o)}const c0=new Set(["table","td","th"]);function u0(e){return c0.has(Lr(e))}const d0=[":popover-open",":modal"];function Ks(e){return d0.some(t=>{try{return e.matches(t)}catch{return!1}})}const f0=["transform","translate","scale","rotate","perspective"],h0=["transform","translate","scale","rotate","perspective","filter"],p0=["paint","layout","strict","content"];function Wa(e){const t=Va(),n=fn(e)?hn(e):e;return f0.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)||h0.some(r=>(n.willChange||"").includes(r))||p0.some(r=>(n.contain||"").includes(r))}function m0(e){let t=Qn(e);for(;Nn(t)&&!Fr(t);){if(Wa(t))return t;if(Ks(t))return null;t=Qn(t)}return null}function Va(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const g0=new Set(["html","body","#document"]);function Fr(e){return g0.has(Lr(e))}function hn(e){return Xt(e).getComputedStyle(e)}function qs(e){return fn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Qn(e){if(Lr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Ef(e)&&e.host||In(e);return Ef(t)?t.host:t}function If(e){const t=Qn(e);return Fr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Nn(t)&&yo(t)?t:If(t)}function vo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=If(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Xt(o);if(s){const a=Ka(i);return t.concat(i,i.visualViewport||[],yo(o)?o:[],a&&n?vo(a):[])}return t.concat(o,vo(o,[],n))}function Ka(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Nf(e){const t=hn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Nn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Bs(n)!==s||Bs(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function qa(e){return fn(e)?e:e.contextElement}function $r(e){const t=qa(e);if(!Nn(t))return kn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Nf(t);let i=(s?Bs(n.width):n.width)/r,a=(s?Bs(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const x0=kn(0);function Af(e){const t=Xt(e);return!Va()||!t.visualViewport?x0:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function y0(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Xt(e)?!1:t}function yr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=qa(e);let i=kn(1);t&&(r?fn(r)&&(i=$r(r)):i=$r(e));const a=y0(s,n,r)?Af(s):kn(0);let l=(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=Xt(s),p=r&&fn(r)?Xt(r):r;let v=h,x=Ka(v);for(;x&&r&&p!==v;){const g=$r(x),y=x.getBoundingClientRect(),b=hn(x),C=y.left+(x.clientLeft+parseFloat(b.paddingLeft))*g.x,E=y.top+(x.clientTop+parseFloat(b.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=C,u+=E,v=Xt(x),x=Ka(v)}}return Ws({width:d,height:f,x:l,y:u})}function Gs(e,t){const n=qs(e).scrollLeft;return t?t.left+n:yr(In(e)).left+n}function _f(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Gs(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function v0(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=In(r),a=t?Ks(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=kn(1);const d=kn(0),f=Nn(r);if((f||!f&&!s)&&((Lr(r)!=="body"||yo(i))&&(l=qs(r)),Nn(r))){const p=yr(r);u=$r(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?_f(i,l):kn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-l.scrollTop*u.y+d.y+h.y}}function b0(e){return Array.from(e.getClientRects())}function w0(e){const t=In(e),n=qs(e),r=e.ownerDocument.body,o=Yt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Yt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Gs(e);const a=-n.scrollTop;return hn(r).direction==="rtl"&&(i+=Yt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const jf=25;function S0(e,t){const n=Xt(e),r=In(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=Va();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const u=Gs(r);if(u<=0){const d=r.ownerDocument,f=d.body,h=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-p);v<=jf&&(s-=v)}else u<=jf&&(s+=u);return{width:s,height:i,x:a,y:l}}const C0=new Set(["absolute","fixed"]);function T0(e,t){const n=yr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Nn(e)?$r(e):kn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,u=r*s.y;return{width:i,height:a,x:l,y:u}}function Rf(e,t,n){let r;if(t==="viewport")r=S0(e,n);else if(t==="document")r=w0(In(e));else if(fn(t))r=T0(t,n);else{const o=Af(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ws(r)}function Pf(e,t){const n=Qn(e);return n===t||!fn(n)||Fr(n)?!1:hn(n).position==="fixed"||Pf(n,t)}function k0(e,t){const n=t.get(e);if(n)return n;let r=vo(e,[],!1).filter(a=>fn(a)&&Lr(a)!=="body"),o=null;const s=hn(e).position==="fixed";let i=s?Qn(e):e;for(;fn(i)&&!Fr(i);){const a=hn(i),l=Wa(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&C0.has(o.position)||yo(i)&&!l&&Pf(e,i))?r=r.filter(d=>d!==i):o=a,i=Qn(i)}return t.set(e,r),r}function E0(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Ks(t)?[]:k0(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=Rf(t,d,o);return u.top=Yt(f.top,u.top),u.right=Zn(f.right,u.right),u.bottom=Zn(f.bottom,u.bottom),u.left=Yt(f.left,u.left),u},Rf(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function I0(e){const{width:t,height:n}=Nf(e);return{width:t,height:n}}function N0(e,t,n){const r=Nn(t),o=In(t),s=n==="fixed",i=yr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=kn(0);function u(){l.x=Gs(o)}if(r||!r&&!s)if((Lr(t)!=="body"||yo(o))&&(a=qs(t)),r){const p=yr(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?_f(o,a):kn(0),f=i.left+a.scrollLeft-l.x-d.x,h=i.top+a.scrollTop-l.y-d.y;return{x:f,y:h,width:i.width,height:i.height}}function Ga(e){return hn(e).position==="static"}function Of(e,t){if(!Nn(e)||hn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return In(e)===n&&(n=n.ownerDocument.body),n}function Mf(e,t){const n=Xt(e);if(Ks(e))return n;if(!Nn(e)){let o=Qn(e);for(;o&&!Fr(o);){if(fn(o)&&!Ga(o))return o;o=Qn(o)}return n}let r=Of(e,t);for(;r&&u0(r)&&Ga(r);)r=Of(r,t);return r&&Fr(r)&&Ga(r)&&!Wa(r)?n:r||m0(e)||n}const A0=async function(e){const t=this.getOffsetParent||Mf,n=this.getDimensions,r=await n(e.floating);return{reference:N0(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function _0(e){return hn(e).direction==="rtl"}const j0={convertOffsetParentRelativeRectToViewportRelativeRect:v0,getDocumentElement:In,getClippingRect:E0,getOffsetParent:Mf,getElementRects:A0,getClientRects:b0,getDimensions:I0,getScale:$r,isElement:fn,isRTL:_0};function Df(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function R0(e,t){let n=null,r;const o=In(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:p}=u;if(a||t(),!h||!p)return;const v=Hs(f),x=Hs(o.clientWidth-(d+h)),g=Hs(o.clientHeight-(f+p)),y=Hs(d),C={rootMargin:-v+"px "+-x+"px "+-g+"px "+-y+"px",threshold:Yt(0,Zn(1,l))||1};let E=!0;function T(k){const I=k[0].intersectionRatio;if(I!==l){if(!E)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!Df(u,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(T,{...C,root:o.ownerDocument})}catch{n=new IntersectionObserver(T,C)}n.observe(e)}return i(!0),s}function P0(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:l=!1}=r,u=qa(e),d=o||s?[...u?vo(u):[],...vo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const f=u&&a?R0(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(y=>{let[b]=y;b&&b.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var C;(C=p)==null||C.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let v,x=l?yr(e):null;l&&g();function g(){const y=yr(e);x&&!Df(x,y)&&n(),x=y,v=requestAnimationFrame(g)}return n(),()=>{var y;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(v)}}const O0=o0,M0=s0,D0=t0,L0=a0,F0=n0,Lf=e0,$0=i0,z0=(e,t,n)=>{const r=new Map,o={platform:j0,...n},s={...o.platform,_c:r};return Qw(e,t,{...o,platform:s})};var B0=typeof document<"u",H0=function(){},Ys=B0?w.useLayoutEffect:H0;function Xs(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(!Xs(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)&&!Xs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Ff(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function $f(e,t){const n=Ff(e);return Math.round(t*n)/n}function Ya(e){const t=m.useRef(e);return Ys(()=>{t.current=e}),t}function U0(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:l,open:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=m.useState(r);Xs(h,r)||p(r);const[v,x]=m.useState(null),[g,y]=m.useState(null),b=m.useCallback($=>{$!==k.current&&(k.current=$,x($))},[]),C=m.useCallback($=>{$!==I.current&&(I.current=$,y($))},[]),E=s||v,T=i||g,k=m.useRef(null),I=m.useRef(null),_=m.useRef(d),R=l!=null,j=Ya(l),H=Ya(o),F=Ya(u),U=m.useCallback(()=>{if(!k.current||!I.current)return;const $={placement:t,strategy:n,middleware:h};H.current&&($.platform=H.current),z0(k.current,I.current,$).then(z=>{const ie={...z,isPositioned:F.current!==!1};D.current&&!Xs(_.current,ie)&&(_.current=ie,Oo.flushSync(()=>{f(ie)}))})},[h,t,n,H,F]);Ys(()=>{u===!1&&_.current.isPositioned&&(_.current.isPositioned=!1,f($=>({...$,isPositioned:!1})))},[u]);const D=m.useRef(!1);Ys(()=>(D.current=!0,()=>{D.current=!1}),[]),Ys(()=>{if(E&&(k.current=E),T&&(I.current=T),E&&T){if(j.current)return j.current(E,T,U);U()}},[E,T,U,j,R]);const G=m.useMemo(()=>({reference:k,floating:I,setReference:b,setFloating:C}),[b,C]),W=m.useMemo(()=>({reference:E,floating:T}),[E,T]),ne=m.useMemo(()=>{const $={position:n,left:0,top:0};if(!W.floating)return $;const z=$f(W.floating,d.x),ie=$f(W.floating,d.y);return a?{...$,transform:"translate("+z+"px, "+ie+"px)",...Ff(W.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:z,top:ie}},[n,a,W.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:U,refs:G,elements:W,floatingStyles:ne}),[d,U,G,W,ne])}const W0=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?Lf({element:r.current,padding:o}).fn(n):{}:r?Lf({element:r,padding:o}).fn(n):{}}}},V0=(e,t)=>({...O0(e),options:[e,t]}),K0=(e,t)=>({...M0(e),options:[e,t]}),q0=(e,t)=>({...$0(e),options:[e,t]}),G0=(e,t)=>({...D0(e),options:[e,t]}),Y0=(e,t)=>({...L0(e),options:[e,t]}),X0=(e,t)=>({...F0(e),options:[e,t]}),J0=(e,t)=>({...W0(e),options:[e,t]});var Z0="Arrow",zf=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(Ie.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});zf.displayName=Z0;var Q0=zf;function Bf(e){const[t,n]=m.useState(void 0);return Tt(()=>{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 l=s.borderBoxSize,u=Array.isArray(l)?l[0]:l;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 Xa="Popper",[Hf,Js]=Sn(Xa),[eS,Uf]=Hf(Xa),Wf=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(eS,{scope:t,anchor:r,onAnchorChange:o,children:n})};Wf.displayName=Xa;var Vf="PopperAnchor",Kf=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Uf(Vf,n),i=m.useRef(null),a=Ve(t,i),l=m.useRef(null);return m.useEffect(()=>{const u=l.current;l.current=(r==null?void 0:r.current)||i.current,u!==l.current&&s.onAnchorChange(l.current)}),r?null:c.jsx(Ie.div,{...o,ref:a})});Kf.displayName=Vf;var Ja="PopperContent",[tS,nS]=Hf(Ja),qf=m.forwardRef((e,t)=>{var K,L,Z,ee,me,se;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:v,...x}=e,g=Uf(Ja,n),[y,b]=m.useState(null),C=Ve(t,ae=>b(ae)),[E,T]=m.useState(null),k=Bf(E),I=(k==null?void 0:k.width)??0,_=(k==null?void 0:k.height)??0,R=r+(s!=="center"?"-"+s:""),j=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},H=Array.isArray(u)?u:[u],F=H.length>0,U={padding:j,boundary:H.filter(oS),altBoundary:F},{refs:D,floatingStyles:G,placement:W,isPositioned:ne,middlewareData:$}=U0({strategy:"fixed",placement:R,whileElementsMounted:(...ae)=>P0(...ae,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[V0({mainAxis:o+_,alignmentAxis:i}),l&&K0({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?q0():void 0,...U}),l&&G0({...U}),Y0({...U,apply:({elements:ae,rects:He,availableWidth:Je,availableHeight:je})=>{const{width:Ue,height:et}=He.reference,Ze=ae.floating.style;Ze.setProperty("--radix-popper-available-width",`${Je}px`),Ze.setProperty("--radix-popper-available-height",`${je}px`),Ze.setProperty("--radix-popper-anchor-width",`${Ue}px`),Ze.setProperty("--radix-popper-anchor-height",`${et}px`)}}),E&&J0({element:E,padding:a}),sS({arrowWidth:I,arrowHeight:_}),h&&X0({strategy:"referenceHidden",...U})]}),[z,ie]=Xf(W),M=At(v);Tt(()=>{ne&&(M==null||M())},[ne,M]);const Y=(K=$.arrow)==null?void 0:K.x,ce=(L=$.arrow)==null?void 0:L.y,be=((Z=$.arrow)==null?void 0:Z.centerOffset)!==0,[ge,ye]=m.useState();return Tt(()=>{y&&ye(window.getComputedStyle(y).zIndex)},[y]),c.jsx("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...G,transform:ne?G.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ge,"--radix-popper-transform-origin":[(ee=$.transformOrigin)==null?void 0:ee.x,(me=$.transformOrigin)==null?void 0:me.y].join(" "),...((se=$.hide)==null?void 0:se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(tS,{scope:n,placedSide:z,onArrowChange:T,arrowX:Y,arrowY:ce,shouldHideArrow:be,children:c.jsx(Ie.div,{"data-side":z,"data-align":ie,...x,ref:C,style:{...x.style,animation:ne?void 0:"none"}})})})});qf.displayName=Ja;var Gf="PopperArrow",rS={top:"bottom",right:"left",bottom:"top",left:"right"},Yf=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=nS(Gf,r),i=rS[s.placedSide];return c.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:c.jsx(Q0,{...o,ref:n,style:{...o.style,display:"block"}})})});Yf.displayName=Gf;function oS(e){return e!==null}var sS=e=>({name:"transformOrigin",options:e,fn(t){var g,y,b;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[u,d]=Xf(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let v="",x="";return u==="bottom"?(v=i?f:`${h}px`,x=`${-l}px`):u==="top"?(v=i?f:`${h}px`,x=`${r.floating.height+l}px`):u==="right"?(v=`${-l}px`,x=i?f:`${p}px`):u==="left"&&(v=`${r.floating.width+l}px`,x=i?f:`${p}px`),{data:{x:v,y:x}}}});function Xf(e){const[t,n="center"]=e.split("-");return[t,n]}var Jf=Wf,Zf=Kf,Qf=qf,eh=Yf,Za="rovingFocusGroup.onEntryFocus",iS={bubbles:!1,cancelable:!0},bo="RovingFocusGroup",[Qa,th,aS]=Fa(bo),[lS,nh]=Sn(bo,[aS]),[cS,uS]=lS(bo),rh=m.forwardRef((e,t)=>c.jsx(Qa.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Qa.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(dS,{...e,ref:t})})}));rh.displayName=bo;var dS=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=m.useRef(null),p=Ve(t,h),v=zs(s),[x,g]=hr({prop:i,defaultProp:a??null,onChange:l,caller:bo}),[y,b]=m.useState(!1),C=At(u),E=th(n),T=m.useRef(!1),[k,I]=m.useState(0);return m.useEffect(()=>{const _=h.current;if(_)return _.addEventListener(Za,C),()=>_.removeEventListener(Za,C)},[C]),c.jsx(cS,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:x,onItemFocus:m.useCallback(_=>g(_),[g]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>I(_=>_+1),[]),onFocusableItemRemove:m.useCallback(()=>I(_=>_-1),[]),children:c.jsx(Ie.div,{tabIndex:y||k===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:pe(e.onMouseDown,()=>{T.current=!0}),onFocus:pe(e.onFocus,_=>{const R=!T.current;if(_.target===_.currentTarget&&R&&!y){const j=new CustomEvent(Za,iS);if(_.currentTarget.dispatchEvent(j),!j.defaultPrevented){const H=E().filter(W=>W.focusable),F=H.find(W=>W.active),U=H.find(W=>W.id===x),G=[F,U,...H].filter(Boolean).map(W=>W.ref.current);ih(G,d)}}T.current=!1}),onBlur:pe(e.onBlur,()=>b(!1))})})}),oh="RovingFocusGroupItem",sh=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Cn(),u=s||l,d=uS(oh,n),f=d.currentTabStopId===u,h=th(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:x}=d;return m.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),c.jsx(Qa.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(Ie.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:pe(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:pe(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:pe(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const y=pS(g,d.orientation,d.dir);if(y!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let C=h().filter(E=>E.focusable).map(E=>E.ref.current);if(y==="last")C.reverse();else if(y==="prev"||y==="next"){y==="prev"&&C.reverse();const E=C.indexOf(g.currentTarget);C=d.loop?mS(C,E+1):C.slice(E+1)}setTimeout(()=>ih(C))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:x!=null}):i})})});sh.displayName=oh;var fS={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function hS(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function pS(e,t,n){const r=hS(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return fS[r]}function ih(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function mS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var gS=rh,xS=sh,el=["Enter"," "],yS=["ArrowDown","PageUp","Home"],ah=["ArrowUp","PageDown","End"],vS=[...yS,...ah],bS={ltr:[...el,"ArrowRight"],rtl:[...el,"ArrowLeft"]},wS={ltr:["ArrowLeft"],rtl:["ArrowRight"]},wo="Menu",[So,SS,CS]=Fa(wo),[vr,lh]=Sn(wo,[CS,Js,nh]),Zs=Js(),ch=nh(),[TS,br]=vr(wo),[kS,Co]=vr(wo),uh=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=Zs(t),[l,u]=m.useState(null),d=m.useRef(!1),f=At(s),h=zs(o);return m.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),c.jsx(Jf,{...a,children:c.jsx(TS,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(kS,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};uh.displayName=wo;var ES="MenuAnchor",tl=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Zs(n);return c.jsx(Zf,{...o,...r,ref:t})});tl.displayName=ES;var nl="MenuPortal",[IS,dh]=vr(nl,{forceMount:void 0}),fh=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=br(nl,t);return c.jsx(IS,{scope:t,forceMount:n,children:c.jsx(Gt,{present:n||s.open,children:c.jsx(Ss,{asChild:!0,container:o,children:r})})})};fh.displayName=nl;var nn="MenuContent",[NS,rl]=vr(nn),hh=m.forwardRef((e,t)=>{const n=dh(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=br(nn,e.__scopeMenu),i=Co(nn,e.__scopeMenu);return c.jsx(So.Provider,{scope:e.__scopeMenu,children:c.jsx(Gt,{present:r||s.open,children:c.jsx(So.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(AS,{...o,ref:t}):c.jsx(_S,{...o,ref:t})})})})}),AS=m.forwardRef((e,t)=>{const n=br(nn,e.__scopeMenu),r=m.useRef(null),o=Ve(t,r);return m.useEffect(()=>{const s=r.current;if(s)return Pa(s)},[]),c.jsx(ol,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:pe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),_S=m.forwardRef((e,t)=>{const n=br(nn,e.__scopeMenu);return c.jsx(ol,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),jS=or.createSlot("MenuContent.ScrollLock"),ol=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:v,...x}=e,g=br(nn,n),y=Co(nn,n),b=Zs(n),C=ch(n),E=SS(n),[T,k]=m.useState(null),I=m.useRef(null),_=Ve(t,I,g.onContentChange),R=m.useRef(0),j=m.useRef(""),H=m.useRef(0),F=m.useRef(null),U=m.useRef("right"),D=m.useRef(0),G=v?Ns:m.Fragment,W=v?{as:jS,allowPinchZoom:!0}:void 0,ne=z=>{var K,L;const ie=j.current+z,M=E().filter(Z=>!Z.disabled),Y=document.activeElement,ce=(K=M.find(Z=>Z.ref.current===Y))==null?void 0:K.textValue,be=M.map(Z=>Z.textValue),ge=US(be,ie,ce),ye=(L=M.find(Z=>Z.textValue===ge))==null?void 0:L.ref.current;(function Z(ee){j.current=ee,window.clearTimeout(R.current),ee!==""&&(R.current=window.setTimeout(()=>Z(""),1e3))})(ie),ye&&setTimeout(()=>ye.focus())};m.useEffect(()=>()=>window.clearTimeout(R.current),[]),Ia();const $=m.useCallback(z=>{var M,Y;return U.current===((M=F.current)==null?void 0:M.side)&&VS(z,(Y=F.current)==null?void 0:Y.area)},[]);return c.jsx(NS,{scope:n,searchRef:j,onItemEnter:m.useCallback(z=>{$(z)&&z.preventDefault()},[$]),onItemLeave:m.useCallback(z=>{var ie;$(z)||((ie=I.current)==null||ie.focus(),k(null))},[$]),onTriggerLeave:m.useCallback(z=>{$(z)&&z.preventDefault()},[$]),pointerGraceTimerRef:H,onPointerGraceIntentChange:m.useCallback(z=>{F.current=z},[]),children:c.jsx(G,{...W,children:c.jsx(ws,{asChild:!0,trapped:o,onMountAutoFocus:pe(s,z=>{var ie;z.preventDefault(),(ie=I.current)==null||ie.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(bs,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:c.jsx(gS,{asChild:!0,...C,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:k,onEntryFocus:pe(l,z=>{y.isUsingKeyboardRef.current||z.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(Qf,{role:"menu","aria-orientation":"vertical","data-state":_h(g.open),"data-radix-menu-content":"",dir:y.dir,...b,...x,ref:_,style:{outline:"none",...x.style},onKeyDown:pe(x.onKeyDown,z=>{const M=z.target.closest("[data-radix-menu-content]")===z.currentTarget,Y=z.ctrlKey||z.altKey||z.metaKey,ce=z.key.length===1;M&&(z.key==="Tab"&&z.preventDefault(),!Y&&ce&&ne(z.key));const be=I.current;if(z.target!==be||!vS.includes(z.key))return;z.preventDefault();const ye=E().filter(K=>!K.disabled).map(K=>K.ref.current);ah.includes(z.key)&&ye.reverse(),BS(ye)}),onBlur:pe(e.onBlur,z=>{z.currentTarget.contains(z.target)||(window.clearTimeout(R.current),j.current="")}),onPointerMove:pe(e.onPointerMove,ko(z=>{const ie=z.target,M=D.current!==z.clientX;if(z.currentTarget.contains(ie)&&M){const Y=z.clientX>D.current?"right":"left";U.current=Y,D.current=z.clientX}}))})})})})})})});hh.displayName=nn;var RS="MenuGroup",sl=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ie.div,{role:"group",...r,ref:t})});sl.displayName=RS;var PS="MenuLabel",ph=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ie.div,{...r,ref:t})});ph.displayName=PS;var Qs="MenuItem",mh="menu.itemSelect",ei=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=Co(Qs,e.__scopeMenu),a=rl(Qs,e.__scopeMenu),l=Ve(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(mh,{bubbles:!0,cancelable:!0});f.addEventListener(mh,p=>r==null?void 0:r(p),{once:!0}),Yu(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(gh,{...o,ref:l,disabled:n,onClick:pe(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:pe(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:pe(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||el.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});ei.displayName=Qs;var gh=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=rl(Qs,n),a=ch(n),l=m.useRef(null),u=Ve(t,l),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const v=l.current;v&&p((v.textContent??"").trim())},[s.children]),c.jsx(So.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(xS,{asChild:!0,...a,focusable:!r,children:c.jsx(Ie.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:pe(e.onPointerMove,ko(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:pe(e.onPointerLeave,ko(v=>i.onItemLeave(v))),onFocus:pe(e.onFocus,()=>f(!0)),onBlur:pe(e.onBlur,()=>f(!1))})})})}),OS="MenuCheckboxItem",xh=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(Sh,{scope:e.__scopeMenu,checked:n,children:c.jsx(ei,{role:"menuitemcheckbox","aria-checked":ti(n)?"mixed":n,...o,ref:t,"data-state":al(n),onSelect:pe(o.onSelect,()=>r==null?void 0:r(ti(n)?!0:!n),{checkForDefaultPrevented:!1})})})});xh.displayName=OS;var yh="MenuRadioGroup",[MS,DS]=vr(yh,{value:void 0,onValueChange:()=>{}}),vh=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=At(r);return c.jsx(MS,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(sl,{...o,ref:t})})});vh.displayName=yh;var bh="MenuRadioItem",wh=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=DS(bh,e.__scopeMenu),s=n===o.value;return c.jsx(Sh,{scope:e.__scopeMenu,checked:s,children:c.jsx(ei,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":al(s),onSelect:pe(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});wh.displayName=bh;var il="MenuItemIndicator",[Sh,LS]=vr(il,{checked:!1}),Ch=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=LS(il,n);return c.jsx(Gt,{present:r||ti(s.checked)||s.checked===!0,children:c.jsx(Ie.span,{...o,ref:t,"data-state":al(s.checked)})})});Ch.displayName=il;var FS="MenuSeparator",Th=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ie.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Th.displayName=FS;var $S="MenuArrow",kh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Zs(n);return c.jsx(eh,{...o,...r,ref:t})});kh.displayName=$S;var zS="MenuSub",[Ck,Eh]=vr(zS),To="MenuSubTrigger",Ih=m.forwardRef((e,t)=>{const n=br(To,e.__scopeMenu),r=Co(To,e.__scopeMenu),o=Eh(To,e.__scopeMenu),s=rl(To,e.__scopeMenu),i=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},d=m.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return m.useEffect(()=>d,[d]),m.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),c.jsx(tl,{asChild:!0,...u,children:c.jsx(gh,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":_h(n.open),...e,ref:ha(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:pe(e.onPointerMove,ko(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:pe(e.onPointerLeave,ko(f=>{var p,v;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const x=(v=n.content)==null?void 0:v.dataset.side,g=x==="right",y=g?-5:5,b=h[g?"left":"right"],C=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+y,y:f.clientY},{x:b,y:h.top},{x:C,y:h.top},{x:C,y:h.bottom},{x:b,y:h.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:pe(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||bS[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});Ih.displayName=To;var Nh="MenuSubContent",Ah=m.forwardRef((e,t)=>{const n=dh(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=br(nn,e.__scopeMenu),i=Co(nn,e.__scopeMenu),a=Eh(Nh,e.__scopeMenu),l=m.useRef(null),u=Ve(t,l);return c.jsx(So.Provider,{scope:e.__scopeMenu,children:c.jsx(Gt,{present:r||s.open,children:c.jsx(So.Slot,{scope:e.__scopeMenu,children:c.jsx(ol,{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=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:pe(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:pe(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:pe(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=wS[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});Ah.displayName=Nh;function _h(e){return e?"open":"closed"}function ti(e){return e==="indeterminate"}function al(e){return ti(e)?"indeterminate":e?"checked":"unchecked"}function BS(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function HS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function US(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=HS(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function WS(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],l=t[i],u=a.x,d=a.y,f=l.x,h=l.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function VS(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return WS(n,t)}function ko(e){return t=>t.pointerType==="mouse"?e(t):void 0}var KS=uh,qS=tl,GS=fh,YS=hh,XS=sl,JS=ph,ZS=ei,QS=xh,eC=vh,tC=wh,nC=Ch,rC=Th,oC=kh,sC=Ih,iC=Ah,ni="DropdownMenu",[aC,Tk]=Sn(ni,[lh]),zt=lh(),[lC,jh]=aC(ni),Rh=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=zt(t),u=m.useRef(null),[d,f]=hr({prop:o,defaultProp:s??!1,onChange:i,caller:ni});return c.jsx(lC,{scope:t,triggerId:Cn(),triggerRef:u,contentId:Cn(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(KS,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Rh.displayName=ni;var Ph="DropdownMenuTrigger",Oh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=jh(Ph,n),i=zt(n);return c.jsx(qS,{asChild:!0,...i,children:c.jsx(Ie.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:ha(t,s.triggerRef),onPointerDown:pe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:pe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Oh.displayName=Ph;var cC="DropdownMenuPortal",Mh=e=>{const{__scopeDropdownMenu:t,...n}=e,r=zt(t);return c.jsx(GS,{...r,...n})};Mh.displayName=cC;var Dh="DropdownMenuContent",Lh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jh(Dh,n),s=zt(n),i=m.useRef(!1);return c.jsx(YS,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:pe(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:pe(e.onInteractOutside,a=>{const l=a.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,d=l.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)"}})});Lh.displayName=Dh;var uC="DropdownMenuGroup",dC=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(XS,{...o,...r,ref:t})});dC.displayName=uC;var fC="DropdownMenuLabel",Fh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(JS,{...o,...r,ref:t})});Fh.displayName=fC;var hC="DropdownMenuItem",$h=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(ZS,{...o,...r,ref:t})});$h.displayName=hC;var pC="DropdownMenuCheckboxItem",zh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(QS,{...o,...r,ref:t})});zh.displayName=pC;var mC="DropdownMenuRadioGroup",gC=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(eC,{...o,...r,ref:t})});gC.displayName=mC;var xC="DropdownMenuRadioItem",Bh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(tC,{...o,...r,ref:t})});Bh.displayName=xC;var yC="DropdownMenuItemIndicator",Hh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(nC,{...o,...r,ref:t})});Hh.displayName=yC;var vC="DropdownMenuSeparator",Uh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(rC,{...o,...r,ref:t})});Uh.displayName=vC;var bC="DropdownMenuArrow",wC=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(oC,{...o,...r,ref:t})});wC.displayName=bC;var SC="DropdownMenuSubTrigger",Wh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(sC,{...o,...r,ref:t})});Wh.displayName=SC;var CC="DropdownMenuSubContent",Vh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(iC,{...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)"}})});Vh.displayName=CC;var TC=Rh,kC=Oh,EC=Mh,Kh=Lh,qh=Fh,Gh=$h,Yh=zh,Xh=Bh,Jh=Hh,Zh=Uh,Qh=Wh,ep=Vh;const IC=TC,NC=kC,AC=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(Qh,{ref:o,className:re("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,c.jsx(ue.ChevronRight,{className:"ml-auto h-4 w-4"})]}));AC.displayName=Qh.displayName;const _C=m.forwardRef(({className:e,...t},n)=>c.jsx(ep,{ref:n,className:re("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}));_C.displayName=ep.displayName;const tp=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(EC,{children:c.jsx(Kh,{ref:r,sideOffset:t,className:re("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})}));tp.displayName=Kh.displayName;const ll=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Gh,{ref:r,className:re("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}));ll.displayName=Gh.displayName;const jC=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(Yh,{ref:o,className:re("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:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Jh,{children:c.jsx(ue.Check,{className:"h-4 w-4"})})}),t]}));jC.displayName=Yh.displayName;const RC=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Xh,{ref:r,className:re("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:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Jh,{children:c.jsx(ue.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));RC.displayName=Xh.displayName;const PC=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(qh,{ref:r,className:re("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));PC.displayName=qh.displayName;const OC=m.forwardRef(({className:e,...t},n)=>c.jsx(Zh,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));OC.displayName=Zh.displayName;function MC(e){var t;if(!Array.isArray(e)||!e.length)return null;for(let n=e.length-1;n>=0;n--){const r=((t=e[n])==null?void 0:t.content)??[];for(let o=0;o<r.length;o++){const s=r[o];if(s&&s.type==="text"&&typeof s.text=="string"){const i=s.text.trim();if(i)return i}}}return null}function ri({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:l=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:h,onError:p}){const{api:v}=Ai(),{currentThreadId:x}=Xo(),{threadId:g,messages:y,hasMore:b,isHistoryLoading:C,isLoading:E,loadOlder:T,navigateToCheckpoint:k,returnToLatest:I,checkpoint:_,checkpoints:R,interrupt:j,metadata:H}=Jo(),{isStreaming:F,error:U,submit:D,stop:G}=Gc(),W=g??x??null,ne=(_==null?void 0:_.id)??null,$=(_==null?void 0:_.namespace)??null,z=(H==null?void 0:H.assemblingMessageId)??null,ie=j,[M,Y]=w.useState(!1);w.useEffect(()=>{ie||Y(!1)},[ie]);const ce=w.useCallback(()=>{Y(!0)},[]),be=w.useCallback(()=>{Y(!1)},[]),ge=!!ie||M,[ye,K]=w.useState(null),[L,Z]=w.useState(""),[ee,me]=w.useState(null),[se,ae]=w.useState([]),[He,Je]=w.useState(0),[je,Ue]=w.useState(0),[et,Ze]=w.useState(!1),[Pe,Ct]=w.useState(null),[kt,Et]=w.useState(null),[st,tt]=w.useState(!1),[ze,ct]=w.useState(null),[bt,X]=w.useState(!1),xe=w.useRef(!1),[de,_e]=w.useState(!1),Fe=w.useCallback((S,P)=>{if(!S||typeof S!="object")return null;const B=S[P];return typeof B=="number"?B:null},[]),nt=w.useCallback((S,P)=>{if(!S||typeof S!="object")return null;const B=S[P];return typeof B=="string"&&B.trim()?B:null},[]),pt=w.useMemo(()=>{const S=Array.isArray(R)?[...R]:[];return S.some(B=>Fe(B.metadata,"step")!==null)&&S.sort((B,oe)=>{const Te=Fe(B.metadata,"step"),$e=Fe(oe.metadata,"step");if(Te!==null||$e!==null)return($e??Number.NEGATIVE_INFINITY)-(Te??Number.NEGATIVE_INFINITY);const Me=Date.parse(B.createdAt??""),ke=Date.parse(oe.createdAt??"");return Number.isNaN(Me)||Number.isNaN(ke)?0:ke-Me}),S},[R,Fe]),Qe=w.useRef(null),ut=w.useRef(null),mt=w.useCallback(()=>{Qe.current&&(Qe.current.value=""),ut.current&&(ut.current.value=""),Je(S=>S+1),Ue(S=>S+1)},[]),$n=w.useRef(!1);w.useEffect(()=>{$n.current&&!F&&(ae([]),mt()),$n.current=F},[F,mt]);const[zn,Tr]=w.useState("desktop");w.useEffect(()=>{const S=()=>{const P=window.innerWidth;Tr(P<640?"phone":P<1024?"tablet":"desktop")};return S(),window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[]),w.useEffect(()=>{X(!1),xe.current=!1},[W]);const Bn=w.useCallback(async()=>{if(!(!b||C||!bt))try{await T()}catch(S){console.warn("loadOlder failed",S)}},[b,bt,C,T]);w.useEffect(()=>{(async()=>{if(!v.baseUrl){ct(null);return}try{const P=await v.getAgent("default");ct(P.uiDefaultMessage||null)}catch(P){console.warn("Failed to fetch default message:",P),ct(null)}})()},[v]),w.useEffect(()=>{U&&!st&&(p==null||p(U))},[U,st,p]);const Ft=S=>{if(S.length>$s)return`Message too long (${S.length}/${$s} characters)`;try{return zw(S),null}catch(P){return(P==null?void 0:P.message)||"Invalid message"}},Io=async S=>{const P=S.trim();if(!(!P&&se.length===0)){if(P){const B=Ft(P);if(B){me(B);return}}try{await D({text:P||"",attachments:se,payload:ye?{edit:!0,originalMessageId:ye}:void 0},{checkpointId:ne??void 0,checkpointNs:$??void 0}),f==null||f(P),me(null),ae([]),mt(),K(null),Z("")}catch(B){const oe=(B==null?void 0:B.message)||"Failed to send message";me(oe),p==null||p(oe)}}},Hn=w.useCallback((S,P)=>{u&&(K(S),Z(P),me(null))},[u]),wt=w.useCallback(()=>{K(null),Z(""),me(null)},[]),mn=w.useCallback((S,P)=>{Hn(S,P)},[Hn]),_n=w.useCallback(S=>{const P=B=>{const oe=B.content||[],Te=oe.filter($e=>$e.type==="text").map($e=>$e.text).join("");if(Te)return Te;try{return JSON.stringify(oe,null,2)}catch{return String(oe)}};for(let B=S-1;B>=0;B--)if(y[B].role==="user"){const oe=P(y[B]);oe&&D({text:oe},{checkpointId:ne??void 0,checkpointNs:$??void 0});break}},[y,D,ne,$]),Ur=S=>{const P=Array.from(S.target.files||[]);ae(B=>[...B,...P]),S.target.value=""},sn=S=>{ae(P=>{const B=P.filter((oe,Te)=>S!==Te);return B.length===0&&mt(),B})},rr=async S=>{const P=(S.target.files||[])[0];if(P){Ct(null),Et(null),Ze(!0);try{await D({attachments:[P]},{checkpointId:ne??void 0,checkpointNs:$??void 0});const B=`Uploaded ${P.name} - processing through chat stream`;Et(B)}catch(B){const oe=B instanceof Error?B.message:"Failed to upload Excel file";console.error("Excel upload failed",B),Ct(oe),p==null||p(oe)}finally{Ze(!1),S.target.value="",mt()}}},gn=S=>{if(!S)return"Unknown";const P=Date.parse(S);return Number.isNaN(P)?S:new Date(P).toLocaleString()},jn=async S=>{if(x){_e(!0);try{if(!S){await I();return}const P=pt.find(oe=>oe.checkpointId===S),B=(P==null?void 0:P.checkpointNs)??null;await k(S,B)}finally{_e(!1)}}},kr=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,No=`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||""}`,Wr=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return c.jsxs("div",{className:kr,children:[!!U&&!st&&c.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:[c.jsx("span",{children:U}),c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>tt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(ue.X,{size:16})})]}),x&&R.length>0&&c.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:[c.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),c.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:ne??"",onChange:S=>{const P=S.target.value||null;jn(P)},children:[c.jsx("option",{value:"",children:"Latest"}),pt.map(S=>{const P=Fe(S.metadata,"step"),B=nt(S.metadata,"source"),oe=MC(S.messages),Te=[];P!==null&&Te.push(`Step ${P}`),B&&Te.push(B),oe&&Te.push(oe.slice(0,40));const $e=Te.length?` — ${Te.join(" • ")}`:"";return c.jsxs("option",{value:S.checkpointId,children:[gn(S.createdAt),$e]},S.checkpointId)})]})]}),c.jsxs("div",{className:`relative ${No}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(La,{className:"h-full",style:{height:"100%"},messages:y,isStreaming:F,streamingAssistantId:z,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:zn,enableMessageEditing:u,editingMessageId:ye,onStartReached:()=>{bt&&Bn()},onScrollAway:S=>{if(!xe.current){xe.current=!0;return}S&&X(!0)},onEdit:mn,onRegenerate:_n,onCancelEdit:wt,emptyMessage:ze??void 0,isNavigatingCheckpoint:de,activeInterrupt:ie,disableInterruptActions:M,onInterruptActionStart:ce,onInterruptActionEnd:be}),E&&c.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:[c.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]})]}),c.jsxs("div",{className:Wr,children:[ye&&c.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ue.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(qe,{variant:"ghost",size:"sm",onClick:wt,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(ue.X,{size:16})})]})}),(a||l)&&c.jsxs("div",{className:"mb-3 space-y-3",children:[a&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:Qe,type:"file",multiple:!0,onChange:S=>Ur(S),className:"hidden"},He),se.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:se.map((S,P)=>c.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:[c.jsx(ue.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:S.name}),c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>sn(P),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 ${S.name}`,children:c.jsx(ue.X,{size:12})})]},P))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:ut,type:"file",accept:".xls,.xlsx,.xlsm",onChange:rr,className:"hidden"},je),et&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),kt&&!et&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:kt}),Pe&&!et&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Pe})]})]}),ee&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:ee}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(IC,{children:[c.jsx(NC,{asChild:!0,children:c.jsx(qe,{type:"button",size:"icon",variant:"outline",disabled:F||ge,title:"More input actions",className:d.moreButton||"",children:c.jsx(ue.Plus,{size:16})})}),c.jsxs(tp,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(ll,{onClick:()=>{var S;return(S=Qe.current)==null?void 0:S.click()},className:"cursor-pointer",children:[c.jsx(ue.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(ll,{onClick:()=>{var S;et||(S=ut.current)==null||S.click()},className:`cursor-pointer ${et?"opacity-60 pointer-events-none":""}`,children:[c.jsx(ue.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx(Qx,{initialValue:L,editingMessageId:ye,placeholder:ye?"Edit your message...":t,isStreaming:F,disabled:ge,maxLength:$s,onSend:Io,onCancelEdit:wt,onStop:G,allowEmptySend:se.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${ye?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${ee?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const oi=m.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:re("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}));oi.displayName="Input";function cl(e,[t,n]){return Math.min(n,Math.max(t,e))}function DC(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var ul="ScrollArea",[np,kk]=Sn(ul),[LC,rn]=np(ul),rp=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=m.useState(null),[u,d]=m.useState(null),[f,h]=m.useState(null),[p,v]=m.useState(null),[x,g]=m.useState(null),[y,b]=m.useState(0),[C,E]=m.useState(0),[T,k]=m.useState(!1),[I,_]=m.useState(!1),R=Ve(t,H=>l(H)),j=zs(o);return c.jsx(LC,{scope:n,type:r,dir:j,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:T,onScrollbarXEnabledChange:k,scrollbarY:x,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:_,onCornerWidthChange:b,onCornerHeightChange:E,children:c.jsx(Ie.div,{dir:j,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});rp.displayName=ul;var op="ScrollAreaViewport",sp=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=rn(op,n),a=m.useRef(null),l=Ve(t,a,i.onViewportChange);return c.jsxs(c.Fragment,{children:[c.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}),c.jsx(Ie.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:c.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});sp.displayName=op;var An="ScrollAreaScrollbar",dl=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(An,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return m.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?c.jsx(FC,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx($C,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(ip,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(fl,{...r,ref:t}):null});dl.displayName=An;var FC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(An,e.__scopeScrollArea),[s,i]=m.useState(!1);return m.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const u=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),c.jsx(Gt,{present:n||s,children:c.jsx(ip,{"data-state":s?"visible":"hidden",...r,ref:t})})}),$C=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(An,e.__scopeScrollArea),s=e.orientation==="horizontal",i=li(()=>l("SCROLL_END"),100),[a,l]=DC("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 m.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,l]),m.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const p=u[d];f!==p&&(l("SCROLL"),i()),f=p};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),c.jsx(Gt,{present:n||a!=="hidden",children:c.jsx(fl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:pe(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:pe(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),ip=m.forwardRef((e,t)=>{const n=rn(An,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",l=li(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return zr(n.viewport,l),zr(n.content,l),c.jsx(Gt,{present:r||s,children:c.jsx(fl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),fl=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=rn(An,e.__scopeScrollArea),s=m.useRef(null),i=m.useRef(0),[a,l]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=dp(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:u>0&&u<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return VC(h,i.current,a,p)}return n==="horizontal"?c.jsx(zC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=fp(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?c.jsx(BC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=fp(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),zC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(An,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Ve(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(lp,{"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":ai(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),pp(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:ii(i.paddingLeft),paddingEnd:ii(i.paddingRight)}})}})}),BC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(An,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Ve(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(lp,{"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":ai(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),pp(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:ii(i.paddingTop),paddingEnd:ii(i.paddingBottom)}})}})}),[HC,ap]=np(An),lp=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,p=rn(An,n),[v,x]=m.useState(null),g=Ve(t,R=>x(R)),y=m.useRef(null),b=m.useRef(""),C=p.viewport,E=r.content-r.viewport,T=At(d),k=At(l),I=li(f,10);function _(R){if(y.current){const j=R.clientX-y.current.left,H=R.clientY-y.current.top;u({x:j,y:H})}}return m.useEffect(()=>{const R=j=>{const H=j.target;(v==null?void 0:v.contains(H))&&T(j,E)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[C,v,E,T]),m.useEffect(k,[r,k]),zr(v,I),zr(p.content,I),c.jsx(HC,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:At(s),onThumbPointerUp:At(i),onThumbPositionChange:k,onThumbPointerDown:At(a),children:c.jsx(Ie.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:pe(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),_(R))}),onPointerMove:pe(e.onPointerMove,_),onPointerUp:pe(e.onPointerUp,R=>{const j=R.target;j.hasPointerCapture(R.pointerId)&&j.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),si="ScrollAreaThumb",cp=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=ap(si,e.__scopeScrollArea);return c.jsx(Gt,{present:n||o.hasThumb,children:c.jsx(UC,{ref:t,...r})})}),UC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=rn(si,n),i=ap(si,n),{onThumbPositionChange:a}=i,l=Ve(t,f=>i.onThumbChange(f)),u=m.useRef(void 0),d=li(()=>{u.current&&(u.current(),u.current=void 0)},100);return m.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const p=KC(f,a);u.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),c.jsx(Ie.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:pe(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),v=f.clientX-p.left,x=f.clientY-p.top;i.onThumbPointerDown({x:v,y:x})}),onPointerUp:pe(e.onPointerUp,i.onThumbPointerUp)})});cp.displayName=si;var hl="ScrollAreaCorner",up=m.forwardRef((e,t)=>{const n=rn(hl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(WC,{...e,ref:t}):null});up.displayName=hl;var WC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=rn(hl,n),[s,i]=m.useState(0),[a,l]=m.useState(0),u=!!(s&&a);return zr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),zr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?c.jsx(Ie.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 ii(e){return e?parseInt(e,10):0}function dp(e,t){const n=e/t;return isNaN(n)?0:n}function ai(e){const t=dp(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function VC(e,t,n,r="ltr"){const o=ai(n),s=o/2,i=t||s,a=o-i,l=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 hp([l,u],f)(e)}function fp(e,t,n="ltr"){const r=ai(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],u=cl(e,l);return hp([0,i],[0,a])(u)}function hp(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 pp(e,t){return e>0&&e<t}var KC=(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 li(e,t){const n=At(e),r=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),m.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function zr(e,t){const n=At(t);Tt(()=>{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 mp=rp,qC=sp,GC=up;const gp=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(mp,{ref:r,className:re("relative overflow-hidden",e),...n,children:[c.jsx(qC,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(xp,{}),c.jsx(GC,{})]}));gp.displayName=mp.displayName;const xp=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(dl,{ref:r,orientation:t,className:re("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:c.jsx(cp,{className:"relative flex-1 rounded-full bg-border"})}));xp.displayName=dl.displayName;function pl({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:u,onThreadDelete:d}){const{threads:f,currentThreadId:h,isLoading:p,actions:v}=Xo(),{loadThread:x}=Jo(),{createThread:g,deleteThread:y,renameThread:b}=v,[C,E]=w.useState(Array.isArray(f)?f:[]),T=w.useRef(C.length>0),[k,I]=w.useState(null),[_,R]=w.useState(""),[j,H]=w.useState(!1);w.useEffect(()=>{const M=Array.isArray(f)?f:[];if(M.length>0){T.current=!0,E(M);return}p||(T.current=!1,E(M))},[f,p]);const F=async M=>{try{await x(M),a==null||a(M),l==null||l(M)}catch(Y){console.error("Failed to select thread:",Y)}},U=async()=>{try{H(!0);const M=await g();u==null||u(M),a==null||a(M)}catch(M){console.error("Failed to create thread:",M)}finally{H(!1)}},D=async(M,Y)=>{if(Y.stopPropagation(),!!confirm("Delete this thread?"))try{await y(M),d==null||d(M)}catch(ce){console.error("Failed to delete thread:",ce)}},G=(M,Y)=>{Y.stopPropagation(),I(M.threadId),R(M.title||`Thread ${M.threadId.slice(0,8)}`)},W=async M=>{if(_.trim())try{await b(M,_.trim()),I(null),R("")}catch(Y){console.error("Failed to update title:",Y)}},ne=()=>{I(null),R("")},$=(M,Y)=>{M.key==="Enter"?W(Y):M.key==="Escape"&&ne()},z=M=>{if(!M)return"";try{const Y=new Date(M),be=new Date().getTime()-Y.getTime(),ge=Math.floor(be/(1e3*60*60*24));return ge===0?Y.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):ge===1?"Yesterday":ge<7?`${ge} days ago`:Y.toLocaleDateString()}catch{return""}},ie=M=>M.title||`Thread ${M.threadId.slice(0,8)}`;return c.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&c.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:c.jsx(qe,{onClick:U,disabled:j||p,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:j?"Creating...":"New Chat",children:c.jsx(ue.MessageSquarePlus,{size:20})})}),c.jsx(gp,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:c.jsx("div",{className:"p-2 space-y-1 pb-4",children:p?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(ue.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):C.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(ue.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),c.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):C.slice().sort((M,Y)=>new Date(Y.updatedAt||Y.createdAt||"").getTime()-new Date(M.updatedAt||M.createdAt||"").getTime()).map(M=>c.jsxs("div",{onClick:()=>F(M.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??h)===M.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:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"flex-1 min-w-0",children:k===M.threadId?c.jsxs("div",{className:"flex items-center gap-2",onClick:Y=>Y.stopPropagation(),children:[c.jsx(oi,{value:_,onChange:Y=>R(Y.target.value),onKeyDown:Y=>$(Y,M.threadId),className:"h-6 text-sm",autoFocus:!0}),c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>W(M.threadId),className:"h-6 w-6 p-0",children:c.jsx(ue.Check,{size:12})}),c.jsx(qe,{variant:"ghost",size:"sm",onClick:ne,className:"h-6 w-6 p-0",children:c.jsx(ue.X,{size:12})})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:ie(M)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(ue.Calendar,{size:10}),c.jsx("span",{children:z(M.updatedAt||M.createdAt)})]})]})}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&k!==M.threadId&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:Y=>G(M,Y),className:"h-6 w-6 p-0",title:"Edit title",children:c.jsx(ue.Edit3,{size:12})}),n&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:Y=>D(M.threadId,Y),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:c.jsx(ue.Trash2,{size:12})})]})]}),i===M.threadId&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},M.threadId))})})]})}function Br(e){if(!(typeof globalThis>"u"))return globalThis[e]}function YC(e){if(typeof e!="string")return;const t=e.trim();if(t)return Mn(t)}function yp(){const e=[Br("__API_BASE_URL__"),Br("__CHAT_API_BASE_URL__"),Br("__CHAT_API_URL__")];for(const t of e){const n=YC(t);if(n)return n}}function vp(){const e=[Br("__API_AUTH_TOKEN__"),Br("__CHAT_API_KEY__"),Br("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function bp(...e){for(const t of e)if(typeof t=="string"&&t.trim())return Mn(t);return Mn()}function wp(){const e={},t=yp(),n=vp();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Sp(){const e=wp(),t=Wn.getAuthToken(),n=yp();return{apiBaseUrl:bp(e.baseUrl,Wn.baseUrl,n),apiKey:t||e.apiKey||vp()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const Cp="chat-settings";function XC(){try{const e=localStorage.getItem(Cp);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function JC(e){try{const t={...e,apiBaseUrl:Mn(e.apiBaseUrl)};localStorage.setItem(Cp,JSON.stringify(t)),t.apiKey&&Wn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function ZC(){const e=Sp(),t=XC(),n=Wn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:bp(Wn.baseUrl,r,e.apiBaseUrl)}}function QC(e){Wn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),JC(e)}var eT="Label",Tp=m.forwardRef((e,t)=>c.jsx(Ie.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())}}));Tp.displayName=eT;var kp=Tp;const tT=Po.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),on=m.forwardRef(({className:e,...t},n)=>c.jsx(kp,{ref:n,className:re(tT(),e),...t}));on.displayName=kp.displayName;function Ep(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var ci="Switch",[nT,Ek]=Sn(ci),[rT,oT]=nT(ci),Ip=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:u,form:d,...f}=e,[h,p]=m.useState(null),v=Ve(t,C=>p(C)),x=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[y,b]=hr({prop:o,defaultProp:s??!1,onChange:u,caller:ci});return c.jsxs(rT,{scope:n,checked:y,disabled:a,children:[c.jsx(Ie.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":jp(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:v,onClick:pe(e.onClick,C=>{b(E=>!E),g&&(x.current=C.isPropagationStopped(),x.current||C.stopPropagation())})}),g&&c.jsx(_p,{control:h,bubbles:!x.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Ip.displayName=ci;var Np="SwitchThumb",Ap=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=oT(Np,n);return c.jsx(Ie.span,{"data-state":jp(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Ap.displayName=Np;var sT="SwitchBubbleInput",_p=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=Ve(i,s),l=Ep(n),u=Bf(t);return m.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const v=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(v)}},[l,n,r]),c.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}})});_p.displayName=sT;function jp(e){return e?"checked":"unchecked"}var Rp=Ip,iT=Ap;const er=m.forwardRef(({className:e,...t},n)=>c.jsx(Rp,{className:re("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:c.jsx(iT,{className:re("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")})}));er.displayName=Rp.displayName;var Pp=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"}),aT="VisuallyHidden",lT=m.forwardRef((e,t)=>c.jsx(Ie.span,{...e,ref:t,style:{...Pp,...e.style}}));lT.displayName=aT;var cT=[" ","Enter","ArrowUp","ArrowDown"],uT=[" ","Enter"],wr="Select",[ui,di,dT]=Fa(wr),[Hr,Ik]=Sn(wr,[dT,Js]),fi=Js(),[fT,tr]=Hr(wr),[hT,pT]=Hr(wr),Op=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:u,name:d,autoComplete:f,disabled:h,required:p,form:v}=e,x=fi(t),[g,y]=m.useState(null),[b,C]=m.useState(null),[E,T]=m.useState(!1),k=zs(u),[I,_]=hr({prop:r,defaultProp:o??!1,onChange:s,caller:wr}),[R,j]=hr({prop:i,defaultProp:a,onChange:l,caller:wr}),H=m.useRef(null),F=g?v||!!g.closest("form"):!0,[U,D]=m.useState(new Set),G=Array.from(U).map(W=>W.props.value).join(";");return c.jsx(Jf,{...x,children:c.jsxs(fT,{required:p,scope:t,trigger:g,onTriggerChange:y,valueNode:b,onValueNodeChange:C,valueNodeHasChildren:E,onValueNodeHasChildrenChange:T,contentId:Cn(),value:R,onValueChange:j,open:I,onOpenChange:_,dir:k,triggerPointerDownPosRef:H,disabled:h,children:[c.jsx(ui.Provider,{scope:t,children:c.jsx(hT,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(W=>{D(ne=>new Set(ne).add(W))},[]),onNativeOptionRemove:m.useCallback(W=>{D(ne=>{const $=new Set(ne);return $.delete(W),$})},[]),children:n})}),F?c.jsxs(om,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:R,onChange:W=>j(W.target.value),disabled:h,form:v,children:[R===void 0?c.jsx("option",{value:""}):null,Array.from(U)]},G):null]})})};Op.displayName=wr;var Mp="SelectTrigger",Dp=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=fi(n),i=tr(Mp,n),a=i.disabled||r,l=Ve(t,i.onTriggerChange),u=di(n),d=m.useRef("touch"),[f,h,p]=im(x=>{const g=u().filter(C=>!C.disabled),y=g.find(C=>C.value===i.value),b=am(g,x,y);b!==void 0&&i.onValueChange(b.value)}),v=x=>{a||(i.onOpenChange(!0),p()),x&&(i.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return c.jsx(Zf,{asChild:!0,...s,children:c.jsx(Ie.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":sm(i.value)?"":void 0,...o,ref:l,onClick:pe(o.onClick,x=>{x.currentTarget.focus(),d.current!=="mouse"&&v(x)}),onPointerDown:pe(o.onPointerDown,x=>{d.current=x.pointerType;const g=x.target;g.hasPointerCapture(x.pointerId)&&g.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(v(x),x.preventDefault())}),onKeyDown:pe(o.onKeyDown,x=>{const g=f.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&h(x.key),!(g&&x.key===" ")&&cT.includes(x.key)&&(v(),x.preventDefault())})})})});Dp.displayName=Mp;var Lp="SelectValue",Fp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=tr(Lp,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=Ve(t,l.onValueNodeChange);return Tt(()=>{u(d)},[u,d]),c.jsx(Ie.span,{...a,ref:f,style:{pointerEvents:"none"},children:sm(l.value)?c.jsx(c.Fragment,{children:i}):s})});Fp.displayName=Lp;var mT="SelectIcon",$p=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(Ie.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});$p.displayName=mT;var gT="SelectPortal",zp=e=>c.jsx(Ss,{asChild:!0,...e});zp.displayName=gT;var Sr="SelectContent",Bp=m.forwardRef((e,t)=>{const n=tr(Sr,e.__scopeSelect),[r,o]=m.useState();if(Tt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Oo.createPortal(c.jsx(Hp,{scope:e.__scopeSelect,children:c.jsx(ui.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(Up,{...e,ref:t})});Bp.displayName=Sr;var pn=10,[Hp,nr]=Hr(Sr),xT="SelectContentImpl",yT=or.createSlot("SelectContent.RemoveScroll"),Up=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:x,avoidCollisions:g,...y}=e,b=tr(Sr,n),[C,E]=m.useState(null),[T,k]=m.useState(null),I=Ve(t,K=>E(K)),[_,R]=m.useState(null),[j,H]=m.useState(null),F=di(n),[U,D]=m.useState(!1),G=m.useRef(!1);m.useEffect(()=>{if(C)return Pa(C)},[C]),Ia();const W=m.useCallback(K=>{const[L,...Z]=F().map(se=>se.ref.current),[ee]=Z.slice(-1),me=document.activeElement;for(const se of K)if(se===me||(se==null||se.scrollIntoView({block:"nearest"}),se===L&&T&&(T.scrollTop=0),se===ee&&T&&(T.scrollTop=T.scrollHeight),se==null||se.focus(),document.activeElement!==me))return},[F,T]),ne=m.useCallback(()=>W([_,C]),[W,_,C]);m.useEffect(()=>{U&&ne()},[U,ne]);const{onOpenChange:$,triggerPointerDownPosRef:z}=b;m.useEffect(()=>{if(C){let K={x:0,y:0};const L=ee=>{var me,se;K={x:Math.abs(Math.round(ee.pageX)-(((me=z.current)==null?void 0:me.x)??0)),y:Math.abs(Math.round(ee.pageY)-(((se=z.current)==null?void 0:se.y)??0))}},Z=ee=>{K.x<=10&&K.y<=10?ee.preventDefault():C.contains(ee.target)||$(!1),document.removeEventListener("pointermove",L),z.current=null};return z.current!==null&&(document.addEventListener("pointermove",L),document.addEventListener("pointerup",Z,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",Z,{capture:!0})}}},[C,$,z]),m.useEffect(()=>{const K=()=>$(!1);return window.addEventListener("blur",K),window.addEventListener("resize",K),()=>{window.removeEventListener("blur",K),window.removeEventListener("resize",K)}},[$]);const[ie,M]=im(K=>{const L=F().filter(me=>!me.disabled),Z=L.find(me=>me.ref.current===document.activeElement),ee=am(L,K,Z);ee&&setTimeout(()=>ee.ref.current.focus())}),Y=m.useCallback((K,L,Z)=>{const ee=!G.current&&!Z;(b.value!==void 0&&b.value===L||ee)&&(R(K),ee&&(G.current=!0))},[b.value]),ce=m.useCallback(()=>C==null?void 0:C.focus(),[C]),be=m.useCallback((K,L,Z)=>{const ee=!G.current&&!Z;(b.value!==void 0&&b.value===L||ee)&&H(K)},[b.value]),ge=r==="popper"?ml:Wp,ye=ge===ml?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:x,avoidCollisions:g}:{};return c.jsx(Hp,{scope:n,content:C,viewport:T,onViewportChange:k,itemRefCallback:Y,selectedItem:_,onItemLeave:ce,itemTextRefCallback:be,focusSelectedItem:ne,selectedItemText:j,position:r,isPositioned:U,searchRef:ie,children:c.jsx(Ns,{as:yT,allowPinchZoom:!0,children:c.jsx(ws,{asChild:!0,trapped:b.open,onMountAutoFocus:K=>{K.preventDefault()},onUnmountAutoFocus:pe(o,K=>{var L;(L=b.trigger)==null||L.focus({preventScroll:!0}),K.preventDefault()}),children:c.jsx(bs,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:K=>K.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:c.jsx(ge,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:K=>K.preventDefault(),...y,...ye,onPlaced:()=>D(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:pe(y.onKeyDown,K=>{const L=K.ctrlKey||K.altKey||K.metaKey;if(K.key==="Tab"&&K.preventDefault(),!L&&K.key.length===1&&M(K.key),["ArrowUp","ArrowDown","Home","End"].includes(K.key)){let ee=F().filter(me=>!me.disabled).map(me=>me.ref.current);if(["ArrowUp","End"].includes(K.key)&&(ee=ee.slice().reverse()),["ArrowUp","ArrowDown"].includes(K.key)){const me=K.target,se=ee.indexOf(me);ee=ee.slice(se+1)}setTimeout(()=>W(ee)),K.preventDefault()}})})})})})})});Up.displayName=xT;var vT="SelectItemAlignedPosition",Wp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=tr(Sr,n),i=nr(Sr,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=Ve(t,I=>d(I)),h=di(n),p=m.useRef(!1),v=m.useRef(!0),{viewport:x,selectedItem:g,selectedItemText:y,focusSelectedItem:b}=i,C=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&x&&g&&y){const I=s.trigger.getBoundingClientRect(),_=u.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),j=y.getBoundingClientRect();if(s.dir!=="rtl"){const me=j.left-_.left,se=R.left-me,ae=I.left-se,He=I.width+ae,Je=Math.max(He,_.width),je=window.innerWidth-pn,Ue=cl(se,[pn,Math.max(pn,je-Je)]);a.style.minWidth=He+"px",a.style.left=Ue+"px"}else{const me=_.right-j.right,se=window.innerWidth-R.right-me,ae=window.innerWidth-I.right-se,He=I.width+ae,Je=Math.max(He,_.width),je=window.innerWidth-pn,Ue=cl(se,[pn,Math.max(pn,je-Je)]);a.style.minWidth=He+"px",a.style.right=Ue+"px"}const H=h(),F=window.innerHeight-pn*2,U=x.scrollHeight,D=window.getComputedStyle(u),G=parseInt(D.borderTopWidth,10),W=parseInt(D.paddingTop,10),ne=parseInt(D.borderBottomWidth,10),$=parseInt(D.paddingBottom,10),z=G+W+U+$+ne,ie=Math.min(g.offsetHeight*5,z),M=window.getComputedStyle(x),Y=parseInt(M.paddingTop,10),ce=parseInt(M.paddingBottom,10),be=I.top+I.height/2-pn,ge=F-be,ye=g.offsetHeight/2,K=g.offsetTop+ye,L=G+W+K,Z=z-L;if(L<=be){const me=H.length>0&&g===H[H.length-1].ref.current;a.style.bottom="0px";const se=u.clientHeight-x.offsetTop-x.offsetHeight,ae=Math.max(ge,ye+(me?ce:0)+se+ne),He=L+ae;a.style.height=He+"px"}else{const me=H.length>0&&g===H[0].ref.current;a.style.top="0px";const ae=Math.max(be,G+x.offsetTop+(me?Y:0)+ye)+Z;a.style.height=ae+"px",x.scrollTop=L-be+x.offsetTop}a.style.margin=`${pn}px 0`,a.style.minHeight=ie+"px",a.style.maxHeight=F+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,x,g,y,s.dir,r]);Tt(()=>C(),[C]);const[E,T]=m.useState();Tt(()=>{u&&T(window.getComputedStyle(u).zIndex)},[u]);const k=m.useCallback(I=>{I&&v.current===!0&&(C(),b==null||b(),v.current=!1)},[C,b]);return c.jsx(wT,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:k,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:c.jsx(Ie.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Wp.displayName=vT;var bT="SelectPopperPosition",ml=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=pn,...s}=e,i=fi(n);return c.jsx(Qf,{...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)"}})});ml.displayName=bT;var[wT,gl]=Hr(Sr,{}),xl="SelectViewport",Vp=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=nr(xl,n),i=gl(xl,n),a=Ve(t,s.onViewportChange),l=m.useRef(0);return c.jsxs(c.Fragment,{children:[c.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}),c.jsx(ui.Slot,{scope:n,children:c.jsx(Ie.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:pe(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const v=window.innerHeight-pn*2,x=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),y=Math.max(x,g);if(y<v){const b=y+p,C=Math.min(v,b),E=b-C;f.style.height=C+"px",f.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Vp.displayName=xl;var Kp="SelectGroup",[ST,CT]=Hr(Kp),TT=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Cn();return c.jsx(ST,{scope:n,id:o,children:c.jsx(Ie.div,{role:"group","aria-labelledby":o,...r,ref:t})})});TT.displayName=Kp;var qp="SelectLabel",Gp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=CT(qp,n);return c.jsx(Ie.div,{id:o.id,...r,ref:t})});Gp.displayName=qp;var hi="SelectItem",[kT,Yp]=Hr(hi),Xp=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=tr(hi,n),l=nr(hi,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),v=Ve(t,b=>{var C;return(C=l.itemRefCallback)==null?void 0:C.call(l,b,r,o)}),x=Cn(),g=m.useRef("touch"),y=()=>{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 c.jsx(kT,{scope:n,value:r,disabled:o,textId:x,isSelected:u,onItemTextChange:m.useCallback(b=>{f(C=>C||((b==null?void 0:b.textContent)??"").trim())},[]),children:c.jsx(ui.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(Ie.div,{role:"option","aria-labelledby":x,"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:v,onFocus:pe(i.onFocus,()=>p(!0)),onBlur:pe(i.onBlur,()=>p(!1)),onClick:pe(i.onClick,()=>{g.current!=="mouse"&&y()}),onPointerUp:pe(i.onPointerUp,()=>{g.current==="mouse"&&y()}),onPointerDown:pe(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:pe(i.onPointerMove,b=>{var C;g.current=b.pointerType,o?(C=l.onItemLeave)==null||C.call(l):g.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:pe(i.onPointerLeave,b=>{var C;b.currentTarget===document.activeElement&&((C=l.onItemLeave)==null||C.call(l))}),onKeyDown:pe(i.onKeyDown,b=>{var E;((E=l.searchRef)==null?void 0:E.current)!==""&&b.key===" "||(uT.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});Xp.displayName=hi;var Eo="SelectItemText",Jp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=tr(Eo,n),a=nr(Eo,n),l=Yp(Eo,n),u=pT(Eo,n),[d,f]=m.useState(null),h=Ve(t,y=>f(y),l.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,y,l.value,l.disabled)}),p=d==null?void 0:d.textContent,v=m.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:x,onNativeOptionRemove:g}=u;return Tt(()=>(x(v),()=>g(v)),[x,g,v]),c.jsxs(c.Fragment,{children:[c.jsx(Ie.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Oo.createPortal(s.children,i.valueNode):null]})});Jp.displayName=Eo;var Zp="SelectItemIndicator",Qp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Yp(Zp,n).isSelected?c.jsx(Ie.span,{"aria-hidden":!0,...r,ref:t}):null});Qp.displayName=Zp;var yl="SelectScrollUpButton",em=m.forwardRef((e,t)=>{const n=nr(yl,e.__scopeSelect),r=gl(yl,e.__scopeSelect),[o,s]=m.useState(!1),i=Ve(t,r.onScrollButtonChange);return Tt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollTop>0;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(nm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});em.displayName=yl;var vl="SelectScrollDownButton",tm=m.forwardRef((e,t)=>{const n=nr(vl,e.__scopeSelect),r=gl(vl,e.__scopeSelect),[o,s]=m.useState(!1),i=Ve(t,r.onScrollButtonChange);return Tt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<u;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(nm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});tm.displayName=vl;var nm=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=nr("SelectScrollButton",n),i=m.useRef(null),a=di(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),Tt(()=>{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]),c.jsx(Ie.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:pe(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:pe(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:pe(o.onPointerLeave,()=>{l()})})}),ET="SelectSeparator",rm=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(Ie.div,{"aria-hidden":!0,...r,ref:t})});rm.displayName=ET;var bl="SelectArrow",IT=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=fi(n),s=tr(bl,n),i=nr(bl,n);return s.open&&i.position==="popper"?c.jsx(eh,{...o,...r,ref:t}):null});IT.displayName=bl;var NT="SelectBubbleInput",om=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=Ve(r,o),i=Ep(t);return m.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(Ie.select,{...n,style:{...Pp,...n.style},ref:s,defaultValue:t})});om.displayName=NT;function sm(e){return e===""||e===void 0}function im(e){const t=At(e),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(i=>{const a=n.current+i;t(a),function l(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function am(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=AT(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function AT(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var _T=Op,lm=Dp,jT=Fp,RT=$p,PT=zp,cm=Bp,OT=Vp,um=Gp,dm=Xp,MT=Jp,DT=Qp,fm=em,hm=tm,pm=rm;const mm=_T,gm=jT,wl=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(lm,{ref:r,className:re("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,c.jsx(RT,{asChild:!0,children:c.jsx(ue.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));wl.displayName=lm.displayName;const xm=m.forwardRef(({className:e,...t},n)=>c.jsx(fm,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ue.ChevronUp,{className:"h-4 w-4"})}));xm.displayName=fm.displayName;const ym=m.forwardRef(({className:e,...t},n)=>c.jsx(hm,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ue.ChevronDown,{className:"h-4 w-4"})}));ym.displayName=hm.displayName;const Sl=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(PT,{children:c.jsxs(cm,{ref:o,className:re("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:[c.jsx(xm,{}),c.jsx(OT,{className:re("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(ym,{})]})}));Sl.displayName=cm.displayName;const LT=m.forwardRef(({className:e,...t},n)=>c.jsx(um,{ref:n,className:re("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));LT.displayName=um.displayName;const Cr=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(dm,{ref:r,className:re("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:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(DT,{children:c.jsx(ue.Check,{className:"h-4 w-4"})})}),c.jsx(MT,{children:t})]}));Cr.displayName=dm.displayName;const FT=m.forwardRef(({className:e,...t},n)=>c.jsx(pm,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));FT.displayName=pm.displayName;var $T="Separator",vm="horizontal",zT=["horizontal","vertical"],bm=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=vm,...o}=e,s=BT(r)?r:vm,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(Ie.div,{"data-orientation":s,...a,...o,ref:t})});bm.displayName=$T;function BT(e){return zT.includes(e)}var wm=bm;const Sm=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(wm,{ref:o,decorative:n,orientation:t,className:re("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Sm.displayName=wm.displayName;const HT=of,UT=ww,WT=sf,Cm=m.forwardRef(({className:e,...t},n)=>c.jsx(Ps,{className:re("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}));Cm.displayName=Ps.displayName;const VT=Po.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"}}),Tm=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(WT,{children:[c.jsx(Cm,{}),c.jsxs(Os,{ref:o,className:re(VT({side:e}),t),...r,children:[n,c.jsxs(af,{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:[c.jsx(ue.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Tm.displayName=Os.displayName;const km=({className:e,...t})=>c.jsx("div",{className:re("flex flex-col space-y-2 text-center sm:text-left",e),...t});km.displayName="SheetHeader";const Em=m.forwardRef(({className:e,...t},n)=>c.jsx(gr,{ref:n,className:re("text-lg font-semibold text-foreground",e),...t}));Em.displayName=gr.displayName;const Im=m.forwardRef(({className:e,...t},n)=>c.jsx(Ms,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));Im.displayName=Ms.displayName;const KT={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 qT({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=w.useState(!1),[s,i]=w.useState(!1),[a,l]=w.useState(e),[u,d]=w.useState(!1),{toast:f}=Sa();w.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),w.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(KT),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},v=()=>{l(e),d(!1),o(!1)},x=async()=>{try{const y=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${y.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return c.jsxs(HT,{open:r,onOpenChange:o,children:[c.jsx(UT,{asChild:!0,children:c.jsxs(qe,{variant:"outline",size:"sm",className:n,children:[c.jsx(ue.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(fa,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(Tm,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(km,{children:[c.jsx(Em,{children:"Chat Settings"}),c.jsx(Im,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),c.jsxs("div",{className:"space-y-6 py-6",children:[c.jsxs(uo,{children:[c.jsx(fo,{className:"pb-3",children:c.jsxs(ho,{className:"text-lg flex items-center gap-2",children:[c.jsx(ue.Server,{className:"h-5 w-5"}),"API Configuration"]})}),c.jsxs(po,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(on,{htmlFor:"api-url",children:"API Base URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(oi,{id:"api-url",value:a.api.baseUrl,onChange:g=>l(y=>({...y,api:{...y.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(qe,{variant:"outline",onClick:x,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(on,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(er,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>l(y=>({...y,api:{...y.api,enableAuth:g}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(on,{htmlFor:"auth-token",children:"Authentication Token"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(oi,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>l(y=>({...y,api:{...y.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(qe,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(ue.EyeOff,{className:"h-4 w-4"}):c.jsx(ue.Eye,{className:"h-4 w-4"})})]})]})]})]}),c.jsxs(uo,{children:[c.jsx(fo,{className:"pb-3",children:c.jsxs(ho,{className:"text-lg flex items-center gap-2",children:[c.jsx(ue.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),c.jsxs(po,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(on,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(mm,{value:a.ui.layout,onValueChange:g=>l(y=>({...y,ui:{...y.ui,layout:g}})),children:[c.jsx(wl,{children:c.jsx(gm,{})}),c.jsxs(Sl,{children:[c.jsx(Cr,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(Cr,{value:"fullscreen",children:"Fullscreen"}),c.jsx(Cr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(on,{htmlFor:"theme",children:"Theme"}),c.jsxs(mm,{value:a.ui.theme,onValueChange:g=>l(y=>({...y,ui:{...y.ui,theme:g}})),children:[c.jsx(wl,{children:c.jsx(gm,{})}),c.jsxs(Sl,{children:[c.jsx(Cr,{value:"light",children:"Light"}),c.jsx(Cr,{value:"dark",children:"Dark"}),c.jsx(Cr,{value:"system",children:"System"})]})]})]}),c.jsx(Sm,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(on,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(er,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,showTimestamps:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(on,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(er,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,showAgentNames:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(on,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(er,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,compactMessages:g}}))})]})]})]})]}),c.jsxs(uo,{children:[c.jsx(fo,{className:"pb-3",children:c.jsxs(ho,{className:"text-lg flex items-center gap-2",children:[c.jsx(ue.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),c.jsxs(po,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(on,{htmlFor:"auto-save",children:"Auto-save Conversations"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),c.jsx(er,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>l(y=>({...y,behavior:{...y.behavior,autoSave:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(on,{htmlFor:"enable-streaming",children:"Enable Streaming"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),c.jsx(er,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>l(y=>({...y,behavior:{...y.behavior,enableStreaming:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(on,{htmlFor:"typing-indicator",children:"Typing Indicator"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),c.jsx(er,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>l(y=>({...y,behavior:{...y.behavior,showTypingIndicator:g}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(qe,{variant:"outline",onClick:p,children:[c.jsx(ue.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(qe,{variant:"outline",onClick:v,children:"Cancel"}),c.jsxs(qe,{onClick:h,disabled:!u,children:[c.jsx(ue.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function GT({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"}),l=w.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?c.jsx(Zo,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsx(ri,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?c.jsx(Zo,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&c.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(pl,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(ri,{onError:s.onError,enableFileUpload:!0})})]})})}):c.jsx(Zo,{...s,onThreadChange:l,children:c.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&c.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(pl,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(ri,{onError:s.onError,enableFileUpload:!0})})]})})}Ne.ChatApi=Sc,Ne.ChatInterface=ri,Ne.ChatProviders=Zo,Ne.ChatSettings=qT,Ne.MarkdownContent=va,Ne.MessageComponent=gf,Ne.MessageList=La,Ne.ThreadManager=pl,Ne.applySettings=QC,Ne.chatApiClient=Wn,Ne.default=GT,Ne.del=wc,Ne.get=ln,Ne.getChatToken=xc,Ne.getCurrentSettings=ZC,Ne.getDefaultApiConfig=wp,Ne.getDefaultChatSettings=Sp,Ne.onChatTokenChanged=yc,Ne.post=vc,Ne.put=bc,Ne.setChatToken=Ni,Ne.useApi=Ai,Ne.useChatStream=$c,Ne.useMessagesReducer=_c,Ne.useStream=Gc,Ne.useThreadState=Jo,Ne.useThreads=Xo,Object.defineProperties(Ne,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
139
+ `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function zw(e,t=$s){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 Bw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),zw(t),$w(t)}function Fa(e){const t=e+"CollectionProvider",[n,r]=Sn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=x=>{const{scope:g,children:y}=x,b=w.useRef(null),C=w.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:C,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=or.createSlot(a),u=w.forwardRef((x,g)=>{const{scope:y,children:b}=x,C=s(a,y),E=Ve(g,C.collectionRef);return c.jsx(l,{ref:E,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=or.createSlot(d),p=w.forwardRef((x,g)=>{const{scope:y,children:b,...C}=x,E=w.useRef(null),k=Ve(g,E),T=s(d,y);return w.useEffect(()=>(T.itemMap.set(E,{ref:E,...C}),()=>void T.itemMap.delete(E))),c.jsx(h,{[f]:"",ref:k,children:b})});p.displayName=d;function v(x){const g=s(e+"CollectionConsumer",x);return w.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const C=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((T,I)=>C.indexOf(T.ref.current)-C.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},v,r]}var Hw=m.createContext(void 0);function zs(e){const t=m.useContext(Hw);return e||t||"ltr"}const Uw=["top","right","bottom","left"],Zn=Math.min,Yt=Math.max,Bs=Math.round,Hs=Math.floor,Tn=e=>({x:e,y:e}),Ww={left:"right",right:"left",bottom:"top",top:"bottom"},Vw={start:"end",end:"start"};function $a(e,t,n){return Yt(e,Zn(t,n))}function Ln(e,t){return typeof e=="function"?e(t):e}function Fn(e){return e.split("-")[0]}function Dr(e){return e.split("-")[1]}function za(e){return e==="x"?"y":"x"}function Ba(e){return e==="y"?"height":"width"}const Kw=new Set(["top","bottom"]);function En(e){return Kw.has(Fn(e))?"y":"x"}function Ha(e){return za(En(e))}function qw(e,t,n){n===void 0&&(n=!1);const r=Dr(e),o=Ha(e),s=Ba(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Us(i)),[i,Us(i)]}function Gw(e){const t=Us(e);return[Ua(e),t,Ua(t)]}function Ua(e){return e.replace(/start|end/g,t=>Vw[t])}const gf=["left","right"],xf=["right","left"],Yw=["top","bottom"],Xw=["bottom","top"];function Jw(e,t,n){switch(e){case"top":case"bottom":return n?t?xf:gf:t?gf:xf;case"left":case"right":return t?Yw:Xw;default:return[]}}function Zw(e,t,n,r){const o=Dr(e);let s=Jw(Fn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ua)))),s}function Us(e){return e.replace(/left|right|bottom|top/g,t=>Ww[t])}function Qw(e){return{top:0,right:0,bottom:0,left:0,...e}}function yf(e){return typeof e!="number"?Qw(e):{top:e,right:e,bottom:e,left:e}}function Ws(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 vf(e,t,n){let{reference:r,floating:o}=e;const s=En(t),i=Ha(t),a=Ba(i),l=Fn(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 p;switch(l){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(Dr(t)){case"start":p[i]-=h*(n&&u?-1:1);break;case"end":p[i]+=h*(n&&u?-1:1);break}return p}const e0=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=vf(u,r,l),h=r,p={},v=0;for(let x=0;x<a.length;x++){const{name:g,fn:y}=a[x],{x:b,y:C,data:E,reset:k}=await y({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});d=b??d,f=C??f,p={...p,[g]:{...p[g],...E}},k&&v<=50&&(v++,typeof k=="object"&&(k.placement&&(h=k.placement),k.rects&&(u=k.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):k.rects),{x:d,y:f}=vf(u,h,l)),x=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function xo(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=Ln(t,e),v=yf(p),g=a[h?f==="floating"?"reference":"floating":f],y=Ws(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:l})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},k=Ws(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:C,strategy:l}):b);return{top:(y.top-k.top+v.top)/E.y,bottom:(k.bottom-y.bottom+v.bottom)/E.y,left:(y.left-k.left+v.left)/E.x,right:(k.right-y.right+v.right)/E.x}}const t0=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:u,padding:d=0}=Ln(e,t)||{};if(u==null)return{};const f=yf(d),h={x:n,y:r},p=Ha(o),v=Ba(p),x=await i.getDimensions(u),g=p==="y",y=g?"top":"left",b=g?"bottom":"right",C=g?"clientHeight":"clientWidth",E=s.reference[v]+s.reference[p]-h[p]-s.floating[v],k=h[p]-s.reference[p],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let I=T?T[C]:0;(!I||!await(i.isElement==null?void 0:i.isElement(T)))&&(I=a.floating[C]||s.floating[v]);const _=E/2-k/2,R=I/2-x[v]/2-1,j=Zn(f[y],R),H=Zn(f[b],R),F=j,U=I-x[v]-H,D=I/2-x[v]/2+_,G=$a(F,D,U),W=!l.arrow&&Dr(o)!=null&&D!==G&&s.reference[v]/2-(D<F?j:H)-x[v]/2<0,ne=W?D<F?D-F:D-U:0;return{[p]:h[p]+ne,data:{[p]:G,centerOffset:D-G-ne,...W&&{alignmentOffset:ne}},reset:W}}}),n0=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:l,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:x=!0,...g}=Ln(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=Fn(o),b=En(a),C=Fn(a)===a,E=await(l.isRTL==null?void 0:l.isRTL(u.floating)),k=h||(C||!x?[Us(a)]:Gw(a)),T=v!=="none";!h&&T&&k.push(...Zw(a,x,v,E));const I=[a,...k],_=await xo(t,g),R=[];let j=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&R.push(_[y]),f){const D=qw(o,i,E);R.push(_[D[0]],_[D[1]])}if(j=[...j,{placement:o,overflows:R}],!R.every(D=>D<=0)){var H,F;const D=(((H=s.flip)==null?void 0:H.index)||0)+1,G=I[D];if(G&&(!(f==="alignment"?b!==En(G):!1)||j.every($=>En($.placement)===b?$.overflows[0]>0:!0)))return{data:{index:D,overflows:j},reset:{placement:G}};let W=(F=j.filter(ne=>ne.overflows[0]<=0).sort((ne,$)=>ne.overflows[1]-$.overflows[1])[0])==null?void 0:F.placement;if(!W)switch(p){case"bestFit":{var U;const ne=(U=j.filter($=>{if(T){const z=En($.placement);return z===b||z==="y"}return!0}).map($=>[$.placement,$.overflows.filter(z=>z>0).reduce((z,ie)=>z+ie,0)]).sort(($,z)=>$[1]-z[1])[0])==null?void 0:U[0];ne&&(W=ne);break}case"initialPlacement":W=a;break}if(o!==W)return{reset:{placement:W}}}return{}}}};function bf(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function wf(e){return Uw.some(t=>e[t]>=0)}const r0=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Ln(e,t);switch(r){case"referenceHidden":{const s=await xo(t,{...o,elementContext:"reference"}),i=bf(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:wf(i)}}}case"escaped":{const s=await xo(t,{...o,altBoundary:!0}),i=bf(s,n.floating);return{data:{escapedOffsets:i,escaped:wf(i)}}}default:return{}}}}},Sf=new Set(["left","top"]);async function o0(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Fn(n),a=Dr(n),l=En(n)==="y",u=Sf.has(i)?-1:1,d=s&&l?-1:1,f=Ln(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof v=="number"&&(p=a==="end"?v*-1:v),l?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const s0=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,l=await o0(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},i0=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,y:b}=g;return{x:y,y:b}}},...l}=Ln(e,t),u={x:n,y:r},d=await xo(t,l),f=En(Fn(o)),h=za(f);let p=u[h],v=u[f];if(s){const g=h==="y"?"top":"left",y=h==="y"?"bottom":"right",b=p+d[g],C=p-d[y];p=$a(b,p,C)}if(i){const g=f==="y"?"top":"left",y=f==="y"?"bottom":"right",b=v+d[g],C=v-d[y];v=$a(b,v,C)}const x=a.fn({...t,[h]:p,[f]:v});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[h]:s,[f]:i}}}}}},a0=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:l=!0,crossAxis:u=!0}=Ln(e,t),d={x:n,y:r},f=En(o),h=za(f);let p=d[h],v=d[f];const x=Ln(a,t),g=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(l){const C=h==="y"?"height":"width",E=s.reference[h]-s.floating[C]+g.mainAxis,k=s.reference[h]+s.reference[C]-g.mainAxis;p<E?p=E:p>k&&(p=k)}if(u){var y,b;const C=h==="y"?"width":"height",E=Sf.has(Fn(o)),k=s.reference[f]-s.floating[C]+(E&&((y=i.offset)==null?void 0:y[f])||0)+(E?0:g.crossAxis),T=s.reference[f]+s.reference[C]+(E?0:((b=i.offset)==null?void 0:b[f])||0)-(E?g.crossAxis:0);v<k?v=k:v>T&&(v=T)}return{[h]:p,[f]:v}}}},l0=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:l=()=>{},...u}=Ln(e,t),d=await xo(t,u),f=Fn(o),h=Dr(o),p=En(o)==="y",{width:v,height:x}=s.floating;let g,y;f==="top"||f==="bottom"?(g=f,y=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=f,g=h==="end"?"top":"bottom");const b=x-d.top-d.bottom,C=v-d.left-d.right,E=Zn(x-d[g],b),k=Zn(v-d[y],C),T=!t.middlewareData.shift;let I=E,_=k;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(_=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=b),T&&!h){const j=Yt(d.left,0),H=Yt(d.right,0),F=Yt(d.top,0),U=Yt(d.bottom,0);p?_=v-2*(j!==0||H!==0?j+H:Yt(d.left,d.right)):I=x-2*(F!==0||U!==0?F+U:Yt(d.top,d.bottom))}await l({...t,availableWidth:_,availableHeight:I});const R=await i.getDimensions(a.floating);return v!==R.width||x!==R.height?{reset:{rects:!0}}:{}}}};function Vs(){return typeof window<"u"}function Lr(e){return Cf(e)?(e.nodeName||"").toLowerCase():"#document"}function Xt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function In(e){var t;return(t=(Cf(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Cf(e){return Vs()?e instanceof Node||e instanceof Xt(e).Node:!1}function fn(e){return Vs()?e instanceof Element||e instanceof Xt(e).Element:!1}function Nn(e){return Vs()?e instanceof HTMLElement||e instanceof Xt(e).HTMLElement:!1}function kf(e){return!Vs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Xt(e).ShadowRoot}const c0=new Set(["inline","contents"]);function yo(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=hn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!c0.has(o)}const u0=new Set(["table","td","th"]);function d0(e){return u0.has(Lr(e))}const f0=[":popover-open",":modal"];function Ks(e){return f0.some(t=>{try{return e.matches(t)}catch{return!1}})}const h0=["transform","translate","scale","rotate","perspective"],p0=["transform","translate","scale","rotate","perspective","filter"],m0=["paint","layout","strict","content"];function Wa(e){const t=Va(),n=fn(e)?hn(e):e;return h0.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)||p0.some(r=>(n.willChange||"").includes(r))||m0.some(r=>(n.contain||"").includes(r))}function g0(e){let t=Qn(e);for(;Nn(t)&&!Fr(t);){if(Wa(t))return t;if(Ks(t))return null;t=Qn(t)}return null}function Va(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const x0=new Set(["html","body","#document"]);function Fr(e){return x0.has(Lr(e))}function hn(e){return Xt(e).getComputedStyle(e)}function qs(e){return fn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Qn(e){if(Lr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||kf(e)&&e.host||In(e);return kf(t)?t.host:t}function Tf(e){const t=Qn(e);return Fr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Nn(t)&&yo(t)?t:Tf(t)}function vo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Tf(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Xt(o);if(s){const a=Ka(i);return t.concat(i,i.visualViewport||[],yo(o)?o:[],a&&n?vo(a):[])}return t.concat(o,vo(o,[],n))}function Ka(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Ef(e){const t=hn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Nn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Bs(n)!==s||Bs(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function qa(e){return fn(e)?e:e.contextElement}function $r(e){const t=qa(e);if(!Nn(t))return Tn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Ef(t);let i=(s?Bs(n.width):n.width)/r,a=(s?Bs(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const y0=Tn(0);function If(e){const t=Xt(e);return!Va()||!t.visualViewport?y0:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function v0(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Xt(e)?!1:t}function yr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=qa(e);let i=Tn(1);t&&(r?fn(r)&&(i=$r(r)):i=$r(e));const a=v0(s,n,r)?If(s):Tn(0);let l=(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=Xt(s),p=r&&fn(r)?Xt(r):r;let v=h,x=Ka(v);for(;x&&r&&p!==v;){const g=$r(x),y=x.getBoundingClientRect(),b=hn(x),C=y.left+(x.clientLeft+parseFloat(b.paddingLeft))*g.x,E=y.top+(x.clientTop+parseFloat(b.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=C,u+=E,v=Xt(x),x=Ka(v)}}return Ws({width:d,height:f,x:l,y:u})}function Gs(e,t){const n=qs(e).scrollLeft;return t?t.left+n:yr(In(e)).left+n}function Nf(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Gs(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function b0(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=In(r),a=t?Ks(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=Tn(1);const d=Tn(0),f=Nn(r);if((f||!f&&!s)&&((Lr(r)!=="body"||yo(i))&&(l=qs(r)),Nn(r))){const p=yr(r);u=$r(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?Nf(i,l):Tn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-l.scrollTop*u.y+d.y+h.y}}function w0(e){return Array.from(e.getClientRects())}function S0(e){const t=In(e),n=qs(e),r=e.ownerDocument.body,o=Yt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Yt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Gs(e);const a=-n.scrollTop;return hn(r).direction==="rtl"&&(i+=Yt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Af=25;function C0(e,t){const n=Xt(e),r=In(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=Va();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const u=Gs(r);if(u<=0){const d=r.ownerDocument,f=d.body,h=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-p);v<=Af&&(s-=v)}else u<=Af&&(s+=u);return{width:s,height:i,x:a,y:l}}const k0=new Set(["absolute","fixed"]);function T0(e,t){const n=yr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Nn(e)?$r(e):Tn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,u=r*s.y;return{width:i,height:a,x:l,y:u}}function _f(e,t,n){let r;if(t==="viewport")r=C0(e,n);else if(t==="document")r=S0(In(e));else if(fn(t))r=T0(t,n);else{const o=If(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ws(r)}function jf(e,t){const n=Qn(e);return n===t||!fn(n)||Fr(n)?!1:hn(n).position==="fixed"||jf(n,t)}function E0(e,t){const n=t.get(e);if(n)return n;let r=vo(e,[],!1).filter(a=>fn(a)&&Lr(a)!=="body"),o=null;const s=hn(e).position==="fixed";let i=s?Qn(e):e;for(;fn(i)&&!Fr(i);){const a=hn(i),l=Wa(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&k0.has(o.position)||yo(i)&&!l&&jf(e,i))?r=r.filter(d=>d!==i):o=a,i=Qn(i)}return t.set(e,r),r}function I0(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Ks(t)?[]:E0(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=_f(t,d,o);return u.top=Yt(f.top,u.top),u.right=Zn(f.right,u.right),u.bottom=Zn(f.bottom,u.bottom),u.left=Yt(f.left,u.left),u},_f(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function N0(e){const{width:t,height:n}=Ef(e);return{width:t,height:n}}function A0(e,t,n){const r=Nn(t),o=In(t),s=n==="fixed",i=yr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=Tn(0);function u(){l.x=Gs(o)}if(r||!r&&!s)if((Lr(t)!=="body"||yo(o))&&(a=qs(t)),r){const p=yr(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?Nf(o,a):Tn(0),f=i.left+a.scrollLeft-l.x-d.x,h=i.top+a.scrollTop-l.y-d.y;return{x:f,y:h,width:i.width,height:i.height}}function Ga(e){return hn(e).position==="static"}function Rf(e,t){if(!Nn(e)||hn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return In(e)===n&&(n=n.ownerDocument.body),n}function Pf(e,t){const n=Xt(e);if(Ks(e))return n;if(!Nn(e)){let o=Qn(e);for(;o&&!Fr(o);){if(fn(o)&&!Ga(o))return o;o=Qn(o)}return n}let r=Rf(e,t);for(;r&&d0(r)&&Ga(r);)r=Rf(r,t);return r&&Fr(r)&&Ga(r)&&!Wa(r)?n:r||g0(e)||n}const _0=async function(e){const t=this.getOffsetParent||Pf,n=this.getDimensions,r=await n(e.floating);return{reference:A0(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function j0(e){return hn(e).direction==="rtl"}const R0={convertOffsetParentRelativeRectToViewportRelativeRect:b0,getDocumentElement:In,getClippingRect:I0,getOffsetParent:Pf,getElementRects:_0,getClientRects:w0,getDimensions:N0,getScale:$r,isElement:fn,isRTL:j0};function Of(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function P0(e,t){let n=null,r;const o=In(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:p}=u;if(a||t(),!h||!p)return;const v=Hs(f),x=Hs(o.clientWidth-(d+h)),g=Hs(o.clientHeight-(f+p)),y=Hs(d),C={rootMargin:-v+"px "+-x+"px "+-g+"px "+-y+"px",threshold:Yt(0,Zn(1,l))||1};let E=!0;function k(T){const I=T[0].intersectionRatio;if(I!==l){if(!E)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!Of(u,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(k,{...C,root:o.ownerDocument})}catch{n=new IntersectionObserver(k,C)}n.observe(e)}return i(!0),s}function O0(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:l=!1}=r,u=qa(e),d=o||s?[...u?vo(u):[],...vo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const f=u&&a?P0(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(y=>{let[b]=y;b&&b.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var C;(C=p)==null||C.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let v,x=l?yr(e):null;l&&g();function g(){const y=yr(e);x&&!Of(x,y)&&n(),x=y,v=requestAnimationFrame(g)}return n(),()=>{var y;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(v)}}const M0=s0,D0=i0,L0=n0,F0=l0,$0=r0,Mf=t0,z0=a0,B0=(e,t,n)=>{const r=new Map,o={platform:R0,...n},s={...o.platform,_c:r};return e0(e,t,{...o,platform:s})};var H0=typeof document<"u",U0=function(){},Ys=H0?w.useLayoutEffect:U0;function Xs(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(!Xs(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)&&!Xs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Df(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Lf(e,t){const n=Df(e);return Math.round(t*n)/n}function Ya(e){const t=m.useRef(e);return Ys(()=>{t.current=e}),t}function W0(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:l,open:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=m.useState(r);Xs(h,r)||p(r);const[v,x]=m.useState(null),[g,y]=m.useState(null),b=m.useCallback($=>{$!==T.current&&(T.current=$,x($))},[]),C=m.useCallback($=>{$!==I.current&&(I.current=$,y($))},[]),E=s||v,k=i||g,T=m.useRef(null),I=m.useRef(null),_=m.useRef(d),R=l!=null,j=Ya(l),H=Ya(o),F=Ya(u),U=m.useCallback(()=>{if(!T.current||!I.current)return;const $={placement:t,strategy:n,middleware:h};H.current&&($.platform=H.current),B0(T.current,I.current,$).then(z=>{const ie={...z,isPositioned:F.current!==!1};D.current&&!Xs(_.current,ie)&&(_.current=ie,Oo.flushSync(()=>{f(ie)}))})},[h,t,n,H,F]);Ys(()=>{u===!1&&_.current.isPositioned&&(_.current.isPositioned=!1,f($=>({...$,isPositioned:!1})))},[u]);const D=m.useRef(!1);Ys(()=>(D.current=!0,()=>{D.current=!1}),[]),Ys(()=>{if(E&&(T.current=E),k&&(I.current=k),E&&k){if(j.current)return j.current(E,k,U);U()}},[E,k,U,j,R]);const G=m.useMemo(()=>({reference:T,floating:I,setReference:b,setFloating:C}),[b,C]),W=m.useMemo(()=>({reference:E,floating:k}),[E,k]),ne=m.useMemo(()=>{const $={position:n,left:0,top:0};if(!W.floating)return $;const z=Lf(W.floating,d.x),ie=Lf(W.floating,d.y);return a?{...$,transform:"translate("+z+"px, "+ie+"px)",...Df(W.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:z,top:ie}},[n,a,W.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:U,refs:G,elements:W,floatingStyles:ne}),[d,U,G,W,ne])}const V0=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?Mf({element:r.current,padding:o}).fn(n):{}:r?Mf({element:r,padding:o}).fn(n):{}}}},K0=(e,t)=>({...M0(e),options:[e,t]}),q0=(e,t)=>({...D0(e),options:[e,t]}),G0=(e,t)=>({...z0(e),options:[e,t]}),Y0=(e,t)=>({...L0(e),options:[e,t]}),X0=(e,t)=>({...F0(e),options:[e,t]}),J0=(e,t)=>({...$0(e),options:[e,t]}),Z0=(e,t)=>({...V0(e),options:[e,t]});var Q0="Arrow",Ff=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(Ie.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});Ff.displayName=Q0;var eS=Ff;function $f(e){const[t,n]=m.useState(void 0);return kt(()=>{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 l=s.borderBoxSize,u=Array.isArray(l)?l[0]:l;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 Xa="Popper",[zf,Js]=Sn(Xa),[tS,Bf]=zf(Xa),Hf=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(tS,{scope:t,anchor:r,onAnchorChange:o,children:n})};Hf.displayName=Xa;var Uf="PopperAnchor",Wf=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Bf(Uf,n),i=m.useRef(null),a=Ve(t,i),l=m.useRef(null);return m.useEffect(()=>{const u=l.current;l.current=(r==null?void 0:r.current)||i.current,u!==l.current&&s.onAnchorChange(l.current)}),r?null:c.jsx(Ie.div,{...o,ref:a})});Wf.displayName=Uf;var Ja="PopperContent",[nS,rS]=zf(Ja),Vf=m.forwardRef((e,t)=>{var K,L,Z,ee,me,se;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:v,...x}=e,g=Bf(Ja,n),[y,b]=m.useState(null),C=Ve(t,ae=>b(ae)),[E,k]=m.useState(null),T=$f(E),I=(T==null?void 0:T.width)??0,_=(T==null?void 0:T.height)??0,R=r+(s!=="center"?"-"+s:""),j=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},H=Array.isArray(u)?u:[u],F=H.length>0,U={padding:j,boundary:H.filter(sS),altBoundary:F},{refs:D,floatingStyles:G,placement:W,isPositioned:ne,middlewareData:$}=W0({strategy:"fixed",placement:R,whileElementsMounted:(...ae)=>O0(...ae,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[K0({mainAxis:o+_,alignmentAxis:i}),l&&q0({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?G0():void 0,...U}),l&&Y0({...U}),X0({...U,apply:({elements:ae,rects:He,availableWidth:Je,availableHeight:je})=>{const{width:Ue,height:et}=He.reference,Ze=ae.floating.style;Ze.setProperty("--radix-popper-available-width",`${Je}px`),Ze.setProperty("--radix-popper-available-height",`${je}px`),Ze.setProperty("--radix-popper-anchor-width",`${Ue}px`),Ze.setProperty("--radix-popper-anchor-height",`${et}px`)}}),E&&Z0({element:E,padding:a}),iS({arrowWidth:I,arrowHeight:_}),h&&J0({strategy:"referenceHidden",...U})]}),[z,ie]=Gf(W),M=At(v);kt(()=>{ne&&(M==null||M())},[ne,M]);const Y=(K=$.arrow)==null?void 0:K.x,ce=(L=$.arrow)==null?void 0:L.y,be=((Z=$.arrow)==null?void 0:Z.centerOffset)!==0,[ge,ye]=m.useState();return kt(()=>{y&&ye(window.getComputedStyle(y).zIndex)},[y]),c.jsx("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...G,transform:ne?G.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ge,"--radix-popper-transform-origin":[(ee=$.transformOrigin)==null?void 0:ee.x,(me=$.transformOrigin)==null?void 0:me.y].join(" "),...((se=$.hide)==null?void 0:se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(nS,{scope:n,placedSide:z,onArrowChange:k,arrowX:Y,arrowY:ce,shouldHideArrow:be,children:c.jsx(Ie.div,{"data-side":z,"data-align":ie,...x,ref:C,style:{...x.style,animation:ne?void 0:"none"}})})})});Vf.displayName=Ja;var Kf="PopperArrow",oS={top:"bottom",right:"left",bottom:"top",left:"right"},qf=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=rS(Kf,r),i=oS[s.placedSide];return c.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:c.jsx(eS,{...o,ref:n,style:{...o.style,display:"block"}})})});qf.displayName=Kf;function sS(e){return e!==null}var iS=e=>({name:"transformOrigin",options:e,fn(t){var g,y,b;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[u,d]=Gf(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let v="",x="";return u==="bottom"?(v=i?f:`${h}px`,x=`${-l}px`):u==="top"?(v=i?f:`${h}px`,x=`${r.floating.height+l}px`):u==="right"?(v=`${-l}px`,x=i?f:`${p}px`):u==="left"&&(v=`${r.floating.width+l}px`,x=i?f:`${p}px`),{data:{x:v,y:x}}}});function Gf(e){const[t,n="center"]=e.split("-");return[t,n]}var Yf=Hf,Xf=Wf,Jf=Vf,Zf=qf,Za="rovingFocusGroup.onEntryFocus",aS={bubbles:!1,cancelable:!0},bo="RovingFocusGroup",[Qa,Qf,lS]=Fa(bo),[cS,eh]=Sn(bo,[lS]),[uS,dS]=cS(bo),th=m.forwardRef((e,t)=>c.jsx(Qa.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Qa.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(fS,{...e,ref:t})})}));th.displayName=bo;var fS=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=m.useRef(null),p=Ve(t,h),v=zs(s),[x,g]=hr({prop:i,defaultProp:a??null,onChange:l,caller:bo}),[y,b]=m.useState(!1),C=At(u),E=Qf(n),k=m.useRef(!1),[T,I]=m.useState(0);return m.useEffect(()=>{const _=h.current;if(_)return _.addEventListener(Za,C),()=>_.removeEventListener(Za,C)},[C]),c.jsx(uS,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:x,onItemFocus:m.useCallback(_=>g(_),[g]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>I(_=>_+1),[]),onFocusableItemRemove:m.useCallback(()=>I(_=>_-1),[]),children:c.jsx(Ie.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:pe(e.onMouseDown,()=>{k.current=!0}),onFocus:pe(e.onFocus,_=>{const R=!k.current;if(_.target===_.currentTarget&&R&&!y){const j=new CustomEvent(Za,aS);if(_.currentTarget.dispatchEvent(j),!j.defaultPrevented){const H=E().filter(W=>W.focusable),F=H.find(W=>W.active),U=H.find(W=>W.id===x),G=[F,U,...H].filter(Boolean).map(W=>W.ref.current);oh(G,d)}}k.current=!1}),onBlur:pe(e.onBlur,()=>b(!1))})})}),nh="RovingFocusGroupItem",rh=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Cn(),u=s||l,d=dS(nh,n),f=d.currentTabStopId===u,h=Qf(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:x}=d;return m.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),c.jsx(Qa.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(Ie.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:pe(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:pe(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:pe(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const y=mS(g,d.orientation,d.dir);if(y!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let C=h().filter(E=>E.focusable).map(E=>E.ref.current);if(y==="last")C.reverse();else if(y==="prev"||y==="next"){y==="prev"&&C.reverse();const E=C.indexOf(g.currentTarget);C=d.loop?gS(C,E+1):C.slice(E+1)}setTimeout(()=>oh(C))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:x!=null}):i})})});rh.displayName=nh;var hS={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function pS(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function mS(e,t,n){const r=pS(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return hS[r]}function oh(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function gS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var xS=th,yS=rh,el=["Enter"," "],vS=["ArrowDown","PageUp","Home"],sh=["ArrowUp","PageDown","End"],bS=[...vS,...sh],wS={ltr:[...el,"ArrowRight"],rtl:[...el,"ArrowLeft"]},SS={ltr:["ArrowLeft"],rtl:["ArrowRight"]},wo="Menu",[So,CS,kS]=Fa(wo),[vr,ih]=Sn(wo,[kS,Js,eh]),Zs=Js(),ah=eh(),[TS,br]=vr(wo),[ES,Co]=vr(wo),lh=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=Zs(t),[l,u]=m.useState(null),d=m.useRef(!1),f=At(s),h=zs(o);return m.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),c.jsx(Yf,{...a,children:c.jsx(TS,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(ES,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};lh.displayName=wo;var IS="MenuAnchor",tl=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Zs(n);return c.jsx(Xf,{...o,...r,ref:t})});tl.displayName=IS;var nl="MenuPortal",[NS,ch]=vr(nl,{forceMount:void 0}),uh=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=br(nl,t);return c.jsx(NS,{scope:t,forceMount:n,children:c.jsx(Gt,{present:n||s.open,children:c.jsx(Ss,{asChild:!0,container:o,children:r})})})};uh.displayName=nl;var nn="MenuContent",[AS,rl]=vr(nn),dh=m.forwardRef((e,t)=>{const n=ch(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=br(nn,e.__scopeMenu),i=Co(nn,e.__scopeMenu);return c.jsx(So.Provider,{scope:e.__scopeMenu,children:c.jsx(Gt,{present:r||s.open,children:c.jsx(So.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(_S,{...o,ref:t}):c.jsx(jS,{...o,ref:t})})})})}),_S=m.forwardRef((e,t)=>{const n=br(nn,e.__scopeMenu),r=m.useRef(null),o=Ve(t,r);return m.useEffect(()=>{const s=r.current;if(s)return Pa(s)},[]),c.jsx(ol,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:pe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),jS=m.forwardRef((e,t)=>{const n=br(nn,e.__scopeMenu);return c.jsx(ol,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),RS=or.createSlot("MenuContent.ScrollLock"),ol=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:v,...x}=e,g=br(nn,n),y=Co(nn,n),b=Zs(n),C=ah(n),E=CS(n),[k,T]=m.useState(null),I=m.useRef(null),_=Ve(t,I,g.onContentChange),R=m.useRef(0),j=m.useRef(""),H=m.useRef(0),F=m.useRef(null),U=m.useRef("right"),D=m.useRef(0),G=v?Ns:m.Fragment,W=v?{as:RS,allowPinchZoom:!0}:void 0,ne=z=>{var K,L;const ie=j.current+z,M=E().filter(Z=>!Z.disabled),Y=document.activeElement,ce=(K=M.find(Z=>Z.ref.current===Y))==null?void 0:K.textValue,be=M.map(Z=>Z.textValue),ge=WS(be,ie,ce),ye=(L=M.find(Z=>Z.textValue===ge))==null?void 0:L.ref.current;(function Z(ee){j.current=ee,window.clearTimeout(R.current),ee!==""&&(R.current=window.setTimeout(()=>Z(""),1e3))})(ie),ye&&setTimeout(()=>ye.focus())};m.useEffect(()=>()=>window.clearTimeout(R.current),[]),Ia();const $=m.useCallback(z=>{var M,Y;return U.current===((M=F.current)==null?void 0:M.side)&&KS(z,(Y=F.current)==null?void 0:Y.area)},[]);return c.jsx(AS,{scope:n,searchRef:j,onItemEnter:m.useCallback(z=>{$(z)&&z.preventDefault()},[$]),onItemLeave:m.useCallback(z=>{var ie;$(z)||((ie=I.current)==null||ie.focus(),T(null))},[$]),onTriggerLeave:m.useCallback(z=>{$(z)&&z.preventDefault()},[$]),pointerGraceTimerRef:H,onPointerGraceIntentChange:m.useCallback(z=>{F.current=z},[]),children:c.jsx(G,{...W,children:c.jsx(ws,{asChild:!0,trapped:o,onMountAutoFocus:pe(s,z=>{var ie;z.preventDefault(),(ie=I.current)==null||ie.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(bs,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:c.jsx(xS,{asChild:!0,...C,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:k,onCurrentTabStopIdChange:T,onEntryFocus:pe(l,z=>{y.isUsingKeyboardRef.current||z.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(Jf,{role:"menu","aria-orientation":"vertical","data-state":Nh(g.open),"data-radix-menu-content":"",dir:y.dir,...b,...x,ref:_,style:{outline:"none",...x.style},onKeyDown:pe(x.onKeyDown,z=>{const M=z.target.closest("[data-radix-menu-content]")===z.currentTarget,Y=z.ctrlKey||z.altKey||z.metaKey,ce=z.key.length===1;M&&(z.key==="Tab"&&z.preventDefault(),!Y&&ce&&ne(z.key));const be=I.current;if(z.target!==be||!bS.includes(z.key))return;z.preventDefault();const ye=E().filter(K=>!K.disabled).map(K=>K.ref.current);sh.includes(z.key)&&ye.reverse(),HS(ye)}),onBlur:pe(e.onBlur,z=>{z.currentTarget.contains(z.target)||(window.clearTimeout(R.current),j.current="")}),onPointerMove:pe(e.onPointerMove,To(z=>{const ie=z.target,M=D.current!==z.clientX;if(z.currentTarget.contains(ie)&&M){const Y=z.clientX>D.current?"right":"left";U.current=Y,D.current=z.clientX}}))})})})})})})});dh.displayName=nn;var PS="MenuGroup",sl=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ie.div,{role:"group",...r,ref:t})});sl.displayName=PS;var OS="MenuLabel",fh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ie.div,{...r,ref:t})});fh.displayName=OS;var Qs="MenuItem",hh="menu.itemSelect",ei=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=Co(Qs,e.__scopeMenu),a=rl(Qs,e.__scopeMenu),l=Ve(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(hh,{bubbles:!0,cancelable:!0});f.addEventListener(hh,p=>r==null?void 0:r(p),{once:!0}),qu(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(ph,{...o,ref:l,disabled:n,onClick:pe(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:pe(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:pe(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||el.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});ei.displayName=Qs;var ph=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=rl(Qs,n),a=ah(n),l=m.useRef(null),u=Ve(t,l),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const v=l.current;v&&p((v.textContent??"").trim())},[s.children]),c.jsx(So.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(yS,{asChild:!0,...a,focusable:!r,children:c.jsx(Ie.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:pe(e.onPointerMove,To(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:pe(e.onPointerLeave,To(v=>i.onItemLeave(v))),onFocus:pe(e.onFocus,()=>f(!0)),onBlur:pe(e.onBlur,()=>f(!1))})})})}),MS="MenuCheckboxItem",mh=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(bh,{scope:e.__scopeMenu,checked:n,children:c.jsx(ei,{role:"menuitemcheckbox","aria-checked":ti(n)?"mixed":n,...o,ref:t,"data-state":al(n),onSelect:pe(o.onSelect,()=>r==null?void 0:r(ti(n)?!0:!n),{checkForDefaultPrevented:!1})})})});mh.displayName=MS;var gh="MenuRadioGroup",[DS,LS]=vr(gh,{value:void 0,onValueChange:()=>{}}),xh=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=At(r);return c.jsx(DS,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(sl,{...o,ref:t})})});xh.displayName=gh;var yh="MenuRadioItem",vh=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=LS(yh,e.__scopeMenu),s=n===o.value;return c.jsx(bh,{scope:e.__scopeMenu,checked:s,children:c.jsx(ei,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":al(s),onSelect:pe(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});vh.displayName=yh;var il="MenuItemIndicator",[bh,FS]=vr(il,{checked:!1}),wh=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=FS(il,n);return c.jsx(Gt,{present:r||ti(s.checked)||s.checked===!0,children:c.jsx(Ie.span,{...o,ref:t,"data-state":al(s.checked)})})});wh.displayName=il;var $S="MenuSeparator",Sh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ie.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Sh.displayName=$S;var zS="MenuArrow",Ch=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Zs(n);return c.jsx(Zf,{...o,...r,ref:t})});Ch.displayName=zS;var BS="MenuSub",[kT,kh]=vr(BS),ko="MenuSubTrigger",Th=m.forwardRef((e,t)=>{const n=br(ko,e.__scopeMenu),r=Co(ko,e.__scopeMenu),o=kh(ko,e.__scopeMenu),s=rl(ko,e.__scopeMenu),i=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},d=m.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return m.useEffect(()=>d,[d]),m.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),c.jsx(tl,{asChild:!0,...u,children:c.jsx(ph,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Nh(n.open),...e,ref:ha(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:pe(e.onPointerMove,To(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:pe(e.onPointerLeave,To(f=>{var p,v;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const x=(v=n.content)==null?void 0:v.dataset.side,g=x==="right",y=g?-5:5,b=h[g?"left":"right"],C=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+y,y:f.clientY},{x:b,y:h.top},{x:C,y:h.top},{x:C,y:h.bottom},{x:b,y:h.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:pe(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||wS[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});Th.displayName=ko;var Eh="MenuSubContent",Ih=m.forwardRef((e,t)=>{const n=ch(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=br(nn,e.__scopeMenu),i=Co(nn,e.__scopeMenu),a=kh(Eh,e.__scopeMenu),l=m.useRef(null),u=Ve(t,l);return c.jsx(So.Provider,{scope:e.__scopeMenu,children:c.jsx(Gt,{present:r||s.open,children:c.jsx(So.Slot,{scope:e.__scopeMenu,children:c.jsx(ol,{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=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:pe(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:pe(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:pe(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=SS[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});Ih.displayName=Eh;function Nh(e){return e?"open":"closed"}function ti(e){return e==="indeterminate"}function al(e){return ti(e)?"indeterminate":e?"checked":"unchecked"}function HS(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function US(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function WS(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=US(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function VS(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],l=t[i],u=a.x,d=a.y,f=l.x,h=l.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function KS(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return VS(n,t)}function To(e){return t=>t.pointerType==="mouse"?e(t):void 0}var qS=lh,GS=tl,YS=uh,XS=dh,JS=sl,ZS=fh,QS=ei,eC=mh,tC=xh,nC=vh,rC=wh,oC=Sh,sC=Ch,iC=Th,aC=Ih,ni="DropdownMenu",[lC,TT]=Sn(ni,[ih]),zt=ih(),[cC,Ah]=lC(ni),_h=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=zt(t),u=m.useRef(null),[d,f]=hr({prop:o,defaultProp:s??!1,onChange:i,caller:ni});return c.jsx(cC,{scope:t,triggerId:Cn(),triggerRef:u,contentId:Cn(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(qS,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};_h.displayName=ni;var jh="DropdownMenuTrigger",Rh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Ah(jh,n),i=zt(n);return c.jsx(GS,{asChild:!0,...i,children:c.jsx(Ie.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:ha(t,s.triggerRef),onPointerDown:pe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:pe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Rh.displayName=jh;var uC="DropdownMenuPortal",Ph=e=>{const{__scopeDropdownMenu:t,...n}=e,r=zt(t);return c.jsx(YS,{...r,...n})};Ph.displayName=uC;var Oh="DropdownMenuContent",Mh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ah(Oh,n),s=zt(n),i=m.useRef(!1);return c.jsx(XS,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:pe(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:pe(e.onInteractOutside,a=>{const l=a.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,d=l.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)"}})});Mh.displayName=Oh;var dC="DropdownMenuGroup",fC=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(JS,{...o,...r,ref:t})});fC.displayName=dC;var hC="DropdownMenuLabel",Dh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(ZS,{...o,...r,ref:t})});Dh.displayName=hC;var pC="DropdownMenuItem",Lh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(QS,{...o,...r,ref:t})});Lh.displayName=pC;var mC="DropdownMenuCheckboxItem",Fh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(eC,{...o,...r,ref:t})});Fh.displayName=mC;var gC="DropdownMenuRadioGroup",xC=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(tC,{...o,...r,ref:t})});xC.displayName=gC;var yC="DropdownMenuRadioItem",$h=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(nC,{...o,...r,ref:t})});$h.displayName=yC;var vC="DropdownMenuItemIndicator",zh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(rC,{...o,...r,ref:t})});zh.displayName=vC;var bC="DropdownMenuSeparator",Bh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(oC,{...o,...r,ref:t})});Bh.displayName=bC;var wC="DropdownMenuArrow",SC=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(sC,{...o,...r,ref:t})});SC.displayName=wC;var CC="DropdownMenuSubTrigger",Hh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(iC,{...o,...r,ref:t})});Hh.displayName=CC;var kC="DropdownMenuSubContent",Uh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(aC,{...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)"}})});Uh.displayName=kC;var TC=_h,EC=Rh,IC=Ph,Wh=Mh,Vh=Dh,Kh=Lh,qh=Fh,Gh=$h,Yh=zh,Xh=Bh,Jh=Hh,Zh=Uh;const NC=TC,AC=EC,_C=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(Jh,{ref:o,className:re("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,c.jsx(ue.ChevronRight,{className:"ml-auto h-4 w-4"})]}));_C.displayName=Jh.displayName;const jC=m.forwardRef(({className:e,...t},n)=>c.jsx(Zh,{ref:n,className:re("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}));jC.displayName=Zh.displayName;const Qh=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(IC,{children:c.jsx(Wh,{ref:r,sideOffset:t,className:re("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})}));Qh.displayName=Wh.displayName;const ll=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Kh,{ref:r,className:re("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}));ll.displayName=Kh.displayName;const RC=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(qh,{ref:o,className:re("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:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Yh,{children:c.jsx(ue.Check,{className:"h-4 w-4"})})}),t]}));RC.displayName=qh.displayName;const PC=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Gh,{ref:r,className:re("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:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Yh,{children:c.jsx(ue.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));PC.displayName=Gh.displayName;const OC=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Vh,{ref:r,className:re("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));OC.displayName=Vh.displayName;const MC=m.forwardRef(({className:e,...t},n)=>c.jsx(Xh,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));MC.displayName=Xh.displayName;function DC(e){var t;if(!Array.isArray(e)||!e.length)return null;for(let n=e.length-1;n>=0;n--){const r=((t=e[n])==null?void 0:t.content)??[];for(let o=0;o<r.length;o++){const s=r[o];if(s&&s.type==="text"&&typeof s.text=="string"){const i=s.text.trim();if(i)return i}}}return null}function ri({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:l=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:h,onError:p}){const{api:v}=Ai(),{currentThreadId:x}=Xo(),{threadId:g,messages:y,hasMore:b,isHistoryLoading:C,isLoading:E,loadOlder:k,navigateToCheckpoint:T,returnToLatest:I,checkpoint:_,checkpoints:R,interrupt:j,metadata:H}=Jo(),{isStreaming:F,error:U,submit:D,stop:G}=Kc(),W=g??x??null,ne=(_==null?void 0:_.id)??null,$=(_==null?void 0:_.namespace)??null,z=(H==null?void 0:H.assemblingMessageId)??null,ie=j,[M,Y]=w.useState(!1);w.useEffect(()=>{ie||Y(!1)},[ie]);const ce=w.useCallback(()=>{Y(!0)},[]),be=w.useCallback(()=>{Y(!1)},[]),ge=!!ie||M,[ye,K]=w.useState(null),[L,Z]=w.useState(""),[ee,me]=w.useState(null),[se,ae]=w.useState([]),[He,Je]=w.useState(0),[je,Ue]=w.useState(0),[et,Ze]=w.useState(!1),[Pe,Ct]=w.useState(null),[Tt,Et]=w.useState(null),[st,tt]=w.useState(!1),[ze,ct]=w.useState(null),[bt,X]=w.useState(!1),xe=w.useRef(!1),[de,_e]=w.useState(!1),Fe=w.useCallback((S,P)=>{if(!S||typeof S!="object")return null;const B=S[P];return typeof B=="number"?B:null},[]),nt=w.useCallback((S,P)=>{if(!S||typeof S!="object")return null;const B=S[P];return typeof B=="string"&&B.trim()?B:null},[]),pt=w.useMemo(()=>{const S=Array.isArray(R)?[...R]:[];return S.some(B=>Fe(B.metadata,"step")!==null)&&S.sort((B,oe)=>{const ke=Fe(B.metadata,"step"),$e=Fe(oe.metadata,"step");if(ke!==null||$e!==null)return($e??Number.NEGATIVE_INFINITY)-(ke??Number.NEGATIVE_INFINITY);const Me=Date.parse(B.createdAt??""),Te=Date.parse(oe.createdAt??"");return Number.isNaN(Me)||Number.isNaN(Te)?0:Te-Me}),S},[R,Fe]),Qe=w.useRef(null),ut=w.useRef(null),mt=w.useCallback(()=>{Qe.current&&(Qe.current.value=""),ut.current&&(ut.current.value=""),Je(S=>S+1),Ue(S=>S+1)},[]),$n=w.useRef(!1);w.useEffect(()=>{$n.current&&!F&&(ae([]),mt()),$n.current=F},[F,mt]);const[zn,kr]=w.useState("desktop");w.useEffect(()=>{const S=()=>{const P=window.innerWidth;kr(P<640?"phone":P<1024?"tablet":"desktop")};return S(),window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[]),w.useEffect(()=>{X(!1),xe.current=!1},[W]);const Bn=w.useCallback(async()=>{if(!(!b||C||!bt))try{await k()}catch(S){console.warn("loadOlder failed",S)}},[b,bt,C,k]);w.useEffect(()=>{(async()=>{if(!v.baseUrl){ct(null);return}try{const P=await v.getAgent("default");ct(P.uiDefaultMessage||null)}catch(P){console.warn("Failed to fetch default message:",P),ct(null)}})()},[v]),w.useEffect(()=>{U&&!st&&(p==null||p(U))},[U,st,p]);const Ft=S=>{if(S.length>$s)return`Message too long (${S.length}/${$s} characters)`;try{return Bw(S),null}catch(P){return(P==null?void 0:P.message)||"Invalid message"}},Io=async S=>{const P=S.trim();if(!(!P&&se.length===0)){if(P){const B=Ft(P);if(B){me(B);return}}try{await D({text:P||"",attachments:se,payload:ye?{edit:!0,originalMessageId:ye}:void 0},{checkpointId:ne??void 0,checkpointNs:$??void 0}),f==null||f(P),me(null),ae([]),mt(),K(null),Z("")}catch(B){const oe=(B==null?void 0:B.message)||"Failed to send message";me(oe),p==null||p(oe)}}},Hn=w.useCallback((S,P)=>{u&&(K(S),Z(P),me(null))},[u]),wt=w.useCallback(()=>{K(null),Z(""),me(null)},[]),mn=w.useCallback((S,P)=>{Hn(S,P)},[Hn]),_n=w.useCallback(S=>{const P=B=>{const oe=B.content||[],ke=oe.filter($e=>$e.type==="text").map($e=>$e.text).join("");if(ke)return ke;try{return JSON.stringify(oe,null,2)}catch{return String(oe)}};for(let B=S-1;B>=0;B--)if(y[B].role==="user"){const oe=P(y[B]);oe&&D({text:oe},{checkpointId:ne??void 0,checkpointNs:$??void 0});break}},[y,D,ne,$]),Ur=S=>{const P=Array.from(S.target.files||[]);ae(B=>[...B,...P]),S.target.value=""},sn=S=>{ae(P=>{const B=P.filter((oe,ke)=>S!==ke);return B.length===0&&mt(),B})},rr=async S=>{const P=(S.target.files||[])[0];if(P){Ct(null),Et(null),Ze(!0);try{await D({attachments:[P]},{checkpointId:ne??void 0,checkpointNs:$??void 0});const B=`Uploaded ${P.name} - processing through chat stream`;Et(B)}catch(B){const oe=B instanceof Error?B.message:"Failed to upload Excel file";console.error("Excel upload failed",B),Ct(oe),p==null||p(oe)}finally{Ze(!1),S.target.value="",mt()}}},gn=S=>{if(!S)return"Unknown";const P=Date.parse(S);return Number.isNaN(P)?S:new Date(P).toLocaleString()},jn=async S=>{if(x){_e(!0);try{if(!S){await I();return}const P=pt.find(oe=>oe.checkpointId===S),B=(P==null?void 0:P.checkpointNs)??null;await T(S,B)}finally{_e(!1)}}},Tr=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,No=`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||""}`,Wr=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return c.jsxs("div",{className:Tr,children:[!!U&&!st&&c.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:[c.jsx("span",{children:U}),c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>tt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(ue.X,{size:16})})]}),x&&R.length>0&&c.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:[c.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),c.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:ne??"",onChange:S=>{const P=S.target.value||null;jn(P)},children:[c.jsx("option",{value:"",children:"Latest"}),pt.map(S=>{const P=Fe(S.metadata,"step"),B=nt(S.metadata,"source"),oe=DC(S.messages),ke=[];P!==null&&ke.push(`Step ${P}`),B&&ke.push(B),oe&&ke.push(oe.slice(0,40));const $e=ke.length?` — ${ke.join(" • ")}`:"";return c.jsxs("option",{value:S.checkpointId,children:[gn(S.createdAt),$e]},S.checkpointId)})]})]}),c.jsxs("div",{className:`relative ${No}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(La,{className:"h-full",style:{height:"100%"},messages:y,isStreaming:F,streamingAssistantId:z,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:zn,enableMessageEditing:u,editingMessageId:ye,onStartReached:()=>{bt&&Bn()},onScrollAway:S=>{if(!xe.current){xe.current=!0;return}S&&X(!0)},onEdit:mn,onRegenerate:_n,onCancelEdit:wt,emptyMessage:ze??void 0,isNavigatingCheckpoint:de,activeInterrupt:ie,disableInterruptActions:M,onInterruptActionStart:ce,onInterruptActionEnd:be}),E&&c.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:[c.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]})]}),c.jsxs("div",{className:Wr,children:[ye&&c.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ue.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(qe,{variant:"ghost",size:"sm",onClick:wt,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(ue.X,{size:16})})]})}),(a||l)&&c.jsxs("div",{className:"mb-3 space-y-3",children:[a&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:Qe,type:"file",multiple:!0,onChange:S=>Ur(S),className:"hidden"},He),se.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:se.map((S,P)=>c.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:[c.jsx(ue.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:S.name}),c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>sn(P),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 ${S.name}`,children:c.jsx(ue.X,{size:12})})]},P))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:ut,type:"file",accept:".xls,.xlsx,.xlsm",onChange:rr,className:"hidden"},je),et&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),Tt&&!et&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:Tt}),Pe&&!et&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Pe})]})]}),ee&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:ee}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(NC,{children:[c.jsx(AC,{asChild:!0,children:c.jsx(qe,{type:"button",size:"icon",variant:"outline",disabled:F||ge,title:"More input actions",className:d.moreButton||"",children:c.jsx(ue.Plus,{size:16})})}),c.jsxs(Qh,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(ll,{onClick:()=>{var S;return(S=Qe.current)==null?void 0:S.click()},className:"cursor-pointer",children:[c.jsx(ue.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(ll,{onClick:()=>{var S;et||(S=ut.current)==null||S.click()},className:`cursor-pointer ${et?"opacity-60 pointer-events-none":""}`,children:[c.jsx(ue.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx(ey,{initialValue:L,editingMessageId:ye,placeholder:ye?"Edit your message...":t,isStreaming:F,disabled:ge,maxLength:$s,onSend:Io,onCancelEdit:wt,onStop:G,allowEmptySend:se.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${ye?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${ee?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const oi=m.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:re("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}));oi.displayName="Input";function cl(e,[t,n]){return Math.min(n,Math.max(t,e))}function LC(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var ul="ScrollArea",[ep,ET]=Sn(ul),[FC,rn]=ep(ul),tp=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=m.useState(null),[u,d]=m.useState(null),[f,h]=m.useState(null),[p,v]=m.useState(null),[x,g]=m.useState(null),[y,b]=m.useState(0),[C,E]=m.useState(0),[k,T]=m.useState(!1),[I,_]=m.useState(!1),R=Ve(t,H=>l(H)),j=zs(o);return c.jsx(FC,{scope:n,type:r,dir:j,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:k,onScrollbarXEnabledChange:T,scrollbarY:x,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:_,onCornerWidthChange:b,onCornerHeightChange:E,children:c.jsx(Ie.div,{dir:j,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});tp.displayName=ul;var np="ScrollAreaViewport",rp=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=rn(np,n),a=m.useRef(null),l=Ve(t,a,i.onViewportChange);return c.jsxs(c.Fragment,{children:[c.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}),c.jsx(Ie.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:c.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});rp.displayName=np;var An="ScrollAreaScrollbar",dl=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(An,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return m.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?c.jsx($C,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(zC,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(op,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(fl,{...r,ref:t}):null});dl.displayName=An;var $C=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(An,e.__scopeScrollArea),[s,i]=m.useState(!1);return m.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const u=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),c.jsx(Gt,{present:n||s,children:c.jsx(op,{"data-state":s?"visible":"hidden",...r,ref:t})})}),zC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(An,e.__scopeScrollArea),s=e.orientation==="horizontal",i=li(()=>l("SCROLL_END"),100),[a,l]=LC("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 m.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,l]),m.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const p=u[d];f!==p&&(l("SCROLL"),i()),f=p};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),c.jsx(Gt,{present:n||a!=="hidden",children:c.jsx(fl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:pe(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:pe(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),op=m.forwardRef((e,t)=>{const n=rn(An,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",l=li(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return zr(n.viewport,l),zr(n.content,l),c.jsx(Gt,{present:r||s,children:c.jsx(fl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),fl=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=rn(An,e.__scopeScrollArea),s=m.useRef(null),i=m.useRef(0),[a,l]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=cp(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:u>0&&u<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return KC(h,i.current,a,p)}return n==="horizontal"?c.jsx(BC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=up(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?c.jsx(HC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=up(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),BC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(An,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Ve(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(ip,{"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":ai(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),fp(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:ii(i.paddingLeft),paddingEnd:ii(i.paddingRight)}})}})}),HC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(An,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Ve(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(ip,{"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":ai(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),fp(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:ii(i.paddingTop),paddingEnd:ii(i.paddingBottom)}})}})}),[UC,sp]=ep(An),ip=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,p=rn(An,n),[v,x]=m.useState(null),g=Ve(t,R=>x(R)),y=m.useRef(null),b=m.useRef(""),C=p.viewport,E=r.content-r.viewport,k=At(d),T=At(l),I=li(f,10);function _(R){if(y.current){const j=R.clientX-y.current.left,H=R.clientY-y.current.top;u({x:j,y:H})}}return m.useEffect(()=>{const R=j=>{const H=j.target;(v==null?void 0:v.contains(H))&&k(j,E)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[C,v,E,k]),m.useEffect(T,[r,T]),zr(v,I),zr(p.content,I),c.jsx(UC,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:At(s),onThumbPointerUp:At(i),onThumbPositionChange:T,onThumbPointerDown:At(a),children:c.jsx(Ie.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:pe(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),_(R))}),onPointerMove:pe(e.onPointerMove,_),onPointerUp:pe(e.onPointerUp,R=>{const j=R.target;j.hasPointerCapture(R.pointerId)&&j.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),si="ScrollAreaThumb",ap=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sp(si,e.__scopeScrollArea);return c.jsx(Gt,{present:n||o.hasThumb,children:c.jsx(WC,{ref:t,...r})})}),WC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=rn(si,n),i=sp(si,n),{onThumbPositionChange:a}=i,l=Ve(t,f=>i.onThumbChange(f)),u=m.useRef(void 0),d=li(()=>{u.current&&(u.current(),u.current=void 0)},100);return m.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const p=qC(f,a);u.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),c.jsx(Ie.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:pe(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),v=f.clientX-p.left,x=f.clientY-p.top;i.onThumbPointerDown({x:v,y:x})}),onPointerUp:pe(e.onPointerUp,i.onThumbPointerUp)})});ap.displayName=si;var hl="ScrollAreaCorner",lp=m.forwardRef((e,t)=>{const n=rn(hl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(VC,{...e,ref:t}):null});lp.displayName=hl;var VC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=rn(hl,n),[s,i]=m.useState(0),[a,l]=m.useState(0),u=!!(s&&a);return zr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),zr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?c.jsx(Ie.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 ii(e){return e?parseInt(e,10):0}function cp(e,t){const n=e/t;return isNaN(n)?0:n}function ai(e){const t=cp(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function KC(e,t,n,r="ltr"){const o=ai(n),s=o/2,i=t||s,a=o-i,l=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 dp([l,u],f)(e)}function up(e,t,n="ltr"){const r=ai(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],u=cl(e,l);return dp([0,i],[0,a])(u)}function dp(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 fp(e,t){return e>0&&e<t}var qC=(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 li(e,t){const n=At(e),r=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),m.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function zr(e,t){const n=At(t);kt(()=>{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 hp=tp,GC=rp,YC=lp;const pp=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(hp,{ref:r,className:re("relative overflow-hidden",e),...n,children:[c.jsx(GC,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(mp,{}),c.jsx(YC,{})]}));pp.displayName=hp.displayName;const mp=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(dl,{ref:r,orientation:t,className:re("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:c.jsx(ap,{className:"relative flex-1 rounded-full bg-border"})}));mp.displayName=dl.displayName;function pl({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:u,onThreadDelete:d}){const{threads:f,currentThreadId:h,isLoading:p,actions:v}=Xo(),{loadThread:x}=Jo(),{createThread:g,deleteThread:y,renameThread:b}=v,[C,E]=w.useState(Array.isArray(f)?f:[]),k=w.useRef(C.length>0),[T,I]=w.useState(null),[_,R]=w.useState(""),[j,H]=w.useState(!1);w.useEffect(()=>{const M=Array.isArray(f)?f:[];if(M.length>0){k.current=!0,E(M);return}p||(k.current=!1,E(M))},[f,p]);const F=async M=>{try{await x(M),a==null||a(M),l==null||l(M)}catch(Y){console.error("Failed to select thread:",Y)}},U=async()=>{try{H(!0);const M=await g();u==null||u(M),a==null||a(M)}catch(M){console.error("Failed to create thread:",M)}finally{H(!1)}},D=async(M,Y)=>{if(Y.stopPropagation(),!!confirm("Delete this thread?"))try{await y(M),d==null||d(M)}catch(ce){console.error("Failed to delete thread:",ce)}},G=(M,Y)=>{Y.stopPropagation(),I(M.threadId),R(M.title||`Thread ${M.threadId.slice(0,8)}`)},W=async M=>{if(_.trim())try{await b(M,_.trim()),I(null),R("")}catch(Y){console.error("Failed to update title:",Y)}},ne=()=>{I(null),R("")},$=(M,Y)=>{M.key==="Enter"?W(Y):M.key==="Escape"&&ne()},z=M=>{if(!M)return"";try{const Y=new Date(M),be=new Date().getTime()-Y.getTime(),ge=Math.floor(be/(1e3*60*60*24));return ge===0?Y.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):ge===1?"Yesterday":ge<7?`${ge} days ago`:Y.toLocaleDateString()}catch{return""}},ie=M=>M.title||`Thread ${M.threadId.slice(0,8)}`;return c.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&c.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:c.jsx(qe,{onClick:U,disabled:j||p,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:j?"Creating...":"New Chat",children:c.jsx(ue.MessageSquarePlus,{size:20})})}),c.jsx(pp,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:c.jsx("div",{className:"p-2 space-y-1 pb-4",children:p?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(ue.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):C.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(ue.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),c.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):C.slice().sort((M,Y)=>new Date(Y.updatedAt||Y.createdAt||"").getTime()-new Date(M.updatedAt||M.createdAt||"").getTime()).map(M=>c.jsxs("div",{onClick:()=>F(M.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??h)===M.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:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"flex-1 min-w-0",children:T===M.threadId?c.jsxs("div",{className:"flex items-center gap-2",onClick:Y=>Y.stopPropagation(),children:[c.jsx(oi,{value:_,onChange:Y=>R(Y.target.value),onKeyDown:Y=>$(Y,M.threadId),className:"h-6 text-sm",autoFocus:!0}),c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>W(M.threadId),className:"h-6 w-6 p-0",children:c.jsx(ue.Check,{size:12})}),c.jsx(qe,{variant:"ghost",size:"sm",onClick:ne,className:"h-6 w-6 p-0",children:c.jsx(ue.X,{size:12})})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:ie(M)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(ue.Calendar,{size:10}),c.jsx("span",{children:z(M.updatedAt||M.createdAt)})]})]})}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&T!==M.threadId&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:Y=>G(M,Y),className:"h-6 w-6 p-0",title:"Edit title",children:c.jsx(ue.Edit3,{size:12})}),n&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:Y=>D(M.threadId,Y),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:c.jsx(ue.Trash2,{size:12})})]})]}),i===M.threadId&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},M.threadId))})})]})}function Br(e){if(!(typeof globalThis>"u"))return globalThis[e]}function XC(e){if(typeof e!="string")return;const t=e.trim();if(t)return Mn(t)}function gp(){const e=[Br("__API_BASE_URL__"),Br("__CHAT_API_BASE_URL__"),Br("__CHAT_API_URL__")];for(const t of e){const n=XC(t);if(n)return n}}function xp(){const e=[Br("__API_AUTH_TOKEN__"),Br("__CHAT_API_KEY__"),Br("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function yp(...e){for(const t of e)if(typeof t=="string"&&t.trim())return Mn(t);return Mn()}function vp(){const e={},t=gp(),n=xp();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function bp(){const e=vp(),t=Wn.getAuthToken(),n=gp();return{apiBaseUrl:yp(e.baseUrl,Wn.baseUrl,n),apiKey:t||e.apiKey||xp()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const wp="chat-settings";function JC(){try{const e=localStorage.getItem(wp);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function ZC(e){try{const t={...e,apiBaseUrl:Mn(e.apiBaseUrl)};localStorage.setItem(wp,JSON.stringify(t)),t.apiKey&&Wn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function QC(){const e=bp(),t=JC(),n=Wn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:yp(Wn.baseUrl,r,e.apiBaseUrl)}}function ek(e){Wn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),ZC(e)}var tk="Label",Sp=m.forwardRef((e,t)=>c.jsx(Ie.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())}}));Sp.displayName=tk;var Cp=Sp;const nk=Po.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),on=m.forwardRef(({className:e,...t},n)=>c.jsx(Cp,{ref:n,className:re(nk(),e),...t}));on.displayName=Cp.displayName;function kp(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var ci="Switch",[rk,IT]=Sn(ci),[ok,sk]=rk(ci),Tp=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:u,form:d,...f}=e,[h,p]=m.useState(null),v=Ve(t,C=>p(C)),x=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[y,b]=hr({prop:o,defaultProp:s??!1,onChange:u,caller:ci});return c.jsxs(ok,{scope:n,checked:y,disabled:a,children:[c.jsx(Ie.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":Ap(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:v,onClick:pe(e.onClick,C=>{b(E=>!E),g&&(x.current=C.isPropagationStopped(),x.current||C.stopPropagation())})}),g&&c.jsx(Np,{control:h,bubbles:!x.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Tp.displayName=ci;var Ep="SwitchThumb",Ip=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=sk(Ep,n);return c.jsx(Ie.span,{"data-state":Ap(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Ip.displayName=Ep;var ik="SwitchBubbleInput",Np=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=Ve(i,s),l=kp(n),u=$f(t);return m.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const v=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(v)}},[l,n,r]),c.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}})});Np.displayName=ik;function Ap(e){return e?"checked":"unchecked"}var _p=Tp,ak=Ip;const er=m.forwardRef(({className:e,...t},n)=>c.jsx(_p,{className:re("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:c.jsx(ak,{className:re("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")})}));er.displayName=_p.displayName;var jp=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"}),lk="VisuallyHidden",ck=m.forwardRef((e,t)=>c.jsx(Ie.span,{...e,ref:t,style:{...jp,...e.style}}));ck.displayName=lk;var uk=[" ","Enter","ArrowUp","ArrowDown"],dk=[" ","Enter"],wr="Select",[ui,di,fk]=Fa(wr),[Hr,NT]=Sn(wr,[fk,Js]),fi=Js(),[hk,tr]=Hr(wr),[pk,mk]=Hr(wr),Rp=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:u,name:d,autoComplete:f,disabled:h,required:p,form:v}=e,x=fi(t),[g,y]=m.useState(null),[b,C]=m.useState(null),[E,k]=m.useState(!1),T=zs(u),[I,_]=hr({prop:r,defaultProp:o??!1,onChange:s,caller:wr}),[R,j]=hr({prop:i,defaultProp:a,onChange:l,caller:wr}),H=m.useRef(null),F=g?v||!!g.closest("form"):!0,[U,D]=m.useState(new Set),G=Array.from(U).map(W=>W.props.value).join(";");return c.jsx(Yf,{...x,children:c.jsxs(hk,{required:p,scope:t,trigger:g,onTriggerChange:y,valueNode:b,onValueNodeChange:C,valueNodeHasChildren:E,onValueNodeHasChildrenChange:k,contentId:Cn(),value:R,onValueChange:j,open:I,onOpenChange:_,dir:T,triggerPointerDownPosRef:H,disabled:h,children:[c.jsx(ui.Provider,{scope:t,children:c.jsx(pk,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(W=>{D(ne=>new Set(ne).add(W))},[]),onNativeOptionRemove:m.useCallback(W=>{D(ne=>{const $=new Set(ne);return $.delete(W),$})},[]),children:n})}),F?c.jsxs(nm,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:R,onChange:W=>j(W.target.value),disabled:h,form:v,children:[R===void 0?c.jsx("option",{value:""}):null,Array.from(U)]},G):null]})})};Rp.displayName=wr;var Pp="SelectTrigger",Op=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=fi(n),i=tr(Pp,n),a=i.disabled||r,l=Ve(t,i.onTriggerChange),u=di(n),d=m.useRef("touch"),[f,h,p]=om(x=>{const g=u().filter(C=>!C.disabled),y=g.find(C=>C.value===i.value),b=sm(g,x,y);b!==void 0&&i.onValueChange(b.value)}),v=x=>{a||(i.onOpenChange(!0),p()),x&&(i.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return c.jsx(Xf,{asChild:!0,...s,children:c.jsx(Ie.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":rm(i.value)?"":void 0,...o,ref:l,onClick:pe(o.onClick,x=>{x.currentTarget.focus(),d.current!=="mouse"&&v(x)}),onPointerDown:pe(o.onPointerDown,x=>{d.current=x.pointerType;const g=x.target;g.hasPointerCapture(x.pointerId)&&g.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(v(x),x.preventDefault())}),onKeyDown:pe(o.onKeyDown,x=>{const g=f.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&h(x.key),!(g&&x.key===" ")&&uk.includes(x.key)&&(v(),x.preventDefault())})})})});Op.displayName=Pp;var Mp="SelectValue",Dp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=tr(Mp,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=Ve(t,l.onValueNodeChange);return kt(()=>{u(d)},[u,d]),c.jsx(Ie.span,{...a,ref:f,style:{pointerEvents:"none"},children:rm(l.value)?c.jsx(c.Fragment,{children:i}):s})});Dp.displayName=Mp;var gk="SelectIcon",Lp=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(Ie.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Lp.displayName=gk;var xk="SelectPortal",Fp=e=>c.jsx(Ss,{asChild:!0,...e});Fp.displayName=xk;var Sr="SelectContent",$p=m.forwardRef((e,t)=>{const n=tr(Sr,e.__scopeSelect),[r,o]=m.useState();if(kt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Oo.createPortal(c.jsx(zp,{scope:e.__scopeSelect,children:c.jsx(ui.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(Bp,{...e,ref:t})});$p.displayName=Sr;var pn=10,[zp,nr]=Hr(Sr),yk="SelectContentImpl",vk=or.createSlot("SelectContent.RemoveScroll"),Bp=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:x,avoidCollisions:g,...y}=e,b=tr(Sr,n),[C,E]=m.useState(null),[k,T]=m.useState(null),I=Ve(t,K=>E(K)),[_,R]=m.useState(null),[j,H]=m.useState(null),F=di(n),[U,D]=m.useState(!1),G=m.useRef(!1);m.useEffect(()=>{if(C)return Pa(C)},[C]),Ia();const W=m.useCallback(K=>{const[L,...Z]=F().map(se=>se.ref.current),[ee]=Z.slice(-1),me=document.activeElement;for(const se of K)if(se===me||(se==null||se.scrollIntoView({block:"nearest"}),se===L&&k&&(k.scrollTop=0),se===ee&&k&&(k.scrollTop=k.scrollHeight),se==null||se.focus(),document.activeElement!==me))return},[F,k]),ne=m.useCallback(()=>W([_,C]),[W,_,C]);m.useEffect(()=>{U&&ne()},[U,ne]);const{onOpenChange:$,triggerPointerDownPosRef:z}=b;m.useEffect(()=>{if(C){let K={x:0,y:0};const L=ee=>{var me,se;K={x:Math.abs(Math.round(ee.pageX)-(((me=z.current)==null?void 0:me.x)??0)),y:Math.abs(Math.round(ee.pageY)-(((se=z.current)==null?void 0:se.y)??0))}},Z=ee=>{K.x<=10&&K.y<=10?ee.preventDefault():C.contains(ee.target)||$(!1),document.removeEventListener("pointermove",L),z.current=null};return z.current!==null&&(document.addEventListener("pointermove",L),document.addEventListener("pointerup",Z,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",Z,{capture:!0})}}},[C,$,z]),m.useEffect(()=>{const K=()=>$(!1);return window.addEventListener("blur",K),window.addEventListener("resize",K),()=>{window.removeEventListener("blur",K),window.removeEventListener("resize",K)}},[$]);const[ie,M]=om(K=>{const L=F().filter(me=>!me.disabled),Z=L.find(me=>me.ref.current===document.activeElement),ee=sm(L,K,Z);ee&&setTimeout(()=>ee.ref.current.focus())}),Y=m.useCallback((K,L,Z)=>{const ee=!G.current&&!Z;(b.value!==void 0&&b.value===L||ee)&&(R(K),ee&&(G.current=!0))},[b.value]),ce=m.useCallback(()=>C==null?void 0:C.focus(),[C]),be=m.useCallback((K,L,Z)=>{const ee=!G.current&&!Z;(b.value!==void 0&&b.value===L||ee)&&H(K)},[b.value]),ge=r==="popper"?ml:Hp,ye=ge===ml?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:x,avoidCollisions:g}:{};return c.jsx(zp,{scope:n,content:C,viewport:k,onViewportChange:T,itemRefCallback:Y,selectedItem:_,onItemLeave:ce,itemTextRefCallback:be,focusSelectedItem:ne,selectedItemText:j,position:r,isPositioned:U,searchRef:ie,children:c.jsx(Ns,{as:vk,allowPinchZoom:!0,children:c.jsx(ws,{asChild:!0,trapped:b.open,onMountAutoFocus:K=>{K.preventDefault()},onUnmountAutoFocus:pe(o,K=>{var L;(L=b.trigger)==null||L.focus({preventScroll:!0}),K.preventDefault()}),children:c.jsx(bs,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:K=>K.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:c.jsx(ge,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:K=>K.preventDefault(),...y,...ye,onPlaced:()=>D(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:pe(y.onKeyDown,K=>{const L=K.ctrlKey||K.altKey||K.metaKey;if(K.key==="Tab"&&K.preventDefault(),!L&&K.key.length===1&&M(K.key),["ArrowUp","ArrowDown","Home","End"].includes(K.key)){let ee=F().filter(me=>!me.disabled).map(me=>me.ref.current);if(["ArrowUp","End"].includes(K.key)&&(ee=ee.slice().reverse()),["ArrowUp","ArrowDown"].includes(K.key)){const me=K.target,se=ee.indexOf(me);ee=ee.slice(se+1)}setTimeout(()=>W(ee)),K.preventDefault()}})})})})})})});Bp.displayName=yk;var bk="SelectItemAlignedPosition",Hp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=tr(Sr,n),i=nr(Sr,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=Ve(t,I=>d(I)),h=di(n),p=m.useRef(!1),v=m.useRef(!0),{viewport:x,selectedItem:g,selectedItemText:y,focusSelectedItem:b}=i,C=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&x&&g&&y){const I=s.trigger.getBoundingClientRect(),_=u.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),j=y.getBoundingClientRect();if(s.dir!=="rtl"){const me=j.left-_.left,se=R.left-me,ae=I.left-se,He=I.width+ae,Je=Math.max(He,_.width),je=window.innerWidth-pn,Ue=cl(se,[pn,Math.max(pn,je-Je)]);a.style.minWidth=He+"px",a.style.left=Ue+"px"}else{const me=_.right-j.right,se=window.innerWidth-R.right-me,ae=window.innerWidth-I.right-se,He=I.width+ae,Je=Math.max(He,_.width),je=window.innerWidth-pn,Ue=cl(se,[pn,Math.max(pn,je-Je)]);a.style.minWidth=He+"px",a.style.right=Ue+"px"}const H=h(),F=window.innerHeight-pn*2,U=x.scrollHeight,D=window.getComputedStyle(u),G=parseInt(D.borderTopWidth,10),W=parseInt(D.paddingTop,10),ne=parseInt(D.borderBottomWidth,10),$=parseInt(D.paddingBottom,10),z=G+W+U+$+ne,ie=Math.min(g.offsetHeight*5,z),M=window.getComputedStyle(x),Y=parseInt(M.paddingTop,10),ce=parseInt(M.paddingBottom,10),be=I.top+I.height/2-pn,ge=F-be,ye=g.offsetHeight/2,K=g.offsetTop+ye,L=G+W+K,Z=z-L;if(L<=be){const me=H.length>0&&g===H[H.length-1].ref.current;a.style.bottom="0px";const se=u.clientHeight-x.offsetTop-x.offsetHeight,ae=Math.max(ge,ye+(me?ce:0)+se+ne),He=L+ae;a.style.height=He+"px"}else{const me=H.length>0&&g===H[0].ref.current;a.style.top="0px";const ae=Math.max(be,G+x.offsetTop+(me?Y:0)+ye)+Z;a.style.height=ae+"px",x.scrollTop=L-be+x.offsetTop}a.style.margin=`${pn}px 0`,a.style.minHeight=ie+"px",a.style.maxHeight=F+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,x,g,y,s.dir,r]);kt(()=>C(),[C]);const[E,k]=m.useState();kt(()=>{u&&k(window.getComputedStyle(u).zIndex)},[u]);const T=m.useCallback(I=>{I&&v.current===!0&&(C(),b==null||b(),v.current=!1)},[C,b]);return c.jsx(Sk,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:T,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:c.jsx(Ie.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Hp.displayName=bk;var wk="SelectPopperPosition",ml=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=pn,...s}=e,i=fi(n);return c.jsx(Jf,{...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)"}})});ml.displayName=wk;var[Sk,gl]=Hr(Sr,{}),xl="SelectViewport",Up=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=nr(xl,n),i=gl(xl,n),a=Ve(t,s.onViewportChange),l=m.useRef(0);return c.jsxs(c.Fragment,{children:[c.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}),c.jsx(ui.Slot,{scope:n,children:c.jsx(Ie.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:pe(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const v=window.innerHeight-pn*2,x=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),y=Math.max(x,g);if(y<v){const b=y+p,C=Math.min(v,b),E=b-C;f.style.height=C+"px",f.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Up.displayName=xl;var Wp="SelectGroup",[Ck,kk]=Hr(Wp),Tk=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Cn();return c.jsx(Ck,{scope:n,id:o,children:c.jsx(Ie.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Tk.displayName=Wp;var Vp="SelectLabel",Kp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=kk(Vp,n);return c.jsx(Ie.div,{id:o.id,...r,ref:t})});Kp.displayName=Vp;var hi="SelectItem",[Ek,qp]=Hr(hi),Gp=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=tr(hi,n),l=nr(hi,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),v=Ve(t,b=>{var C;return(C=l.itemRefCallback)==null?void 0:C.call(l,b,r,o)}),x=Cn(),g=m.useRef("touch"),y=()=>{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 c.jsx(Ek,{scope:n,value:r,disabled:o,textId:x,isSelected:u,onItemTextChange:m.useCallback(b=>{f(C=>C||((b==null?void 0:b.textContent)??"").trim())},[]),children:c.jsx(ui.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(Ie.div,{role:"option","aria-labelledby":x,"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:v,onFocus:pe(i.onFocus,()=>p(!0)),onBlur:pe(i.onBlur,()=>p(!1)),onClick:pe(i.onClick,()=>{g.current!=="mouse"&&y()}),onPointerUp:pe(i.onPointerUp,()=>{g.current==="mouse"&&y()}),onPointerDown:pe(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:pe(i.onPointerMove,b=>{var C;g.current=b.pointerType,o?(C=l.onItemLeave)==null||C.call(l):g.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:pe(i.onPointerLeave,b=>{var C;b.currentTarget===document.activeElement&&((C=l.onItemLeave)==null||C.call(l))}),onKeyDown:pe(i.onKeyDown,b=>{var E;((E=l.searchRef)==null?void 0:E.current)!==""&&b.key===" "||(dk.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});Gp.displayName=hi;var Eo="SelectItemText",Yp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=tr(Eo,n),a=nr(Eo,n),l=qp(Eo,n),u=mk(Eo,n),[d,f]=m.useState(null),h=Ve(t,y=>f(y),l.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,y,l.value,l.disabled)}),p=d==null?void 0:d.textContent,v=m.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:x,onNativeOptionRemove:g}=u;return kt(()=>(x(v),()=>g(v)),[x,g,v]),c.jsxs(c.Fragment,{children:[c.jsx(Ie.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Oo.createPortal(s.children,i.valueNode):null]})});Yp.displayName=Eo;var Xp="SelectItemIndicator",Jp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return qp(Xp,n).isSelected?c.jsx(Ie.span,{"aria-hidden":!0,...r,ref:t}):null});Jp.displayName=Xp;var yl="SelectScrollUpButton",Zp=m.forwardRef((e,t)=>{const n=nr(yl,e.__scopeSelect),r=gl(yl,e.__scopeSelect),[o,s]=m.useState(!1),i=Ve(t,r.onScrollButtonChange);return kt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollTop>0;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(em,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Zp.displayName=yl;var vl="SelectScrollDownButton",Qp=m.forwardRef((e,t)=>{const n=nr(vl,e.__scopeSelect),r=gl(vl,e.__scopeSelect),[o,s]=m.useState(!1),i=Ve(t,r.onScrollButtonChange);return kt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<u;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(em,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Qp.displayName=vl;var em=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=nr("SelectScrollButton",n),i=m.useRef(null),a=di(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),kt(()=>{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]),c.jsx(Ie.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:pe(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:pe(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:pe(o.onPointerLeave,()=>{l()})})}),Ik="SelectSeparator",tm=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(Ie.div,{"aria-hidden":!0,...r,ref:t})});tm.displayName=Ik;var bl="SelectArrow",Nk=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=fi(n),s=tr(bl,n),i=nr(bl,n);return s.open&&i.position==="popper"?c.jsx(Zf,{...o,...r,ref:t}):null});Nk.displayName=bl;var Ak="SelectBubbleInput",nm=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=Ve(r,o),i=kp(t);return m.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(Ie.select,{...n,style:{...jp,...n.style},ref:s,defaultValue:t})});nm.displayName=Ak;function rm(e){return e===""||e===void 0}function om(e){const t=At(e),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(i=>{const a=n.current+i;t(a),function l(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function sm(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=_k(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function _k(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var jk=Rp,im=Op,Rk=Dp,Pk=Lp,Ok=Fp,am=$p,Mk=Up,lm=Kp,cm=Gp,Dk=Yp,Lk=Jp,um=Zp,dm=Qp,fm=tm;const hm=jk,pm=Rk,wl=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(im,{ref:r,className:re("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,c.jsx(Pk,{asChild:!0,children:c.jsx(ue.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));wl.displayName=im.displayName;const mm=m.forwardRef(({className:e,...t},n)=>c.jsx(um,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ue.ChevronUp,{className:"h-4 w-4"})}));mm.displayName=um.displayName;const gm=m.forwardRef(({className:e,...t},n)=>c.jsx(dm,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ue.ChevronDown,{className:"h-4 w-4"})}));gm.displayName=dm.displayName;const Sl=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(Ok,{children:c.jsxs(am,{ref:o,className:re("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:[c.jsx(mm,{}),c.jsx(Mk,{className:re("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(gm,{})]})}));Sl.displayName=am.displayName;const Fk=m.forwardRef(({className:e,...t},n)=>c.jsx(lm,{ref:n,className:re("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Fk.displayName=lm.displayName;const Cr=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(cm,{ref:r,className:re("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:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Lk,{children:c.jsx(ue.Check,{className:"h-4 w-4"})})}),c.jsx(Dk,{children:t})]}));Cr.displayName=cm.displayName;const $k=m.forwardRef(({className:e,...t},n)=>c.jsx(fm,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));$k.displayName=fm.displayName;var zk="Separator",xm="horizontal",Bk=["horizontal","vertical"],ym=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=xm,...o}=e,s=Hk(r)?r:xm,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(Ie.div,{"data-orientation":s,...a,...o,ref:t})});ym.displayName=zk;function Hk(e){return Bk.includes(e)}var vm=ym;const bm=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(vm,{ref:o,decorative:n,orientation:t,className:re("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));bm.displayName=vm.displayName;const Uk=nf,Wk=Sw,Vk=rf,wm=m.forwardRef(({className:e,...t},n)=>c.jsx(Ps,{className:re("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}));wm.displayName=Ps.displayName;const Kk=Po.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"}}),Sm=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(Vk,{children:[c.jsx(wm,{}),c.jsxs(Os,{ref:o,className:re(Kk({side:e}),t),...r,children:[n,c.jsxs(of,{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:[c.jsx(ue.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Sm.displayName=Os.displayName;const Cm=({className:e,...t})=>c.jsx("div",{className:re("flex flex-col space-y-2 text-center sm:text-left",e),...t});Cm.displayName="SheetHeader";const km=m.forwardRef(({className:e,...t},n)=>c.jsx(gr,{ref:n,className:re("text-lg font-semibold text-foreground",e),...t}));km.displayName=gr.displayName;const Tm=m.forwardRef(({className:e,...t},n)=>c.jsx(Ms,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));Tm.displayName=Ms.displayName;const qk={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 Gk({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=w.useState(!1),[s,i]=w.useState(!1),[a,l]=w.useState(e),[u,d]=w.useState(!1),{toast:f}=Sa();w.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),w.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(qk),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},v=()=>{l(e),d(!1),o(!1)},x=async()=>{try{const y=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${y.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return c.jsxs(Uk,{open:r,onOpenChange:o,children:[c.jsx(Wk,{asChild:!0,children:c.jsxs(qe,{variant:"outline",size:"sm",className:n,children:[c.jsx(ue.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(fa,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(Sm,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(Cm,{children:[c.jsx(km,{children:"Chat Settings"}),c.jsx(Tm,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),c.jsxs("div",{className:"space-y-6 py-6",children:[c.jsxs(uo,{children:[c.jsx(fo,{className:"pb-3",children:c.jsxs(ho,{className:"text-lg flex items-center gap-2",children:[c.jsx(ue.Server,{className:"h-5 w-5"}),"API Configuration"]})}),c.jsxs(po,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(on,{htmlFor:"api-url",children:"API Base URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(oi,{id:"api-url",value:a.api.baseUrl,onChange:g=>l(y=>({...y,api:{...y.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(qe,{variant:"outline",onClick:x,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(on,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(er,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>l(y=>({...y,api:{...y.api,enableAuth:g}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(on,{htmlFor:"auth-token",children:"Authentication Token"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(oi,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>l(y=>({...y,api:{...y.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(qe,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(ue.EyeOff,{className:"h-4 w-4"}):c.jsx(ue.Eye,{className:"h-4 w-4"})})]})]})]})]}),c.jsxs(uo,{children:[c.jsx(fo,{className:"pb-3",children:c.jsxs(ho,{className:"text-lg flex items-center gap-2",children:[c.jsx(ue.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),c.jsxs(po,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(on,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(hm,{value:a.ui.layout,onValueChange:g=>l(y=>({...y,ui:{...y.ui,layout:g}})),children:[c.jsx(wl,{children:c.jsx(pm,{})}),c.jsxs(Sl,{children:[c.jsx(Cr,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(Cr,{value:"fullscreen",children:"Fullscreen"}),c.jsx(Cr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(on,{htmlFor:"theme",children:"Theme"}),c.jsxs(hm,{value:a.ui.theme,onValueChange:g=>l(y=>({...y,ui:{...y.ui,theme:g}})),children:[c.jsx(wl,{children:c.jsx(pm,{})}),c.jsxs(Sl,{children:[c.jsx(Cr,{value:"light",children:"Light"}),c.jsx(Cr,{value:"dark",children:"Dark"}),c.jsx(Cr,{value:"system",children:"System"})]})]})]}),c.jsx(bm,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(on,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(er,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,showTimestamps:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(on,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(er,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,showAgentNames:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(on,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(er,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,compactMessages:g}}))})]})]})]})]}),c.jsxs(uo,{children:[c.jsx(fo,{className:"pb-3",children:c.jsxs(ho,{className:"text-lg flex items-center gap-2",children:[c.jsx(ue.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),c.jsxs(po,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(on,{htmlFor:"auto-save",children:"Auto-save Conversations"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),c.jsx(er,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>l(y=>({...y,behavior:{...y.behavior,autoSave:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(on,{htmlFor:"enable-streaming",children:"Enable Streaming"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),c.jsx(er,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>l(y=>({...y,behavior:{...y.behavior,enableStreaming:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(on,{htmlFor:"typing-indicator",children:"Typing Indicator"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),c.jsx(er,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>l(y=>({...y,behavior:{...y.behavior,showTypingIndicator:g}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(qe,{variant:"outline",onClick:p,children:[c.jsx(ue.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(qe,{variant:"outline",onClick:v,children:"Cancel"}),c.jsxs(qe,{onClick:h,disabled:!u,children:[c.jsx(ue.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function Yk({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"}),l=w.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?c.jsx(Zo,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsx(ri,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?c.jsx(Zo,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&c.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(pl,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(ri,{onError:s.onError,enableFileUpload:!0})})]})})}):c.jsx(Zo,{...s,onThreadChange:l,children:c.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&c.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(pl,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(ri,{onError:s.onError,enableFileUpload:!0})})]})})}Ne.ChatApi=Sc,Ne.ChatInterface=ri,Ne.ChatProviders=Zo,Ne.ChatSettings=Gk,Ne.MarkdownContent=va,Ne.MessageComponent=pf,Ne.MessageList=La,Ne.ThreadManager=pl,Ne.applySettings=ek,Ne.chatApiClient=Wn,Ne.default=Yk,Ne.del=wc,Ne.get=ln,Ne.getChatToken=xc,Ne.getCurrentSettings=QC,Ne.getDefaultApiConfig=vp,Ne.getDefaultChatSettings=bp,Ne.onChatTokenChanged=yc,Ne.post=vc,Ne.put=bc,Ne.setChatToken=Ni,Ne.useApi=Ai,Ne.useChatStream=Lc,Ne.useMessagesReducer=Ac,Ne.useStream=Kc,Ne.useThreadState=Jo,Ne.useThreads=Xo,Object.defineProperties(Ne,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});