teodor-new-chat-ui 4.3.43 → 4.3.45

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,Am,jm,pi){"use strict";var JT=Object.defineProperty;var ZT=(Ne,w,ue)=>w in Ne?JT(Ne,w,{enumerable:!0,configurable:!0,writable:!0,value:ue}):Ne[w]=ue;var Im=(Ne,w,ue)=>ZT(Ne,typeof w!="symbol"?w+"":w,ue);function El(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=El(w),Oo=El(pi);var mi={exports:{}},Vr={};/**
1
+ (function(Ie,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):(Ie=typeof globalThis<"u"?globalThis:Ie||self,w(Ie.NewChatUI={},Ie.React,Ie.LucideReact,Ie.reactSlot,Ie.classVarianceAuthority,Ie.clsx,Ie.tailwindMerge,Ie.ReactDOM))})(this,function(Ie,w,me,or,Ro,Tm,Em,pi){"use strict";var Gk=Object.defineProperty;var Yk=(Ie,w,me)=>w in Ie?Gk(Ie,w,{enumerable:!0,configurable:!0,writable:!0,value:me}):Ie[w]=me;var Cm=(Ie,w,me)=>Yk(Ie,typeof w!="symbol"?w+"":w,me);function kl(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=kl(w),Po=kl(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 Il;function _m(){if(Il)return Vr;Il=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 Tl;function Im(){if(Tl)return Vr;Tl=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 Nl;function Rm(){return Nl||(Nl=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,j=!1,R;R=Symbol.for("react.module.reference");function _(S){return!!(typeof S=="string"||typeof S=="function"||S===r||S===s||j||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(jt){oe=jt}Reflect.construct(S,[],Me)}else{try{Me.call()}catch(jt){oe=jt}S.call(Me.prototype)}}else{try{throw Error()}catch(jt){oe=jt}S()}}catch(jt){if(jt&&oe&&typeof jt.stack=="string"){for(var ke=jt.stack.split(`
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 _e=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(_e);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(_e.call(S,"ref")){var P=Object.getOwnPropertyDescriptor(S,"ref").get;if(P&&P.isReactWarning)return!1}return S.ref!==void 0}function je(S){if(_e.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),je(P)&&(ze(P.key),ke=""+P.key),de(P)&&(It=P.ref,Fe(P,Te));for($e in P)_e.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`
17
+ */var El;function Am(){return El||(El=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 R=v&&S[v]||S[x];return typeof R=="function"?R:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(S){{for(var R=arguments.length,B=new Array(R>1?R-1:0),ae=1;ae<R;ae++)B[ae-1]=arguments[ae];C("error",S,B)}}function C(S,R,B){{var ae=y.ReactDebugCurrentFrame,ke=ae.getStackAddendum();ke!==""&&(R+="%s",B=B.concat([ke]));var Ae=B.map(function(De){return String(De)});Ae.unshift("Warning: "+R),Function.prototype.apply.call(console[S],console,Ae)}}var E=!1,k=!1,T=!1,I=!1,_=!1,P;P=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===P||S.getModuleId!==void 0))}function H(S,R,B){var ae=S.displayName;if(ae)return ae;var ke=R.displayName||R.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 R=S;return F(R)+".Consumer";case i:var B=S;return F(B._context)+".Provider";case l:return H(S,S.render,"ForwardRef");case f:var ae=S.displayName||null;return ae!==null?ae:U(S.type)||"Memo";case h:{var ke=S,Ae=ke._payload,De=ke._init;try{return U(De(Ae))}catch{return null}}}return null}var D=Object.assign,G=0,W,ne,$,z,se,M,Y;function ce(){}ce.__reactDisabledLog=!0;function be(){{if(G===0){W=console.log,ne=console.info,$=console.warn,z=console.error,se=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:se}),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,R,B){{if(K===void 0)try{throw Error()}catch(ke){var ae=ke.stack.trim().match(/\n( *(at )?)/);K=ae&&ae[1]||""}return`
18
+ `+K+S}}var Z=!1,ee;{var pe=typeof WeakMap=="function"?WeakMap:Map;ee=new pe}function oe(S,R){if(!S||Z)return"";{var B=ee.get(S);if(B!==void 0)return B}var ae;Z=!0;var ke=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Ae;Ae=ye.current,ye.current=null,be();try{if(R){var De=function(){throw Error()};if(Object.defineProperty(De.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(De,[])}catch($t){ae=$t}Reflect.construct(S,[],De)}else{try{De.call()}catch($t){ae=$t}S.call(De.prototype)}}else{try{throw Error()}catch($t){ae=$t}S()}}catch($t){if($t&&ae&&typeof $t.stack=="string"){for(var Oe=$t.stack.split(`
19
+ `),It=ae.stack.split(`
20
+ `),dt=Oe.length-1,ht=It.length-1;dt>=1&&ht>=0&&Oe[dt]!==It[ht];)ht--;for(;dt>=1&&ht>=0;dt--,ht--)if(Oe[dt]!==It[ht]){if(dt!==1||ht!==1)do if(dt--,ht--,ht<0||Oe[dt]!==It[ht]){var At=`
21
+ `+Oe[dt].replace(" at new "," at ");return S.displayName&&At.includes("<anonymous>")&&(At=At.replace("<anonymous>",S.displayName)),typeof S=="function"&&ee.set(S,At),At}while(dt>=1&&ht>=0);break}}}finally{Z=!1,ye.current=Ae,ge(),Error.prepareStackTrace=ke}var zn=S?S.displayName||S.name:"",Bn=zn?L(zn):"";return typeof S=="function"&&ee.set(S,Bn),Bn}function ie(S,R,B){return oe(S,!1)}function Be(S){var R=S.prototype;return!!(R&&R.isReactComponent)}function Je(S,R,B){if(S==null)return"";if(typeof S=="function")return oe(S,Be(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 ie(S.render);case f:return Je(S.type,R,B);case h:{var ae=S,ke=ae._payload,Ae=ae._init;try{return Je(Ae(ke),R,B)}catch{}}}return""}var je=Object.prototype.hasOwnProperty,He={},Qe=y.ReactDebugCurrentFrame;function Ze(S){if(S){var R=S._owner,B=Je(S.type,S._source,R?R.type:null);Qe.setExtraStackFrame(B)}else Qe.setExtraStackFrame(null)}function Pe(S,R,B,ae,ke){{var Ae=Function.call.bind(je);for(var De in S)if(Ae(S,De)){var Oe=void 0;try{if(typeof S[De]!="function"){var It=Error((ae||"React class")+": "+B+" type `"+De+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof S[De]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw It.name="Invariant Violation",It}Oe=S[De](R,De,ae,B,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(dt){Oe=dt}Oe&&!(Oe 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).",ae||"React class",B,De,typeof Oe),Ze(null)),Oe instanceof Error&&!(Oe.message in He)&&(He[Oe.message]=!0,Ze(ke),b("Failed %s type: %s",B,Oe.message),Ze(null))}}}var wt=Array.isArray;function Ct(S){return wt(S)}function kt(S){{var R=typeof Symbol=="function"&&Symbol.toStringTag,B=R&&S[Symbol.toStringTag]||S.constructor.name||"Object";return B}}function ot(S){try{return et(S),!1}catch{return!0}}function et(S){return""+S}function $e(S){if(ot(S))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",kt(S)),et(S)}var ct=y.ReactCurrentOwner,vt={key:!0,ref:!0,__self:!0,__source:!0},J,xe;function ue(S){if(je.call(S,"ref")){var R=Object.getOwnPropertyDescriptor(S,"ref").get;if(R&&R.isReactWarning)return!1}return S.ref!==void 0}function _e(S){if(je.call(S,"key")){var R=Object.getOwnPropertyDescriptor(S,"key").get;if(R&&R.isReactWarning)return!1}return S.key!==void 0}function Ve(S,R){typeof S.ref=="string"&&ct.current}function at(S,R){{var B=function(){J||(J=!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)",R))};B.isReactWarning=!0,Object.defineProperty(S,"key",{get:B,configurable:!0})}}function Tt(S,R){{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)",R))};B.isReactWarning=!0,Object.defineProperty(S,"ref",{get:B,configurable:!0})}}var rt=function(S,R,B,ae,ke,Ae,De){var Oe={$$typeof:t,type:S,key:R,ref:B,props:De,_owner:Ae};return Oe._store={},Object.defineProperty(Oe._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Oe,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ae}),Object.defineProperty(Oe,"_source",{configurable:!1,enumerable:!1,writable:!1,value:ke}),Object.freeze&&(Object.freeze(Oe.props),Object.freeze(Oe)),Oe};function ut(S,R,B,ae,ke){{var Ae,De={},Oe=null,It=null;B!==void 0&&($e(B),Oe=""+B),_e(R)&&($e(R.key),Oe=""+R.key),ue(R)&&(It=R.ref,Ve(R,ke));for(Ae in R)je.call(R,Ae)&&!vt.hasOwnProperty(Ae)&&(De[Ae]=R[Ae]);if(S&&S.defaultProps){var dt=S.defaultProps;for(Ae in dt)De[Ae]===void 0&&(De[Ae]=dt[Ae])}if(Oe||It){var ht=typeof S=="function"?S.displayName||S.name||"Unknown":S;Oe&&at(De,ht),It&&Tt(De,ht)}return rt(S,Oe,It,ke,ae,ct.current,De)}}var pt=y.ReactCurrentOwner,$n=y.ReactDebugCurrentFrame;function sn(S){if(S){var R=S._owner,B=Je(S.type,S._source,R?R.type:null);$n.setExtraStackFrame(B)}else $n.setExtraStackFrame(null)}var jt;jt=!1;function Cr(S){return typeof S=="object"&&S!==null&&S.$$typeof===t}function tr(){{if(pt.current){var S=U(pt.current.type);if(S)return`
22
22
 
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=`
23
+ Check the render method of \``+S+"`."}return""}}function Et(S){return""}var an={};function gn(S){{var R=tr();if(!R){var B=typeof S=="string"?S:S.displayName||S.name;B&&(R=`
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 jn(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=_(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++)jn(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 jn(Bt,S)}if(_e.call(P,"key")){var Jt=U(S),jt=Object.keys(P).filter(function(Cl){return Cl!=="key"}),Ao=jt.length>0?"{key: someKey, "+jt.join(": ..., ")+": ...}":"{key: someKey}";if(!rr[Jt+Ao]){var Sl=jt.length>0?"{"+jt.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+B+">.")}return R}}function kr(S,R){{if(!S._store||S._store.validated||S.key!=null)return;S._store.validated=!0;var B=gn(R);if(an[B])return;an[B]=!0;var ae="";S&&S._owner&&S._owner!==pt.current&&(ae=" It was passed a child from "+U(S._owner.type)+"."),sn(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,ae),sn(null)}}function Jt(S,R){{if(typeof S!="object")return;if(Ct(S))for(var B=0;B<S.length;B++){var ae=S[B];Cr(ae)&&kr(ae,R)}else if(Cr(S))S._store&&(S._store.validated=!0);else if(S){var ke=g(S);if(typeof ke=="function"&&ke!==S.entries)for(var Ae=ke.call(S),De;!(De=Ae.next()).done;)Cr(De.value)&&kr(De.value,R)}}}function Tr(S){{var R=S.type;if(R==null||typeof R=="string")return;var B;if(typeof R=="function")B=R.propTypes;else if(typeof R=="object"&&(R.$$typeof===l||R.$$typeof===f))B=R.propTypes;else return;if(B){var ae=U(R);Pe(B,S.props,"prop",ae,S)}else if(R.PropTypes!==void 0&&!jt){jt=!0;var ke=U(R);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ke||"Unknown")}typeof R.getDefaultProps=="function"&&!R.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function jn(S){{for(var R=Object.keys(S.props),B=0;B<R.length;B++){var ae=R[B];if(ae!=="children"&&ae!=="key"){sn(S),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ae),sn(null);break}}S.ref!==null&&(sn(S),b("Invalid attribute `ref` supplied to `React.Fragment`."),sn(null))}}var xn={};function nr(S,R,B,ae,ke,Ae){{var De=j(S);if(!De){var Oe="";(S===void 0||typeof S=="object"&&S!==null&&Object.keys(S).length===0)&&(Oe+=" 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=Et();It?Oe+=It:Oe+=tr();var dt;S===null?dt="null":Ct(S)?dt="array":S!==void 0&&S.$$typeof===t?(dt="<"+(U(S.type)||"Unknown")+" />",Oe=" 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,Oe)}var ht=ut(S,R,B,ke,Ae);if(ht==null)return ht;if(De){var At=R.children;if(At!==void 0)if(ae)if(Ct(At)){for(var zn=0;zn<At.length;zn++)Jt(At[zn],S);Object.freeze&&Object.freeze(At)}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 Jt(At,S)}if(je.call(R,"key")){var Bn=U(S),$t=Object.keys(R).filter(function(N){return N!=="key"}),Ao=$t.length>0?"{key: someKey, "+$t.join(": ..., ")+": ...}":"{key: someKey}";if(!xn[Bn+Ao]){var A=$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,Sl,Jt),rr[Jt+Ao]=!0}}return S===r?sn(ht):Ur(ht),ht}}function _n(S,P,B){return gn(S,P,B,!0)}function kr(S,P,B){return gn(S,P,B,!1)}var No=kr,Wr=_n;Kr.Fragment=r,Kr.jsx=No,Kr.jsxs=Wr}()),Kr}process.env.NODE_ENV==="production"?mi.exports=_m():mi.exports=Rm();var c=mi.exports;function Al(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 _l=an("ArrayBuffer");function Om(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&_l(e.buffer),t}const Mm=Lo("string"),Ht=Lo("function"),Rl=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 Pl(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,Ol=e=>!Ir(e)&&e!==sr;function xi(){const{caseless:e,skipUndefined:t}=Ol(this)&&this||{},n={},r=(o,s)=>{const i=e&&Pl(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]=Al(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(!Rl(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}),Ml=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),ag=an("RegExp"),Dl=(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=>{Dl(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),Ll=((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||Ll,O={isArray:Er,isArrayBuffer:_l,isBuffer:qr,isFormData:Um,isArrayBufferView:Om,isString:Mm,isNumber:Rl,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:Ml,hasOwnProp:Ml,reduceDescriptors:Dl,freezeMethods:lg,toObjectSet:cg,toCamelCase:ig,noop:ug,toFiniteNumber:dg,findKey:Pl,global:sr,isContextDefined:Ol,isSpecCompliantForm:fg,toJSONObject:hg,isAsyncFn:pg,isThenable:mg,setImmediate:Ll,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 Fl=Re.prototype,$l={};["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=>{$l[e]={value:e}}),Object.defineProperties(Re,$l),Object.defineProperty(Fl,"isAxiosError",{value:!0}),Re.from=(e,t,n,r,o,s)=>{const i=Object.create(Fl);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 zl(e){return O.endsWith(e,"[]")?e.slice(0,-2):e}function Bl(e,t,n){return e?e.concat(t).map(function(o,s){return o=zl(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=zl(x),y.forEach(function(C,E){!(O.isUndefined(C)||C===null)&&t.append(i===!0?Bl([x],E,s):i===null?x:x+"[]",u(C))}),!1}return yi(v)?!0:(t.append(Bl(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 Hl(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 Ul=vi.prototype;Ul.append=function(t,n){this._pairs.push([t,n])},Ul.toString=function(t){const n=t?function(r){return t.call(this,r,Hl)}:Hl;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 Wl(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 Vl{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 Kl={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",Tg=bi&&window.location.href||"http://localhost",Ot={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:bi,hasStandardBrowserEnv:Sg,hasStandardBrowserWebWorkerEnv:Cg,navigator:wi,origin:Tg},Symbol.toStringTag,{value:"Module"})),...wg};function kg(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 ql(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:Kl,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(ql(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 kg(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"]),jg=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},Gl=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 _g(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(jg(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 _g(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[Gl]=this[Gl]={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 Yl(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 Xl(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)},Jl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Zl=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 Ql(e,t,n){let r=!zg(t);return e&&(r||n==!1)?Bg(e,t):t}const ec=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(ec(u),ec(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 tc=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=Wl(Ql(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=tc(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};Xl(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||Kl;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=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()}},nc=(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})},rc=64*1024,{isFunction:Ho}=O,qg=(({Request:e,Response:t})=>({Request:e,Response:t}))(O.global),{ReadableStream:oc,TextEncoder:sc}=O.global,ic=(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(oc),l=o&&(typeof sc=="function"?(v=>x=>v.encode(x))(new sc):async v=>new Uint8Array(await new n(v).arrayBuffer())),u=s&&a&&ic(()=>{let v=!1;const x=new n(Ot.origin,{body:new oc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!x}),d=i&&a&&ic(()=>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:j,withCredentials:R="same-origin",fetchOptions:_}=tc(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(k&&u&&g!=="get"&&g!=="head"&&(G=await p(j,y))!==0){let M=new n(x,{method:"POST",body:y,duplex:"half"}),Y;if(O.isFormData(y)&&(Y=M.headers.get("content-type"))&&j.setContentType(Y),M.body){const[ce,be]=Jl(G,Bo(Zl(k)));y=nc(M.body,rc,ce,be)}}O.isString(R)||(R=R?"include":"omit");const W=s&&"credentials"in n.prototype,ne={..._,signal:F,method:g.toUpperCase(),headers:j.normalize().toJSON(),body:y,duplex:"half",credentials:W?R:void 0};U=s&&new n(x,ne);let $=await(s?H(U,_):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&&Jl(Y,Bo(Zl(T),!0))||[];$=new r(nc($.body,rc,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)=>{Xl(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,ac=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};ac();const Ti={http:xg,xhr:Hg,fetch:{get:ac}};O.forEach(Ti,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const lc=e=>`- ${e}`,Xg=e=>O.isFunction(e)||e===null||e===!1,cc={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=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 :
33
- `+i.map(lc).join(`
34
- `):" "+lc(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 uc(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),cc.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 Yl(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 dc="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 fc={};Uo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+dc+"] 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&&!fc[i]&&(fc[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 Vl,response:new Vl}}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=[uc.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=uc.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=Ql(t.baseURL,t.url,t.allowAbsoluteUrls);return Wl(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 hc(e){const t=new ar(e),n=Al(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 hc(ir(e,o))},n}const gt=hc(Xr);gt.Axios=ar,gt.CanceledError=Nr,gt.CancelToken=Zg,gt.isCancel=Yl,gt.VERSION=dc,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=>ql(O.isHTMLForm(e)?new FormData(e):e),gt.getAdapter=cc.getAdapter,gt.HttpStatusCode=Ei,gt.default=gt;const{Axios:sk,AxiosError:ik,CanceledError:ak,isCancel:lk,CancelToken:ck,VERSION:uk,all:dk,Cancel:fk,isAxiosError:hk,spread:pk,toFormData:mk,AxiosHeaders:gk,HttpStatusCode:xk,formToJSON:yk,getAdapter:vk,mergeConfig:bk}=gt,pc=typeof window<"u"?window.__API_BASE_URL__:void 0,mc=pc?Mn(pc):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 gc(){return Vo}function Ni(e){Vo=e,Ii.forEach(t=>t(e))}function xc(e){return Ii.add(e),()=>Ii.delete(e)}const Zt=gt.create({...mc?{baseURL:mc}:{},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 yc(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 vc(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 bc(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 wc{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 gc()}setAuthToken(t){Ni(t)}onTokenChange(t){return xc(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 yc("/threads",t?{title:t}:void 0);return yn(r)}async updateThread(t,n){const r=await vc(`/threads/${t}`,{title:n});return yn(r)}async deleteThread(t){const n=await bc(`/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 wc,Sc=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(Sc.Provider,{value:r,children:e})}function Ai(){const e=w.useContext(Sc);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 ji(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 Cc(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(!ji(r))return{threadId:n,latest:null,checkpoints:[],interrupt:null,snapshots:{}};const{orderedSnapshots:o,snapshotMap:s}=ix(t),i=Tc(r,0);return{threadId:n,latest:i,checkpoints:o,interrupt:(i==null?void 0:i.interrupt)??null,snapshots:s}}function Tc(e,t){if(!ji(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,_)=>px(R,_)).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"]),j=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: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:j??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(!ji(o))return;const i=Tc(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=kc(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 kc(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=kc(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:_i(((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=_i(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=_i(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":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 jc(e,t){var n,r,o,s;if(t.type==="message_start"&&t.role==="assistant"){const i=t.id,a=jx(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}=Nx(u.content,t.delta,f,h);if(!x)return e;const g={...u,content:p},y=_c(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?Ex(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=Ax(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"){const i=Tx(t.pendingInterrupt,e.pendingInterrupt),a=i===null?Rc(e.messages):e.messages;return{...e,messages:a,pendingInterrupt:i}}return e}function _i(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 _c(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 Tx(e,t){if(e==null)return null;if(typeof e=="object"){const r=e,o=typeof r.id=="string"?r.id.trim():null,s=o&&o.length?o:(t==null?void 0:t.id)??"pending-interrupt",i=Object.prototype.hasOwnProperty.call(r,"value")?r.value:r;return{id:s,value:i}}return{id:(t==null?void 0:t.id)??"pending-interrupt",value: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 Ex(e,t,n){return kx(e,t,r=>({...r,content:Ix(r.content,n)}))}function Ix(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 Nx(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 Ax(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 _c(e,r,s)}return e}function jx(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),T=w.useRef(0),k=w.useCallback(_=>{o(_)},[]),I=w.useCallback(()=>{var _;(_=C.current)==null||_.abort(),C.current=null,l(!1),b(!1),T.current=0,g(0)},[]),j=w.useCallback(()=>{h(""),v(null),d(null)},[]),R=w.useCallback((_,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(_));const be=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...ce,...s.current},body:JSON.stringify(_),signal:U.signal,credentials:i});if(!be.ok||!be.body){const _e=await be.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",be.status,_e==null?void 0:_e.slice(0,500)),new Error(`stream ${be.status}${_e?": "+_e:""}`)}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 _e=L.join("");L=[],E.current&&h(Ue=>Ue+_e)}ee=null},se=()=>{typeof window<"u"&&ee==null&&(ee=requestAnimationFrame(me))};let ae=Date.now();const He=setInterval(()=>{var _e;if(Date.now()-ae>6e4){const Ue="Stream idle timeout";d(Ue),U.abort(),(_e=F==null?void 0:F.onError)==null||_e.call(F,Ue)}},5e3),Je=1024*1024;try{const _e=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=_e??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(`
30
+ <%s key={someKey} {...props} />`,Ao,Bn,A,Bn),xn[Bn+Ao]=!0}}return S===r?jn(ht):Tr(ht),ht}}function Io(S,R,B){return nr(S,R,B,!0)}function Ur(S,R,B){return nr(S,R,B,!1)}var Wr=Ur,rr=Io;Kr.Fragment=r,Kr.jsx=Wr,Kr.jsxs=rr}()),Kr}process.env.NODE_ENV==="production"?mi.exports=Im():mi.exports=Am();var c=mi.exports;function Il(e,t){return function(){return e.apply(t,arguments)}}const{toString:Nm}=Object.prototype,{getPrototypeOf:gi}=Object,{iterator:Oo,toStringTag:Al}=Symbol,Mo=(e=>t=>{const n=Nm.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),ln=e=>(e=e.toLowerCase(),t=>Mo(t)===e),Do=e=>t=>typeof t===e,{isArray:Er}=Array,Ir=Do("undefined");function qr(e){return e!==null&&!Ir(e)&&e.constructor!==null&&!Ir(e.constructor)&&Ht(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Nl=ln("ArrayBuffer");function _m(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Nl(e.buffer),t}const jm=Do("string"),Ht=Do("function"),_l=Do("number"),Gr=e=>e!==null&&typeof e=="object",Rm=e=>e===!0||e===!1,Lo=e=>{if(Mo(e)!=="object")return!1;const t=gi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Al in e)&&!(Oo in e)},Pm=e=>{if(!Gr(e)||qr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Om=ln("Date"),Mm=ln("File"),Dm=ln("Blob"),Lm=ln("FileList"),Fm=e=>Gr(e)&&Ht(e.pipe),$m=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ht(e.append)&&((t=Mo(e))==="formdata"||t==="object"&&Ht(e.toString)&&e.toString()==="[object FormData]"))},zm=ln("URLSearchParams"),[Bm,Hm,Um,Wm]=["ReadableStream","Request","Response","Headers"].map(ln),Vm=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 jl(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,Rl=e=>!Ir(e)&&e!==sr;function xi(){const{caseless:e,skipUndefined:t}=Rl(this)&&this||{},n={},r=(o,s)=>{const i=e&&jl(n,s)||s;Lo(n[i])&&Lo(o)?n[i]=xi(n[i],o):Lo(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 Km=(e,t,n,{allOwnKeys:r}={})=>(Yr(t,(o,s)=>{n&&Ht(o)?e[s]=Il(o,n):e[s]=o},{allOwnKeys:r}),e),qm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Gm=(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)},Ym=(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},Xm=(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},Jm=e=>{if(!e)return null;if(Er(e))return e;let t=e.length;if(!_l(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Zm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&gi(Uint8Array)),Qm=(e,t)=>{const r=(e&&e[Oo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},eg=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},tg=ln("HTMLFormElement"),ng=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Pl=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),rg=ln("RegExp"),Ol=(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)},og=e=>{Ol(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+"'")})}})},sg=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return Er(e)?r(e):r(String(e).split(t)),n},ig=()=>{},ag=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function lg(e){return!!(e&&Ht(e.append)&&e[Al]==="FormData"&&e[Oo])}const cg=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)},ug=ln("AsyncFunction"),dg=e=>e&&(Gr(e)||Ht(e))&&Ht(e.then)&&Ht(e.catch),Ml=((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)),fg=typeof queueMicrotask<"u"?queueMicrotask.bind(sr):typeof process<"u"&&process.nextTick||Ml,O={isArray:Er,isArrayBuffer:Nl,isBuffer:qr,isFormData:$m,isArrayBufferView:_m,isString:jm,isNumber:_l,isBoolean:Rm,isObject:Gr,isPlainObject:Lo,isEmptyObject:Pm,isReadableStream:Bm,isRequest:Hm,isResponse:Um,isHeaders:Wm,isUndefined:Ir,isDate:Om,isFile:Mm,isBlob:Dm,isRegExp:rg,isFunction:Ht,isStream:Fm,isURLSearchParams:zm,isTypedArray:Zm,isFileList:Lm,forEach:Yr,merge:xi,extend:Km,trim:Vm,stripBOM:qm,inherits:Gm,toFlatObject:Ym,kindOf:Mo,kindOfTest:ln,endsWith:Xm,toArray:Jm,forEachEntry:Qm,matchAll:eg,isHTMLForm:tg,hasOwnProperty:Pl,hasOwnProp:Pl,reduceDescriptors:Ol,freezeMethods:og,toObjectSet:sg,toCamelCase:ng,noop:ig,toFiniteNumber:ag,findKey:jl,global:sr,isContextDefined:Rl,isSpecCompliantForm:lg,toJSONObject:cg,isAsyncFn:ug,isThenable:dg,setImmediate:Ml,asap:fg,isIterable:e=>e!=null&&Ht(e[Oo])};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 Dl=Re.prototype,Ll={};["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=>{Ll[e]={value:e}}),Object.defineProperties(Re,Ll),Object.defineProperty(Dl,"isAxiosError",{value:!0}),Re.from=(e,t,n,r,o,s)=>{const i=Object.create(Dl);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 hg=null;function yi(e){return O.isPlainObject(e)||O.isArray(e)}function Fl(e){return O.endsWith(e,"[]")?e.slice(0,-2):e}function $l(e,t,n){return e?e.concat(t).map(function(o,s){return o=Fl(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function pg(e){return O.isArray(e)&&!e.some(yi)}const mg=O.toFlatObject(O,{},null,function(t){return/^is[A-Z]/.test(t)});function Fo(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)&&pg(v)||(O.isFileList(v)||O.endsWith(x,"[]"))&&(y=O.toArray(v)))return x=Fl(x),y.forEach(function(C,E){!(O.isUndefined(C)||C===null)&&t.append(i===!0?$l([x],E,s):i===null?x:x+"[]",u(C))}),!1}return yi(v)?!0:(t.append($l(g,x,s),u(v)),!1)}const f=[],h=Object.assign(mg,{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 zl(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&&Fo(e,this,t)}const Bl=vi.prototype;Bl.append=function(t,n){this._pairs.push([t,n])},Bl.toString=function(t){const n=t?function(r){return t.call(this,r,zl)}:zl;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function gg(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Hl(e,t,n){if(!t)return e;const r=n&&n.encode||gg;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 Ul{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 Wl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},xg={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,yg=bi&&(!wi||["ReactNative","NativeScript","NS"].indexOf(wi.product)<0),vg=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",bg=bi&&window.location.href||"http://localhost",Mt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:bi,hasStandardBrowserEnv:yg,hasStandardBrowserWebWorkerEnv:vg,navigator:wi,origin:bg},Symbol.toStringTag,{value:"Module"})),...xg};function wg(e,t){return Fo(e,new Mt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Mt.isNode&&O.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Sg(e){return O.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Cg(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 Vl(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]=Cg(o[i])),!a)}if(O.isFormData(e)&&O.isFunction(e.entries)){const n={};return O.forEachEntry(e,(r,o)=>{t(Sg(r),o,n,0)}),n}return null}function kg(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:Wl,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(Vl(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 wg(t,this.formSerializer).toString();if((a=O.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Fo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),kg(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:Mt.classes.FormData,Blob:Mt.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 Tg=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"]),Eg=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]&&Tg[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Kl=Symbol("internals");function Jr(e){return e&&String(e).trim().toLowerCase()}function $o(e){return e===!1||e==null?e:O.isArray(e)?e.map($o):String(e)}function Ig(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 Ag=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 Ng(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function _g(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]=$o(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())&&!Ag(t))i(Eg(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 Ig(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]=$o(o),delete n[s];return}const a=t?Ng(s):String(s).trim();a!==s&&delete n[s],n[a]=$o(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[Kl]=this[Kl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Jr(i);r[a]||(_g(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 ql(e){return!!(e&&e.__CANCEL__)}function Ar(e,t,n){Re.call(this,e??"canceled",Re.ERR_CANCELED,t,n),this.name="CanceledError"}O.inherits(Ar,Re,{__CANCEL__:!0});function Gl(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 jg(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Rg(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 Pg(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 zo=(e,t,n=3)=>{let r=0;const o=Rg(50,250);return Pg(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)},Yl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Xl=e=>(...t)=>O.asap(()=>e(...t)),Og=Mt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Mt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Mt.origin),Mt.navigator&&/(msie|trident)/i.test(Mt.navigator.userAgent)):()=>!0,Mg=Mt.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 Dg(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Lg(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Jl(e,t,n){let r=!Dg(t);return e&&(r||n==!1)?Lg(e,t):t}const Zl=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(Zl(u),Zl(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 Ql=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=Hl(Jl(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(Mt.hasStandardBrowserEnv||Mt.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(Mt.hasStandardBrowserEnv&&(r&&O.isFunction(r)&&(r=r(t)),r||r!==!1&&Og(t.url))){const l=o&&s&&Mg.read(s);l&&i.set(o,l)}return t},Fg=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Ql(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};Gl(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||Wl;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]=zo(u,!0),g.addEventListener("progress",h)),l&&g.upload&&([f,p]=zo(l),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=C=>{g&&(r(!C||C.type?new Ar(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=jg(o.url);if(b&&Mt.protocols.indexOf(b)===-1){r(new Re("Unsupported protocol "+b+":",Re.ERR_BAD_REQUEST,e));return}g.send(s||null)})},$g=(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 Ar(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}},zg=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},Bg=async function*(e,t){for await(const n of Hg(e))yield*zg(n,t)},Hg=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()}},ec=(e,t,n,r)=>{const o=Bg(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})},tc=64*1024,{isFunction:Bo}=O,Ug=(({Request:e,Response:t})=>({Request:e,Response:t}))(O.global),{ReadableStream:nc,TextEncoder:rc}=O.global,oc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Wg=e=>{e=O.merge.call({skipUndefined:!0},Ug,e);const{fetch:t,Request:n,Response:r}=e,o=t?Bo(t):typeof fetch=="function",s=Bo(n),i=Bo(r);if(!o)return!1;const a=o&&Bo(nc),l=o&&(typeof rc=="function"?(v=>x=>v.encode(x))(new rc):async v=>new Uint8Array(await new n(v).arrayBuffer())),u=s&&a&&oc(()=>{let v=!1;const x=new n(Mt.origin,{body:new nc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!x}),d=i&&a&&oc(()=>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(Mt.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:P="same-origin",fetchOptions:j}=Ql(v),H=t||fetch;I=I?(I+"").toLowerCase():"text";let F=$g([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]=Yl(G,zo(Xl(T)));y=ec(M.body,tc,ce,be)}}O.isString(P)||(P=P?"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?P: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&&Yl(Y,zo(Xl(k),!0))||[];$=new r(ec($.body,tc,ce,()=>{be&&be(),D&&D()}),M)}I=I||"text";let se=await f[O.findKey(f,I)||"text"]($,v);return!z&&D&&D(),await new Promise((M,Y)=>{Gl(M,Y,{data:se,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)}}},Vg=new Map,sc=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=Vg;for(;a--;)l=s[a],u=d.get(l),u===void 0&&d.set(l,u=a?new Map:Wg(t)),d=u;return u};sc();const ki={http:hg,xhr:Fg,fetch:{get:sc}};O.forEach(ki,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const ic=e=>`- ${e}`,Kg=e=>O.isFunction(e)||e===null||e===!1,ac={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,!Kg(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
+ `+i.map(ic).join(`
34
+ `):" "+ic(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 Ar(null,e)}function lc(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),ac.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 ql(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 cc="1.12.2",Ho={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ho[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const uc={};Ho.transitional=function(t,n,r){function o(s,i){return"[Axios v"+cc+"] 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&&!uc[i]&&(uc[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}},Ho.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 Uo={assertOptions:qg,validators:Ho},yn=Uo.validators;let ar=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Ul,response:new Ul}}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&&Uo.assertOptions(r,{silentJSONParsing:yn.transitional(yn.boolean),forcedJSONParsing:yn.transitional(yn.boolean),clarifyTimeoutError:yn.transitional(yn.boolean)},!1),o!=null&&(O.isFunction(o)?n.paramsSerializer={serialize:o}:Uo.assertOptions(o,{encode:yn.function,serialize:yn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Uo.assertOptions(n,{baseUrl:yn.spelling("baseURL"),withXsrfToken:yn.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=[lc.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=lc.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=Jl(t.baseURL,t.url,t.allowAbsoluteUrls);return Hl(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 Gg=class km{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 Ar(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 km(function(o){t=o}),cancel:t}}};function Yg(e){return function(n){return e.apply(null,n)}}function Xg(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 dc(e){const t=new ar(e),n=Il(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 dc(ir(e,o))},n}const mt=dc(Xr);mt.Axios=ar,mt.CanceledError=Ar,mt.CancelToken=Gg,mt.isCancel=ql,mt.VERSION=cc,mt.toFormData=Fo,mt.AxiosError=Re,mt.Cancel=mt.CanceledError,mt.all=function(t){return Promise.all(t)},mt.spread=Yg,mt.isAxiosError=Xg,mt.mergeConfig=ir,mt.AxiosHeaders=Ut,mt.formToJSON=e=>Vl(O.isHTMLForm(e)?new FormData(e):e),mt.getAdapter=ac.getAdapter,mt.HttpStatusCode=Ei,mt.default=mt;const{Axios:nT,AxiosError:rT,CanceledError:oT,isCancel:sT,CancelToken:iT,VERSION:aT,all:lT,Cancel:cT,isAxiosError:uT,spread:dT,toFormData:fT,AxiosHeaders:hT,HttpStatusCode:pT,formToJSON:mT,getAdapter:gT,mergeConfig:xT}=mt,fc=typeof window<"u"?window.__API_BASE_URL__:void 0,hc=fc?Mn(fc):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 Wo=null;const Ii=new Set;function pc(){return Wo}function Ai(e){Wo=e,Ii.forEach(t=>t(e))}function mc(e){return Ii.add(e),()=>Ii.delete(e)}const Zt=mt.create({...hc?{baseURL:hc}:{},timeout:3e4,withCredentials:!0});Zt.interceptors.request.use(e=>(Wo&&(e.headers.Authorization=`Bearer ${Wo}`),e)),Zt.interceptors.response.use(e=>e,e=>Promise.reject(e));async function cn(e,t){return Zt.defaults.baseURL?(await Zt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function gc(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 xc(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 yc(e,t){return Zt.defaults.baseURL?(await Zt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function vn(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class vc{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&&Ai(t.authToken)}getAuthToken(){return pc()}setAuthToken(t){Ai(t)}onTokenChange(t){return mc(t)}async listThreads(){const t=await cn("/threads"),n=vn(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await gc("/threads",t?{title:t}:void 0);return vn(r)}async updateThread(t,n){const r=await xc(`/threads/${t}`,{title:n});return vn(r)}async deleteThread(t){const n=await yc(`/threads/${t}`);return vn(n)}async threadInfo(t){const n=await cn(`/threads/${t}/info`);return vn(n)}async listAgents(){const t=await cn("/agents"),n=vn(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await cn(`/agents/${t}`);return vn(n)}async getAgentSchema(t){const n=await cn(`/agents/${t}/schema`);return vn(n)}async getState(t){const n=await cn(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return vn(n)}async getStateHistory(t){const n=await cn(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return vn(n)}}const Hn=new vc,bc=w.createContext(null);function Jg({children:e,apiConfig:t}){const n=Hn;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(bc.Provider,{value:r,children:e})}function Ni(){const e=w.useContext(bc);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function Zg(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 Qg(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const u=await Zg(l);a.push({filename:l.name,data:u,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const ex={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}=nx(t),i=wc(r,0);return{threadId:n,latest:i,checkpoints:o,interrupt:(i==null?void 0:i.interrupt)??null,snapshots:s}}function wc(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(P=>!!P&&typeof P=="object").map(P=>({...P})):a===null?null:void 0,u=r.map((P,j)=>ux(P,j)).filter(P=>!!P),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:tx(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 tx(e,t,n){const r=lx(e,n);return r||ax(t,n)}function nx(e){const t=new Map;e.forEach((o,s)=>{if(!_i(o))return;const i=wc(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,rx(l,i))});const n=Array.from(t.values());n.sort((o,s)=>Cc(s.createdAt??"")-Cc(o.createdAt??""));const r={};for(const[o,s]of t.entries())r[o]=s;return{orderedSnapshots:n,snapshotMap:r}}function rx(e,t){const n=Vo(e.metadata,t.metadata),r=Vo(e.config,t.config),o=Vo(e.parentConfig,t.parentConfig),s=sx(e.next,t.next),i=ix(e.tasks,t.tasks),a=ox(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 Vo(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 ox(e,t){return Vo(e,t)}function sx(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 ix(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 ax(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 lx(e,t){if(!Array.isArray(e)||!e.length)return null;for(let n=e.length-1;n>=0;n--){const r=cx(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 cx(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=Sc(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 Sc(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=Sc(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 Cc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function ux(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=ex[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=dx(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=gx(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=fx((u==null?void 0:u.tool_calls)??o.tool_calls);if(b.length&&(x.content=[...x.content,...b]),i==="tool"){const C=px(o,x.content);C&&(x.content=C)}return x}function dx(e){if(!e)return[];if(Array.isArray(e))return e.map(t=>kc(t)).filter(t=>!!t);if(typeof e=="string")return e.trim()?[{type:"text",text:e.trim()}]:[];if(typeof e=="object"){const t=kc(e);return t?[t]:[]}return[]}function kc(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 hx(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 fx(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=Tc(a);return{type:"tool_call",id:o??`tool_call_${n}`,name:i,args:l}}).filter(t=>!!t):[]}function hx(e){const t=ft(e,["id","call_id"]),n=ft(e,["name"]);if(!t||!n)return null;const r=Tc(e.args??e.arguments);return{type:"tool_call",id:t,name:n,args:r}}function px(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"?mx(r):r,s={type:"tool_end",toolCallId:n,output:o};return typeof e.error=="string"&&(s.error=e.error),[s]}function Tc(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 mx(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 gx(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 xx(e){return e.type!=="thread_info"&&e.type!=="token"}const yx={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,messagesStreamMeta:{},pendingInterrupt:null};function vx(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 Ic(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Ic(o,s),e):e}case"interrupt_response":return{...e,messages:Nc(e.messages),pendingInterrupt:null};default:return e}}function Ec(e=[]){const[t,n]=w.useReducer(vx,{...yx,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 Ic(e,t){var n,r,o,s;if(t.type==="message_start"&&t.role==="assistant"){const i=t.id,a=Tx(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??_c(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:jc(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}=Cx(u.content,t.delta,f,h);if(!x)return e;const g={...u,content:p},y=Ac(a,l,g),b={...d,[i]:v};return{...e,messages:y,messagesStreamMeta:b}}if(t.type==="message_end"){const i=e.assemblingId??_c(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?wx(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=kx(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?Nc(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 Ac(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Nc(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 _c(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function bx(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 wx(e,t,n){return bx(e,t,r=>({...r,content:Sx(r.content,n)}))}function Sx(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=Pc(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 jc(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function Cx(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??jc(e);let l="",u=e.slice();if(s){const f=Pc(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 Rc(e){return e.replace(/\s+/g," ").trim()}function Pc(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=Rc(e),o=Rc(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 kx(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 Ac(e,r,s)}return e}function Tx(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Oc(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)},[]),P=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,se,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 He=window.__AUTH_TOKEN__,Qe=((G=window.localStorage)==null?void 0:G.getItem("authToken"))||null;let Ze=null;try{const wt=(W=window.localStorage)==null?void 0:W.getItem("chat-settings");wt&&(Ze=((ne=JSON.parse(wt))==null?void 0:ne.apiKey)||null)}catch{}const Pe=He||Qe||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 pe=()=>{if(L.length){const je=L.join("");L=[],E.current&&h(He=>He+je)}ee=null},oe=()=>{typeof window<"u"&&ee==null&&(ee=requestAnimationFrame(pe))};let ie=Date.now();const Be=setInterval(()=>{var je;if(Date.now()-ie>6e4){const He="Stream idle timeout";d(He),U.abort(),(je=F==null?void 0:F.onError)==null||je.call(F,He)}},5e3),Je=1024*1024;try{const je=be.headers.get("X-Thread-Id")||be.headers.get("x-thread-id"),He=be.headers.get("X-Thread-Created")||be.headers.get("x-thread-created"),Qe=je??null,Ze=String(He??"").toLowerCase()==="true";for(($=F==null?void 0:F.onOpen)==null||$.call(F,{threadId:Qe,created:Ze});;){const{value:Pe,done:wt}=await ge.read();if(wt)break;K+=ye.decode(Pe,{stream:!0}),K.length>Je&&(K="",console.warn("Stream buffer reset: exceeded 1MB"));let Ct;for(;(Ct=K.indexOf(`
36
36
 
37
- `))>=0;){const Et=K.slice(0,kt);K=K.slice(kt+2);const st=Rx(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,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(_e){if(_e.name!=="AbortError"){const Ue=_e.message||String(_e);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 _;E.current=!1,(_=C.current)==null||_.abort()},[]),{isStreaming:a,error:u,assistantText:f,lastCheckpointId:p,lastSeq:x,connected:y,stream:R,stop:I,clear:j,setToken:k}}function _x(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function Rx(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 Px({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 Ri(e){return e==null?e:{...e}}function Ox(e){return e==null?e:{...e}}function Mx(e){if(Array.isArray(e))return e.slice();if(e==null)return e}function Dx(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=Ri(e==null?void 0:e.metadata),s=Ri(e==null?void 0:e.config),i=Ri(e==null?void 0:e.parentConfig),a=Mx(e==null?void 0:e.next),l=Dx(e==null?void 0:e.tasks),u=Ox(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 Lx(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 Pi(e){if(!lr())return null;try{return window.localStorage.getItem(e)}catch{return null}}function Oi(e,t){if(!lr())return!1;try{return window.localStorage.setItem(e,t),!0}catch{return!1}}function Mi(e){if(lr())try{window.localStorage.removeItem(e)}catch{}}const Fx="cachedThreads",$x="v1",Di=200;function zx(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 Li(e,t){return`cachedThreads:v1:${e}:${zx(t||"anon")}`}function Bx(){const e=Pi(Fx);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 Hx(e){const t=Pi(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 Fi(e,t){Oi(e,JSON.stringify(t))}function $i(e){const t=Hx(e);if(t.length>0)return t;const n=Bx();if(n.length>0)try{Fi(e,n.slice(0,Di))}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 zi(e){return e.order.map(t=>e.byId[t]).filter(Boolean)}function Bi(e,t){return`${e}${t}`}function Ux(e,t){const n=Pi(Bi(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 Wx(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=Bi(e,t.threadId),i=JSON.stringify(o);if(!Oi(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),Oi(s,i))break}catch{}}function Vx(e,t){Mi(Bi(e,t))}function Kx(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),qx=w.createContext(!1),Uc=50,Gx=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 Yx(e,t){return Yo(e,t)}function Xx(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 Jx(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=Xx(e.next,t.next),i=Jx(e.tasks,t.tasks),a=Yx(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 Zx({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:${$x}:${f}:`,[f]),p=w.useCallback(N=>Ux(h,N),[h]),v=w.useCallback((N,A=100)=>{Wx(h,N,A)},[h]),x=w.useCallback(N=>{Vx(h,N)},[h]),g=w.useCallback(()=>{Kx(h)},[h]),[y,b]=w.useState(()=>{var N;return Li(f,(N=l.getAuthToken)==null?void 0:N.call(l))}),[C,E]=w.useState(()=>{var A;const N=$i(Li(f,(A=l.getAuthToken)==null?void 0:A.call(l)));return Go(N)}),T=w.useMemo(()=>zi(C),[C]),[k,I]=w.useState(t),[j,R]=w.useState(!1),[_,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=$i(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:_e,pushUser:Ue,onEvent:et,reset:Ze}=Ac(),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),je=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=je.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 _t=Vc(yt,Xe);Q.set(De,{...yt,..._t})}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),je.current.delete(Q);else{if(A!=null&&A.preferCache){const Xe=je.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=>(je.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??Lx(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=zi(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(""),jn=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{Mi(y)}catch{}mn.current="";return}if(q===mn.current)return;const te=()=>{try{const le=N.slice(0,Di);Fi(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(()=>{jn(T,{immediate:!0})},[jn,T]),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:[],_t=Qt(Xe),Rn=Array.isArray(N==null?void 0:N.messages)?N.messages:[],Rt=new Set,Pt=[...Rn,...yt].filter(Nt=>{const kl=Nt==null?void 0:Nt.id;return kl?Rt.has(kl)?!1:(Rt.add(kl),!0):!0}),jo=Vc(_t,Q),_o={checkpointId:_t.checkpointId??Q.checkpointId??null,checkpointNs:_t.checkpointNs??Q.checkpointNs??null,createdAt:Q.createdAt??_t.createdAt??null,parentId:Q.parentId??_t.parentId??null,branchLabel:Q.branchLabel??_t.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??_t.nextCursor??null,nextCursorNs:Q.nextCursorNs??_t.nextCursorNs??null,interrupt:_t.interrupt??Q.interrupt??null,...jo};if(tt.current.set(le,{threadId:le,snapshot:Qt(_o,{cloneMessages:!0})}),!Be)return;Rn.length&&_e(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)},[_e,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 je.current.keys())q.startsWith(A)&&je.current.delete(q);ze.current===N&&(ze.current=null)},[x]),_n=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}=Px({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{Mi(y)}catch{}mn.current="";return}if(N===mn.current)return;const A=()=>{try{const q=T.slice(0,Di);Fi(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)}},[T,jn]),w.useEffect(()=>{var te;const N=l.getAuthToken();oe(N);const A=le=>{const Q=Li(f,le);bt.current!==Q&&(bt.current=Q,ct.current=!1),b(Q);const Be=$i(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(),je.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=zi(Q),Q}),A&&jn(A,{immediate:!0}),gn(N),Pe.current===N&&(st.current=N,I(null),Pe.current=null,ze.current=null,_n()),await Ft(),U(null)}catch(A){throw U(String(A)),A}},[l,_n,gn,Ft,jn]),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=Wc(N,A??null,q??null),We=je.current.get(Be),De=!te&&!A&&!q&&We&&Date.now()-We.timestamp<Gx,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 _t=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:jo,checkpoints:_o,snapshots:Pn}=Cc(Pt);sn(jo,"replace",N),pt(N,_o,"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)}};_t?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,_n(),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")},[_n,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}=Cc(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,_t=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(),..._t!=null?{checkpointId:_t}:{},...Rn!=null?{checkpointNs:Rn}:{}};Xe.length>0&&Ue(Rt);const Pt={...Rt,content:Xe},jo=Q.length>0,_o={messages:Xe.length>0?[Pt]:[],files_info:De,...o&&jo&&s?{active_agent:s}:{},...Be},Pn={threadId:q??null,payload:_o,checkpointId:_t??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]),jt=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=!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:T,currentThreadId:k,setCurrentThreadId:I,isLoading:j,error:F,actions:{createThread:Te,deleteThread:$e,renameThread:Me,refreshThreads:()=>Ft()},persistThreadsCache:Ur,hydrateFromCache:ie}),[T,k,j,F,Te,$e,Me,Ft,Ur,ie,I]),Sl=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:_,isHistoryLoading:ce,error:D,hasMore:M,loadOlder:Bt,seedFromSnapshot:Un,clearState:_n,navigateToCheckpoint:dt,returnToLatest:ht,loadThread:ke,clearThread:It,respondToInterrupt:jt}},[It,_n,k,W,M,ce,_,Bt,ke,ae.assemblingId,ae.lastBranch,ae.lastCheckpointId,ae.lastCheckpointNs,ae.messages,dt,jt,ht,Un,D,$]),Cl=w.useMemo(()=>({isStreaming:P,error:B,submit:Jt,send:Jt,stop:S,setAuthToken:oe}),[P,B,Jt,S,oe]);return c.jsx(qx.Provider,{value:!0,children:c.jsx(Hc.Provider,{value:Cl,children:c.jsx(zc.Provider,{value:Ao,children:c.jsx(Bc.Provider,{value:Sl,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(Zx,{initialThreadId:n,autoLoadInitial:r,disableAutoRestore:o,enableFileAgentRouting:s,fileAgentId:i,onError:a,onThreadChange:l,children:e})})}function re(...e){return jm.twMerge(Am.clsx(e))}const Qx=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(Qx({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 ey({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 _=g.current;_&&(_.style.height="auto",_.style.height=`${_.scrollHeight}px`)},[]);w.useEffect(()=>{C()},[C]);const E=w.useCallback(async _=>{_&&_.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(_=>{p(_.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(_=>{_.key==="Enter"&&!_.shiftKey?(_.preventDefault(),E()):_.key==="Escape"&&t&&(_.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:_=>void E(_),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: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 ty=w.memo(ey),Qo=0,Vn=1,Ar=2,Gc=4;function Yc(e){return()=>e}function ny(e){e()}function Xc(e,t){return n=>e(t(n))}function Jc(e,t){return()=>e(t)}function ry(e,t){return n=>e(t,n)}function Hi(e){return e!==void 0}function oy(...e){return()=>{e.map(ny)}}function jr(){}function es(e,t){return t(e),e}function sy(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 Ui(e){e(Ar)}function xt(e){return e(Gc)}function ve(e,t){return Ye(e,ry(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=iy(...t);return(r,o)=>{switch(r){case Ar:Ui(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 iy(...e){return t=>e.reduceRight(sy,t)}function ay(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(),jr);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:ly(),singleton:n}}const ly=()=>Symbol();function cy(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:{Ui(t);return}case Vn:return r===o&&i(n),Ye(t,i)}}}function Ce(e,t=Qc){return V(e,at(t))}function Wi(...e){return function(t,n){switch(t){case Ar:return;case Vn:return oy(...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 uy={0:"debug",3:"error",1:"log",2:"warn"},dy=()=>typeof globalThis>"u"?window:globalThis,Kn=Ge(()=>{const e=J(3);return{log:J((t,n,r=1)=>{var o;const s=(o=dy().VIRTUOSO_LOG_LEVEL)!=null?o:xt(e);r>=s&&console[uy[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 Vi(e,t,n).callbackRef}function Vi(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 fy(e,t,n,r,o,s,i,a,l){const u=w.useCallback(d=>{const f=hy(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 Vi(u,n,l)}function hy(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}=Vi(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 _r(){return eo}function ts(e,t,n){if(rt(e))return[];const r=un(e,t)[0];return py(qi(e,r,n))}function Ki(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:Ki(r,t)})):ns(St(e,{r:Ki(o,t)}))}function dr(e){return rt(e)?[]:[...dr(e.l),{k:e.k,v:e.v},...dr(e.r)]}function qi(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(qi(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(qi(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(Gi(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(Gi(e))return Yi(St(e,{lvl:n-1}));if(!rt(r)&&!rt(r.l)){const o=r.l,s=Gi(o)?r.lvl-1:r.lvl;return St(o,{l:St(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Yi(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 Gi(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 Yi(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 Yi(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 py(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 Xi=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 my(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 Ji({index:e},t){return t===e?0:t<e?-1:1}function gy(){return{groupIndices:[],groupOffsetTree:_r(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:_r()}}function xy(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(Ty(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=Ki(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 yy(e){return typeof e.groupIndex<"u"}function vy({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,Ji),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(yy(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 by(e,t,n,r=0){return r>0&&(t=Math.max(t,cu(e,r,Ji).offset)),nu(my(e,t,n,vy),Cy)}function wy(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]=xy(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=Zi(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>qt(h,p,ro(p,f,o)),_r()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function Sy(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 Zi(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=rs(o,t-1,Ji),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 Cy(e){return{index:e.index,value:e}}function Ty(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((T,k)=>qn(T,ky[k])),h=J(void 0),p=J(0),v=gy(),x=Mt(V(n,Le(l,e,p),bn(wy,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 j=T.reduce((R,_,H)=>qt(R,_,ro(_,k.offsetTree,I)||H),_r());return{...k,groupIndices:T,groupOffsetTree:j}})),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+fu(T,k));else if(T<0){const I=xt(g);I.length>0&&(T-=fu(-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,j=[],R=k.lastSize;if(I){const _=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;j.push({endIndex:D,size:_,startIndex:D}),j.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:j}).ranges}return dr(k.sizeTree).reduce((_,{k:H,v:F})=>({prevIndex:H+T,prevSize:F,ranges:[..._.ranges,{endIndex:H+T-1,size:_.prevSize,startIndex:_.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),n);const E=Kt(V(i,Le(x,p),fe(([T,{offsetTree:k},I])=>{const j=-T;return ro(j,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 j=_r();const R=xt(g);let _=0,H=0,F=0;for(;_<-T;){F=R[H];const U=R[H+1]-F-1;H++,_+=U+1}if(j=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);j=qt(j,0,U);const D=un(k.sizeTree,-T+1)[1];j=qt(j,1,D)}return{...k,sizeTree:j,...Zi(k.offsetTree,0,j,I)}}else{const j=dr(k.sizeTree).reduce((R,{k:_,v:H})=>qt(R,Math.max(0,_+T),H),_r());return{...k,sizeTree:j,...Zi(k.offsetTree,0,j,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,Xi),{singleton:!0});function Ey(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(Ey)));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}),Iy=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||!Iy)&&(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,j,R,_,H],F,U,D])=>{const G=pu(E),{align:W,behavior:ne,offset:$}=G,z=I-1,ie=du(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+=_)):W==="center"?M+=(U+un(T.sizeTree,ie)[1]-k+D)/2:M-=j,$&&(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,Ny(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 Ny(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Qi(e,t){e==0?t():requestAnimationFrame(()=>{Qi(e-1,t)})}function ea(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)||Hi(p))&&!f&&!v),Le(l)),([,d])=>{cn(o,()=>{Oe(u,!0)}),Qi(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",Ay="none",jy={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(Wi(V(Ce(o),cr(1),vn(!0)),V(Ce(o),cr(1),vn(!1),Zc(100))),at()),!1),p=Mt(V(Wi(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},T,k,I,j])=>{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:_}}let H;return _.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:_}},jy),at((b,C)=>b&&b.atBottom===C.atBottom))),x=Mt(V(r,bn((b,{scrollHeight:C,scrollTop:E,viewportHeight:T})=>{if(mu(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(Ay)),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 ta=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=gu;const j=yu(C,ss),R=yu(C,is);return p-=b,p+=h+y,v+=h+y,v-=b,p>d+T-j&&(I=io),v<d-k+f+R&&(I=ao),I!==gu?[Math.max(E-h-xu(x,ss,I)-j,0),E-k-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 Ry(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 na={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=ea(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(([k,I,,j,,,,,,,R])=>{const _=R&&R.length!==j;return k&&!I&&!_}),fe(([,,[k,I],j,R,_,H,F,U,D,G])=>{const W=R,{offsetTree:ne,sizeTree:$}=W,z=xt(g);if(j===0)return{...na,totalCount:j};if(k===0&&I===0)return z===0?{...na,totalCount:j}:vu(z,_,R,U,D,G||[]);if(rt($))return z>0?null:as(Ry(ea(_,j),W,G),[],j,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,j,D,W,U);const M=F.length>0?F[F.length-1]+1:0,Y=by(ne,k,I,M);if(Y.length===0)return null;const ce=j-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,j,D,W,U)}),Ee(k=>k!==null),at()),na);ve(V(e,Ee(Hi),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,j=k.length-1;for(;k[I].type==="group"&&I<j;)I++;for(;k[j].type==="group"&&j>I;)j--;return{endIndex:k[j].index,startIndex:k[I].index}}),at(lu)));return{endReached:C,initialItemCount:g,itemsRendered:y,listState:b,rangeChanged:T,startReached:E,topItemsIndexes:x,...h}},it(wn,hu,ta,so,oo,lo,Gn,Xi),{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}),Py=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)})),Oy=({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:T,calculateViewLocation:k=Oy,done:I,...j}=f,R=du(f,h,v-1),_=ro(R,h.offsetTree,C)+x+g,H=_+un(h.sizeTree,R)[1],F=b+g,U=b+p-y,D=k({itemBottom:H,itemTop:_,locationParams:{align:E,behavior:T,...j},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 Tu(e){return e?e==="smooth"?"smooth":"auto":!1}const My=(e,t)=>typeof e=="function"?Tu(e(t)):t&&Tu(e),Dy=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,j,R,_])=>{let H=k&&R,F="auto";return H&&(F=My(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(Wi(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,j,R,_])=>k&&j&&(I==null?void 0:I({context:_,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,Su,Cu)),Ly=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}),Fy=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}),ku=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}),ra=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)),$y=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=Sy(v.sizeTree);g&&y!==null&&b!==null&&(x=y.scrollTop-b.offsetTop),x-=C,p({ranges:E,scrollTop:x})}),ve(V(d,Ee(Hi),fe(zy)),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,ra));function zy(e){return{align:"start",index:0,offset:e.scrollTop}}const By=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 Hy=Eu(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Uy=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},j])=>{const R=E+k;let _=0;return b===I&&y.length>0&&T.length>0&&(T[0].originalIndex===0&&y[0].originalIndex===0||(_=R-C,_!==0&&(_+=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&&Hy()?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 j=to(E,0);let R=0,_=0;for(;R<y;){R++,I+=j;let H=b.length===_+1?1/0:b[_+1]-b[_]-1;R+H>y&&(I-=j,H=y-R+1),R+=H,I+=k(H),_++}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,Xi)),Wy=Ge(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),it(ta,Ly,Gn,ku,wu,Fy,Py,ra,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:T},k,{topItemCount:I},{groupCounts:j},R])=>(ve(E.rangeChanged,R.scrollSeekRangeChanged),ve(V(R.windowViewportRect,fe(_=>_.visibleHeight)),x.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:j,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,$y,Dy,fr,oo,Uy,By,hu,Wy));function Vy(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]=ay(g[t.events[b]]),y),{})}const f=w.forwardRef((g,y)=>{const{children:b,...C}=g,[E]=w.useState(()=>es(cy(e),I=>{l(I,C)})),[T]=w.useState(Jc(d,E));ls(()=>{for(const I of i)I in C&&Ye(T[I],C[I]);return()=>{Object.values(T).map(Ui)}},[C,T,E]),ls(()=>{l(E,C)}),w.useImperativeHandle(y,Yc(u(E)));const k=n;return c.jsx(a.Provider,{value:E,children:n?c.jsx(k,{...Vy([...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),ju=w.createContext(void 0),_u=typeof document<"u"?w.useLayoutEffect:w.useEffect;function oa(e){return"self"in e}function Ky(e){return"body"in e}function Ru(e,t,n,r=jr,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(Ky(g)||oa(g)){const b=oa(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;oa(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 sa="-webkit-sticky",Pu="sticky",ia=Eu(()=>{if(typeof document>"u")return Pu;const e=document.createElement("div");return e.style.position=sa,e.style.position===sa?sa:Pu});function aa(e){return e}const qy=Ge(()=>{const e=J(a=>`Item ${a}`),t=J(a=>`Group ${a}`),n=J({}),r=J(aa),o=J("div"),s=J(jr),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")}}),Gy=Ge(([e,t])=>({...e,...t}),it(Iu,qy)),Yy=({height:e})=>c.jsx("div",{style:{height:e}}),Xy={overflowAnchor:"none",position:ia(),zIndex:1},Ou={overflowAnchor:"none"},Jy={...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}=fy(n,h,f,e?jr:a,p,v,o,x,Ae("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);la("deviation",D=>{y!==D&&b(D)});const C=Ae("EmptyPlaceholder"),E=Ae("ScrollSeekPlaceholder")||Yy,T=Ae("ListComponent"),k=Ae("ItemComponent"),I=Ae("GroupComponent"),j=Ae("computeItemKey"),R=Ae("isSeeking"),_=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=j(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:Xy},d(D.index,u)):w.createElement(k,{...Dt(k,u),...tv(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?Jy:Ou},_?l(D.index,D.groupIndex,D.data,u):l(D.index,D.data,u))})})}),Zy={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Qy={outline:"none",overflowX:"auto",position:"relative"},cs=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),ev={position:ia(),top:0,width:"100%",zIndex:1};function Dt(e,t){if(typeof e!="string")return{context:t}}function tv(e,t){return{item:typeof e=="string"?void 0:t}}const nv=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}),rv=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?Qy:Zy,...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 _u(()=>{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 ov=({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})},sv=({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})},iv=({children:e})=>{const t=Ae("TopItemListComponent")||"div",n=Ae("headerHeight"),r={...ev,marginTop:`${n}px`},o=Ae("context");return c.jsx(t,{style:r,...Dt(t,o),children:e})},av=w.memo(function(e){const t=Ae("useWindowScroll"),n=Ae("topItemsIndexes").length>0,r=Ae("customScrollParent"),o=Ae("context");return c.jsxs(r||t?uv:cv,{...e,context:o,children:[n&&c.jsx(iv,{children:c.jsx(Mu,{showTopList:!0})}),c.jsxs(r||t?sv:ov,{children:[c.jsx(nv,{}),c.jsx(Mu,{}),c.jsx(rv,{})]})]})}),{Component:lv,useEmitter:la,useEmitterValue:Ae,usePublisher:en}=Nu(Gy,{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"}},av),cv=Du({useEmitter:la,useEmitterValue:Ae,usePublisher:en}),uv=Lu({useEmitter:la,useEmitterValue:Ae,usePublisher:en}),dv=lv;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(aa),a=J(jr),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")}})),ia();const Fu={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},fv={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:$u,floor:us,max:co,min:ca,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 hv(e){return{...fv,items:e}}function ds(e,t){return e&&e.width===t.width&&e.height===t.height}function pv(e,t){return e&&e.column===t.column&&e.row===t.row}const mv=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=J(Fu),R=J({height:0,width:0}),_=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,_,R,z,M),Ee(([L,Z,ee,me,,se])=>L&&!Z&&ee.height!==0&&me.height!==0&&!se)),([,,,,L])=>{Oe(M,!0),Qi(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(_,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(_,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,pv),Ce(_,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,,_e,Ue])=>{const{column:et,row:Ze}=me,{height:Pe,width:Ct}=se,{width:kt}=ae;if(Je===0&&(L===0||kt===0))return Fu;if(Ct===0){const de=ea(Ue,L),je=de+Math.max(Je-1,0);return hv(Bu(de,je,He))}const Et=Hu(kt,Ct,et);let st,tt;_e?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=ca(L-1,co(tt,Et-1)),st=ca(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}})),j),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}=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(j,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(j),Ee(({items:L})=>L.length>0&&L[0].index===0),vn(0),at())),ye=Kt(V(Ce(j),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,_,k,G),fe(([L,Z,ee,me,se])=>{const ae=pu(L),{align:He,behavior:Je,offset:_e}=ae;let Ue=ae.index;Ue==="LAST"&&(Ue=me-1),Ue=co(0,Ue,ca(me-1,Ue));let et=ua(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)),_e&&(et+=_e),{behavior:Je,top:et}})),l);const K=Mt(V(j,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:_,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:j,horizontalDirection:Y,initialTopMostItemIndex:z,totalListHeight:K,...h,endReached:be,propsReady:x,rangeChanged:ye,startReached:ge,stateChanged:W,stateRestoreInProgress:$,...T}},it(ta,$t,lo,ku,Gn,ra,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=ua(e,t,n,r[0].index);return{bottom:ua(e,t,n,r[r.length-1].index)+o,top:s}}function ua(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 gv=Ge(()=>{const e=J(f=>`Item ${f}`),t=J({}),n=J(null),r=J("virtuoso-grid-item"),o=J("virtuoso-grid-list"),s=J(aa),i=J("div"),a=J(jr),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")}}),xv=Ge(([e,t])=>({...e,...t}),it(mv,gv)),yv=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:Vu("column-gap",getComputedStyle(y).columnGap,p),row:Vu("row-gap",getComputedStyle(y).rowGap,p)})},[i,f,h,p]),!0,!1);return _u(()=>{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))})})}),vv=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}),bv=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}),wv=({children:e})=>{const t=w.useContext(ju),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})},Sv=({children:e})=>{const t=w.useContext(ju),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})},Cv=w.memo(function({...e}){const t=lt("useWindowScroll"),n=lt("customScrollParent"),r=n||t?kv:Tv,o=n||t?Sv:wv,s=lt("context");return c.jsx(r,{...e,...Dt(r,s),children:c.jsxs(o,{children:[c.jsx(vv,{}),c.jsx(yv,{}),c.jsx(bv,{})]})})}),{useEmitter:Wu,useEmitterValue:lt,usePublisher:tn}=Nu(xv,{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"}},Cv),Tv=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 Ev=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 da({className:e,variant:t,...n}){return c.jsx("div",{className:re(Ev({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 Iv(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,Nv(o,...t)]}function Nv(...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:()=>{},Av=m[" useInsertionEffect ".trim().toString()]||Tt;function hr({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=jv({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 jv({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return Av(()=>{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 fa(...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(fa(...e),e)}var Rv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ie=Rv.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 Pv(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Gt=e=>{const{present:t,children:n}=e,r=Ov(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=Ve(r.ref,Mv(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};Gt.displayName="Presence";function Ov(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Pv(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 Mv(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 Dv=m[" useId ".trim().toString()]||(()=>{}),Lv=0;function Cn(e){const[t,n]=m.useState(Dv());return Tt(()=>{n(r=>r??String(Lv++))},[e]),e||(t?`radix-${t}`:"")}var hs="Collapsible",[Fv,Sk]=Sn(hs),[$v,ha]=Fv(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($v,{scope:n,disabled:s,contentId:Cn(),open:l,onOpenToggle:m.useCallback(()=>u(d=>!d),[u]),children:c.jsx(Ie.div,{"data-state":ma(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=ha(Yu,n);return c.jsx(Ie.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":ma(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:pe(e.onClick,o.onOpenToggle)})});Xu.displayName=Yu;var pa="CollapsibleContent",zv=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=ha(pa,e.__scopeCollapsible);return c.jsx(Gt,{present:n||o.open,children:({present:s})=>c.jsx(Bv,{...r,ref:t,present:s})})});zv.displayName=pa;var Bv=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=ha(pa,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":ma(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 ma(e){return e?"open":"closed"}var Hv=Gu;const Ju=Hv,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 Uv(e){pr=e}const nd=/[&<>"']/,Wv=new RegExp(nd.source,"g"),rd=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Vv=new RegExp(rd.source,"g"),Kv={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},od=e=>Kv[e];function Lt(e,t){if(t){if(nd.test(e))return e.replace(Wv,od)}else if(rd.test(e))return e.replace(Vv,od);return e}const qv=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function sd(e){return e.replace(qv,(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 Gv=/(^|[^\[])\^/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(Gv,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const Yv=/[^\w:]/g,Xv=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function id(e,t,n){if(e){let r;try{r=decodeURIComponent(sd(n)).replace(Yv,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!Xv.test(n)&&(n=eb(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const ps={},Jv=/^[^:]+:\/*[^/]*$/,Zv=/^([^:]+:)[\s\S]*$/,Qv=/^([^:]+:\/*[^/]*)[\s\S]*$/;function eb(e,t){ps[" "+e]||(Jv.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(Zv,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(Qv,"$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 tb(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 nb(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 rb(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
37
+ `))>=0;){const kt=K.slice(0,Ct);K=K.slice(Ct+2);const ot=Ix(kt);if(!ot)continue;let et;try{et=JSON.parse(ot)}catch{console.debug("[use-chat] malformed SSE:",ot.slice(0,200));continue}const $e=Ex(et)?et.data:et;ie=Date.now();const ct=$e.seq;if(ct!==void 0){if(ct<=Z){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:ct,lastProcessedSeq:Z,type:$e.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:$e.seq,type:$e.type,preview:(()=>{var vt;try{return $e.type==="message_delta"?{deltaTypes:(vt=$e.delta)==null?void 0:vt.map(J=>J.type),textLen:($e.delta||[]).filter(J=>J.type==="text").map(J=>String(J.text||"").length)}:$e.content||$e.delta?{hasContent:!0}:{}}catch(J){return{err:String(J)}}})()}),H==null||H($e),$e.type==="token"&&e.autoAppendAssistant!==!1)L.push($e.content),oe();else if($e.type==="message_delta"){const vt=$e.delta.filter(J=>J.type==="text").map(J=>J.text).join("");vt&&e.autoAppendAssistant!==!1&&(L.push(vt),oe())}else $e.type==="heartbeat"?console.debug("[use-chat] heartbeat received"):(ee!==null&&cancelAnimationFrame(ee),pe(),$e.type==="checkpoint"?v($e.checkpointId):$e.type==="error"&&d($e.message))}}pe()}catch(je){if(je.name!=="AbortError"){const He=je.message||String(je);d(He),(se=F==null?void 0:F.onError)==null||se.call(F,He)}}finally{try{await ge.cancel()}catch{}finally{(M=ge.releaseLock)==null||M.call(ge)}ee!==null&&typeof window<"u"&&window.cancelAnimationFrame(ee),clearInterval(Be),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:P,stop:I,clear:_,setToken:T}}function Ex(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function Ix(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 Ax({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(xx(p)){n(p);return}r==null||r(p)},[n,o,t,r]),{stream:a,stop:l,isStreaming:u,error:d,setToken:f}=Oc({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 Nx(e){return e==null?e:{...e}}function _x(e){if(Array.isArray(e))return e.slice();if(e==null)return e}function jx(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=_x(e==null?void 0:e.next),l=jx(e==null?void 0:e.tasks),u=Nx(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 Rx(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 Mc(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 Ko=300;function Dc(e,t=Ko){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 Px="cachedThreads",Ox="v1",Li=200;function Mx(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}:${Mx(t||"anon")}`}function Dx(){const e=Oi(Px);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 Lx(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=Lx(e);if(t.length>0)return t;const n=Dx();if(n.length>0)try{$i(e,n.slice(0,Li))}catch{}return n}function qo(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 Fx(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 $x(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 zx(e,t){Di(Hi(e,t))}function Bx(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 Lc=w.createContext(null),Fc=w.createContext(null),$c=w.createContext(null),Hx=w.createContext(!1),zc=50,Ux=750;function Bc(e,t,n){return`${e}__${t??""}__${n??""}`}function Go(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 Wx(e,t){return Go(e,t)}function Vx(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 Kx(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 Hc(e,t){const n=Go(e.metadata,t.metadata),r=Go(e.config,t.config),o=Go(e.parentConfig,t.parentConfig),s=Vx(e.next,t.next),i=Kx(e.tasks,t.tasks),a=Wx(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 qx({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}=Ni(),d=w.useMemo(()=>Mn(u),[u]),f=w.useMemo(()=>{try{return new URL(u).host}catch{return"unknown"}},[u]),h=w.useMemo(()=>`threadPayload:${Ox}:${f}:`,[f]),p=w.useCallback(A=>Fx(h,A),[h]),v=w.useCallback((A,N=100)=>{$x(h,A,N)},[h]),x=w.useCallback(A=>{zx(h,A)},[h]),g=w.useCallback(()=>{Bx(h)},[h]),[y,b]=w.useState(()=>{var A;return Fi(f,(A=l.getAuthToken)==null?void 0:A.call(l))}),[C,E]=w.useState(()=>{var N;const A=zi(Fi(f,(N=l.getAuthToken)==null?void 0:N.call(l)));return qo(A)}),k=w.useMemo(()=>Bi(C),[C]),[T,I]=w.useState(t),[_,P]=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([]),se=w.useCallback(()=>{const A=zi(y);w.startTransition(()=>{E(qo(A))})},[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),[pe,oe]=w.useState(void 0),{state:ie,dispatch:Be,seed:Je,prepend:je,pushUser:He,onEvent:Qe,reset:Ze}=Ec(),Pe=w.useRef(T);w.useEffect(()=>{Pe.current=T},[T]);const wt=w.useRef(!1),Ct=w.useRef([]),kt=w.useRef(null),ot=w.useRef(null),et=w.useRef(new Map),$e=w.useRef(T),ct=w.useRef(!1),vt=w.useRef(null),J=w.useRef(new Map),xe=w.useRef(new Map),ue=w.useRef(new Map),_e=w.useRef(new Map),Ve=w.useCallback(A=>{if(!A){z([]);return}const N=J.current.get(A);if(!N||!N.length){z([]);return}z(N.map(q=>Qt(q,{cloneMessages:!0})))},[]);w.useEffect(()=>{Ve(T)},[T,Ve]);const at=w.useCallback(()=>{var te;const A=_e.current;if(A.size<=zc)return;const N=Array.from(A.entries()).sort((le,Q)=>le[1].timestamp-Q[1].timestamp),q=A.size-zc;for(let le=0;le<q;le++){const Q=(te=N[le])==null?void 0:te[0];Q&&A.delete(Q)}},[]),Tt=w.useCallback((A,N,q)=>{if(!A)return;const te=q==="replace"?[]:J.current.get(A)??[],le=q==="replace"?N:[...N,...te];if(!le.length){q==="replace"&&J.current.set(A,[]);return}const Q=new Map;for(const Ue of le){if(!(Ue!=null&&Ue.checkpointId))continue;const Le=`${Ue.checkpointId}::${Ue.checkpointNs??""}`,Xe=Qt(Ue,{cloneMessages:!0}),xt=Q.get(Le);if(!xt){Q.set(Le,Xe);continue}const Rt=Hc(xt,Xe);Q.set(Le,{...xt,...Rt})}const ze=Array.from(Q.values()).sort((Ue,Le)=>{const Xe=Number.isFinite(Date.parse(Ue.createdAt??""))?Date.parse(Ue.createdAt??""):0;return(Number.isFinite(Date.parse(Le.createdAt??""))?Date.parse(Le.createdAt??""):0)-Xe});J.current.set(A,ze),A===Pe.current&&Ve(A)},[Ve]),rt=w.useCallback((A,N,q)=>{if(!A)return;const te=xe.current.get(A),le=q==="replace"||!te?new Map:new Map(te);if(N&&typeof N=="object")for(const[Q,ze]of Object.entries(N)){if(!(ze!=null&&ze.checkpointId))continue;const Ue=Q||Zr(ze.checkpointId,ze.checkpointNs??null);le.set(Ue,Qt(ze,{cloneMessages:!0}))}xe.current.set(A,le)},[]),ut=w.useCallback((A,N)=>{const{threadId:q,checkpointId:te=null,checkpointNs:le=null}=A,Q=Bc(q,te,le);if(N!=null&&N.force)ue.current.delete(Q),_e.current.delete(Q);else{if(N!=null&&N.preferCache){const Xe=_e.current.get(Q);if(Xe)return Promise.resolve(Xe.payload)}const Le=ue.current.get(Q);if(Le)return Le}const Ue=l.getStateHistory({threadId:q,checkpointId:te??void 0,checkpointNs:le??void 0}).then(Le=>(_e.current.set(Q,{payload:Le,timestamp:Date.now()}),at(),Le)).finally(()=>{ue.current.get(Q)===Ue&&ue.current.delete(Q)});return ue.current.set(Q,Ue),Ue},[l,at]),pt=w.useCallback((A,N)=>new Promise((q,te)=>{const le=async()=>{wt.current=!0;try{await A(),q()}catch(Q){te(Q)}finally{wt.current=!1;const Q=Ct.current.shift();Q&&Q().catch(()=>{})}};wt.current?Ct.current.push(le):le().catch(Q=>{te(Q)})}),[]),$n=w.useRef(k.length),sn=w.useRef(!1);w.useEffect(()=>{$n.current=k.length},[k.length]),w.useEffect(()=>{const A=ie.pendingInterrupt??Rx(ie.messages);Mc(W,A)||ne(A??null)},[W,ie.messages,ie.pendingInterrupt]);const jt=w.useCallback(async()=>{const A=$n.current>0;A||P(!0);try{const N=await l.listThreads();w.startTransition(()=>{E(q=>{const te=ze=>ze.map(Ue=>`${Ue.threadId}:${Ue.updatedAt??""}:${Ue.messageCount??""}`).join("|"),le=Bi(q);return te(le)===te(N)||N.length===0&&le.length>0&&!sn.current?q:qo(N)})}),U(null),sn.current||(sn.current=!0)}catch(N){i==null||i(String(N)),console.error("[ChatSessionProvider] Failed to refresh threads:",N),U(String(N))}finally{A||P(!1)}},[l,i]),Cr=w.useRef(!1),tr=w.useRef(null),Et=w.useRef(null),an=w.useRef(""),gn=w.useCallback((A,N)=>{if(!lr())return;Et.current!==null&&(window.clearTimeout(Et.current),Et.current=null);const q=A.map(le=>`${le.threadId}:${le.updatedAt??""}:${le.messageCount??""}`).join("|");if(A.length===0){try{Di(y)}catch{}an.current="";return}if(q===an.current)return;const te=()=>{try{const le=A.slice(0,Li);$i(y,le),an.current=q}catch{}finally{Et.current=null}};if(N!=null&&N.immediate){te();return}Et.current=window.setTimeout(()=>{Dc(te)},Ko)},[y]),kr=w.useCallback(()=>{gn(k,{immediate:!0})},[gn,k]),Jt=w.useCallback((A,N,q,te)=>{var Sm;const le=q??Pe.current;if(!le)return;const Q=Qt(A),ze=le===Pe.current,Ue=(te==null?void 0:te.persist)!==!1;if(N==="replace"){if(Ue){const Nt={threadId:le,snapshot:Qt(A,{cloneMessages:!0})};et.current.set(le,Nt),$e.current=le}if(!ze)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),oe(Q.nextCursorNs??void 0);return}const Le=et.current.get(le),Xe=(Le==null?void 0:Le.snapshot)??null,xt=Array.isArray(Xe==null?void 0:Xe.messages)?Xe.messages:[],Rt=Qt(Xe),Rn=Array.isArray(A==null?void 0:A.messages)?A.messages:[],Pt=new Set,Ot=[...Rn,...xt].filter(Nt=>{const Cl=Nt==null?void 0:Nt.id;return Cl?Pt.has(Cl)?!1:(Pt.add(Cl),!0):!0}),No=Hc(Rt,Q),_o={checkpointId:Rt.checkpointId??Q.checkpointId??null,checkpointNs:Rt.checkpointNs??Q.checkpointNs??null,createdAt:Q.createdAt??Rt.createdAt??null,parentId:Q.parentId??Rt.parentId??null,branchLabel:Q.branchLabel??Rt.branchLabel??null,lastMessageId:((Sm=Ot[Ot.length-1])==null?void 0:Sm.id)??null,messagesLen:Ot.length,hasMessages:Ot.length>0,messages:Ot,nextCursor:Q.nextCursor??Rt.nextCursor??null,nextCursorNs:Q.nextCursorNs??Rt.nextCursorNs??null,interrupt:Rt.interrupt??Q.interrupt??null,...No};if(et.current.set(le,{threadId:le,snapshot:Qt(_o,{cloneMessages:!0})}),!ze)return;Rn.length&&je(Rn);const Pn=A&&Object.prototype.hasOwnProperty.call(A,"checkpointId")?A.checkpointId:void 0,jo=A&&Object.prototype.hasOwnProperty.call(A,"checkpointNs")?A.checkpointNs:void 0,On=A&&Object.prototype.hasOwnProperty.call(A,"nextCursor")?A.nextCursor:void 0,Sl=A&&Object.prototype.hasOwnProperty.call(A,"nextCursorNs")?A.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=>jo!==void 0?jo??Nt??void 0:Nt??void 0),oe(Nt=>Sl!==void 0?Sl??void 0:Nt)},[je,Je,ne]),Tr=w.useCallback(A=>{if(A.threadId!=null&&A.threadId!==Pe.current)return;const N=Qt(A.snapshot,{cloneMessages:!0});Je(N.messages,{checkpointId:N.checkpointId??null,checkpointNs:N.checkpointNs??null,pendingInterrupt:N.interrupt??null}),ne(N.interrupt??null),ye(N.nextCursor??null),Y(!!N.nextCursor),L(N.checkpointId??void 0),ee(N.checkpointNs??void 0),oe(N.nextCursorNs??void 0),$e.current=A.threadId,Ve(A.threadId??Pe.current??null)},[Je,ne,Ve]),jn=w.useCallback(A=>{if(!A)return;et.current.delete(A),x(A),J.current.delete(A),xe.current.delete(A),A===Pe.current&&z([]);const N=`${A}__`;for(const q of ue.current.keys())q.startsWith(N)&&ue.current.delete(q);for(const q of _e.current.keys())q.startsWith(N)&&_e.current.delete(q);$e.current===A&&($e.current=null)},[x]),xn=w.useCallback(()=>{const A=Pe.current;A&&jn(A),Ze([]),Y(!1),be(!1),ye(null),L(void 0),ee(void 0),oe(void 0)},[jn,Ze]),nr=w.useCallback(({from:A,to:N})=>{const q=Pe.current;q&&console.warn(`[ChatSessionProvider] Stream sequence gap detected (${A} -> ${N}) for thread ${q}`)},[]),Io=w.useCallback(A=>{const N=A.threadId;console.log("[ChatSessionProvider] 📥 Handling thread_info event:",{threadId:N,title:A.title,created:A.created,currentThreads:k.length});const q={threadId:N,title:A.title||`Thread ${N.slice(0,8)}`,createdAt:A.createdAt||new Date().toISOString(),updatedAt:A.updatedAt||new Date().toISOString(),messageCount:A.messageCount||0};Pe.current!==N&&(!Pe.current&&ie.messages.length<=1&&(ot.current=N),I(N)),w.startTransition(()=>{E(te=>{const le=te.byId[N];return le?le.title===q.title&&le.updatedAt===q.updatedAt&&le.messageCount===q.messageCount?te:{byId:{...te.byId,[N]:q},order:te.order}:{byId:{...te.byId,[N]:q},order:[N,...te.order]}})})},[ie.messages.length]),{startStream:Ur,stop:Wr,isStreaming:rr,error:S,setAuthToken:R}=Ax({baseUrl:d,onThreadInfo:Io,onMessageEvent:Qe,onUnhandledEvent:A=>{console.warn(`[ChatSessionProvider] Unhandled stream event: ${A.type}`,A)},onSequenceGap:nr});w.useEffect(()=>{Cr.current=rr},[rr]),w.useEffect(()=>{if(!lr())return;Et.current!==null&&(window.clearTimeout(Et.current),Et.current=null);const A=k.map(q=>`${q.threadId}:${q.updatedAt??""}:${q.messageCount??""}`).join("|");if(k.length===0){try{Di(y)}catch{}an.current="";return}if(A===an.current)return;const N=()=>{try{const q=k.slice(0,Li);$i(y,q),an.current=A}catch{}finally{Et.current=null}};return Et.current=window.setTimeout(()=>{Dc(N),Et.current=null},Ko),()=>{Et.current!==null&&(window.clearTimeout(Et.current),Et.current=null)}},[k,gn]),w.useEffect(()=>{var te;const A=l.getAuthToken();R(A);const N=le=>{const Q=Fi(f,le);vt.current!==Q&&(vt.current=Q,ct.current=!1),b(Q);const ze=zi(Q);w.startTransition(()=>{E(qo(ze))}),ct.current||(ct.current=!0,jt().catch(()=>{}))};N(A);const q=(te=l.onTokenChange)==null?void 0:te.call(l,le=>{R(le),g(),ue.current.clear(),_e.current.clear(),N(le)});return()=>{q==null||q()}},[l,f,R,g,jt]);const B=w.useCallback(async A=>{var te;const N=`Thread ${(te=crypto.randomUUID)==null?void 0:te.call(crypto)}`,q={threadId:N,title:A||"New Chat",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messageCount:0};E(le=>({byId:{...le.byId,[N]:q},order:[N,...le.order]})),I(N);try{const le=await l.createThread(A),Q=typeof le=="string"?le:le.threadId;return E(ze=>{const Ue=ze.byId[N];if(!Ue)return ze;const Le={...ze.byId};delete Le[N],Le[Q]={...Ue,threadId:Q};const Xe=ze.order.map(xt=>xt===N?Q:xt);return{byId:Le,order:Xe}}),I(Q),setTimeout(()=>jt(),10),U(null),Q}catch(le){throw E(Q=>{if(!Q.byId[N])return Q;const ze={...Q.byId};delete ze[N];const Ue=Q.order.filter(Le=>Le!==N);return{byId:ze,order:Ue}}),I(null),U(String(le)),le}},[l,jt]),ae=w.useCallback(async A=>{try{await l.deleteThread(A);let N=null;E(q=>{if(!q.byId[A])return q;const te={...q.byId};delete te[A];const le=q.order.filter(ze=>ze!==A),Q={byId:te,order:le};return N=Bi(Q),Q}),N&&gn(N,{immediate:!0}),jn(A),Pe.current===A&&(ot.current=A,I(null),Pe.current=null,$e.current=null,xn()),await jt(),U(null)}catch(N){throw U(String(N)),N}},[l,xn,jn,jt,gn]),ke=w.useCallback(async(A,N)=>{try{await l.updateThread(A,N),E(q=>{const te=q.byId[A];return te?{byId:{...q.byId,[A]:{...te,title:N}},order:q.order}:q}),U(null)}catch(q){throw await jt(),U(String(q)),q}},[l,jt]),Ae=w.useCallback(async(A,N,q,te=!1)=>{await pt(async()=>{if(ot.current===A&&!te){ot.current=null;return}if(kt.current===A&&!te)return;I(Pt=>Pt===A?Pt:A),Pe.current=A;const ze=Bc(A,N??null,q??null),Ue=_e.current.get(ze),Le=!te&&!N&&!q&&Ue&&Date.now()-Ue.timestamp<Ux,Xe=!te&&!N&&!q;let xt=!1;if(Xe){const Pt=et.current.get(A);if(Pt)Tr(Pt),xt=!0;else{const Ot=p(A);Ot&&(et.current.set(A,Ot),Tr(Ot),xt=!0)}}const Rt=te||!xt||!!N||!!q,Rn=async Pt=>{Pt&&H(!0),kt.current=A;try{const Ot=await ut({threadId:A,checkpointId:N,checkpointNs:q},{force:te}),{latest:No,checkpoints:_o,snapshots:Pn}=ji(Ot);Jt(No,"replace",A),Tt(A,_o,"replace"),rt(A,Pn,"replace"),G(null)}catch(Ot){throw(!xt||te||Pt)&&(i==null||i(String(Ot))),G(String(Ot)),Ot}finally{kt.current=null,Pt&&H(!1)}};Rt?await Rn(!0):Xe&&xt&&!Le&&Rn(!1).catch(Pt=>{console.warn("[ChatSessionProvider] Background refresh failed:",Pt)})},`loadThread-${A}`)},[Tr,Jt,pt,ut,i,Tt,rt]),De=w.useCallback(async()=>{await pt(async()=>{const A=Pe.current;A&&jn(A),ot.current=null,I(null),Pe.current=null,$e.current=null,xn(),L(void 0),ee(void 0),oe(void 0),z([]);try{localStorage.removeItem("lastThreadId")}catch(N){console.warn("[ChatSessionProvider] Failed to clear lastThreadId:",N)}},"clearCurrentThread")},[xn,jn,pt]),Oe=w.useCallback(async(A,N)=>{var Q;const q=Pe.current;if(!q)throw new Error("No active thread");const te=Zr(A,N??null),le=(Q=xe.current.get(q))==null?void 0:Q.get(te);if(le){await pt(async()=>{Jt(le,"replace",q,{persist:!1})},`navigateToCheckpoint-${q}-${te}`);return}await Ae(q,A,N??void 0,!0)},[Jt,pt,Ae]),It=w.useCallback(async()=>{if(!Pe.current)throw new Error("No active thread");await Ae(Pe.current,void 0,void 0,!0)},[Ae]),dt=w.useCallback(async()=>{if(!Pe.current)throw new Error("No active thread");if(ce||!M)return;const A=ge;if(A){be(!0);try{const N=Pe.current,q=await ut({threadId:N,checkpointId:A??K??null,checkpointNs:pe??Z??null}),{latest:te,checkpoints:le,snapshots:Q}=ji(q),ze=N?xe.current.get(N):null;let Ue=le.length>0;if(Ue&&ze&&ze.size>0&&(Ue=le.some(Le=>{if(!(Le!=null&&Le.checkpointId))return!1;const Xe=Zr(Le.checkpointId,Le.checkpointNs??null);return!ze.has(Xe)})),!Ue){ye(null),oe(void 0),Y(!1),G(null);return}Jt(te,"prepend",N??void 0),N&&(Tt(N,le,"prepend"),rt(N,Q,"prepend")),G(null)}catch(N){throw G(String(N)),N}finally{be(!1)}}},[Jt,ut,M,K,Z,pe,ge,ce,Tt,rt]),ht=w.useCallback(A=>{if(A!=null&&A.threadId){if(A.checkpointId){const N=Zr(A.checkpointId,A.checkpointNs??null),q=Qt({...A,interrupt:A.interrupt??null},{cloneMessages:!0});rt(A.threadId,{[N]:q},"prepend")}Jt(A,"replace",A.threadId)}},[Jt,rt]),At=w.useCallback(async(A,N)=>{var jo;const q=Pe.current,te=(A==null?void 0:A.text)??"",le=(A==null?void 0:A.attachments)??[],Q=le.length?le:(N==null?void 0:N.attachments)??[],ze={...(N==null?void 0:N.payloadExtras)??{},...(A==null?void 0:A.payload)??{}};if(!q&&!Object.keys(ze).length&&Q.length===0&&!te.trim()){console.warn("[ChatSessionProvider] Nothing to submit - skipping");return}!q&&!ze.messages&&console.warn("[ChatSessionProvider] No thread ID - message will create new thread");const{contentParts:Ue,filesInfo:Le}=await Qg(l,Q),Xe=[...Ue];te&&te.trim()&&Xe.push({type:"text",text:te.trim()});const xt=!!q,Rt=xt?(N==null?void 0:N.checkpointId)??ie.lastCheckpointId??void 0:void 0,Rn=xt?(N==null?void 0:N.checkpointNs)??ie.lastCheckpointNs??void 0:void 0,Pt={id:((jo=crypto.randomUUID)==null?void 0:jo.call(crypto))||`user-${Date.now()}`,role:"user",content:Xe,createdAt:new Date().toISOString(),...Rt!=null?{checkpointId:Rt}:{},...Rn!=null?{checkpointNs:Rn}:{}};Xe.length>0&&He(Pt);const Ot={...Pt,content:Xe},No=Q.length>0,_o={messages:Xe.length>0?[Ot]:[],files_info:Le,...o&&No&&s?{active_agent:s}:{},...ze},Pn={threadId:q??null,payload:_o,checkpointId:Rt??null,checkpointNs:Rn??null,nodeFilter:(N==null?void 0:N.nodeFilter)??null,config:N==null?void 0:N.config,command:(N==null?void 0:N.command)??null};Pn.threadId||delete Pn.threadId,Pn.command||delete Pn.command,Ur(Pn,{onError:On=>{console.warn("[ChatSessionProvider] Stream error:",On)},onOpen:({threadId:On})=>{!Pe.current&&On&&(ie.messages.length<=1&&(ot.current=On),I(On))},onGap:nr})},[l,o,s,nr,ie.lastCheckpointId,ie.lastCheckpointNs,ie.messages.length,He,Ur]),zn=w.useCallback(async(A,N,q)=>{if(!Pe.current)throw new Error("No active thread to handle interrupt");const le=N?q??!0:!1;try{try{Be({type:"interrupt_response",payload:{interruptId:A}})}catch(Q){console.warn("[ChatSessionProvider] optimistic interrupt_response dispatch failed:",Q)}await At({payload:{}},{checkpointId:ie.lastCheckpointId??void 0,checkpointNs:ie.lastCheckpointNs??void 0,command:{kind:"resume",value:le}}),ne(null)}catch(Q){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${A}:`,Q),Q}},[Be,ie.lastCheckpointId,ie.lastCheckpointNs,At]);w.useEffect(()=>{if(a==null||a(T),T)try{localStorage.setItem("lastThreadId",T)}catch(A){console.warn("[ChatSessionProvider] Failed to persist lastThreadId:",A)}},[T,a]),w.useEffect(()=>((async()=>{try{if(jt().catch(N=>{console.error("[ChatSessionProvider] Failed to refresh threads (background):",N),i==null||i(String(N))}),!r&&!t)try{const N=localStorage.getItem("lastThreadId");N&&(I(N),n&&await Ae(N))}catch(N){console.warn("[ChatSessionProvider] Failed to restore last thread:",N)}else t&&n&&await Ae(t)}catch(N){console.error("[ChatSessionProvider] Initialization failed:",N),i==null||i(String(N))}})(),()=>{}),[]),w.useEffect(()=>{const A=Pe.current;if(!A||$e.current!==A)return;ie.messages.length&&ie.messages[ie.messages.length-1];const N=Qt({checkpointId:ie.lastCheckpointId??null,checkpointNs:ie.lastCheckpointNs??null,messages:ie.messages.slice(),nextCursor:ge??null,nextCursorNs:pe??null,interrupt:ie.pendingInterrupt??W??null}),q=et.current.get(A),te=q==null?void 0:q.snapshot,le=!te||te.messages.length!==N.messages.length||te.messages.some((Le,Xe)=>{var xt;return(Le==null?void 0:Le.id)!==((xt=N.messages[Xe])==null?void 0:xt.id)}),Q=((te==null?void 0:te.checkpointId)??null)!==N.checkpointId||((te==null?void 0:te.checkpointNs)??null)!==N.checkpointNs,ze=((te==null?void 0:te.nextCursor)??null)!==N.nextCursor||((te==null?void 0:te.nextCursorNs)??null)!==N.nextCursorNs,Ue=!Mc((te==null?void 0:te.interrupt)??null,N.interrupt??null);if(le||Q||ze||Ue){const Le={threadId:A,snapshot:N};et.current.set(A,Le),tr.current&&window.clearTimeout(tr.current),tr.current=window.setTimeout(()=>{try{v(Le,100)}catch(Xe){console.warn("[ChatSessionProvider] Failed to persist thread payload:",Xe)}},Ko)}},[ge,pe,ie.lastCheckpointId,ie.lastCheckpointNs,ie.messages,ie.pendingInterrupt,W,v]);const Bn=w.useMemo(()=>({threads:k,currentThreadId:T,setCurrentThreadId:I,isLoading:_,error:F,actions:{createThread:B,deleteThread:ae,renameThread:ke,refreshThreads:()=>jt()},persistThreadsCache:kr,hydrateFromCache:se}),[k,T,_,F,B,ae,ke,jt,kr,se,I]),$t=w.useMemo(()=>{const A=ie.lastBranch??null,N=ie.assemblingId??null,q=A||N?{branchLabel:(A==null?void 0:A.branchLabel)??null,lastBranch:A,assemblingMessageId:N}:null;return{threadId:T,messages:ie.messages,interrupt:W,checkpoint:{id:ie.lastCheckpointId??null,namespace:ie.lastCheckpointNs??null},checkpoints:$,metadata:q,isLoading:j,isHistoryLoading:ce,error:D,hasMore:M,loadOlder:dt,seedFromSnapshot:ht,clearState:xn,navigateToCheckpoint:Oe,returnToLatest:It,loadThread:Ae,clearThread:De,respondToInterrupt:zn}},[De,xn,T,W,M,ce,j,dt,Ae,ie.assemblingId,ie.lastBranch,ie.lastCheckpointId,ie.lastCheckpointNs,ie.messages,Oe,zn,It,ht,D,$]),Ao=w.useMemo(()=>({isStreaming:rr,error:S,submit:At,send:At,stop:Wr,setAuthToken:R}),[rr,S,At,Wr,R]);return c.jsx(Hx.Provider,{value:!0,children:c.jsx($c.Provider,{value:Ao,children:c.jsx(Lc.Provider,{value:Bn,children:c.jsx(Fc.Provider,{value:$t,children:e})})})})}function Yo(){const e=w.useContext(Lc);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Xo(){const e=w.useContext(Fc);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function Uc(){const e=w.useContext($c);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function Jo({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(Jg,{apiConfig:t,children:c.jsx(qx,{initialThreadId:n,autoLoadInitial:r,disableAutoRestore:o,enableFileAgentRouting:s,fileAgentId:i,onError:a,onThreadChange:l,children:e})})}function re(...e){return Em.twMerge(Tm.clsx(e))}const Gx=Ro.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"}}),Ge=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(Gx({variant:t,size:n,className:e})),ref:s,...o})});Ge.displayName="Button";const Wc=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}));Wc.displayName="Textarea";function Yx({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]),P=`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(Wc,{ref:g,value:h,onChange:k,onKeyDown:T,placeholder:t?"Edit your message...":n,className:P,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),c.jsx("div",{children:r?c.jsx(Ge,{type:"button",onClick:()=>{l==null||l()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!l,children:c.jsx(me.Square,{size:16})}):c.jsx(Ge,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||v,children:c.jsx(me.Send,{size:16})})})]})})}const Xx=w.memo(Yx),Zo=0,Un=1,Nr=2,Vc=4;function Kc(e){return()=>e}function Jx(e){e()}function qc(e,t){return n=>e(t(n))}function Gc(e,t){return()=>e(t)}function Zx(e,t){return n=>e(t,n)}function Ui(e){return e!==void 0}function Qx(...e){return()=>{e.map(Jx)}}function _r(){}function Qo(e,t){return t(e),e}function ey(e,t){return t(e)}function st(...e){return e}function Ye(e,t){return e(Un,t)}function Me(e,t){e(Zo,t)}function Wi(e){e(Nr)}function gt(e){return e(Vc)}function ve(e,t){return Ye(e,Zx(t,Zo))}function un(e,t){const n=e(Un,r=>{n(),t(r)});return n}function Yc(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Xc(e,t){return e===t}function it(e=Xc){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Te(e){return t=>n=>{e(n)&&t(n)}}function de(e){return t=>qc(t,e)}function bn(e){return t=>()=>{t(e)}}function V(e,...t){const n=ty(...t);return(r,o)=>{switch(r){case Nr:Wi(e);return;case Un:return Ye(e,n(o))}}}function wn(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 Fe(...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 ty(...e){return t=>e.reduceRight(ey,t)}function ny(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Un:return s?n===s?void 0:(r(),n=s,t=Ye(e,s),t):(r(),_r);case Nr:r(),n=null;return}}}function X(e){let t=e;const n=Ke();return(r,o)=>{switch(r){case Zo:t=o;break;case Un:{o(t);break}case Vc:return t}return n(r,o)}}function Dt(e,t){return Qo(X(t),n=>ve(e,n))}function Ke(){const e=[];return(t,n)=>{switch(t){case Zo:e.slice().forEach(r=>{r(n)});return;case Nr:e.splice(0,e.length);return;case Un:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Kt(e){return Qo(Ke(),t=>ve(e,t))}function qe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:ry(),singleton:n}}const ry=()=>Symbol();function oy(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 yt(...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&&Me(t,n)})}),function(s,i){switch(s){case Nr:{Wi(t);return}case Un:return r===o&&i(n),Ye(t,i)}}}function Ce(e,t=Xc){return V(e,it(t))}function Vi(...e){return function(t,n){switch(t){case Nr:return;case Un:return Qx(...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 sy={0:"debug",3:"error",1:"log",2:"warn"},iy=()=>typeof globalThis>"u"?window:globalThis,Wn=qe(()=>{const e=X(3);return{log:X((t,n,r=1)=>{var o;const s=(o=iy().VIRTUOSO_LOG_LEVEL)!=null?o:gt(e);r>=s&&console[sy[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 ay(e,t,n,r,o,s,i,a,l){const u=w.useCallback(d=>{const f=ly(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?Jc("column-gap",getComputedStyle(d).columnGap,o):Jc("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return Ki(u,n,l)}function ly(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 Jc(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 Zc(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 zt=qe(()=>{const e=Ke(),t=Ke(),n=X(0),r=Ke(),o=X(0),s=Ke(),i=Ke(),a=X(0),l=X(0),u=X(0),d=X(0),f=Ke(),h=Ke(),p=X(!1),v=X(!1),x=X(!1);return ve(V(e,de(({scrollTop:g})=>g)),t),ve(V(e,de(({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 Qc(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 tt(e){return e===eo}function to(e,t){if(!tt(e))return t===e.k?e.v:t<e.k?to(e.l,t):to(e.r,t)}function dn(e,t,n="k"){if(tt(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=dn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return dn(e.l,t,n)}function qt(e,t,n){return tt(e)?nu(t,n,1):t===e.k?bt(e,{k:t,v:n}):t<e.k?ru(bt(e,{l:qt(e.l,t,n)})):ru(bt(e,{r:qt(e.r,t,n)}))}function jr(){return eo}function es(e,t,n){if(tt(e))return[];const r=dn(e,t)[0];return cy(Gi(e,r,n))}function qi(e,t){if(tt(e))return eo;const{k:n,l:r,r:o}=e;if(t===n){if(tt(r))return o;if(tt(o))return r;{const[s,i]=tu(r);return ts(bt(e,{k:s,l:eu(r),v:i}))}}else return t<n?ts(bt(e,{l:qi(r,t)})):ts(bt(e,{r:qi(o,t)}))}function dr(e){return tt(e)?[]:[...dr(e.l),{k:e.k,v:e.v},...dr(e.r)]}function Gi(e,t,n){if(tt(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 ts(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 ou(bt(e,{lvl:n-1}));if(!tt(t)&&!tt(t.r))return bt(t.r,{l:bt(t,{r:t.r.l}),lvl:n,r:bt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Yi(e))return Xi(bt(e,{lvl:n-1}));if(!tt(r)&&!tt(r.l)){const o=r.l,s=Yi(o)?r.lvl-1:r.lvl;return bt(o,{l:bt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Xi(bt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function bt(e,t){return nu(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 eu(e){return tt(e.r)?e.l:ts(bt(e,{r:eu(e.r)}))}function Yi(e){return tt(e)||e.lvl>e.r.lvl}function tu(e){return tt(e.r)?[e.k,e.v]:tu(e.r)}function nu(e,t,n,r=eo,o=eo){return{k:e,l:r,lvl:n,r:o,v:t}}function ru(e){return Xi(ou(e))}function ou(e){const{l:t}=e;return!tt(t)&&t.lvl===e.lvl?bt(t,{r:bt(e,{l:t.r})}):e}function Xi(e){const{lvl:t,r:n}=e;return!tt(n)&&!tt(n.r)&&n.lvl===t&&n.r.lvl===t?bt(n,{l:bt(e,{r:n.l}),lvl:t+1}):e}function cy(e){return Qc(e,({k:t,v:n})=>({index:t,value:n}))}function su(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=qe(()=>({recalcInProgress:X(!1)}),[],{singleton:!0});function iu(e,t,n){return e[ns(e,t,n)]}function ns(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 uy(e,t,n,r){const o=ns(e,t,r),s=ns(e,n,r,o);return e.slice(o,s+1)}function Vn(e,t){return Math.round(e.getBoundingClientRect()[t])}function rs(e){return!tt(e.groupOffsetTree)}function Zi({index:e},t){return t===e?0:t<e?-1:1}function dy(){return{groupIndices:[],groupOffsetTree:jr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:jr()}}function fy(e,t){let n=tt(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),tt(e)){e=qt(e,0,s);continue}const a=es(e,i-1,o+1);if(a.some(vy(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 hy(e){return typeof e.groupIndex<"u"}function py({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}=iu(t,e,Zi),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function au(e,t){if(!rs(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function lu(e,t,n){if(hy(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=au(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function my(e,t,n,r=0){return r>0&&(t=Math.max(t,iu(e,r,Zi).offset)),Qc(uy(e,t,n,py),yy)}function gy(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&&tt(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]=fy(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 xy(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 cu(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=ns(o,t-1,Zi),a=o[l].offset;const u=dn(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===dn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:u,value:d}of es(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 yy(e){return{index:e.index,value:e}}function vy(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 by={offsetHeight:"height",offsetWidth:"width"},Sn=qe(([{log:e},{recalcInProgress:t}])=>{const n=Ke(),r=Ke(),o=Dt(r,0),s=Ke(),i=Ke(),a=X(0),l=X([]),u=X(void 0),d=X(void 0),f=X((k,T)=>Vn(k,by[T])),h=X(void 0),p=X(0),v=dy(),x=Dt(V(n,Fe(l,e,p),wn(gy,v),it()),v),g=Dt(V(l,it(),wn((k,T)=>({current:T,prev:k.current}),{current:[],prev:[]}),de(({prev:k})=>k)),[]);ve(V(l,Te(k=>k.length>0),Fe(x,p),de(([k,T,I])=>{const _=k.reduce((P,j,H)=>qt(P,j,ro(j,T.offsetTree,I)||H),jr());return{...T,groupIndices:k,groupOffsetTree:_}})),x),ve(V(r,Fe(x),Te(([k,{lastIndex:T}])=>k<T),de(([k,{lastIndex:T,lastSize:I}])=>[{endIndex:T,size:I,startIndex:k}])),n),ve(u,d);const y=Dt(V(u,de(k=>k===void 0)),!0);ve(V(d,Te(k=>k!==void 0&&tt(gt(x).sizeTree)),de(k=>[{endIndex:0,size:k,startIndex:0}])),n);const b=Kt(V(n,Fe(x),wn(({sizes:k},[T,I])=>({changed:I!==k,sizes:I}),{changed:!1,sizes:v}),de(k=>k.changed)));Ye(V(a,wn((k,T)=>({diff:k.prev-T,prev:T}),{diff:0,prev:0}),de(k=>k.diff)),k=>{const{groupIndices:T}=gt(x);if(k>0)Me(t,!0),Me(s,k+cu(k,T));else if(k<0){const I=gt(g);I.length>0&&(k-=cu(-k,I)),Me(i,k)}}),Ye(V(a,Fe(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,Fe(x),de(([k,T])=>{const I=T.groupIndices.length>0,_=[],P=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:P,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:P,ranges:[]}).ranges})),n);const E=Kt(V(i,Fe(x,p),de(([k,{offsetTree:T},I])=>{const _=-k;return ro(_,T,I)})));return ve(V(i,Fe(x,p),de(([k,T,I])=>{if(T.groupIndices.length>0){if(tt(T.sizeTree))return T;let _=jr();const P=gt(g);let j=0,H=0,F=0;for(;j<-k;){F=P[H];const U=P[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=dn(T.sizeTree,-k+1)[1];_=qt(_,1,D)}return{...T,sizeTree:_,...Qi(T.offsetTree,0,_,I)}}else{const _=dr(T.sizeTree).reduce((P,{k:j,v:H})=>qt(P,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}},st(Wn,Ji),{singleton:!0});function wy(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const uu=qe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Ke(),i=Ke(),a=Kt(V(s,de(wy)));return ve(V(a,de(l=>l.totalCount)),n),ve(V(a,de(l=>l.groupIndices)),e),ve(V(yt(o,t,r),Te(([l,u])=>rs(u)),de(([l,u,d])=>dn(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),it(),de(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},st(Sn,zt)),Kn=qe(([{log:e}])=>{const t=X(!1),n=Kt(V(t,Te(r=>r),it()));return Ye(t,r=>{r&&gt(e)("props updated",{},Wt.DEBUG)}),{didMount:n,propsReady:t}},st(Wn),{singleton:!0}),Sy=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function du(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Sy)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const oo=qe(([{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=X(0);let g=null,y=null,b=null;function C(){g&&(g(),g=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),Me(l,!1)}return ve(V(p,Fe(n,f,r,x,a,i,h),Fe(e,s,o),de(([[E,k,T,I,_,P,j,H],F,U,D])=>{const G=du(E),{align:W,behavior:ne,offset:$}=G,z=I-1,se=lu(G,k,z);let M=ro(se,k.offsetTree,F)+P;W==="end"?(M+=U+dn(k.sizeTree,se)[1]-T+D,se===z&&(M+=j)):W==="center"?M+=(U+dn(k.sizeTree,se)[1]-T+D)/2:M-=_,$&&(M+=$);const Y=ce=>{C(),ce?(H("retrying to scroll to",{location:E},Wt.DEBUG),Me(p,E)):(Me(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=un(d,()=>{Y(ce)})}else g=un(V(t,Cy(150)),Y);return y=setTimeout(()=>{C()},1200),Me(l,!0),H("scrolling from index to",{behavior:ne,index:se,top:M},Wt.DEBUG),{behavior:ne,top:M}})),u),{scrollTargetReached:v,scrollToIndex:p,topListHeight:x}},st(Sn,zt,Wn),{singleton:!0});function Cy(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=qe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=X(!0),l=X(0),u=X(!0);return ve(V(i,Fe(l),Te(([d,f])=>!!f),bn(!1)),a),ve(V(i,Fe(l),Te(([d,f])=>!!f),bn(!1)),u),Ye(V(yt(t,i),Fe(a,n,e,u),Te(([[,d],f,{sizeTree:h},p,v])=>d&&(!tt(h)||Ui(p))&&!f&&!v),Fe(l)),([,d])=>{un(o,()=>{Me(u,!0)}),ea(4,()=>{un(r,()=>{Me(a,!0)}),Me(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},st(Sn,zt,oo,Kn),{singleton:!0});function fu(e,t){return Math.abs(e-t)<1.01}const io="up",ao="down",ky="none",Ty={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Ey=0,lo=qe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=X(!1),a=X(!0),l=Ke(),u=Ke(),d=X(4),f=X(Ey),h=Dt(V(Vi(V(Ce(o),cr(1),bn(!0)),V(Ce(o),cr(1),bn(!1),Yc(100))),it()),!1),p=Dt(V(Vi(V(n,bn(!0)),V(n,bn(!1),Yc(200))),it()),!1);ve(V(yt(Ce(o),Ce(f)),de(([b,C])=>b<=C),it()),a),ve(V(a,Dn(50)),u);const v=Kt(V(yt(r,Ce(s),Ce(t),Ce(e),Ce(d)),wn((b,[{scrollHeight:C,scrollTop:E},k,T,I,_])=>{const P=E+k-C>-_,j={scrollHeight:C,scrollTop:E,viewportHeight:k};if(P){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}},Ty),it((b,C)=>b&&b.atBottom===C.atBottom))),x=Dt(V(r,wn((b,{scrollHeight:C,scrollTop:E,viewportHeight:k})=>{if(fu(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}),Te(b=>b.changed),de(b=>b.jump)),0);ve(V(v,de(b=>b.atBottom)),i),ve(V(i,Dn(50)),l);const g=X(ao);ve(V(r,de(({scrollTop:b})=>b),it(),wn((b,C)=>gt(p)?{direction:b.direction,prevScrollTop:C}:{direction:C<b.prevScrollTop?io:ao,prevScrollTop:C},{direction:ao,prevScrollTop:0}),de(b=>b.direction)),g),ve(V(r,Dn(50),bn(ky)),g);const y=X(0);return ve(V(h,Te(b=>!b),bn(0)),y),ve(V(o,Dn(100),Fe(h),Te(([b,C])=>!!C),wn(([b,C],[E])=>[C,E],[0,0]),de(([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}},st(zt)),os="top",ss="bottom",hu="none";function pu(e,t,n){return typeof e=="number"?n===io&&t===os||n===ao&&t===ss?e:0:n===io?t===os?e.main:e.reverse:t===ss?e.main:e.reverse}function mu(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const na=qe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Ke(),i=X(0),a=X(0),l=X(0),u=Dt(V(yt(Ce(r),Ce(o),Ce(n),Ce(s,no),Ce(l),Ce(i),Ce(t),Ce(e),Ce(a)),de(([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=hu;const _=mu(C,os),P=mu(C,ss);return p-=b,p+=h+y,v+=h+y,v-=b,p>d+k-_&&(I=io),v<d-T+f+P&&(I=ao),I!==hu?[Math.max(E-h-pu(x,os,I)-_,0),E-T-y+f+pu(x,ss,I)+P]:null}),Te(d=>d!=null),it(no)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},st(zt),{singleton:!0});function Iy(e,t,n){if(rs(t)){const r=au(e,t);return[{index:dn(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 is(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:xu(e,o,s),offsetBottom:v,offsetTop:u,top:p,topItems:xu(t,o,s),topListHeight:t.reduce((x,g)=>g.size+x,0),totalCount:n}}function gu(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 is(u,[],a,o,n,r)}function xu(e,t,n){if(e.length===0)return[];if(!rs(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=es(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=qe(([{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=X([]),g=X(0),y=Ke();ve(s.topItemsIndexes,x);const b=Dt(V(yt(p,v,Ce(l,no),Ce(o),Ce(r),Ce(u),d,Ce(x),Ce(t),Ce(n),e),Te(([T,I,,_,,,,,,,P])=>{const j=P&&P.length!==_;return T&&!I&&!j}),de(([,,[T,I],_,P,j,H,F,U,D,G])=>{const W=P,{offsetTree:ne,sizeTree:$}=W,z=gt(g);if(_===0)return{...ra,totalCount:_};if(T===0&&I===0)return z===0?{...ra,totalCount:_}:gu(z,j,P,U,D,G||[]);if(tt($))return z>0?null:is(Iy(ta(j,_),W,G),[],_,D,W,U);const se=[];if(F.length>0){const ge=F[0],ye=F[F.length-1];let K=0;for(const L of es($,ge,ye)){const Z=L.value,ee=Math.max(L.start,ge),pe=Math.min(L.end,ye);for(let oe=ee;oe<=pe;oe++)se.push({data:G==null?void 0:G[oe],index:oe,offset:K,size:Z}),K+=Z}}if(!H)return is([],se,_,D,W,U);const M=F.length>0?F[F.length-1]+1:0,Y=my(ne,T,I,M);if(Y.length===0)return null;const ce=_-1,be=Qo([],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 oe=Z-ye.start;L+=oe*ee+oe*D}Z<M&&(L+=(M-Z)*ee,Z=M);const pe=Math.min(ye.end,ce);for(let oe=Z;oe<=pe&&!(L>=I);oe++)ge.push({data:G==null?void 0:G[oe],index:oe,offset:L,size:ee}),L+=ee+D}});return is(be,se,_,D,W,U)}),Te(T=>T!==null),it()),ra);ve(V(e,Te(Ui),de(T=>T==null?void 0:T.length)),o),ve(V(b,de(T=>T.topListHeight)),f),ve(f,a),ve(V(b,de(T=>[T.top,T.bottom])),i),ve(V(b,de(T=>T.items)),y);const C=Kt(V(b,Te(({items:T})=>T.length>0),Fe(o,e),Te(([{items:T},I])=>T[T.length-1].originalIndex===I-1),de(([,T,I])=>[T-1,I]),it(no),de(([T])=>T))),E=Kt(V(b,Dn(200),Te(({items:T,topItems:I})=>T.length>0&&T[0].originalIndex===I.length),de(({items:T})=>T[0].index),it())),k=Kt(V(b,Te(({items:T})=>T.length>0),de(({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}}),it(su)));return{endReached:C,initialItemCount:g,itemsRendered:y,listState:b,rangeChanged:k,startReached:E,topItemsIndexes:x,...h}},st(Sn,uu,na,so,oo,lo,Kn,Ji),{singleton:!0}),yu=qe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Ke(),i=Dt(V(yt(n,e,r,t,o),de(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return ve(Ce(i),s),{totalListHeight:i,totalListHeightChanged:s}},st(zt,fr),{singleton:!0}),Ay=qe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=X(!1),r=Dt(V(yt(n,e,t),Te(([o])=>o),de(([,o,s])=>Math.max(0,o-s)),Dn(0),it()),0);return{alignToBottom:n,paddingTopAddition:r}},st(zt,yu),{singleton:!0}),vu=qe(()=>({context:X(null)})),Ny=({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,bu=qe(([{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,Fe(t,l,n,s,o,r,a),Fe(e),de(([[f,h,p,v,x,g,y,b],C])=>{const{align:E,behavior:k,calculateViewLocation:T=Ny,done:I,..._}=f,P=lu(f,h,v-1),j=ro(P,h.offsetTree,C)+x+g,H=j+dn(h.sizeTree,P)[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&&un(V(i,Te(G=>!G),cr(gt(i)?1:2)),I):I&&I(),D}),Te(f=>f!==null)),u),{scrollIntoView:d}},st(Sn,zt,oo,fr,Wn),{singleton:!0});function wu(e){return e?e==="smooth"?"smooth":"auto":!1}const _y=(e,t)=>typeof e=="function"?wu(e(t)):t&&wu(e),jy=qe(([{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=X(!1),x=Ke();let g=null;function y(k){Me(i,{align:"end",behavior:k,index:"LAST"})}Ye(V(yt(V(Ce(t),cr(1)),l),Fe(Ce(v),s,a,f),de(([[k,T],I,_,P,j])=>{let H=T&&P,F="auto";return H&&(F=_y(I,_||j),H=H&&!!F),{followOutputBehavior:F,shouldFollow:H,totalCount:k}}),Te(({shouldFollow:k})=>k)),({followOutputBehavior:k,totalCount:T})=>{g&&(g(),g=null),gt(n)?requestAnimationFrame(()=>{gt(d)("following output to ",{totalCount:T},Wt.DEBUG),y(k)}):g=un(e,()=>{gt(d)("following output to ",{totalCount:T},Wt.DEBUG),y(k),g=null})});function b(k){const T=un(o,I=>{k&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(gt(d)("scrolling to bottom due to increased size",{},Wt.DEBUG),y("auto"))});setTimeout(T,100)}Ye(V(yt(Ce(v),t,u),Te(([k,,T])=>k&&T),wn(({value:k},[,T])=>({refreshed:k===T,value:T}),{refreshed:!1,value:0}),Te(({refreshed:k})=>k),Fe(v,t)),([,k])=>{gt(a)&&b(k!==!1)}),Ye(x,()=>{b(gt(v)!==!1)}),Ye(yt(Ce(v),o),([k,T])=>{k&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const C=X(null),E=Ke();return ve(Vi(V(Ce(r),de(k=>{var T;return(T=k==null?void 0:k.length)!=null?T:0})),V(Ce(t))),E),Ye(V(yt(V(E,cr(1)),l),Fe(Ce(C),a,f,h),de(([[k,T],I,_,P,j])=>T&&_&&(I==null?void 0:I({context:j,totalCount:k,scrollingInProgress:P}))),Te(k=>!!k),Dn(0)),k=>{g&&(g(),g=null),gt(n)?requestAnimationFrame(()=>{gt(d)("scrolling into view",{}),Me(p,k)}):g=un(e,()=>{gt(d)("scrolling into view",{}),Me(p,k),g=null})}),{autoscrollToBottom:x,followOutput:v,scrollIntoViewOnChange:C}},st(Sn,lo,oo,so,Kn,Wn,zt,vu,bu)),Ry=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ve(V(a,Fe(s),Te(([,l])=>l!==0),Fe(o,r,t,n,e),de(([[,l],u,d,f,h,p=[]])=>gu(l,u,d,f,h,p))),i),{}),st(Sn,so,fr,Kn),{singleton:!0}),Py=qe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=X(0);return Ye(V(e,Fe(r),Te(([,o])=>o!==0),de(([,o])=>({top:o}))),o=>{un(V(n,cr(1),Te(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Me(t,o)})})}),{initialScrollTop:r}},st(Kn,zt,fr),{singleton:!0}),Su=qe(([{scrollVelocity:e}])=>{const t=X(!1),n=Ke(),r=X(!1);return ve(V(e,Fe(r,t,n),Te(([o,s])=>!!s),de(([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}),it()),t),Ye(V(yt(t,e,n),Fe(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},st(lo),{singleton:!0}),oa=qe(([{scrollContainerState:e,scrollTo:t}])=>{const n=Ke(),r=Ke(),o=Ke(),s=X(!1),i=X(void 0);return ve(V(yt(n,r),de(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),ve(V(t,Fe(r),de(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},st(zt)),Oy=qe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=Ke(),d=X(void 0),f=X(null),h=X(null);return ve(a,f),ve(l,h),Ye(V(u,Fe(t,r,i,f,h,n)),([p,v,x,g,y,b,C])=>{const E=xy(v.sizeTree);g&&y!==null&&b!==null&&(x=y.scrollTop-b.offsetTop),x-=C,p({ranges:E,scrollTop:x})}),ve(V(d,Te(Ui),de(My)),o),ve(V(s,Fe(d),Te(([,p])=>p!==void 0),it(),de(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},st(Sn,zt,so,Kn,oa));function My(e){return{align:"start",index:0,offset:e.scrollTop}}const Dy=qe(([{topItemsIndexes:e}])=>{const t=X(0);return ve(V(t,Te(n=>n>=0),de(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},st(fr));function Cu(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const Ly=Cu(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Fy=qe(([{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,Fe(i),wn(([,y,b,C],[{bottom:E,items:k,offsetBottom:T,totalCount:I},_])=>{const P=E+T;let j=0;return b===I&&y.length>0&&k.length>0&&(k[0].originalIndex===0&&y[0].originalIndex===0||(j=P-C,j!==0&&(j+=_))),[j,k,I,P]},[0,[],0,0]),Te(([y])=>y!==0),Fe(r,a,n,o,p,v),Te(([,y,b,C,,,E])=>!E&&!C&&y!==0&&b===io),de(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},Wt.DEBUG),y))));function g(y){y>0?(Me(t,{behavior:"auto",top:-y}),Me(e,0)):(Me(e,0),Me(t,{behavior:"auto",top:-y}))}return Ye(V(x,Fe(e,s)),([y,b,C])=>{C&&Ly()?Me(e,b-y):g(-y)}),Ye(V(yt(Dt(s,!1),e,v),Te(([y,b,C])=>!y&&!C&&b!==0),de(([y,b])=>b),Dn(1)),g),ve(V(f,de(y=>({top:-y}))),t),Ye(V(u,Fe(h,d),de(([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 P=0,j=0;for(;P<y;){P++,I+=_;let H=b.length===j+1?1/0:b[j+1]-b[j]-1;P+H>y&&(I-=_,H=y-P+1),P+=H,I+=T(H),j++}return I}})),y=>{Me(e,y),requestAnimationFrame(()=>{Me(t,{top:y}),requestAnimationFrame(()=>{Me(e,0),Me(v,!1)})})}),{deviation:e}},st(zt,lo,fr,Sn,Wn,Ji)),$y=qe(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),st(na,Ry,Kn,Su,yu,Py,Ay,oa,bu,Wn,vu)),ku=qe(([{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:_},P])=>(ve(E.rangeChanged,P.scrollSeekRangeChanged),ve(V(P.windowViewportRect,de(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,...P,...x,sizes:l,...g}),st(Sn,so,zt,Oy,jy,fr,oo,Fy,Dy,uu,$y));function zy(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 as=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Tu(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&&Me(g.propsReady,!1);for(const b of r){const C=g[t.required[b]];Me(C,y[b])}for(const b of o)if(b in y){const C=g[t.optional[b]];Me(C,y[b])}g.propsReady&&Me(g.propsReady,!0)}function u(g){return s.reduce((y,b)=>(y[b]=C=>{const E=g[t.methods[b]];Me(E,C)},y),{})}function d(g){return i.reduce((y,b)=>(y[b]=ny(g[t.events[b]]),y),{})}const f=w.forwardRef((g,y)=>{const{children:b,...C}=g,[E]=w.useState(()=>Qo(oy(e),I=>{l(I,C)})),[k]=w.useState(Gc(d,E));as(()=>{for(const I of i)I in C&&Ye(k[I],C[I]);return()=>{Object.values(k).map(Wi)}},[C,k,E]),as(()=>{l(E,C)}),w.useImperativeHandle(y,Kc(u(E)));const T=n;return c.jsx(a.Provider,{value:E,children:n?c.jsx(T,{...zy([...r,...o,...i],C),children:b}):b})}),h=g=>{const y=w.useContext(a);return w.useCallback(b=>{Me(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,()=>gt(y),()=>gt(y))},v=g=>{const y=w.useContext(a)[g],[b,C]=w.useState(Gc(gt,y));return as(()=>Ye(y,E=>{E!==b&&C(Kc(E))}),[y,b]),b},x=w.version.startsWith("18")?p:v;return{Component:f,useEmitter:(g,y)=>{const b=w.useContext(a)[g];as(()=>Ye(b,y),[y,b])},useEmitterValue:x,usePublisher:h}}const Eu=w.createContext(void 0),Iu=w.createContext(void 0),Au=typeof document<"u"?w.useLayoutEffect:w.useEffect;function sa(e){return"self"in e}function By(e){return"body"in e}function Nu(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(By(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(Vn(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=Vn(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)),fu(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",_u="sticky",aa=Cu(()=>{if(typeof document>"u")return _u;const e=document.createElement("div");return e.style.position=ia,e.style.position===ia?ia:_u});function la(e){return e}const Hy=qe(()=>{const e=X(a=>`Item ${a}`),t=X(a=>`Group ${a}`),n=X({}),r=X(la),o=X("div"),s=X(_r),i=(a,l=null)=>Dt(V(n,de(u=>u[a]),it()),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")}}),Uy=qe(([e,t])=>({...e,...t}),st(ku,Hy)),Wy=({height:e})=>c.jsx("div",{style:{height:e}}),Vy={overflowAnchor:"none",position:aa(),zIndex:1},ju={overflowAnchor:"none"},Ky={...ju,display:"inline-block",height:"100%"},Ru=w.memo(function({showTopList:e=!1}){const t=Ne("listState"),n=en("sizeRanges"),r=Ne("useWindowScroll"),o=Ne("customScrollParent"),s=en("windowScrollContainerState"),i=en("scrollContainerState"),a=o||r?s:i,l=Ne("itemContent"),u=Ne("context"),d=Ne("groupContent"),f=Ne("trackItemSizes"),h=Ne("itemSize"),p=Ne("log"),v=en("gap"),x=Ne("horizontalDirection"),{callbackRef:g}=ay(n,h,f,e?_r:a,p,v,o,x,Ne("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);ca("deviation",D=>{y!==D&&b(D)});const C=Ne("EmptyPlaceholder"),E=Ne("ScrollSeekPlaceholder")||Wy,k=Ne("ListComponent"),T=Ne("ItemComponent"),I=Ne("GroupComponent"),_=Ne("computeItemKey"),P=Ne("isSeeking"),j=Ne("groupIndices").length>0,H=Ne("alignToBottom"),F=Ne("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,{...Lt(C,u)}):c.jsx(k,{...Lt(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 P?w.createElement(E,{...Lt(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,{...Lt(I,u),"data-index":G,"data-item-index":D.index,"data-known-size":D.size,key:W,style:Vy},d(D.index,u)):w.createElement(T,{...Lt(T,u),...Xy(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?Ky:ju},j?l(D.index,D.groupIndex,D.data,u):l(D.index,D.data,u))})})}),qy={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Gy={outline:"none",overflowX:"auto",position:"relative"},ls=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Yy={position:aa(),top:0,width:"100%",zIndex:1};function Lt(e,t){if(typeof e!="string")return{context:t}}function Xy(e,t){return{item:typeof e=="string"?void 0:t}}const Jy=w.memo(function(){const e=Ne("HeaderComponent"),t=en("headerHeight"),n=Ne("HeaderFooterTag"),r=ur(w.useMemo(()=>s=>{t(Vn(s,"height"))},[t]),!0,Ne("skipAnimationFrameInResizeObserver")),o=Ne("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Lt(e,o)})}):null}),Zy=w.memo(function(){const e=Ne("FooterComponent"),t=en("footerHeight"),n=Ne("HeaderFooterTag"),r=ur(w.useMemo(()=>s=>{t(Vn(s,"height"))},[t]),!0,Ne("skipAnimationFrameInResizeObserver")),o=Ne("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Lt(e,o)})}):null});function Pu({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}=Nu(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?Gy:qy,...o},tabIndex:0,...i,...Lt(l,s),children:r})})}function Ou({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}=Nu(a,u,l,v,h);return Au(()=>{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,...Lt(l,s),children:r})})}const Qy=({children:e})=>{const t=w.useContext(Eu),n=en("viewportHeight"),r=en("fixedItemHeight"),o=Ne("alignToBottom"),s=Ne("horizontalDirection"),i=w.useMemo(()=>qc(n,l=>Vn(l,s?"width":"height")),[n,s]),a=ur(i,!0,Ne("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),c.jsx("div",{"data-viewport-type":"element",ref:a,style:ls(o),children:e})},ev=({children:e})=>{const t=w.useContext(Eu),n=en("windowViewportRect"),r=en("fixedItemHeight"),o=Ne("customScrollParent"),s=Zc(n,o,Ne("skipAnimationFrameInResizeObserver")),i=Ne("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:ls(i),children:e})},tv=({children:e})=>{const t=Ne("TopItemListComponent")||"div",n=Ne("headerHeight"),r={...Yy,marginTop:`${n}px`},o=Ne("context");return c.jsx(t,{style:r,...Lt(t,o),children:e})},nv=w.memo(function(e){const t=Ne("useWindowScroll"),n=Ne("topItemsIndexes").length>0,r=Ne("customScrollParent"),o=Ne("context");return c.jsxs(r||t?sv:ov,{...e,context:o,children:[n&&c.jsx(tv,{children:c.jsx(Ru,{showTopList:!0})}),c.jsxs(r||t?ev:Qy,{children:[c.jsx(Jy,{}),c.jsx(Ru,{}),c.jsx(Zy,{})]})]})}),{Component:rv,useEmitter:ca,useEmitterValue:Ne,usePublisher:en}=Tu(Uy,{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"}},nv),ov=Pu({useEmitter:ca,useEmitterValue:Ne,usePublisher:en}),sv=Ou({useEmitter:ca,useEmitterValue:Ne,usePublisher:en}),iv=rv;st(ku,qe(()=>{const e=X(u=>c.jsxs("td",{children:["Item $",u]})),t=X(null),n=X(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=X(null),o=X(null),s=X({}),i=X(la),a=X(_r),l=(u,d=null)=>Dt(V(s,de(f=>f[u]),it()),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 Mu={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},av={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Du,floor:cs,max:co,min:ua,round:Lu}=Math;function Fu(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function lv(e){return{...av,items:e}}function us(e,t){return e&&e.width===t.width&&e.height===t.height}function cv(e,t){return e&&e.column===t.column&&e.row===t.row}const uv=qe(([{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=X(0),I=X(0),_=X(Mu),P=X({height:0,width:0}),j=X({height:0,width:0}),H=Ke(),F=Ke(),U=X(0),D=X(null),G=X({column:0,row:0}),W=Ke(),ne=Ke(),$=X(!1),z=X(0),se=X(!0),M=X(!1),Y=X(!1);Ye(V(v,Fe(z),Te(([L,Z])=>!!Z)),()=>{Me(se,!1)}),Ye(V(yt(v,se,j,P,z,M),Te(([L,Z,ee,pe,,oe])=>L&&!Z&&ee.height!==0&&pe.height!==0&&!oe)),([,,,,L])=>{Me(M,!0),ea(1,()=>{Me(H,L)}),un(V(u),()=>{Me(t,[0,0]),Me(se,!0)})}),ve(V(ne,Te(L=>L!=null&&L.scrollTop>0),bn(0)),I),Ye(V(v,Fe(ne),Te(([,L])=>L!=null)),([,L])=>{L&&(Me(P,L.viewport),Me(j,L.item),Me(G,L.gap),L.scrollTop>0&&(Me($,!0),un(V(u,cr(1)),Z=>{Me($,!1)}),Me(l,{top:L.scrollTop})))}),ve(V(P,de(({height:L})=>L)),f),ve(V(yt(Ce(P,us),Ce(j,us),Ce(G,(L,Z)=>L&&L.column===Z.column&&L.row===Z.row),Ce(u)),de(([L,Z,ee,pe])=>({gap:ee,item:Z,scrollTop:pe,viewport:L}))),W),ve(V(yt(Ce(T),r,Ce(G,cv),Ce(j,us),Ce(P,us),Ce(D),Ce(I),Ce($),Ce(se),Ce(z)),Te(([,,,,,,,L])=>!L),de(([L,[Z,ee],pe,oe,ie,Be,Je,,je,He])=>{const{column:Qe,row:Ze}=pe,{height:Pe,width:wt}=oe,{width:Ct}=ie;if(Je===0&&(L===0||Ct===0))return Mu;if(wt===0){const ue=ta(He,L),_e=ue+Math.max(Je-1,0);return lv(Fu(ue,_e,Be))}const kt=$u(Ct,wt,Qe);let ot,et;je?Z===0&&ee===0&&Je>0?(ot=0,et=Je-1):(ot=kt*cs((Z+Ze)/(Pe+Ze)),et=kt*Du((ee+Ze)/(Pe+Ze))-1,et=ua(L-1,co(et,kt-1)),ot=ua(et,co(0,ot))):(ot=0,et=-1);const $e=Fu(ot,et,Be),{bottom:ct,top:vt}=zu(ie,pe,oe,$e),J=Du(L/kt),xe=J*Pe+(J-1)*Ze-ct;return{bottom:ct,itemHeight:Pe,items:$e,itemWidth:wt,offsetBottom:xe,offsetTop:vt,top:vt}})),_),ve(V(D,Te(L=>L!==null),de(L=>L.length)),T),ve(V(yt(P,j,_,G),Te(([L,Z,{items:ee}])=>ee.length>0&&Z.height!==0&&L.height!==0),de(([L,Z,{items:ee},pe])=>{const{bottom:oe,top:ie}=zu(L,pe,Z,ee);return[ie,oe]}),it(no)),t);const ce=X(!1);ve(V(u,Fe(ce),de(([L,Z])=>Z||L!==0)),ce);const be=Kt(V(yt(_,T),Te(([{items:L}])=>L.length>0),Fe(ce),Te(([[L,Z],ee])=>{const pe=L.items[L.items.length-1].index===Z-1;return(ee||L.bottom>0&&L.itemHeight>0&&L.offsetBottom===0&&L.items.length===Z)&&pe}),de(([[,L]])=>L-1),it())),ge=Kt(V(Ce(_),Te(({items:L})=>L.length>0&&L[0].index===0),bn(0),it())),ye=Kt(V(Ce(_),Fe($),Te(([{items:L},Z])=>L.length>0&&!Z),de(([{items:L}])=>({endIndex:L[L.length-1].index,startIndex:L[0].index})),it(su),Dn(0)));ve(ye,p.scrollSeekRangeChanged),ve(V(H,Fe(P,j,T,G),de(([L,Z,ee,pe,oe])=>{const ie=du(L),{align:Be,behavior:Je,offset:je}=ie;let He=ie.index;He==="LAST"&&(He=pe-1),He=co(0,He,ua(pe-1,He));let Qe=da(Z,oe,ee,He);return Be==="end"?Qe=Lu(Qe-Z.height+ee.height):Be==="center"&&(Qe=Lu(Qe-Z.height/2+ee.height/2)),je&&(Qe+=je),{behavior:Je,top:Qe}})),l);const K=Dt(V(_,de(L=>L.offsetBottom+L.bottom)),0);return ve(V(E,de(L=>({height:L.visibleHeight,width:L.visibleWidth}))),P),{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:P,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}},st(na,zt,lo,Su,Kn,oa,Wn));function $u(e,t,n){return co(1,cs((e+n)/(cs(t)+n)))}function zu(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=$u(e.width,n.width,t.column),s=cs(r/o),i=s*n.height+co(0,s-1)*t.row;return i>0?i+t.row:i}const dv=qe(()=>{const e=X(f=>`Item ${f}`),t=X({}),n=X(null),r=X("virtuoso-grid-item"),o=X("virtuoso-grid-list"),s=X(la),i=X("div"),a=X(_r),l=(f,h=null)=>Dt(V(t,de(p=>p[f]),it()),h),u=X(!1),d=X(!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")}}),fv=qe(([e,t])=>({...e,...t}),st(uv,dv)),hv=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:Hu("column-gap",getComputedStyle(y).columnGap,p),row:Hu("row-gap",getComputedStyle(y).rowGap,p)})},[i,f,h,p]),!0,!1);return Au(()=>{e.itemHeight>0&&e.itemWidth>0&&x(!0)},[e]),v?null:c.jsx(l,{className:t,ref:g,...Lt(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,{...Lt(u,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{...Lt(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),pv=w.memo(function(){const e=lt("HeaderComponent"),t=tn("headerHeight"),n=lt("headerFooterTag"),r=ur(w.useMemo(()=>s=>{t(Vn(s,"height"))},[t]),!0,!1),o=lt("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Lt(e,o)})}):null}),mv=w.memo(function(){const e=lt("FooterComponent"),t=tn("footerHeight"),n=lt("headerFooterTag"),r=ur(w.useMemo(()=>s=>{t(Vn(s,"height"))},[t]),!0,!1),o=lt("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Lt(e,o)})}):null}),gv=({children:e})=>{const t=w.useContext(Iu),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:ls(!1),children:e})},xv=({children:e})=>{const t=w.useContext(Iu),n=tn("windowViewportRect"),r=tn("itemDimensions"),o=lt("customScrollParent"),s=Zc(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:ls(!1),children:e})},yv=w.memo(function({...e}){const t=lt("useWindowScroll"),n=lt("customScrollParent"),r=n||t?bv:vv,o=n||t?xv:gv,s=lt("context");return c.jsx(r,{...e,...Lt(r,s),children:c.jsxs(o,{children:[c.jsx(pv,{}),c.jsx(hv,{}),c.jsx(mv,{})]})})}),{useEmitter:Bu,useEmitterValue:lt,usePublisher:tn}=Tu(fv,{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"}},yv),vv=Pu({useEmitter:Bu,useEmitterValue:lt,usePublisher:tn}),bv=Ou({useEmitter:Bu,useEmitterValue:lt,usePublisher:tn});function Hu(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 wv=Ro.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 Uu({className:e,variant:t,...n}){return c.jsx("div",{className:re(wv({variant:t}),e),...n})}function he(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 Sv(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 Cn(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,Cv(o,...t)]}function Cv(...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 St=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},kv=m[" useInsertionEffect ".trim().toString()]||St;function hr({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Tv({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=Ev(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 Tv({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return kv(()=>{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 Ev(e){return typeof e=="function"}function Wu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function fa(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Wu(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():Wu(e[o],null)}}}}function We(...e){return m.useCallback(fa(...e),e)}var Iv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ee=Iv.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 Vu(e,t){e&&Po.flushSync(()=>e.dispatchEvent(t))}function Av(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Gt=e=>{const{present:t,children:n}=e,r=Nv(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=We(r.ref,_v(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};Gt.displayName="Presence";function Nv(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Av(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=ds(r.current);s.current=a==="mounted"?u:"none"},[a]),St(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,p=ds(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]),St(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const x=ds(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=ds(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 ds(e){return(e==null?void 0:e.animationName)||"none"}function _v(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 jv=m[" useId ".trim().toString()]||(()=>{}),Rv=0;function kn(e){const[t,n]=m.useState(jv());return St(()=>{n(r=>r??String(Rv++))},[e]),e||(t?`radix-${t}`:"")}var fs="Collapsible",[Pv,vT]=Cn(fs),[Ov,ha]=Pv(fs),Ku=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:fs});return c.jsx(Ov,{scope:n,disabled:s,contentId:kn(),open:l,onOpenToggle:m.useCallback(()=>u(d=>!d),[u]),children:c.jsx(Ee.div,{"data-state":ma(l),"data-disabled":s?"":void 0,...a,ref:t})})});Ku.displayName=fs;var qu="CollapsibleTrigger",Gu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=ha(qu,n);return c.jsx(Ee.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":ma(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:he(e.onClick,o.onOpenToggle)})});Gu.displayName=qu;var pa="CollapsibleContent",Mv=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=ha(pa,e.__scopeCollapsible);return c.jsx(Gt,{present:n||o.open,children:({present:s})=>c.jsx(Dv,{...r,ref:t,present:s})})});Mv.displayName=pa;var Dv=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=ha(pa,n),[a,l]=m.useState(r),u=m.useRef(null),d=We(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)},[]),St(()=>{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(Ee.div,{"data-state":ma(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 ma(e){return e?"open":"closed"}var Lv=Ku;const Fv=Lv,$v=Gu,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 Yu=m.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:re("text-sm text-muted-foreground",e),...t}));Yu.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 Xu=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:re("flex items-center p-6 pt-0",e),...t}));Xu.displayName="CardFooter";function Ju(){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=Ju();function zv(e){pr=e}const Zu=/[&<>"']/,Bv=new RegExp(Zu.source,"g"),Qu=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Hv=new RegExp(Qu.source,"g"),Uv={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ed=e=>Uv[e];function Ft(e,t){if(t){if(Zu.test(e))return e.replace(Bv,ed)}else if(Qu.test(e))return e.replace(Hv,ed);return e}const Wv=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function td(e){return e.replace(Wv,(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 Vv=/(^|[^\[])\^/g;function nt(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(Vv,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const Kv=/[^\w:]/g,qv=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function nd(e,t,n){if(e){let r;try{r=decodeURIComponent(td(n)).replace(Kv,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!qv.test(n)&&(n=Jv(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const hs={},Gv=/^[^:]+:\/*[^/]*$/,Yv=/^([^:]+:)[\s\S]*$/,Xv=/^([^:]+:\/*[^/]*)[\s\S]*$/;function Jv(e,t){hs[" "+e]||(Gv.test(e)?hs[" "+e]=e+"/":hs[" "+e]=ms(e,"/",!0)),e=hs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(Yv,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(Xv,"$1")+t:e+t}const ps={exec:function(){}};function rd(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 ms(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 Zv(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 Qv(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 od(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function sd(e,t,n,r){const o=t.href,s=t.title?Ft(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:Ft(i)}}function eb(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
- `)}class ga{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=rb(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(`
40
+ `)}class ga{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:ms(r,`
41
+ `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=eb(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=ms(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: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=tb(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 ob(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 ga,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]):Ft(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:rd(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]=rd(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:Ft(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]):Ft(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=ms(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=Zv(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)),sd(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 sd(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=Ft(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=Ft(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Ft(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=Ft(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=Ft(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]):Ft(r[0]):r[0]:o=Ft(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:ps,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=nt(we.def).replace("label",we._label).replace("title",we._title).getRegex(),we.bullet=/(?:[*+-]|\d{1,9}[.)])/,we.listItemStart=nt(/^( *)(bull) */).replace("bull",we.bullet).getRegex(),we.list=nt(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=nt(we.html,"i").replace("comment",we._comment).replace("tag",we._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),we.paragraph=nt(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=nt(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=nt(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=nt(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:nt(`^ *(?: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:ps,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:nt(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 fe={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:ps,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:ps,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};fe._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",fe.punctuation=nt(fe.punctuation).replace(/punctuation/g,fe._punctuation).getRegex(),fe.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,fe.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,fe._comment=nt(we._comment).replace("(?:-->|$)","-->").getRegex(),fe.emStrong.lDelim=nt(fe.emStrong.lDelim).replace(/punct/g,fe._punctuation).getRegex(),fe.emStrong.rDelimAst=nt(fe.emStrong.rDelimAst,"g").replace(/punct/g,fe._punctuation).getRegex(),fe.emStrong.rDelimUnd=nt(fe.emStrong.rDelimUnd,"g").replace(/punct/g,fe._punctuation).getRegex(),fe._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,fe._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,fe._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])?)+(?![-_])/,fe.autolink=nt(fe.autolink).replace("scheme",fe._scheme).replace("email",fe._email).getRegex(),fe._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,fe.tag=nt(fe.tag).replace("comment",fe._comment).replace("attribute",fe._attribute).getRegex(),fe._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,fe._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,fe._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,fe.link=nt(fe.link).replace("label",fe._label).replace("href",fe._href).replace("title",fe._title).getRegex(),fe.reflink=nt(fe.reflink).replace("label",fe._label).replace("ref",we._label).getRegex(),fe.nolink=nt(fe.nolink).replace("ref",we._label).getRegex(),fe.reflinkSearch=nt(fe.reflinkSearch,"g").replace("reflink",fe.reflink).replace("nolink",fe.nolink).getRegex(),fe.normal={...fe},fe.pedantic={...fe.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:nt(/^!?\[(label)\]\((.*?)\)/).replace("label",fe._label).getRegex(),reflink:nt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",fe._label).getRegex()},fe.gfm={...fe.normal,escape:nt(fe.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},fe.gfm.url=nt(fe.gfm.url,"i").replace("email",fe.gfm._extended_email).getRegex(),fe.breaks={...fe.gfm,br:nt(fe.br).replace("{2,}","*").getRegex(),text:nt(fe.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function tb(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 id(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 qn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||pr,this.options.tokenizer=this.options.tokenizer||new ga,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:fe.normal};this.options.pedantic?(n.block=we.pedantic,n.inline=fe.pedantic):this.options.gfm&&(n.block=we.gfm,this.options.breaks?n.inline=fe.breaks:n.inline=fe.gfm),this.tokenizer.rules=n}static get rules(){return{block:we,inline:fe}}static lex(t,n){return new qn(n).lex(t)}static lexInline(t,n){return new qn(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,9 +58,9 @@ 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)+"["+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,ob)){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 xa{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
- `,o?'<pre><code class="'+this.options.langPrefix+Lt(o)+'">'+(r?t:Lt(t,!0))+`</code></pre>
63
- `:"<pre><code>"+(r?t:Lt(t,!0))+`</code></pre>
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)+"["+od("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)+"["+od("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,id)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,id))){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,tb)){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 xa{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
+ `,o?'<pre><code class="'+this.options.langPrefix+Ft(o)+'">'+(r?t:Ft(t,!0))+`</code></pre>
63
+ `:"<pre><code>"+(r?t:Ft(t,!0))+`</code></pre>
64
64
  `}blockquote(t){return`<blockquote>
65
65
  ${t}</blockquote>
66
66
  `}html(t){return t}heading(t,n,r,o){if(this.options.headerIds){const s=this.options.headerPrefix+o.slug(r);return`<h${n} id="${s}">${t}</h${n}>
@@ -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=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 xa,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,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,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&&(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 j='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(j);return}else throw new Error(j)}}}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 sb(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=sb(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(nb(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},Uv(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 xa;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 ga;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=xa,Se.TextRenderer=dd,Se.Lexer=Yn,Se.lexer=Yn.lex,Se.Tokenizer=ga,Se.Slugger=fd,Se.Hooks=xs,Se.parse=Se,Se.options,Se.setOptions,Se.use,Se.walkTokens,Se.parseInline,Xn.parse,Yn.lex;function ya({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 ib(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 ab(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await ln("/files",{params:r})}const lb=1,cb=1e6;let va=0;function ub(){return va=(va+1)%Number.MAX_SAFE_INTEGER,va.toString()}const ba=new Map,gd=e=>{if(ba.has(e))return;const t=setTimeout(()=>{ba.delete(e),mo({type:"REMOVE_TOAST",toastId:e})},cb);ba.set(e,t)},db=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,lb)};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=db(vs,e),ys.forEach(t=>{t(vs)})}function fb({...e}){const t=ub(),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 wa(){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:fb,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 hb(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 pb="DismissableLayer",Sa="dismissableLayer.update",mb="dismissableLayer.pointerDownOutside",gb="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,T=vb(I=>{const j=I.target,R=[...u.branches].some(_=>_.contains(j));!E||R||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},h),k=bb(I=>{const j=I.target;[...u.branches].some(_=>_.contains(j))||(s==null||s(I),i==null||i(I),I.defaultPrevented||a==null||a())},h);return hb(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(Sa,I),()=>document.removeEventListener(Sa,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=pb;var xb="DismissableLayerBranch",yb=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})});yb.displayName=xb;function vb(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(mb,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 bb(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(gb,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(Sa);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 Ca="focusScope.autoFocusOnMount",Ta="focusScope.autoFocusOnUnmount",wd={bubbles:!1,cancelable:!0},wb="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){Td.add(p);const x=document.activeElement;if(!a.contains(x)){const y=new CustomEvent(Ca,wd);a.addEventListener(Ca,u),a.dispatchEvent(y),y.defaultPrevented||(Sb(Ib(Sd(a)),{select:!0}),document.activeElement===x&&Jn(a))}return()=>{a.removeEventListener(Ca,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),Td.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]=Cb(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=wb;function Sb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Jn(r,{select:t}),document.activeElement!==n)return}function Cb(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(!Tb(n,{upTo:t}))return n}function Tb(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 Td=Eb();function Eb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=kd(e,t),e.unshift(t)},remove(t){var n;e=kd(e,t),(n=e[0])==null||n.resume()}}}function kd(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Ib(e){return e.filter(t=>t.tagName!=="A")}var Nb="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=Nb;var ka=0;function Ea(){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()),ka++,()=>{ka===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),ka--}},[])}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 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 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 Ab(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",jb="with-scroll-bars-hidden",_b="--removed-body-scroll-bar-size";function Ia(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Rb(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 Pb=typeof window<"u"?m.useLayoutEffect:m.useEffect,Nd=new WeakMap;function Ob(e,t){var n=Rb(null,function(r){return e.forEach(function(o){return Ia(o,r)})});return Pb(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)||Ia(a,null)}),s.forEach(function(a){o.has(a)||Ia(a,i)})}Nd.set(n,e)},[e]),n}function Mb(e){return e}function Db(e,t){t===void 0&&(t=Mb);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 Lb(e){e===void 0&&(e={});var t=Db(null);return t.options=Tn({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,Tn({},n))};Ad.isSideCarExport=!0;function Fb(e,t){return e.useMedium(t),Ad}var jd=Lb(),Na=function(){},ks=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:Na,onWheelCapture:Na,onTouchMoveCapture:Na}),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"]),T=h,k=Ob([n,t]),I=Tn(Tn({},E),o);return m.createElement(m.Fragment,null,d&&m.createElement(T,{sideCar:jd,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 $b=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function zb(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=$b();return t&&e.setAttribute("nonce",t),e}function Bb(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Hb(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Ub=function(){var e=0,t=null;return{add:function(n){e==0&&(t=zb())&&(Bb(t,n),Hb(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Wb=function(){var e=Ub();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},_d=function(){var e=Wb(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Vb={left:0,top:0,right:0,gap:0},Aa=function(e){return parseInt(e||"",10)||0},Kb=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[Aa(n),Aa(r),Aa(o)]},qb=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Vb;var t=Kb(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])}},Gb=_d(),Rr="data-scroll-locked",Yb=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(jb,` {
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=nd(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=nd(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 ad{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 ld{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 Gn{constructor(t){this.options=t||pr,this.options.renderer=this.options.renderer||new xa,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new ad,this.slugger=new ld}static parse(t,n){return new Gn(n).parse(t)}static parseInline(t,n){return new Gn(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,td(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 gs{constructor(t){this.options=t||pr}preprocess(t){return t}postprocess(t){return t}}Cm(gs,"passThroughHooks",new Set(["preprocess","postprocess"]));function nb(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>"+Ft(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 cd(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...Se.defaults,...s};const i=nb(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(Qv(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 cd(qn.lex,Gn.parse)(e,t,n)}Se.options=Se.setOptions=function(e){return Se.defaults={...Se.defaults,...e},zv(Se.defaults),Se},Se.getDefaults=Ju,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 xa;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 ga;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 gs;for(const s in n.hooks){const i=o[s];gs.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=cd(qn.lexInline,Gn.parseInline),Se.Parser=Gn,Se.parser=Gn.parse,Se.Renderer=xa,Se.TextRenderer=ad,Se.Lexer=qn,Se.lexer=qn.lex,Se.Tokenizer=ga,Se.Slugger=ld,Se.Hooks=gs,Se.parse=Se,Se.options,Se.setOptions,Se.use,Se.walkTokens,Se.parseInline,Gn.parse,qn.lex;function ya({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 ud(e,t){return await cn(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function dd(e,t){return await(await ud(`/files/${e}/view`,t)).text()}async function rb(e,t){const n=await ud(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await cn(`/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 ob(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await cn("/files",{params:r})}const sb=1,ib=1e6;let va=0;function ab(){return va=(va+1)%Number.MAX_SAFE_INTEGER,va.toString()}const ba=new Map,fd=e=>{if(ba.has(e))return;const t=setTimeout(()=>{ba.delete(e),mo({type:"REMOVE_TOAST",toastId:e})},ib);ba.set(e,t)},lb=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,sb)};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?fd(n):e.toasts.forEach(r=>{fd(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)}}},xs=[];let ys={toasts:[]};function mo(e){ys=lb(ys,e),xs.forEach(t=>{t(ys)})}function cb({...e}){const t=ab(),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 wa(){const[e,t]=m.useState(ys);return m.useEffect(()=>(xs.push(t),()=>{const n=xs.indexOf(t);n>-1&&xs.splice(n,1)}),[e]),{...e,toast:cb,dismiss:n=>mo({type:"DISMISS_TOAST",toastId:n})}}function _t(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 ub(e,t=globalThis==null?void 0:globalThis.document){const n=_t(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 db="DismissableLayer",Sa="dismissableLayer.update",fb="dismissableLayer.pointerDownOutside",hb="dismissableLayer.focusOutside",hd,pd=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),vs=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=m.useContext(pd),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),v=We(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=gb(I=>{const _=I.target,P=[...u.branches].some(j=>j.contains(_));!E||P||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},h),T=xb(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 ub(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&&(hd=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),md(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=hd)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),md())},[d,u]),m.useEffect(()=>{const I=()=>p({});return document.addEventListener(Sa,I),()=>document.removeEventListener(Sa,I)},[]),c.jsx(Ee.div,{...l,ref:v,style:{pointerEvents:C?E?"auto":"none":void 0,...e.style},onFocusCapture:he(e.onFocusCapture,T.onFocusCapture),onBlurCapture:he(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:he(e.onPointerDownCapture,k.onPointerDownCapture)})});vs.displayName=db;var pb="DismissableLayerBranch",mb=m.forwardRef((e,t)=>{const n=m.useContext(pd),r=m.useRef(null),o=We(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(Ee.div,{...e,ref:o})});mb.displayName=pb;function gb(e,t=globalThis==null?void 0:globalThis.document){const n=_t(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){gd(fb,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 xb(e,t=globalThis==null?void 0:globalThis.document){const n=_t(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&gd(hb,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 md(){const e=new CustomEvent(Sa);document.dispatchEvent(e)}function gd(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?Vu(o,s):o.dispatchEvent(s)}var Ca="focusScope.autoFocusOnMount",ka="focusScope.autoFocusOnUnmount",xd={bubbles:!1,cancelable:!0},yb="FocusScope",bs=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=m.useState(null),u=_t(o),d=_t(s),f=m.useRef(null),h=We(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:Yn(f.current,{select:!0})},g=function(C){if(p.paused||!a)return;const E=C.relatedTarget;E!==null&&(a.contains(E)||Yn(f.current,{select:!0}))},y=function(C){if(document.activeElement===document.body)for(const k of C)k.removedNodes.length>0&&Yn(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){bd.add(p);const x=document.activeElement;if(!a.contains(x)){const y=new CustomEvent(Ca,xd);a.addEventListener(Ca,u),a.dispatchEvent(y),y.defaultPrevented||(vb(kb(yd(a)),{select:!0}),document.activeElement===x&&Yn(a))}return()=>{a.removeEventListener(Ca,u),setTimeout(()=>{const y=new CustomEvent(ka,xd);a.addEventListener(ka,d),a.dispatchEvent(y),y.defaultPrevented||Yn(x??document.body,{select:!0}),a.removeEventListener(ka,d),bd.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]=bb(b);C&&E?!x.shiftKey&&y===E?(x.preventDefault(),n&&Yn(C,{select:!0})):x.shiftKey&&y===C&&(x.preventDefault(),n&&Yn(E,{select:!0})):y===b&&x.preventDefault()}},[n,r,p.paused]);return c.jsx(Ee.div,{tabIndex:-1,...i,ref:h,onKeyDown:v})});bs.displayName=yb;function vb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Yn(r,{select:t}),document.activeElement!==n)return}function bb(e){const t=yd(e),n=vd(t,e),r=vd(t.reverse(),e);return[n,r]}function yd(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 vd(e,t){for(const n of e)if(!wb(n,{upTo:t}))return n}function wb(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 Sb(e){return e instanceof HTMLInputElement&&"select"in e}function Yn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Sb(e)&&t&&e.select()}}var bd=Cb();function Cb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=wd(e,t),e.unshift(t)},remove(t){var n;e=wd(e,t),(n=e[0])==null||n.resume()}}}function wd(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 Tb="Portal",ws=m.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=m.useState(!1);St(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?pi.createPortal(c.jsx(Ee.div,{...r,ref:t}),i):null});ws.displayName=Tb;var Ta=0;function Ea(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Sd()),document.body.insertAdjacentElement("beforeend",e[1]??Sd()),Ta++,()=>{Ta===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Ta--}},[])}function Sd(){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 Cd(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 Eb(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 Ss="right-scroll-bar-position",Cs="width-before-scroll-bar",Ib="with-scroll-bars-hidden",Ab="--removed-body-scroll-bar-size";function Ia(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Nb(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 _b=typeof window<"u"?m.useLayoutEffect:m.useEffect,kd=new WeakMap;function jb(e,t){var n=Nb(null,function(r){return e.forEach(function(o){return Ia(o,r)})});return _b(function(){var r=kd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Ia(a,null)}),s.forEach(function(a){o.has(a)||Ia(a,i)})}kd.set(n,e)},[e]),n}function Rb(e){return e}function Pb(e,t){t===void 0&&(t=Rb);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 Ob(e){e===void 0&&(e={});var t=Pb(null);return t.options=Tn({async:!0,ssr:!1},e),t}var Td=function(e){var t=e.sideCar,n=Cd(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))};Td.isSideCarExport=!0;function Mb(e,t){return e.useMedium(t),Td}var Ed=Ob(),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=Cd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=h,T=jb([n,t]),I=Tn(Tn({},E),o);return m.createElement(m.Fragment,null,d&&m.createElement(k,{sideCar:Ed,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:T})):m.createElement(b,Tn({},I,{className:l,ref:T}),a))});ks.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ks.classNames={fullWidth:Cs,zeroRight:Ss};var Db=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Lb(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Db();return t&&e.setAttribute("nonce",t),e}function Fb(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function $b(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var zb=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Lb())&&(Fb(t,n),$b(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Bb=function(){var e=zb();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Id=function(){var e=Bb(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Hb={left:0,top:0,right:0,gap:0},Na=function(e){return parseInt(e||"",10)||0},Ub=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[Na(n),Na(r),Na(o)]},Wb=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Hb;var t=Ub(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])}},Vb=Id(),Rr="data-scroll-locked",Kb=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(Ib,` {
85
85
  overflow: hidden `).concat(r,`;
86
86
  padding-right: `).concat(a,"px ").concat(r,`;
87
87
  }
@@ -98,37 +98,36 @@ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An err
98
98
  `),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
99
99
  }
100
100
 
101
- .`).concat(Cs,` {
101
+ .`).concat(Ss,` {
102
102
  right: `).concat(a,"px ").concat(r,`;
103
103
  }
104
104
 
105
- .`).concat(Ts,` {
105
+ .`).concat(Cs,` {
106
106
  margin-right: `).concat(a,"px ").concat(r,`;
107
107
  }
108
108
 
109
- .`).concat(Cs," .").concat(Cs,` {
109
+ .`).concat(Ss," .").concat(Ss,` {
110
110
  right: 0 `).concat(r,`;
111
111
  }
112
112
 
113
- .`).concat(Ts," .").concat(Ts,` {
113
+ .`).concat(Cs," .").concat(Cs,` {
114
114
  margin-right: 0 `).concat(r,`;
115
115
  }
116
116
 
117
117
  body[`).concat(Rr,`] {
118
- `).concat(_b,": ").concat(a,`px;
118
+ `).concat(Ab,": ").concat(a,`px;
119
119
  }
120
- `)},Rd=function(){var e=parseInt(document.body.getAttribute(Rr)||"0",10);return isFinite(e)?e:0},Xb=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())}},[])},Jb=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Xb();var s=m.useMemo(function(){return qb(o)},[o]);return m.createElement(Gb,{styles:Yb(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,Zb=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&&!Zb(e)&&n[t]==="visible")},Qb=function(e){return Pd(e,"overflowY")},ew=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},tw=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},nw=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Md=function(e,t){return e==="v"?Qb(t):ew(t)},Dd=function(e,t){return e==="v"?tw(t):nw(t)},rw=function(e,t){return e==="h"&&t==="rtl"?-1:1},ow=function(e,t,n,r,o){var s=rw(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},sw=function(e,t){return e[0]===t[0]&&e[1]===t[1]},iw=function(e){return`
120
+ `)},Ad=function(){var e=parseInt(document.body.getAttribute(Rr)||"0",10);return isFinite(e)?e:0},qb=function(){m.useEffect(function(){return document.body.setAttribute(Rr,(Ad()+1).toString()),function(){var e=Ad()-1;e<=0?document.body.removeAttribute(Rr):document.body.setAttribute(Rr,e.toString())}},[])},Gb=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;qb();var s=m.useMemo(function(){return Wb(o)},[o]);return m.createElement(Vb,{styles:Kb(s,!t,o,n?"":"!important")})},_a=!1;if(typeof window<"u")try{var Ts=Object.defineProperty({},"passive",{get:function(){return _a=!0,!0}});window.addEventListener("test",Ts,Ts),window.removeEventListener("test",Ts,Ts)}catch{_a=!1}var Pr=_a?{passive:!1}:!1,Yb=function(e){return e.tagName==="TEXTAREA"},Nd=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Yb(e)&&n[t]==="visible")},Xb=function(e){return Nd(e,"overflowY")},Jb=function(e){return Nd(e,"overflowX")},_d=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=jd(e,r);if(o){var s=Rd(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Zb=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Qb=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},jd=function(e,t){return e==="v"?Xb(t):Jb(t)},Rd=function(e,t){return e==="v"?Zb(t):Qb(t)},ew=function(e,t){return e==="h"&&t==="rtl"?-1:1},tw=function(e,t,n,r,o){var s=ew(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=Rd(e,a),v=p[0],x=p[1],g=p[2],y=x-g-s*v;(v||y)&&jd(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},Es=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Pd=function(e){return[e.deltaX,e.deltaY]},Od=function(e){return e&&"current"in e?e.current:e},nw=function(e,t){return e[0]===t[0]&&e[1]===t[1]},rw=function(e){return`
121
121
  .block-interactivity-`.concat(e,` {pointer-events: none;}
122
122
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
123
- `)},aw=0,Or=[];function lw(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(aw++)[0],s=m.useState(_d)[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=Ab([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],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 j=Od(I,k);if(!j)return!0;if(j?T=I:(T=I==="v"?"h":"v",j=Od(I,k)),!j)return!1;if(!r.current&&"changedTouches"in x&&(C||E)&&(r.current=T),!T)return!0;var R=r.current||T;return ow(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(T){return T.name===g.type&&(T.target===g.target||g.target===T.shadowParent)&&sw(T.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(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:cw(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:iw(o)}):null,p?m.createElement(Jb,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function cw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const uw=Fb(jd,lw);var Ns=m.forwardRef(function(e,t){return m.createElement(ks,Tn({},e,{ref:t,sideCar:uw}))});Ns.classNames=ks.classNames;var dw=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,js={},_a=0,$d=function(e){return e&&(e.host||$d(e.parentNode))},fw=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})},hw=function(e,t,n,r){var o=fw(t,Array.isArray(e)?e:[e]);js[n]||(js[n]=new WeakMap);var s=js[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(),_a++,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)}),_a--,_a||(Mr=new WeakMap,Mr=new WeakMap,As=new WeakMap,js={})}},Ra=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=dw(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),hw(r,o,n,"aria-hidden")):function(){return null}},_s="Dialog",[zd,Ck]=Sn(_s),[pw,dn]=zd(_s),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:_s});return c.jsx(pw,{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=_s;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":Ma(o.open),...r,ref:s,onClick:pe(e.onClick,o.onOpenToggle)})});Ud.displayName=Hd;var Pa="DialogPortal",[mw,Wd]=zd(Pa,{forceMount:void 0}),Vd=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=dn(Pa,t);return c.jsx(mw,{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=Pa;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(xw,{...o,ref:t})}):null});Kd.displayName=Rs;var gw=or.createSlot("DialogOverlay.RemoveScroll"),xw=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Rs,n);return c.jsx(Ns,{as:gw,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(Ie.div,{"data-state":Ma(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(yw,{...o,ref:t}):c.jsx(vw,{...o,ref:t})})});qd.displayName=mr;var yw=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 Ra(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())})}),vw=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 Ea(),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":Ma(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(bw,{titleId:a.titleId}),c.jsx(Sw,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Oa="DialogTitle",Yd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Oa,n);return c.jsx(Ie.h2,{id:o.titleId,...r,ref:t})});Yd.displayName=Oa;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 Ma(e){return e?"open":"closed"}var ef="DialogTitleWarning",[Tk,tf]=Iv(ef,{contentName:mr,titleName:Oa,docsSlug:"dialog"}),bw=({titleId:e})=>{const t=tf(ef),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
123
+ `)},ow=0,Or=[];function sw(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(ow++)[0],s=m.useState(Id)[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=Eb([e.lockRef.current],(e.shards||[]).map(Od),!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=Es(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 _=_d(I,T);if(!_)return!0;if(_?k=I:(k=I==="v"?"h":"v",_=_d(I,T)),!_)return!1;if(!r.current&&"changedTouches"in x&&(C||E)&&(r.current=k),!k)return!0;var P=r.current||k;return tw(P,g,x,P==="h"?C:E)},[]),l=m.useCallback(function(x){var g=x;if(!(!Or.length||Or[Or.length-1]!==s)){var y="deltaY"in g?Pd(g):Es(g),b=t.current.filter(function(k){return k.name===g.type&&(k.target===g.target||g.target===k.shadowParent)&&nw(k.delta,y)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}if(!b){var C=(i.current.shards||[]).map(Od).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:iw(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=Es(x),r.current=void 0},[]),f=m.useCallback(function(x){u(x.type,Pd(x),x.target,a(x,e.lockRef.current))},[]),h=m.useCallback(function(x){u(x.type,Es(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:rw(o)}):null,p?m.createElement(Gb,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function iw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const aw=Mb(Ed,sw);var Is=m.forwardRef(function(e,t){return m.createElement(ks,Tn({},e,{ref:t,sideCar:aw}))});Is.classNames=ks.classNames;var lw=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,Ns={},ja=0,Md=function(e){return e&&(e.host||Md(e.parentNode))},cw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Md(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})},uw=function(e,t,n,r){var o=cw(t,Array.isArray(e)?e:[e]);Ns[n]||(Ns[n]=new WeakMap);var s=Ns[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(),ja++,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)}),ja--,ja||(Mr=new WeakMap,Mr=new WeakMap,As=new WeakMap,Ns={})}},Ra=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=lw(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),uw(r,o,n,"aria-hidden")):function(){return null}},_s="Dialog",[Dd,bT]=Cn(_s),[dw,fn]=Dd(_s),Ld=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:_s});return c.jsx(dw,{scope:t,triggerRef:a,contentRef:l,contentId:kn(),titleId:kn(),descriptionId:kn(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Ld.displayName=_s;var Fd="DialogTrigger",$d=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(Fd,n),s=We(t,o.triggerRef);return c.jsx(Ee.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ma(o.open),...r,ref:s,onClick:he(e.onClick,o.onOpenToggle)})});$d.displayName=Fd;var Pa="DialogPortal",[fw,zd]=Dd(Pa,{forceMount:void 0}),Bd=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=fn(Pa,t);return c.jsx(fw,{scope:t,forceMount:n,children:m.Children.map(r,i=>c.jsx(Gt,{present:n||s.open,children:c.jsx(ws,{asChild:!0,container:o,children:i})}))})};Bd.displayName=Pa;var js="DialogOverlay",Hd=m.forwardRef((e,t)=>{const n=zd(js,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=fn(js,e.__scopeDialog);return s.modal?c.jsx(Gt,{present:r||s.open,children:c.jsx(pw,{...o,ref:t})}):null});Hd.displayName=js;var hw=or.createSlot("DialogOverlay.RemoveScroll"),pw=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(js,n);return c.jsx(Is,{as:hw,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(Ee.div,{"data-state":Ma(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),mr="DialogContent",Ud=m.forwardRef((e,t)=>{const n=zd(mr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=fn(mr,e.__scopeDialog);return c.jsx(Gt,{present:r||s.open,children:s.modal?c.jsx(mw,{...o,ref:t}):c.jsx(gw,{...o,ref:t})})});Ud.displayName=mr;var mw=m.forwardRef((e,t)=>{const n=fn(mr,e.__scopeDialog),r=m.useRef(null),o=We(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return Ra(s)},[]),c.jsx(Wd,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:he(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:he(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:he(e.onFocusOutside,s=>s.preventDefault())})}),gw=m.forwardRef((e,t)=>{const n=fn(mr,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return c.jsx(Wd,{...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()}})}),Wd=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=fn(mr,n),l=m.useRef(null),u=We(t,l);return Ea(),c.jsxs(c.Fragment,{children:[c.jsx(bs,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(vs,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Ma(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(xw,{titleId:a.titleId}),c.jsx(vw,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Oa="DialogTitle",Vd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(Oa,n);return c.jsx(Ee.h2,{id:o.titleId,...r,ref:t})});Vd.displayName=Oa;var Kd="DialogDescription",qd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(Kd,n);return c.jsx(Ee.p,{id:o.descriptionId,...r,ref:t})});qd.displayName=Kd;var Gd="DialogClose",Yd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(Gd,n);return c.jsx(Ee.button,{type:"button",...r,ref:t,onClick:he(e.onClick,()=>o.onOpenChange(!1))})});Yd.displayName=Gd;function Ma(e){return e?"open":"closed"}var Xd="DialogTitleWarning",[wT,Jd]=Sv(Xd,{contentName:mr,titleName:Oa,docsSlug:"dialog"}),xw=({titleId:e})=>{const t=Jd(Xd),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},ww="DialogDescriptionWarning",Sw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${tf(ww).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,Cw=Ud,rf=Vd,Ps=Kd,Os=qd,gr=Yd,Ms=Jd,of=Qd;const Tw=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 Ew=m.forwardRef(({className:e,...t},n)=>c.jsx(Ms,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));Ew.displayName=Ms.displayName;function Iw({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}=wa(),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 ib(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(Tw,{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 Nw(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Aw(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 jw(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 Rw(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 Pw(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 Ow({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:T}){const[k,I]=w.useState(!1),[j,R]=w.useState("collapsed"),[_,H]=w.useState(!1),{currentThreadId:F}=Xo(),{respondToInterrupt:U}=Jo(),{toast:D}=wa(),[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(()=>Nw(t.content),[t.content]),K=w.useMemo(()=>Aw(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(()=>Rw(t.content),[t.content]);const Je=w.useMemo(()=>He.length<=xr?He:`${He.slice(0,xr)}
129
- … [truncated ${He.length-xr} chars]`,[He]),_e=w.useCallback(async(X="all")=>{const de=X==="visible"&&ce?Je:ce?He:ye;async function je(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 je(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 je=String(xe.url??""),Fe=je.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(je.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 ab(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(je){console.error("File click error:",je),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??"",je=de.trim(),Fe=uf(je);return Fe&&Y!=="tool"?c.jsx(Mw,{data:Fe},xe):Y==="user"&&f&&je.length>h?c.jsxs(Ju,{open:_,onOpenChange:H,children:[c.jsx("div",{className:re("text-sm text-[hsl(var(--chat-bubble-user-text))]",M&&"text-xs"),children:_?c.jsx(ya,{content:je,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:[je.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:_?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 (",je.length-h," chars)"]})})})]},xe):c.jsx(ya,{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,je=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:[je,G[xe]?" (processing)":""]})]},xe)}if(X.type==="interrupt"){const de=X,je=Fs((de==null?void 0:de.id)??(de==null?void 0:de.interrupt_id)),Fe=!!(se&&je&&je===se),nt=Fe?ae??(de==null?void 0:de.value):de==null?void 0:de.value,pt=je?{...de,id:je,interrupt_id:je}:de;return c.jsx(Lw,{interruptPart:pt,onApprove:Et,onReject:st,disabled:C,isActive:Fe,payload:nt},xe)}return null},[Ze,G,Et,st,Y,f,h,_,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(Fw,{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,je=ff(de);if(je)return c.jsx($w,{issues:je})}if(ce){const xe=jw(t.content);if(xe.length>0)return c.jsx("div",{className:"space-y-2",children:xe.map((de,je)=>{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=j==="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(da,{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??je)})})}if(!ce){const xe=c.jsx("div",{className:"space-y-2",children:t.content.map((de,je)=>c.jsx(tt,{part:de,i:je},je))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[xe,c.jsx(Ow,{className:ge})]}):xe}},[ye,L.length,Z.length,ee.length,r,t.model,ce,K.name,He,j,u,ze,ge]),bt=w.useMemo(()=>Pw(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(da,{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":j!=="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:j!=="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 ",j!=="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:()=>_e(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:()=>_e("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&&j==="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:()=>_e(),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(Iw,{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 Mw({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:Dw(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 Dw(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 Lw({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 Fw({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 $w({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}`,Da=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),j=w.useRef(null),R=w.useRef(!1),[_,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:_?"auto":!1,[_,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(dv,{ref:$=>{I.current=$},scrollerRef:$=>{j.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:T})})}})})});Da.displayName="MessageList";const $s=1e4;function zw(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},yw="DialogDescriptionWarning",vw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Jd(yw).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},Zd=Ld,bw=$d,Qd=Bd,Rs=Hd,Ps=Ud,gr=Vd,Os=qd,ef=Yd;const ww=Zd,Sw=Qd,tf=m.forwardRef(({className:e,...t},n)=>c.jsx(Rs,{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}));tf.displayName=Rs.displayName;const nf=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(Sw,{children:[c.jsx(tf,{}),c.jsxs(Ps,{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(ef,{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(me.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});nf.displayName=Ps.displayName;const rf=({className:e,...t})=>c.jsx("div",{className:re("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});rf.displayName="DialogHeader";const of=m.forwardRef(({className:e,...t},n)=>c.jsx(gr,{ref:n,className:re("text-lg font-semibold leading-none tracking-tight",e),...t}));of.displayName=gr.displayName;const Cw=m.forwardRef(({className:e,...t},n)=>c.jsx(Os,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));Cw.displayName=Os.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}=wa(),h=w.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await dd(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 rb(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 dd(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(me.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(Ge,{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(me.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(me.Image,{className:"h-5 w-5"}):c.jsx(me.FileText,{className:"h-5 w-5"});return c.jsx(ww,{open:e,onOpenChange:t,children:c.jsxs(nf,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[c.jsx(rf,{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(of,{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(Ge,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[c.jsx(me.ExternalLink,{className:"h-4 w-4"}),"External"]}),c.jsxs(Ge,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[c.jsx(me.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),c.jsx("div",{className:"flex-1 overflow-hidden",children:x()})]})})}function sf(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 af(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(af(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 Ms(e){if(typeof e=="string")return e;if(af(e))return"";try{const t=go(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function lf(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 lf(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 Ds="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",Ls=1e5;function Tw(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Ew(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 Iw(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=Ls)=>{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 Nw(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 _w(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function cf(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 jw({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 uf=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),[_,P]=w.useState("preview"),[j,H]=w.useState(!1),{currentThreadId:F}=Yo(),{respondToInterrupt:U}=Xo(),{toast:D}=wa(),[G,W]=w.useState({}),[ne,$]=w.useState(!1),[z,se]=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(()=>Tw(t.content),[t.content]),K=w.useMemo(()=>Ew(t.content),[t.content]),L=w.useMemo(()=>t.content.filter(J=>J.type==="image_url"),[t.content]),Z=w.useMemo(()=>t.content.filter(J=>J.type==="file"),[t.content]),ee=w.useMemo(()=>t.content.filter(J=>J.type==="interrupt"),[t.content]),pe=(b==null?void 0:b.id)??(b==null?void 0:b.interrupt_id),oe=Fs(pe),ie=b==null?void 0:b.value,Be=w.useMemo(()=>Aw(t.content),[t.content]);w.useMemo(()=>Nw(t.content),[t.content]);const Je=w.useMemo(()=>Be.length<=Ls?Be:`${Be.slice(0,Ls)}
129
+ … [truncated ${Be.length-Ls} chars]`,[Be]),je=w.useCallback(async(J="all")=>{const ue=J==="visible"&&ce?Je:ce?Be:ye;async function _e(Ve){try{await navigator.clipboard.writeText(Ve)}catch{try{const at=document.createElement("textarea");at.value=Ve,at.setAttribute("readonly",""),at.style.position="absolute",at.style.left="-9999px",document.body.appendChild(at),at.select(),document.execCommand("copy"),document.body.removeChild(at)}catch(at){throw console.error("Failed to copy:",at),at}}}try{await _e(ue),I(!0),setTimeout(()=>I(!1),2e3),y==null||y(ue)}catch(Ve){console.error("Failed to copy:",Ve)}},[ce,Be,ye,Je,y]),He=w.useCallback(()=>{if(!v)return;const J=ce?Be:ye;v(t.id,J)},[v,t.id,ce,Be,ye]),Qe=w.useCallback(()=>{x==null||x(n)},[x,n]),Ze=w.useCallback(async(J,xe,ue)=>{if(!be){J.preventDefault();return}if(G[ue]){J.preventDefault();return}try{const _e=String(xe.url??""),Ve=_e.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(Ve){J.preventDefault();const at=Ve[1],Tt=xe.name||`file_${at}`,rt=xe.mimeType||"application/octet-stream";se({id:at,name:Tt,mimeType:rt}),$(!0);return}if(_e.startsWith("data:")){J.preventDefault(),W(rt=>({...rt,[ue]:!0}));const at=`${xe.name}_${xe.size}_${Date.now()}`,Tt=D({title:"Fetching file...",description:"",open:!0});try{const rt=await ob(F??void 0);if(!rt||!Array.isArray(rt))throw new Error("Invalid file list response");const ut=rt.find(pt=>!pt||typeof pt!="object"||!((pt.filename??"")===(xe.name??""))?!1:typeof xe.size=="number"&&typeof pt.size=="number"?pt.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");se({id:ut.id,name:xe.name||ut.filename||`file_${ut.id}`,mimeType:xe.mimeType||ut.mime_type||"application/octet-stream"}),$(!0),Tt.update({id:Tt.id,title:"Success",description:`Opened ${xe.name}`,open:!0})}catch(rt){console.error("Failed to fetch server file:",rt);const ut=rt instanceof Error?rt.message:"Unknown error occurred";Tt.update({id:Tt.id,title:"Failed",description:ut}),D({title:"Failed to fetch file",description:ut,open:!0})}finally{W(rt=>({...rt,[ue]:!1}))}}}catch(_e){console.error("File click error:",_e),W(Ve=>({...Ve,[ue]:!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(me.User,{className:xe});case"assistant":return c.jsx(me.Bot,{className:xe});case"tool":return c.jsx(me.Wrench,{className:xe});default:return c.jsx(me.Bot,{className:xe})}},[M,ge,Y]),wt=w.useCallback(()=>{const J="group relative mb-4 flex w-full";switch(Y){case"user":return re(J,"justify-end");case"assistant":case"tool":case"system":return re(J,"justify-start");default:return J}},[Y]),Ct=w.useCallback(()=>{const J=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(J,"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(J,"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(J,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return re(J,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return re(J,"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]),kt=w.useCallback(async J=>{if(C)return;const xe=Fs((J==null?void 0:J.id)??(J==null?void 0:J.interrupt_id));if(!xe){console.warn("Interrupt part missing id",J);return}try{E==null||E(),await U(xe,!0)}catch(ue){console.error("Failed to approve interrupt:",ue)}finally{k==null||k()}},[C,k,E,U]),ot=w.useCallback(async J=>{if(C)return;const xe=Fs((J==null?void 0:J.id)??(J==null?void 0:J.interrupt_id));if(!xe){console.warn("Interrupt part missing id",J);return}try{E==null||E(),await U(xe,!1)}catch(ue){console.error("Failed to reject interrupt:",ue)}finally{k==null||k()}},[C,k,E,U]),et=w.useCallback(({part:J,i:xe})=>{if(J.type==="text"){const ue=J.text??"",_e=ue.trim(),Ve=sf(_e);return Ve&&Y!=="tool"?c.jsx(Rw,{data:Ve},xe):Y==="user"&&f&&_e.length>h?c.jsxs(Fv,{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(ya,{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($v,{asChild:!0,children:c.jsx(Ge,{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(me.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(me.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",_e.length-h," chars)"]})})})]},xe):c.jsx(ya,{content:ue,allowHtml:!1},xe)}if(J.type==="image_url"){const ue=J;return c.jsx("div",{className:"my-2",children:c.jsx("img",{src:ue.url,alt:ue.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},xe)}if(J.type==="file"){const ue=J,_e=ue.name||"file";return c.jsxs("a",{href:ue.url,onClick:Ve=>Ze(Ve,ue,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(me.Loader,{className:"h-4 w-4 animate-spin"}):null,c.jsxs("span",{className:"truncate max-w-[180px]",children:[_e,G[xe]?" (processing)":""]})]},xe)}if(J.type==="interrupt"){const ue=J,_e=Fs((ue==null?void 0:ue.id)??(ue==null?void 0:ue.interrupt_id)),Ve=!!(oe&&_e&&_e===oe),at=Ve?ie??(ue==null?void 0:ue.value):ue==null?void 0:ue.value,Tt=_e?{...ue,id:_e,interrupt_id:_e}:ue;return c.jsx(Ow,{interruptPart:Tt,onApprove:kt,onReject:ot,disabled:C,isActive:Ve,payload:at},xe)}return null},[Ze,G,kt,ot,Y,f,h,j,M,oe,ie,b,C,ee]),$e=w.useCallback(()=>c.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[c.jsx(me.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 J=ye.trim().length>0||L.length>0||Z.length>0||ee.length>0;if(!ce&&!J&&!r)return $e();if(t.model==="reflection"){const xe=ye.trim(),ue=sf(xe);if(ue&&typeof ue=="object")return c.jsx(Mw,{data:ue})}if(ce&&K.name==="get_issues"){const xe=t.content.find(Ve=>Ve.type==="tool_end"),ue=(xe==null?void 0:xe.output)??Be,_e=lf(ue);if(_e)return c.jsx(Dw,{issues:_e})}if(ce){const xe=Iw(t.content);if(xe.length>0)return c.jsx("div",{className:"space-y-3",children:xe.map((ue,_e)=>{const Ve=typeof ue.output=="string"?ue.output:Ms(ue.output);return _==="expanded"||!u?c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[c.jsx("span",{children:ue.name??"tool"}),ue.toolCallId&&c.jsxs("span",{children:["• ",ue.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:Ve})})]},ue.toolCallId??_e):null})})}if(!ce){const xe=c.jsx("div",{className:"space-y-2",children:t.content.map((ue,_e)=>c.jsx(et,{part:ue,i:_e},_e))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[xe,c.jsx(jw,{className:ge})]}):xe}},[ye,L.length,Z.length,ee.length,r,t.model,ce,K.name,Be,_,u,d,$e,ge]),vt=w.useMemo(()=>_w(t),[t]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:re(wt(),p.container),children:c.jsxs("div",{className:re(Ct(),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&&vt&&c.jsx("span",{className:re("font-medium",M?"text-xs":"text-sm"),children:vt}),ce&&c.jsxs(Uu,{variant:"outline",className:re("text-xs flex items-center gap-1 cursor-pointer select-none",ge,"border border-current/40",M&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":_==="expanded",onClick:()=>P(J=>J==="expanded"?"preview":"expanded"),onKeyDown:J=>{(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),P(xe=>xe==="expanded"?"preview":"expanded"))},children:[c.jsx("span",{children:K.name??"Tool Output"}),K.toolCallId&&c.jsx("span",{className:"opacity-70",children:K.toolCallId.slice(0,8)}),_==="expanded"?c.jsx(me.ChevronUp,{className:"h-3 w-3"}):c.jsx(me.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(Ge,{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(me.Copy,{className:re(T?"text-success":ge,M?"h-3 w-3":"h-4 w-4")})}),ce&&c.jsx(Ge,{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(Ge,{variant:"ghost",size:"sm",onClick:He,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(me.Edit,{className:re(ge,M?"h-3 w-3":"h-4 w-4")})}),Y==="assistant"&&x&&c.jsx(Ge,{variant:"ghost",size:"sm",onClick:Qe,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(me.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(Ge,{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(me.Copy,{className:re(T?"text-success":"text-current",M?"h-3 w-3":"h-4 w-4")})}),Y==="user"&&v&&c.jsx(Ge,{variant:"ghost",size:"sm",onClick:He,className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:c.jsx(me.Edit,{className:re("text-current",M?"h-3 w-3":"h-4 w-4")})}),Y==="assistant"&&x&&c.jsx(Ge,{variant:"ghost",size:"sm",onClick:Qe,className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:c.jsx(me.RotateCcw,{className:re("text-current",M?"h-3 w-3":"h-4 w-4")})})]})]})}),z&&c.jsx(kw,{isOpen:ne,onClose:()=>{$(!1),se(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&&cf(e.message)===cf(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 Rw({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?c.jsx("div",{className:Ds,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:Ms(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:Ds,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:Ds,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:Pw(i)})]},s))})})}return c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Ms(e)})}function Pw(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 Ow({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=Ms(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(Yu,{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(Xu,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(Ge,{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(Ge,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}function Mw({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 Dw({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:Ds,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 df=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Da=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),P=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 se=b.value;if(se&&typeof se=="object"&&!Array.isArray(se)){const M=se.title;typeof M=="string"&&M.trim()&&(z=M.trim())}return{id:`interrupt-${$}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:$,value:se,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(!P.current){P.current=!0;try{await a()}finally{P.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(iv,{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)=>df(z,$),itemContent:($,z)=>{const se=df(z,$);return c.jsx("div",{className:"mb-4 last:mb-0","data-message-id":se,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(uf,{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})})}})})});Da.displayName="MessageList";const $s=1e4;function Lw(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
131
  `).replace(/<p>(.*?)<\/p>/gi,`$1
133
132
 
134
133
  `).replace(/<h([1-6])>(.*?)<\/h[1-6]>/gi,(o,s,i)=>`${"#".repeat(parseInt(s))} ${i}
@@ -136,4 +135,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
136
135
  `).replace(/<ul>/gi,"").replace(/<\/ul>/gi,`
137
136
  `).replace(/<ol>/gi,"").replace(/<\/ol>/gi,`
138
137
  `).replace(/<li>(.*?)<\/li>/gi,`- $1
139
- `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function Bw(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 Hw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),Bw(t),zw(t)}function La(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 Uw=m.createContext(void 0);function zs(e){const t=m.useContext(Uw);return e||t||"ltr"}const Ww=["top","right","bottom","left"],Zn=Math.min,Yt=Math.max,Bs=Math.round,Hs=Math.floor,kn=e=>({x:e,y:e}),Vw={left:"right",right:"left",bottom:"top",top:"bottom"},Kw={start:"end",end:"start"};function Fa(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 $a(e){return e==="x"?"y":"x"}function za(e){return e==="y"?"height":"width"}const qw=new Set(["top","bottom"]);function En(e){return qw.has(Fn(e))?"y":"x"}function Ba(e){return $a(En(e))}function Gw(e,t,n){n===void 0&&(n=!1);const r=Dr(e),o=Ba(e),s=za(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 Yw(e){const t=Us(e);return[Ha(e),t,Ha(t)]}function Ha(e){return e.replace(/start|end/g,t=>Kw[t])}const gf=["left","right"],xf=["right","left"],Xw=["top","bottom"],Jw=["bottom","top"];function Zw(e,t,n){switch(e){case"top":case"bottom":return n?t?xf:gf:t?gf:xf;case"left":case"right":return t?Xw:Jw;default:return[]}}function Qw(e,t,n,r){const o=Dr(e);let s=Zw(Fn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ha)))),s}function Us(e){return e.replace(/left|right|bottom|top/g,t=>Vw[t])}function e0(e){return{top:0,right:0,bottom:0,left:0,...e}}function yf(e){return typeof e!="number"?e0(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=Ba(t),a=za(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 t0=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: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}=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},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 n0=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=Ba(o),v=za(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 j=E/2-T/2,R=I/2-x[v]/2-1,_=Zn(f[y],R),H=Zn(f[b],R),F=_,U=I-x[v]-H,D=I/2-x[v]/2+j,G=Fa(F,D,U),W=!l.arrow&&Dr(o)!=null&&D!==G&&s.reference[v]/2-(D<F?_: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}}}),r0=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)]:Yw(a)),k=v!=="none";!h&&k&&T.push(...Qw(a,x,v,E));const I=[a,...T],j=await xo(t,g),R=[];let _=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&R.push(j[y]),f){const D=Gw(o,i,E);R.push(j[D[0]],j[D[1]])}if(_=[..._,{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)||_.every($=>En($.placement)===b?$.overflows[0]>0:!0)))return{data:{index:D,overflows:_},reset:{placement:G}};let W=(F=_.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=_.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 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 Ww.some(t=>e[t]>=0)}const o0=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 s0(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 i0=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 s0(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}}}}},a0=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=$a(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=Fa(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=Fa(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}}}}}},l0=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=$a(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=Sf.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}}}},c0=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,j=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=b),k&&!h){const _=Yt(d.left,0),H=Yt(d.right,0),F=Yt(d.top,0),U=Yt(d.bottom,0);p?j=v-2*(_!==0||H!==0?_+H:Yt(d.left,d.right)):I=x-2*(F!==0||U!==0?F+U:Yt(d.top,d.bottom))}await l({...t,availableWidth:j,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 Tf(e){return!Vs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Xt(e).ShadowRoot}const u0=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)&&!u0.has(o)}const d0=new Set(["table","td","th"]);function f0(e){return d0.has(Lr(e))}const h0=[":popover-open",":modal"];function Ks(e){return h0.some(t=>{try{return e.matches(t)}catch{return!1}})}const p0=["transform","translate","scale","rotate","perspective"],m0=["transform","translate","scale","rotate","perspective","filter"],g0=["paint","layout","strict","content"];function Ua(e){const t=Wa(),n=fn(e)?hn(e):e;return p0.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)||m0.some(r=>(n.willChange||"").includes(r))||g0.some(r=>(n.contain||"").includes(r))}function x0(e){let t=Qn(e);for(;Nn(t)&&!Fr(t);){if(Ua(t))return t;if(Ks(t))return null;t=Qn(t)}return null}function Wa(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const y0=new Set(["html","body","#document"]);function Fr(e){return y0.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||Tf(e)&&e.host||In(e);return Tf(t)?t.host:t}function kf(e){const t=Qn(e);return Fr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Nn(t)&&yo(t)?t:kf(t)}function vo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=kf(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Xt(o);if(s){const a=Va(i);return t.concat(i,i.visualViewport||[],yo(o)?o:[],a&&n?vo(a):[])}return t.concat(o,vo(o,[],n))}function Va(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 Ka(e){return fn(e)?e:e.contextElement}function $r(e){const t=Ka(e);if(!Nn(t))return kn(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 v0=kn(0);function If(e){const t=Xt(e);return!Wa()||!t.visualViewport?v0:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function b0(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=Ka(e);let i=kn(1);t&&(r?fn(r)&&(i=$r(r)):i=$r(e));const a=b0(s,n,r)?If(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=Va(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=Va(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 w0(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?Nf(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 S0(e){return Array.from(e.getClientRects())}function C0(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 T0(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=Wa();(!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 E0(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 jf(e,t,n){let r;if(t==="viewport")r=T0(e,n);else if(t==="document")r=C0(In(e));else if(fn(t))r=E0(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 _f(e,t){const n=Qn(e);return n===t||!fn(n)||Fr(n)?!1:hn(n).position==="fixed"||_f(n,t)}function I0(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=Ua(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&k0.has(o.position)||yo(i)&&!l&&_f(e,i))?r=r.filter(d=>d!==i):o=a,i=Qn(i)}return t.set(e,r),r}function N0(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Ks(t)?[]:I0(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=jf(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},jf(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function A0(e){const{width:t,height:n}=Ef(e);return{width:t,height:n}}function j0(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?Nf(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 qa(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)&&!qa(o))return o;o=Qn(o)}return n}let r=Rf(e,t);for(;r&&f0(r)&&qa(r);)r=Rf(r,t);return r&&Fr(r)&&qa(r)&&!Ua(r)?n:r||x0(e)||n}const _0=async function(e){const t=this.getOffsetParent||Pf,n=this.getDimensions,r=await n(e.floating);return{reference:j0(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function R0(e){return hn(e).direction==="rtl"}const P0={convertOffsetParentRelativeRectToViewportRelativeRect:w0,getDocumentElement:In,getClippingRect:N0,getOffsetParent:Pf,getElementRects:_0,getClientRects:S0,getDimensions:A0,getScale:$r,isElement:fn,isRTL:R0};function Of(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function O0(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&&!Of(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 M0(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=Ka(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?O0(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 D0=i0,L0=a0,F0=r0,$0=c0,z0=o0,Mf=n0,B0=l0,H0=(e,t,n)=>{const r=new Map,o={platform:P0,...n},s={...o.platform,_c:r};return t0(e,t,{...o,platform:s})};var U0=typeof document<"u",W0=function(){},Ys=U0?w.useLayoutEffect:W0;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 Ga(e){const t=m.useRef(e);return Ys(()=>{t.current=e}),t}function V0(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),j=m.useRef(d),R=l!=null,_=Ga(l),H=Ga(o),F=Ga(u),U=m.useCallback(()=>{if(!k.current||!I.current)return;const $={placement:t,strategy:n,middleware:h};H.current&&($.platform=H.current),H0(k.current,I.current,$).then(z=>{const ie={...z,isPositioned:F.current!==!1};D.current&&!Xs(j.current,ie)&&(j.current=ie,Oo.flushSync(()=>{f(ie)}))})},[h,t,n,H,F]);Ys(()=>{u===!1&&j.current.isPositioned&&(j.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(_.current)return _.current(E,T,U);U()}},[E,T,U,_,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=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 K0=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):{}}}},q0=(e,t)=>({...D0(e),options:[e,t]}),G0=(e,t)=>({...L0(e),options:[e,t]}),Y0=(e,t)=>({...B0(e),options:[e,t]}),X0=(e,t)=>({...F0(e),options:[e,t]}),J0=(e,t)=>({...$0(e),options:[e,t]}),Z0=(e,t)=>({...z0(e),options:[e,t]}),Q0=(e,t)=>({...K0(e),options:[e,t]});var eS="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=eS;var tS=Ff;function $f(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 Ya="Popper",[zf,Js]=Sn(Ya),[nS,Bf]=zf(Ya),Hf=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(nS,{scope:t,anchor:r,onAnchorChange:o,children:n})};Hf.displayName=Ya;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 Xa="PopperContent",[rS,oS]=zf(Xa),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(Xa,n),[y,b]=m.useState(null),C=Ve(t,ae=>b(ae)),[E,T]=m.useState(null),k=$f(E),I=(k==null?void 0:k.width)??0,j=(k==null?void 0:k.height)??0,R=r+(s!=="center"?"-"+s:""),_=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:_,boundary:H.filter(iS),altBoundary:F},{refs:D,floatingStyles:G,placement:W,isPositioned:ne,middlewareData:$}=V0({strategy:"fixed",placement:R,whileElementsMounted:(...ae)=>M0(...ae,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[q0({mainAxis:o+j,alignmentAxis:i}),l&&G0({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Y0():void 0,...U}),l&&X0({...U}),J0({...U,apply:({elements:ae,rects:He,availableWidth:Je,availableHeight:_e})=>{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",`${_e}px`),Ze.setProperty("--radix-popper-anchor-width",`${Ue}px`),Ze.setProperty("--radix-popper-anchor-height",`${et}px`)}}),E&&Q0({element:E,padding:a}),aS({arrowWidth:I,arrowHeight:j}),h&&Z0({strategy:"referenceHidden",...U})]}),[z,ie]=Gf(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(rS,{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"}})})})});Vf.displayName=Xa;var Kf="PopperArrow",sS={top:"bottom",right:"left",bottom:"top",left:"right"},qf=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=oS(Kf,r),i=sS[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(tS,{...o,ref:n,style:{...o.style,display:"block"}})})});qf.displayName=Kf;function iS(e){return e!==null}var aS=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,Ja="rovingFocusGroup.onEntryFocus",lS={bubbles:!1,cancelable:!0},bo="RovingFocusGroup",[Za,Qf,cS]=La(bo),[uS,eh]=Sn(bo,[cS]),[dS,fS]=uS(bo),th=m.forwardRef((e,t)=>c.jsx(Za.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Za.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(hS,{...e,ref:t})})}));th.displayName=bo;var hS=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),T=m.useRef(!1),[k,I]=m.useState(0);return m.useEffect(()=>{const j=h.current;if(j)return j.addEventListener(Ja,C),()=>j.removeEventListener(Ja,C)},[C]),c.jsx(dS,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:x,onItemFocus:m.useCallback(j=>g(j),[g]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>I(j=>j+1),[]),onFocusableItemRemove:m.useCallback(()=>I(j=>j-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,j=>{const R=!T.current;if(j.target===j.currentTarget&&R&&!y){const _=new CustomEvent(Ja,lS);if(j.currentTarget.dispatchEvent(_),!_.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)}}T.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=fS(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(Za.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=gS(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?xS(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 pS={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function mS(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function gS(e,t,n){const r=mS(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return pS[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 xS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var yS=th,vS=rh,Qa=["Enter"," "],bS=["ArrowDown","PageUp","Home"],sh=["ArrowUp","PageDown","End"],wS=[...bS,...sh],SS={ltr:[...Qa,"ArrowRight"],rtl:[...Qa,"ArrowLeft"]},CS={ltr:["ArrowLeft"],rtl:["ArrowRight"]},wo="Menu",[So,TS,kS]=La(wo),[vr,ih]=Sn(wo,[kS,Js,eh]),Zs=Js(),ah=eh(),[ES,br]=vr(wo),[IS,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(ES,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(IS,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};lh.displayName=wo;var NS="MenuAnchor",el=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Zs(n);return c.jsx(Xf,{...o,...r,ref:t})});el.displayName=NS;var tl="MenuPortal",[AS,ch]=vr(tl,{forceMount:void 0}),uh=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=br(tl,t);return c.jsx(AS,{scope:t,forceMount:n,children:c.jsx(Gt,{present:n||s.open,children:c.jsx(Ss,{asChild:!0,container:o,children:r})})})};uh.displayName=tl;var nn="MenuContent",[jS,nl]=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(RS,{...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 Ra(s)},[]),c.jsx(rl,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:pe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),RS=m.forwardRef((e,t)=>{const n=br(nn,e.__scopeMenu);return c.jsx(rl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),PS=or.createSlot("MenuContent.ScrollLock"),rl=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=TS(n),[T,k]=m.useState(null),I=m.useRef(null),j=Ve(t,I,g.onContentChange),R=m.useRef(0),_=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:PS,allowPinchZoom:!0}:void 0,ne=z=>{var K,L;const ie=_.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=VS(be,ie,ce),ye=(L=M.find(Z=>Z.textValue===ge))==null?void 0:L.ref.current;(function Z(ee){_.current=ee,window.clearTimeout(R.current),ee!==""&&(R.current=window.setTimeout(()=>Z(""),1e3))})(ie),ye&&setTimeout(()=>ye.focus())};m.useEffect(()=>()=>window.clearTimeout(R.current),[]),Ea();const $=m.useCallback(z=>{var M,Y;return U.current===((M=F.current)==null?void 0:M.side)&&qS(z,(Y=F.current)==null?void 0:Y.area)},[]);return c.jsx(jS,{scope:n,searchRef:_,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(yS,{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(Jf,{role:"menu","aria-orientation":"vertical","data-state":Nh(g.open),"data-radix-menu-content":"",dir:y.dir,...b,...x,ref:j,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||!wS.includes(z.key))return;z.preventDefault();const ye=E().filter(K=>!K.disabled).map(K=>K.ref.current);sh.includes(z.key)&&ye.reverse(),US(ye)}),onBlur:pe(e.onBlur,z=>{z.currentTarget.contains(z.target)||(window.clearTimeout(R.current),_.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}}))})})})})})})});dh.displayName=nn;var OS="MenuGroup",ol=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ie.div,{role:"group",...r,ref:t})});ol.displayName=OS;var MS="MenuLabel",fh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ie.div,{...r,ref:t})});fh.displayName=MS;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=nl(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===" "||Qa.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=nl(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(vS,{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))})})})}),DS="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":il(n),onSelect:pe(o.onSelect,()=>r==null?void 0:r(ti(n)?!0:!n),{checkForDefaultPrevented:!1})})})});mh.displayName=DS;var gh="MenuRadioGroup",[LS,FS]=vr(gh,{value:void 0,onValueChange:()=>{}}),xh=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=At(r);return c.jsx(LS,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(ol,{...o,ref:t})})});xh.displayName=gh;var yh="MenuRadioItem",vh=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=FS(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":il(s),onSelect:pe(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});vh.displayName=yh;var sl="MenuItemIndicator",[bh,$S]=vr(sl,{checked:!1}),wh=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=$S(sl,n);return c.jsx(Gt,{present:r||ti(s.checked)||s.checked===!0,children:c.jsx(Ie.span,{...o,ref:t,"data-state":il(s.checked)})})});wh.displayName=sl;var zS="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=zS;var BS="MenuArrow",Ch=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Zs(n);return c.jsx(Zf,{...o,...r,ref:t})});Ch.displayName=BS;var HS="MenuSub",[kk,Th]=vr(HS),To="MenuSubTrigger",kh=m.forwardRef((e,t)=>{const n=br(To,e.__scopeMenu),r=Co(To,e.__scopeMenu),o=Th(To,e.__scopeMenu),s=nl(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(el,{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:fa(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===" "||SS[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});kh.displayName=To;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=Th(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(rl,{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=CS[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 il(e){return ti(e)?"indeterminate":e?"checked":"unchecked"}function US(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function WS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function VS(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=WS(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 KS(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 qS(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return KS(n,t)}function ko(e){return t=>t.pointerType==="mouse"?e(t):void 0}var GS=lh,YS=el,XS=uh,JS=dh,ZS=ol,QS=fh,eC=ei,tC=mh,nC=xh,rC=vh,oC=wh,sC=Sh,iC=Ch,aC=kh,lC=Ih,ni="DropdownMenu",[cC,Ek]=Sn(ni,[ih]),zt=ih(),[uC,Ah]=cC(ni),jh=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(uC,{scope:t,triggerId:Cn(),triggerRef:u,contentId:Cn(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(GS,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};jh.displayName=ni;var _h="DropdownMenuTrigger",Rh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Ah(_h,n),i=zt(n);return c.jsx(YS,{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:fa(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=_h;var dC="DropdownMenuPortal",Ph=e=>{const{__scopeDropdownMenu:t,...n}=e,r=zt(t);return c.jsx(XS,{...r,...n})};Ph.displayName=dC;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(JS,{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 fC="DropdownMenuGroup",hC=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(ZS,{...o,...r,ref:t})});hC.displayName=fC;var pC="DropdownMenuLabel",Dh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(QS,{...o,...r,ref:t})});Dh.displayName=pC;var mC="DropdownMenuItem",Lh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(eC,{...o,...r,ref:t})});Lh.displayName=mC;var gC="DropdownMenuCheckboxItem",Fh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(tC,{...o,...r,ref:t})});Fh.displayName=gC;var xC="DropdownMenuRadioGroup",yC=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(nC,{...o,...r,ref:t})});yC.displayName=xC;var vC="DropdownMenuRadioItem",$h=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(rC,{...o,...r,ref:t})});$h.displayName=vC;var bC="DropdownMenuItemIndicator",zh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(oC,{...o,...r,ref:t})});zh.displayName=bC;var wC="DropdownMenuSeparator",Bh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(sC,{...o,...r,ref:t})});Bh.displayName=wC;var SC="DropdownMenuArrow",CC=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(iC,{...o,...r,ref:t})});CC.displayName=SC;var TC="DropdownMenuSubTrigger",Hh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(aC,{...o,...r,ref:t})});Hh.displayName=TC;var kC="DropdownMenuSubContent",Uh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return c.jsx(lC,{...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 EC=jh,IC=Rh,NC=Ph,Wh=Mh,Vh=Dh,Kh=Lh,qh=Fh,Gh=$h,Yh=zh,Xh=Bh,Jh=Hh,Zh=Uh;const AC=EC,jC=IC,_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 RC=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}));RC.displayName=Zh.displayName;const Qh=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(NC,{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 al=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}));al.displayName=Kh.displayName;const PC=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]}));PC.displayName=qh.displayName;const OC=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]}));OC.displayName=Gh.displayName;const MC=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}));MC.displayName=Vh.displayName;const DC=m.forwardRef(({className:e,...t},n)=>c.jsx(Xh,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));DC.displayName=Xh.displayName;function LC(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:j,checkpoints:R,interrupt:_,metadata:H}=Jo(),{isStreaming:F,error:U,submit:D,stop:G}=Kc(),W=g??x??null,ne=(j==null?void 0:j.id)??null,$=(j==null?void 0:j.namespace)??null,z=(H==null?void 0:H.assemblingMessageId)??null,ie=_,[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),[_e,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,je]=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 Hw(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]),jn=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()},_n=async S=>{if(x){je(!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{je(!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;_n(P)},children:[c.jsx("option",{value:"",children:"Latest"}),pt.map(S=>{const P=Fe(S.metadata,"step"),B=nt(S.metadata,"source"),oe=LC(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(Da,{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:jn,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"},_e),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(AC,{children:[c.jsx(jC,{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(al,{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(al,{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(ty,{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 ll(e,[t,n]){return Math.min(n,Math.max(t,e))}function FC(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var cl="ScrollArea",[ep,Ik]=Sn(cl),[$C,rn]=ep(cl),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),[T,k]=m.useState(!1),[I,j]=m.useState(!1),R=Ve(t,H=>l(H)),_=zs(o);return c.jsx($C,{scope:n,type:r,dir:_,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:j,onCornerWidthChange:b,onCornerHeightChange:E,children:c.jsx(Ie.div,{dir:_,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});tp.displayName=cl;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",ul=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(zC,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(BC,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(op,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(dl,{...r,ref:t}):null});ul.displayName=An;var zC=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})})}),BC=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]=FC("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(dl,{"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(dl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),dl=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 qC(h,i.current,a,p)}return n==="horizontal"?c.jsx(HC,{...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(UC,{...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}),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.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)}})}})}),UC=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)}})}})}),[WC,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,T=At(d),k=At(l),I=li(f,10);function j(R){if(y.current){const _=R.clientX-y.current.left,H=R.clientY-y.current.top;u({x:_,y:H})}}return m.useEffect(()=>{const R=_=>{const H=_.target;(v==null?void 0:v.contains(H))&&T(_,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(WC,{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"),j(R))}),onPointerMove:pe(e.onPointerMove,j),onPointerUp:pe(e.onPointerUp,R=>{const _=R.target;_.hasPointerCapture(R.pointerId)&&_.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(VC,{ref:t,...r})})}),VC=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=GC(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 fl="ScrollAreaCorner",lp=m.forwardRef((e,t)=>{const n=rn(fl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(KC,{...e,ref:t}):null});lp.displayName=fl;var KC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=rn(fl,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 qC(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=ll(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 GC=(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 hp=tp,YC=rp,XC=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(YC,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(mp,{}),c.jsx(XC,{})]}));pp.displayName=hp.displayName;const mp=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(ul,{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=ul.displayName;function hl({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),[j,R]=w.useState(""),[_,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(j.trim())try{await b(M,j.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:_||p,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:_?"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:k===M.threadId?c.jsxs("div",{className:"flex items-center gap-2",onClick:Y=>Y.stopPropagation(),children:[c.jsx(oi,{value:j,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 JC(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=JC(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 ZC(){try{const e=localStorage.getItem(wp);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function QC(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 eT(){const e=bp(),t=ZC(),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 tT(e){Wn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),QC(e)}var nT="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=nT;var Cp=Sp;const rT=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(rT(),e),...t}));on.displayName=Cp.displayName;function Tp(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",[oT,Nk]=Sn(ci),[sT,iT]=oT(ci),kp=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(sT,{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%)"}})]})});kp.displayName=ci;var Ep="SwitchThumb",Ip=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=iT(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 aT="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=Tp(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=aT;function Ap(e){return e?"checked":"unchecked"}var jp=kp,lT=Ip;const er=m.forwardRef(({className:e,...t},n)=>c.jsx(jp,{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(lT,{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=jp.displayName;var _p=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"}),cT="VisuallyHidden",uT=m.forwardRef((e,t)=>c.jsx(Ie.span,{...e,ref:t,style:{..._p,...e.style}}));uT.displayName=cT;var dT=[" ","Enter","ArrowUp","ArrowDown"],fT=[" ","Enter"],wr="Select",[ui,di,hT]=La(wr),[Hr,Ak]=Sn(wr,[hT,Js]),fi=Js(),[pT,tr]=Hr(wr),[mT,gT]=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,T]=m.useState(!1),k=zs(u),[I,j]=hr({prop:r,defaultProp:o??!1,onChange:s,caller:wr}),[R,_]=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(pT,{required:p,scope:t,trigger:g,onTriggerChange:y,valueNode:b,onValueNodeChange:C,valueNodeHasChildren:E,onValueNodeHasChildrenChange:T,contentId:Cn(),value:R,onValueChange:_,open:I,onOpenChange:j,dir:k,triggerPointerDownPosRef:H,disabled:h,children:[c.jsx(ui.Provider,{scope:t,children:c.jsx(mT,{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=>_(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===" ")&&dT.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 Tt(()=>{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 xT="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=xT;var yT="SelectPortal",Fp=e=>c.jsx(Ss,{asChild:!0,...e});Fp.displayName=yT;var Sr="SelectContent",$p=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(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),vT="SelectContentImpl",bT=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),[T,k]=m.useState(null),I=Ve(t,K=>E(K)),[j,R]=m.useState(null),[_,H]=m.useState(null),F=di(n),[U,D]=m.useState(!1),G=m.useRef(!1);m.useEffect(()=>{if(C)return Ra(C)},[C]),Ea();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([j,C]),[W,j,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"?pl:Hp,ye=ge===pl?{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:T,onViewportChange:k,itemRefCallback:Y,selectedItem:j,onItemLeave:ce,itemTextRefCallback:be,focusSelectedItem:ne,selectedItemText:_,position:r,isPositioned:U,searchRef:ie,children:c.jsx(Ns,{as:bT,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=vT;var wT="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(),j=u.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),_=y.getBoundingClientRect();if(s.dir!=="rtl"){const me=_.left-j.left,se=R.left-me,ae=I.left-se,He=I.width+ae,Je=Math.max(He,j.width),_e=window.innerWidth-pn,Ue=ll(se,[pn,Math.max(pn,_e-Je)]);a.style.minWidth=He+"px",a.style.left=Ue+"px"}else{const me=j.right-_.right,se=window.innerWidth-R.right-me,ae=window.innerWidth-I.right-se,He=I.width+ae,Je=Math.max(He,j.width),_e=window.innerWidth-pn,Ue=ll(se,[pn,Math.max(pn,_e-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(CT,{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}})})})});Hp.displayName=wT;var ST="SelectPopperPosition",pl=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)"}})});pl.displayName=ST;var[CT,ml]=Hr(Sr,{}),gl="SelectViewport",Up=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=nr(gl,n),i=ml(gl,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=gl;var Wp="SelectGroup",[TT,kT]=Hr(Wp),ET=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Cn();return c.jsx(TT,{scope:n,id:o,children:c.jsx(Ie.div,{role:"group","aria-labelledby":o,...r,ref:t})})});ET.displayName=Wp;var Vp="SelectLabel",Kp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=kT(Vp,n);return c.jsx(Ie.div,{id:o.id,...r,ref:t})});Kp.displayName=Vp;var hi="SelectItem",[IT,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(IT,{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===" "||(fT.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=gT(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]})});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 xl="SelectScrollUpButton",Zp=m.forwardRef((e,t)=>{const n=nr(xl,e.__scopeSelect),r=ml(xl,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(em,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Zp.displayName=xl;var yl="SelectScrollDownButton",Qp=m.forwardRef((e,t)=>{const n=nr(yl,e.__scopeSelect),r=ml(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.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=yl;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]),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()})})}),NT="SelectSeparator",tm=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(Ie.div,{"aria-hidden":!0,...r,ref:t})});tm.displayName=NT;var vl="SelectArrow",AT=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=fi(n),s=tr(vl,n),i=nr(vl,n);return s.open&&i.position==="popper"?c.jsx(Zf,{...o,...r,ref:t}):null});AT.displayName=vl;var jT="SelectBubbleInput",nm=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=Ve(r,o),i=Tp(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:{..._p,...n.style},ref:s,defaultValue:t})});nm.displayName=jT;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=_T(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 _T(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var RT=Rp,im=Op,PT=Dp,OT=Lp,MT=Fp,am=$p,DT=Up,lm=Kp,cm=Gp,LT=Yp,FT=Jp,um=Zp,dm=Qp,fm=tm;const hm=RT,pm=PT,bl=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(OT,{asChild:!0,children:c.jsx(ue.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));bl.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 wl=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(MT,{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(DT,{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,{})]})}));wl.displayName=am.displayName;const $T=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}));$T.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(FT,{children:c.jsx(ue.Check,{className:"h-4 w-4"})})}),c.jsx(LT,{children:t})]}));Cr.displayName=cm.displayName;const zT=m.forwardRef(({className:e,...t},n)=>c.jsx(fm,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));zT.displayName=fm.displayName;var BT="Separator",xm="horizontal",HT=["horizontal","vertical"],ym=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=xm,...o}=e,s=UT(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=BT;function UT(e){return HT.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 WT=nf,VT=Cw,KT=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 qT=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(KT,{children:[c.jsx(wm,{}),c.jsxs(Os,{ref:o,className:re(qT({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 Tm=m.forwardRef(({className:e,...t},n)=>c.jsx(gr,{ref:n,className:re("text-lg font-semibold text-foreground",e),...t}));Tm.displayName=gr.displayName;const km=m.forwardRef(({className:e,...t},n)=>c.jsx(Ms,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));km.displayName=Ms.displayName;const GT={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 YT({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}=wa();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(GT),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(WT,{open:r,onOpenChange:o,children:[c.jsx(VT,{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(da,{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(Tm,{children:"Chat Settings"}),c.jsx(km,{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(bl,{children:c.jsx(pm,{})}),c.jsxs(wl,{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(bl,{children:c.jsx(pm,{})}),c.jsxs(wl,{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 XT({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(hl,{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(hl,{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=wc,Ne.ChatInterface=ri,Ne.ChatProviders=Zo,Ne.ChatSettings=YT,Ne.MarkdownContent=ya,Ne.MessageComponent=pf,Ne.MessageList=Da,Ne.ThreadManager=hl,Ne.applySettings=tT,Ne.chatApiClient=Wn,Ne.default=XT,Ne.del=bc,Ne.get=ln,Ne.getChatToken=gc,Ne.getCurrentSettings=eT,Ne.getDefaultApiConfig=vp,Ne.getDefaultChatSettings=bp,Ne.onChatTokenChanged=xc,Ne.post=yc,Ne.put=vc,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"}})});
138
+ `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function Fw(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 $w(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),Fw(t),Lw(t)}function La(e){const t=e+"CollectionProvider",[n,r]=Cn(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=We(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=We(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 zw=m.createContext(void 0);function zs(e){const t=m.useContext(zw);return e||t||"ltr"}const Bw=["top","right","bottom","left"],Xn=Math.min,Yt=Math.max,Bs=Math.round,Hs=Math.floor,En=e=>({x:e,y:e}),Hw={left:"right",right:"left",bottom:"top",top:"bottom"},Uw={start:"end",end:"start"};function Fa(e,t,n){return Yt(e,Xn(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 $a(e){return e==="x"?"y":"x"}function za(e){return e==="y"?"height":"width"}const Ww=new Set(["top","bottom"]);function In(e){return Ww.has(Fn(e))?"y":"x"}function Ba(e){return $a(In(e))}function Vw(e,t,n){n===void 0&&(n=!1);const r=Dr(e),o=Ba(e),s=za(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 Kw(e){const t=Us(e);return[Ha(e),t,Ha(t)]}function Ha(e){return e.replace(/start|end/g,t=>Uw[t])}const ff=["left","right"],hf=["right","left"],qw=["top","bottom"],Gw=["bottom","top"];function Yw(e,t,n){switch(e){case"top":case"bottom":return n?t?hf:ff:t?ff:hf;case"left":case"right":return t?qw:Gw;default:return[]}}function Xw(e,t,n,r){const o=Dr(e);let s=Yw(Fn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ha)))),s}function Us(e){return e.replace(/left|right|bottom|top/g,t=>Hw[t])}function Jw(e){return{top:0,right:0,bottom:0,left:0,...e}}function pf(e){return typeof e!="number"?Jw(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 mf(e,t,n){let{reference:r,floating:o}=e;const s=In(t),i=Ba(t),a=za(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 Zw=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}=mf(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}=mf(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=pf(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 Qw=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=pf(d),h={x:n,y:r},p=Ba(o),v=za(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,P=I/2-x[v]/2-1,j=Xn(f[y],P),H=Xn(f[b],P),F=j,U=I-x[v]-H,D=I/2-x[v]/2+_,G=Fa(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}}}),e0=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=In(a),C=Fn(a)===a,E=await(l.isRTL==null?void 0:l.isRTL(u.floating)),k=h||(C||!x?[Us(a)]:Kw(a)),T=v!=="none";!h&&T&&k.push(...Xw(a,x,v,E));const I=[a,...k],_=await xo(t,g),P=[];let j=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&P.push(_[y]),f){const D=Vw(o,i,E);P.push(_[D[0]],_[D[1]])}if(j=[...j,{placement:o,overflows:P}],!P.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!==In(G):!1)||j.every($=>In($.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=In($.placement);return z===b||z==="y"}return!0}).map($=>[$.placement,$.overflows.filter(z=>z>0).reduce((z,se)=>z+se,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 gf(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function xf(e){return Bw.some(t=>e[t]>=0)}const t0=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=gf(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:xf(i)}}}case"escaped":{const s=await xo(t,{...o,altBoundary:!0}),i=gf(s,n.floating);return{data:{escapedOffsets:i,escaped:xf(i)}}}default:return{}}}}},yf=new Set(["left","top"]);async function n0(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=In(n)==="y",u=yf.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 r0=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 n0(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}}}}},o0=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=In(Fn(o)),h=$a(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=Fa(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=Fa(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}}}}}},s0=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=In(o),h=$a(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=yf.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}}}},i0=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=In(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=Xn(x-d[g],b),k=Xn(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 P=await i.getDimensions(a.floating);return v!==P.width||x!==P.height?{reset:{rects:!0}}:{}}}};function Vs(){return typeof window<"u"}function Lr(e){return vf(e)?(e.nodeName||"").toLowerCase():"#document"}function Xt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function An(e){var t;return(t=(vf(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function vf(e){return Vs()?e instanceof Node||e instanceof Xt(e).Node:!1}function hn(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 bf(e){return!Vs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Xt(e).ShadowRoot}const a0=new Set(["inline","contents"]);function yo(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=pn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!a0.has(o)}const l0=new Set(["table","td","th"]);function c0(e){return l0.has(Lr(e))}const u0=[":popover-open",":modal"];function Ks(e){return u0.some(t=>{try{return e.matches(t)}catch{return!1}})}const d0=["transform","translate","scale","rotate","perspective"],f0=["transform","translate","scale","rotate","perspective","filter"],h0=["paint","layout","strict","content"];function Ua(e){const t=Wa(),n=hn(e)?pn(e):e;return d0.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)||f0.some(r=>(n.willChange||"").includes(r))||h0.some(r=>(n.contain||"").includes(r))}function p0(e){let t=Jn(e);for(;Nn(t)&&!Fr(t);){if(Ua(t))return t;if(Ks(t))return null;t=Jn(t)}return null}function Wa(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const m0=new Set(["html","body","#document"]);function Fr(e){return m0.has(Lr(e))}function pn(e){return Xt(e).getComputedStyle(e)}function qs(e){return hn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Jn(e){if(Lr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||bf(e)&&e.host||An(e);return bf(t)?t.host:t}function wf(e){const t=Jn(e);return Fr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Nn(t)&&yo(t)?t:wf(t)}function vo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=wf(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Xt(o);if(s){const a=Va(i);return t.concat(i,i.visualViewport||[],yo(o)?o:[],a&&n?vo(a):[])}return t.concat(o,vo(o,[],n))}function Va(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Sf(e){const t=pn(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 Ka(e){return hn(e)?e:e.contextElement}function $r(e){const t=Ka(e);if(!Nn(t))return En(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Sf(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 g0=En(0);function Cf(e){const t=Xt(e);return!Wa()||!t.visualViewport?g0:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function x0(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Xt(e)?!1:t}function xr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Ka(e);let i=En(1);t&&(r?hn(r)&&(i=$r(r)):i=$r(e));const a=x0(s,n,r)?Cf(s):En(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&&hn(r)?Xt(r):r;let v=h,x=Va(v);for(;x&&r&&p!==v;){const g=$r(x),y=x.getBoundingClientRect(),b=pn(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=Va(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:xr(An(e)).left+n}function kf(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 y0(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=An(r),a=t?Ks(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=En(1);const d=En(0),f=Nn(r);if((f||!f&&!s)&&((Lr(r)!=="body"||yo(i))&&(l=qs(r)),Nn(r))){const p=xr(r);u=$r(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?kf(i,l):En(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 v0(e){return Array.from(e.getClientRects())}function b0(e){const t=An(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 pn(r).direction==="rtl"&&(i+=Yt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Tf=25;function w0(e,t){const n=Xt(e),r=An(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=Wa();(!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<=Tf&&(s-=v)}else u<=Tf&&(s+=u);return{width:s,height:i,x:a,y:l}}const S0=new Set(["absolute","fixed"]);function C0(e,t){const n=xr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Nn(e)?$r(e):En(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 Ef(e,t,n){let r;if(t==="viewport")r=w0(e,n);else if(t==="document")r=b0(An(e));else if(hn(t))r=C0(t,n);else{const o=Cf(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ws(r)}function If(e,t){const n=Jn(e);return n===t||!hn(n)||Fr(n)?!1:pn(n).position==="fixed"||If(n,t)}function k0(e,t){const n=t.get(e);if(n)return n;let r=vo(e,[],!1).filter(a=>hn(a)&&Lr(a)!=="body"),o=null;const s=pn(e).position==="fixed";let i=s?Jn(e):e;for(;hn(i)&&!Fr(i);){const a=pn(i),l=Ua(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&S0.has(o.position)||yo(i)&&!l&&If(e,i))?r=r.filter(d=>d!==i):o=a,i=Jn(i)}return t.set(e,r),r}function T0(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=Ef(t,d,o);return u.top=Yt(f.top,u.top),u.right=Xn(f.right,u.right),u.bottom=Xn(f.bottom,u.bottom),u.left=Yt(f.left,u.left),u},Ef(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function E0(e){const{width:t,height:n}=Sf(e);return{width:t,height:n}}function I0(e,t,n){const r=Nn(t),o=An(t),s=n==="fixed",i=xr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=En(0);function u(){l.x=Gs(o)}if(r||!r&&!s)if((Lr(t)!=="body"||yo(o))&&(a=qs(t)),r){const p=xr(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?kf(o,a):En(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 qa(e){return pn(e).position==="static"}function Af(e,t){if(!Nn(e)||pn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return An(e)===n&&(n=n.ownerDocument.body),n}function Nf(e,t){const n=Xt(e);if(Ks(e))return n;if(!Nn(e)){let o=Jn(e);for(;o&&!Fr(o);){if(hn(o)&&!qa(o))return o;o=Jn(o)}return n}let r=Af(e,t);for(;r&&c0(r)&&qa(r);)r=Af(r,t);return r&&Fr(r)&&qa(r)&&!Ua(r)?n:r||p0(e)||n}const A0=async function(e){const t=this.getOffsetParent||Nf,n=this.getDimensions,r=await n(e.floating);return{reference:I0(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function N0(e){return pn(e).direction==="rtl"}const _0={convertOffsetParentRelativeRectToViewportRelativeRect:y0,getDocumentElement:An,getClippingRect:T0,getOffsetParent:Nf,getElementRects:A0,getClientRects:v0,getDimensions:E0,getScale:$r,isElement:hn,isRTL:N0};function _f(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function j0(e,t){let n=null,r;const o=An(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,Xn(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&&!_f(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 R0(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=Ka(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?j0(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?xr(e):null;l&&g();function g(){const y=xr(e);x&&!_f(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 P0=r0,O0=o0,M0=e0,D0=i0,L0=t0,jf=Qw,F0=s0,$0=(e,t,n)=>{const r=new Map,o={platform:_0,...n},s={...o.platform,_c:r};return Zw(e,t,{...o,platform:s})};var z0=typeof document<"u",B0=function(){},Ys=z0?w.useLayoutEffect:B0;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 Rf(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Pf(e,t){const n=Rf(e);return Math.round(t*n)/n}function Ga(e){const t=m.useRef(e);return Ys(()=>{t.current=e}),t}function H0(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),P=l!=null,j=Ga(l),H=Ga(o),F=Ga(u),U=m.useCallback(()=>{if(!T.current||!I.current)return;const $={placement:t,strategy:n,middleware:h};H.current&&($.platform=H.current),$0(T.current,I.current,$).then(z=>{const se={...z,isPositioned:F.current!==!1};D.current&&!Xs(_.current,se)&&(_.current=se,Po.flushSync(()=>{f(se)}))})},[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,P]);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=Pf(W.floating,d.x),se=Pf(W.floating,d.y);return a?{...$,transform:"translate("+z+"px, "+se+"px)",...Rf(W.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:z,top:se}},[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 U0=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?jf({element:r.current,padding:o}).fn(n):{}:r?jf({element:r,padding:o}).fn(n):{}}}},W0=(e,t)=>({...P0(e),options:[e,t]}),V0=(e,t)=>({...O0(e),options:[e,t]}),K0=(e,t)=>({...F0(e),options:[e,t]}),q0=(e,t)=>({...M0(e),options:[e,t]}),G0=(e,t)=>({...D0(e),options:[e,t]}),Y0=(e,t)=>({...L0(e),options:[e,t]}),X0=(e,t)=>({...U0(e),options:[e,t]});var J0="Arrow",Of=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(Ee.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"})})});Of.displayName=J0;var Z0=Of;function Mf(e){const[t,n]=m.useState(void 0);return St(()=>{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 Ya="Popper",[Df,Js]=Cn(Ya),[Q0,Lf]=Df(Ya),Ff=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(Q0,{scope:t,anchor:r,onAnchorChange:o,children:n})};Ff.displayName=Ya;var $f="PopperAnchor",zf=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Lf($f,n),i=m.useRef(null),a=We(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(Ee.div,{...o,ref:a})});zf.displayName=$f;var Xa="PopperContent",[eS,tS]=Df(Xa),Bf=m.forwardRef((e,t)=>{var K,L,Z,ee,pe,oe;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=Lf(Xa,n),[y,b]=m.useState(null),C=We(t,ie=>b(ie)),[E,k]=m.useState(null),T=Mf(E),I=(T==null?void 0:T.width)??0,_=(T==null?void 0:T.height)??0,P=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(rS),altBoundary:F},{refs:D,floatingStyles:G,placement:W,isPositioned:ne,middlewareData:$}=H0({strategy:"fixed",placement:P,whileElementsMounted:(...ie)=>R0(...ie,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[W0({mainAxis:o+_,alignmentAxis:i}),l&&V0({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?K0():void 0,...U}),l&&q0({...U}),G0({...U,apply:({elements:ie,rects:Be,availableWidth:Je,availableHeight:je})=>{const{width:He,height:Qe}=Be.reference,Ze=ie.floating.style;Ze.setProperty("--radix-popper-available-width",`${Je}px`),Ze.setProperty("--radix-popper-available-height",`${je}px`),Ze.setProperty("--radix-popper-anchor-width",`${He}px`),Ze.setProperty("--radix-popper-anchor-height",`${Qe}px`)}}),E&&X0({element:E,padding:a}),oS({arrowWidth:I,arrowHeight:_}),h&&Y0({strategy:"referenceHidden",...U})]}),[z,se]=Wf(W),M=_t(v);St(()=>{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 St(()=>{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,(pe=$.transformOrigin)==null?void 0:pe.y].join(" "),...((oe=$.hide)==null?void 0:oe.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(eS,{scope:n,placedSide:z,onArrowChange:k,arrowX:Y,arrowY:ce,shouldHideArrow:be,children:c.jsx(Ee.div,{"data-side":z,"data-align":se,...x,ref:C,style:{...x.style,animation:ne?void 0:"none"}})})})});Bf.displayName=Xa;var Hf="PopperArrow",nS={top:"bottom",right:"left",bottom:"top",left:"right"},Uf=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=tS(Hf,r),i=nS[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(Z0,{...o,ref:n,style:{...o.style,display:"block"}})})});Uf.displayName=Hf;function rS(e){return e!==null}var oS=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]=Wf(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 Wf(e){const[t,n="center"]=e.split("-");return[t,n]}var Vf=Ff,Kf=zf,qf=Bf,Gf=Uf,Ja="rovingFocusGroup.onEntryFocus",sS={bubbles:!1,cancelable:!0},bo="RovingFocusGroup",[Za,Yf,iS]=La(bo),[aS,Xf]=Cn(bo,[iS]),[lS,cS]=aS(bo),Jf=m.forwardRef((e,t)=>c.jsx(Za.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Za.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(uS,{...e,ref:t})})}));Jf.displayName=bo;var uS=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=We(t,h),v=zs(s),[x,g]=hr({prop:i,defaultProp:a??null,onChange:l,caller:bo}),[y,b]=m.useState(!1),C=_t(u),E=Yf(n),k=m.useRef(!1),[T,I]=m.useState(0);return m.useEffect(()=>{const _=h.current;if(_)return _.addEventListener(Ja,C),()=>_.removeEventListener(Ja,C)},[C]),c.jsx(lS,{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(Ee.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:he(e.onMouseDown,()=>{k.current=!0}),onFocus:he(e.onFocus,_=>{const P=!k.current;if(_.target===_.currentTarget&&P&&!y){const j=new CustomEvent(Ja,sS);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);eh(G,d)}}k.current=!1}),onBlur:he(e.onBlur,()=>b(!1))})})}),Zf="RovingFocusGroupItem",Qf=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=kn(),u=s||l,d=cS(Zf,n),f=d.currentTabStopId===u,h=Yf(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:x}=d;return m.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),c.jsx(Za.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(Ee.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:he(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:he(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:he(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const y=hS(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?pS(C,E+1):C.slice(E+1)}setTimeout(()=>eh(C))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:x!=null}):i})})});Qf.displayName=Zf;var dS={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function fS(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function hS(e,t,n){const r=fS(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return dS[r]}function eh(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function pS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var mS=Jf,gS=Qf,Qa=["Enter"," "],xS=["ArrowDown","PageUp","Home"],th=["ArrowUp","PageDown","End"],yS=[...xS,...th],vS={ltr:[...Qa,"ArrowRight"],rtl:[...Qa,"ArrowLeft"]},bS={ltr:["ArrowLeft"],rtl:["ArrowRight"]},wo="Menu",[So,wS,SS]=La(wo),[yr,nh]=Cn(wo,[SS,Js,Xf]),Zs=Js(),rh=Xf(),[CS,vr]=yr(wo),[kS,Co]=yr(wo),oh=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=_t(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(Vf,{...a,children:c.jsx(CS,{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})})})};oh.displayName=wo;var TS="MenuAnchor",el=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Zs(n);return c.jsx(Kf,{...o,...r,ref:t})});el.displayName=TS;var tl="MenuPortal",[ES,sh]=yr(tl,{forceMount:void 0}),ih=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=vr(tl,t);return c.jsx(ES,{scope:t,forceMount:n,children:c.jsx(Gt,{present:n||s.open,children:c.jsx(ws,{asChild:!0,container:o,children:r})})})};ih.displayName=tl;var nn="MenuContent",[IS,nl]=yr(nn),ah=m.forwardRef((e,t)=>{const n=sh(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=vr(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(NS,{...o,ref:t})})})})}),AS=m.forwardRef((e,t)=>{const n=vr(nn,e.__scopeMenu),r=m.useRef(null),o=We(t,r);return m.useEffect(()=>{const s=r.current;if(s)return Ra(s)},[]),c.jsx(rl,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:he(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),NS=m.forwardRef((e,t)=>{const n=vr(nn,e.__scopeMenu);return c.jsx(rl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),_S=or.createSlot("MenuContent.ScrollLock"),rl=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=vr(nn,n),y=Co(nn,n),b=Zs(n),C=rh(n),E=wS(n),[k,T]=m.useState(null),I=m.useRef(null),_=We(t,I,g.onContentChange),P=m.useRef(0),j=m.useRef(""),H=m.useRef(0),F=m.useRef(null),U=m.useRef("right"),D=m.useRef(0),G=v?Is:m.Fragment,W=v?{as:_S,allowPinchZoom:!0}:void 0,ne=z=>{var K,L;const se=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=HS(be,se,ce),ye=(L=M.find(Z=>Z.textValue===ge))==null?void 0:L.ref.current;(function Z(ee){j.current=ee,window.clearTimeout(P.current),ee!==""&&(P.current=window.setTimeout(()=>Z(""),1e3))})(se),ye&&setTimeout(()=>ye.focus())};m.useEffect(()=>()=>window.clearTimeout(P.current),[]),Ea();const $=m.useCallback(z=>{var M,Y;return U.current===((M=F.current)==null?void 0:M.side)&&WS(z,(Y=F.current)==null?void 0:Y.area)},[]);return c.jsx(IS,{scope:n,searchRef:j,onItemEnter:m.useCallback(z=>{$(z)&&z.preventDefault()},[$]),onItemLeave:m.useCallback(z=>{var se;$(z)||((se=I.current)==null||se.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(bs,{asChild:!0,trapped:o,onMountAutoFocus:he(s,z=>{var se;z.preventDefault(),(se=I.current)==null||se.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(vs,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:c.jsx(mS,{asChild:!0,...C,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:k,onCurrentTabStopIdChange:T,onEntryFocus:he(l,z=>{y.isUsingKeyboardRef.current||z.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(qf,{role:"menu","aria-orientation":"vertical","data-state":kh(g.open),"data-radix-menu-content":"",dir:y.dir,...b,...x,ref:_,style:{outline:"none",...x.style},onKeyDown:he(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||!yS.includes(z.key))return;z.preventDefault();const ye=E().filter(K=>!K.disabled).map(K=>K.ref.current);th.includes(z.key)&&ye.reverse(),zS(ye)}),onBlur:he(e.onBlur,z=>{z.currentTarget.contains(z.target)||(window.clearTimeout(P.current),j.current="")}),onPointerMove:he(e.onPointerMove,To(z=>{const se=z.target,M=D.current!==z.clientX;if(z.currentTarget.contains(se)&&M){const Y=z.clientX>D.current?"right":"left";U.current=Y,D.current=z.clientX}}))})})})})})})});ah.displayName=nn;var jS="MenuGroup",ol=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ee.div,{role:"group",...r,ref:t})});ol.displayName=jS;var RS="MenuLabel",lh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ee.div,{...r,ref:t})});lh.displayName=RS;var Qs="MenuItem",ch="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=nl(Qs,e.__scopeMenu),l=We(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(ch,{bubbles:!0,cancelable:!0});f.addEventListener(ch,p=>r==null?void 0:r(p),{once:!0}),Vu(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(uh,{...o,ref:l,disabled:n,onClick:he(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:he(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:he(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||Qa.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});ei.displayName=Qs;var uh=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=nl(Qs,n),a=rh(n),l=m.useRef(null),u=We(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(gS,{asChild:!0,...a,focusable:!r,children:c.jsx(Ee.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:he(e.onPointerMove,To(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:he(e.onPointerLeave,To(v=>i.onItemLeave(v))),onFocus:he(e.onFocus,()=>f(!0)),onBlur:he(e.onBlur,()=>f(!1))})})})}),PS="MenuCheckboxItem",dh=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(gh,{scope:e.__scopeMenu,checked:n,children:c.jsx(ei,{role:"menuitemcheckbox","aria-checked":ti(n)?"mixed":n,...o,ref:t,"data-state":il(n),onSelect:he(o.onSelect,()=>r==null?void 0:r(ti(n)?!0:!n),{checkForDefaultPrevented:!1})})})});dh.displayName=PS;var fh="MenuRadioGroup",[OS,MS]=yr(fh,{value:void 0,onValueChange:()=>{}}),hh=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=_t(r);return c.jsx(OS,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(ol,{...o,ref:t})})});hh.displayName=fh;var ph="MenuRadioItem",mh=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=MS(ph,e.__scopeMenu),s=n===o.value;return c.jsx(gh,{scope:e.__scopeMenu,checked:s,children:c.jsx(ei,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":il(s),onSelect:he(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});mh.displayName=ph;var sl="MenuItemIndicator",[gh,DS]=yr(sl,{checked:!1}),xh=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=DS(sl,n);return c.jsx(Gt,{present:r||ti(s.checked)||s.checked===!0,children:c.jsx(Ee.span,{...o,ref:t,"data-state":il(s.checked)})})});xh.displayName=sl;var LS="MenuSeparator",yh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ee.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});yh.displayName=LS;var FS="MenuArrow",vh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Zs(n);return c.jsx(Gf,{...o,...r,ref:t})});vh.displayName=FS;var $S="MenuSub",[ST,bh]=yr($S),ko="MenuSubTrigger",wh=m.forwardRef((e,t)=>{const n=vr(ko,e.__scopeMenu),r=Co(ko,e.__scopeMenu),o=bh(ko,e.__scopeMenu),s=nl(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(el,{asChild:!0,...u,children:c.jsx(uh,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":kh(n.open),...e,ref:fa(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:he(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:he(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:he(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||vS[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});wh.displayName=ko;var Sh="MenuSubContent",Ch=m.forwardRef((e,t)=>{const n=sh(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=vr(nn,e.__scopeMenu),i=Co(nn,e.__scopeMenu),a=bh(Sh,e.__scopeMenu),l=m.useRef(null),u=We(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(rl,{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:he(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:he(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:he(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=bS[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});Ch.displayName=Sh;function kh(e){return e?"open":"closed"}function ti(e){return e==="indeterminate"}function il(e){return ti(e)?"indeterminate":e?"checked":"unchecked"}function zS(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function BS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function HS(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=BS(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 US(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 WS(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return US(n,t)}function To(e){return t=>t.pointerType==="mouse"?e(t):void 0}var VS=oh,KS=el,qS=ih,GS=ah,YS=ol,XS=lh,JS=ei,ZS=dh,QS=hh,eC=mh,tC=xh,nC=yh,rC=vh,oC=wh,sC=Ch,ni="DropdownMenu",[iC,CT]=Cn(ni,[nh]),Bt=nh(),[aC,Th]=iC(ni),Eh=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Bt(t),u=m.useRef(null),[d,f]=hr({prop:o,defaultProp:s??!1,onChange:i,caller:ni});return c.jsx(aC,{scope:t,triggerId:kn(),triggerRef:u,contentId:kn(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(VS,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Eh.displayName=ni;var Ih="DropdownMenuTrigger",Ah=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Th(Ih,n),i=Bt(n);return c.jsx(KS,{asChild:!0,...i,children:c.jsx(Ee.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:fa(t,s.triggerRef),onPointerDown:he(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:he(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Ah.displayName=Ih;var lC="DropdownMenuPortal",Nh=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Bt(t);return c.jsx(qS,{...r,...n})};Nh.displayName=lC;var _h="DropdownMenuContent",jh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Th(_h,n),s=Bt(n),i=m.useRef(!1);return c.jsx(GS,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:he(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:he(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)"}})});jh.displayName=_h;var cC="DropdownMenuGroup",uC=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(YS,{...o,...r,ref:t})});uC.displayName=cC;var dC="DropdownMenuLabel",Rh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(XS,{...o,...r,ref:t})});Rh.displayName=dC;var fC="DropdownMenuItem",Ph=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(JS,{...o,...r,ref:t})});Ph.displayName=fC;var hC="DropdownMenuCheckboxItem",Oh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(ZS,{...o,...r,ref:t})});Oh.displayName=hC;var pC="DropdownMenuRadioGroup",mC=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(QS,{...o,...r,ref:t})});mC.displayName=pC;var gC="DropdownMenuRadioItem",Mh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(eC,{...o,...r,ref:t})});Mh.displayName=gC;var xC="DropdownMenuItemIndicator",Dh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(tC,{...o,...r,ref:t})});Dh.displayName=xC;var yC="DropdownMenuSeparator",Lh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(nC,{...o,...r,ref:t})});Lh.displayName=yC;var vC="DropdownMenuArrow",bC=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(rC,{...o,...r,ref:t})});bC.displayName=vC;var wC="DropdownMenuSubTrigger",Fh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(oC,{...o,...r,ref:t})});Fh.displayName=wC;var SC="DropdownMenuSubContent",$h=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(sC,{...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)"}})});$h.displayName=SC;var CC=Eh,kC=Ah,TC=Nh,zh=jh,Bh=Rh,Hh=Ph,Uh=Oh,Wh=Mh,Vh=Dh,Kh=Lh,qh=Fh,Gh=$h;const EC=CC,IC=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(me.ChevronRight,{className:"ml-auto h-4 w-4"})]}));AC.displayName=qh.displayName;const NC=m.forwardRef(({className:e,...t},n)=>c.jsx(Gh,{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}));NC.displayName=Gh.displayName;const Yh=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(TC,{children:c.jsx(zh,{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})}));Yh.displayName=zh.displayName;const al=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Hh,{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}));al.displayName=Hh.displayName;const _C=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(Uh,{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(Vh,{children:c.jsx(me.Check,{className:"h-4 w-4"})})}),t]}));_C.displayName=Uh.displayName;const jC=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Wh,{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(Vh,{children:c.jsx(me.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));jC.displayName=Wh.displayName;const RC=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Bh,{ref:r,className:re("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));RC.displayName=Bh.displayName;const PC=m.forwardRef(({className:e,...t},n)=>c.jsx(Kh,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));PC.displayName=Kh.displayName;function OC(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}=Ni(),{currentThreadId:x}=Yo(),{threadId:g,messages:y,hasMore:b,isHistoryLoading:C,isLoading:E,loadOlder:k,navigateToCheckpoint:T,returnToLatest:I,checkpoint:_,checkpoints:P,interrupt:j,metadata:H}=Xo(),{isStreaming:F,error:U,submit:D,stop:G}=Uc(),W=g??x??null,ne=(_==null?void 0:_.id)??null,$=(_==null?void 0:_.namespace)??null,z=(H==null?void 0:H.assemblingMessageId)??null,se=j,[M,Y]=w.useState(!1);w.useEffect(()=>{se||Y(!1)},[se]);const ce=w.useCallback(()=>{Y(!0)},[]),be=w.useCallback(()=>{Y(!1)},[]),ge=!!se||M,[ye,K]=w.useState(null),[L,Z]=w.useState(""),[ee,pe]=w.useState(null),[oe,ie]=w.useState([]),[Be,Je]=w.useState(0),[je,He]=w.useState(0),[Qe,Ze]=w.useState(!1),[Pe,wt]=w.useState(null),[Ct,kt]=w.useState(null),[ot,et]=w.useState(!1),[$e,ct]=w.useState(null),[vt,J]=w.useState(!1),xe=w.useRef(!1),[ue,_e]=w.useState(!1),Ve=w.useCallback((S,R)=>{if(!S||typeof S!="object")return null;const B=S[R];return typeof B=="number"?B:null},[]),at=w.useCallback((S,R)=>{if(!S||typeof S!="object")return null;const B=S[R];return typeof B=="string"&&B.trim()?B:null},[]),Tt=w.useMemo(()=>{const S=Array.isArray(P)?[...P]:[];return S.some(B=>Ve(B.metadata,"step")!==null)&&S.sort((B,ae)=>{const ke=Ve(B.metadata,"step"),Ae=Ve(ae.metadata,"step");if(ke!==null||Ae!==null)return(Ae??Number.NEGATIVE_INFINITY)-(ke??Number.NEGATIVE_INFINITY);const De=Date.parse(B.createdAt??""),Oe=Date.parse(ae.createdAt??"");return Number.isNaN(De)||Number.isNaN(Oe)?0:Oe-De}),S},[P,Ve]),rt=w.useRef(null),ut=w.useRef(null),pt=w.useCallback(()=>{rt.current&&(rt.current.value=""),ut.current&&(ut.current.value=""),Je(S=>S+1),He(S=>S+1)},[]),$n=w.useRef(!1);w.useEffect(()=>{$n.current&&!F&&(ie([]),pt()),$n.current=F},[F,pt]);const[sn,jt]=w.useState("desktop");w.useEffect(()=>{const S=()=>{const R=window.innerWidth;jt(R<640?"phone":R<1024?"tablet":"desktop")};return S(),window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[]),w.useEffect(()=>{J(!1),xe.current=!1},[W]);const Cr=w.useCallback(async()=>{if(!(!b||C||!vt))try{await k()}catch(S){console.warn("loadOlder failed",S)}},[b,vt,C,k]);w.useEffect(()=>{(async()=>{if(!v.baseUrl){ct(null);return}try{const R=await v.getAgent("default");ct(R.uiDefaultMessage||null)}catch(R){console.warn("Failed to fetch default message:",R),ct(null)}})()},[v]),w.useEffect(()=>{U&&!ot&&(p==null||p(U))},[U,ot,p]);const tr=S=>{if(S.length>$s)return`Message too long (${S.length}/${$s} characters)`;try{return $w(S),null}catch(R){return(R==null?void 0:R.message)||"Invalid message"}},Et=async S=>{const R=S.trim();if(!(!R&&oe.length===0)){if(R){const B=tr(R);if(B){pe(B);return}}try{await D({text:R||"",attachments:oe,payload:ye?{edit:!0,originalMessageId:ye}:void 0},{checkpointId:ne??void 0,checkpointNs:$??void 0}),f==null||f(R),pe(null),ie([]),pt(),K(null),Z("")}catch(B){const ae=(B==null?void 0:B.message)||"Failed to send message";pe(ae),p==null||p(ae)}}},an=w.useCallback((S,R)=>{u&&(K(S),Z(R),pe(null))},[u]),gn=w.useCallback(()=>{K(null),Z(""),pe(null)},[]),kr=w.useCallback((S,R)=>{an(S,R)},[an]),Jt=w.useCallback(S=>{const R=B=>{const ae=B.content||[],ke=ae.filter(Ae=>Ae.type==="text").map(Ae=>Ae.text).join("");if(ke)return ke;try{return JSON.stringify(ae,null,2)}catch{return String(ae)}};for(let B=S-1;B>=0;B--)if(y[B].role==="user"){const ae=R(y[B]);ae&&D({text:ae},{checkpointId:ne??void 0,checkpointNs:$??void 0});break}},[y,D,ne,$]),Tr=S=>{const R=Array.from(S.target.files||[]);ie(B=>[...B,...R]),S.target.value=""},jn=S=>{ie(R=>{const B=R.filter((ae,ke)=>S!==ke);return B.length===0&&pt(),B})},xn=async S=>{const R=(S.target.files||[])[0];if(R){wt(null),kt(null),Ze(!0);try{await D({attachments:[R]},{checkpointId:ne??void 0,checkpointNs:$??void 0});const B=`Uploaded ${R.name} - processing through chat stream`;kt(B)}catch(B){const ae=B instanceof Error?B.message:"Failed to upload Excel file";console.error("Excel upload failed",B),wt(ae),p==null||p(ae)}finally{Ze(!1),S.target.value="",pt()}}},nr=S=>{if(!S)return"Unknown";const R=Date.parse(S);return Number.isNaN(R)?S:new Date(R).toLocaleString()},Io=async S=>{if(x){_e(!0);try{if(!S){await I();return}const R=Tt.find(ae=>ae.checkpointId===S),B=(R==null?void 0:R.checkpointNs)??null;await T(S,B)}finally{_e(!1)}}},Ur=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,Wr=`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||""}`,rr=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return c.jsxs("div",{className:Ur,children:[!!U&&!ot&&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(Ge,{variant:"ghost",size:"sm",onClick:()=>et(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(me.X,{size:16})})]}),x&&P.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 R=S.target.value||null;Io(R)},children:[c.jsx("option",{value:"",children:"Latest"}),Tt.map(S=>{const R=Ve(S.metadata,"step"),B=at(S.metadata,"source"),ae=OC(S.messages),ke=[];R!==null&&ke.push(`Step ${R}`),B&&ke.push(B),ae&&ke.push(ae.slice(0,40));const Ae=ke.length?` — ${ke.join(" • ")}`:"";return c.jsxs("option",{value:S.checkpointId,children:[nr(S.createdAt),Ae]},S.checkpointId)})]})]}),c.jsxs("div",{className:`relative ${Wr}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(Da,{className:"h-full",style:{height:"100%"},messages:y,isStreaming:F,streamingAssistantId:z,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:sn,enableMessageEditing:u,editingMessageId:ye,onStartReached:()=>{vt&&Cr()},onScrollAway:S=>{if(!xe.current){xe.current=!0;return}S&&J(!0)},onEdit:kr,onRegenerate:Jt,onCancelEdit:gn,emptyMessage:$e??void 0,isNavigatingCheckpoint:ue,activeInterrupt:se,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(me.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:rr,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(me.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(Ge,{variant:"ghost",size:"sm",onClick:gn,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(me.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:rt,type:"file",multiple:!0,onChange:S=>Tr(S),className:"hidden"},Be),oe.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:oe.map((S,R)=>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(me.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:S.name}),c.jsx(Ge,{variant:"ghost",size:"sm",onClick:()=>jn(R),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(me.X,{size:12})})]},R))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:ut,type:"file",accept:".xls,.xlsx,.xlsm",onChange:xn,className:"hidden"},je),Qe&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(me.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),Ct&&!Qe&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:Ct}),Pe&&!Qe&&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(EC,{children:[c.jsx(IC,{asChild:!0,children:c.jsx(Ge,{type:"button",size:"icon",variant:"outline",disabled:F||ge,title:"More input actions",className:d.moreButton||"",children:c.jsx(me.Plus,{size:16})})}),c.jsxs(Yh,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(al,{onClick:()=>{var S;return(S=rt.current)==null?void 0:S.click()},className:"cursor-pointer",children:[c.jsx(me.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(al,{onClick:()=>{var S;Qe||(S=ut.current)==null||S.click()},className:`cursor-pointer ${Qe?"opacity-60 pointer-events-none":""}`,children:[c.jsx(me.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx(Xx,{initialValue:L,editingMessageId:ye,placeholder:ye?"Edit your message...":t,isStreaming:F,disabled:ge,maxLength:$s,onSend:Et,onCancelEdit:gn,onStop:G,allowEmptySend:oe.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 ll(e,[t,n]){return Math.min(n,Math.max(t,e))}function MC(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var cl="ScrollArea",[Xh,kT]=Cn(cl),[DC,rn]=Xh(cl),Jh=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),P=We(t,H=>l(H)),j=zs(o);return c.jsx(DC,{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(Ee.div,{dir:j,...i,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});Jh.displayName=cl;var Zh="ScrollAreaViewport",Qh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=rn(Zh,n),a=m.useRef(null),l=We(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(Ee.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})})]})});Qh.displayName=Zh;var _n="ScrollAreaScrollbar",ul=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(_n,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(LC,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(FC,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(ep,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(dl,{...r,ref:t}):null});ul.displayName=_n;var LC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(_n,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(ep,{"data-state":s?"visible":"hidden",...r,ref:t})})}),FC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(_n,e.__scopeScrollArea),s=e.orientation==="horizontal",i=li(()=>l("SCROLL_END"),100),[a,l]=MC("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(dl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:he(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:he(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),ep=m.forwardRef((e,t)=>{const n=rn(_n,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(dl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),dl=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=rn(_n,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=sp(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 WC(h,i.current,a,p)}return n==="horizontal"?c.jsx($C,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=ip(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(zC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=ip(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}),$C=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(_n,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=We(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(np,{"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),lp(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)}})}})}),zC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(_n,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=We(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(np,{"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),lp(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)}})}})}),[BC,tp]=Xh(_n),np=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(_n,n),[v,x]=m.useState(null),g=We(t,P=>x(P)),y=m.useRef(null),b=m.useRef(""),C=p.viewport,E=r.content-r.viewport,k=_t(d),T=_t(l),I=li(f,10);function _(P){if(y.current){const j=P.clientX-y.current.left,H=P.clientY-y.current.top;u({x:j,y:H})}}return m.useEffect(()=>{const P=j=>{const H=j.target;(v==null?void 0:v.contains(H))&&k(j,E)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[C,v,E,k]),m.useEffect(T,[r,T]),zr(v,I),zr(p.content,I),c.jsx(BC,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:_t(s),onThumbPointerUp:_t(i),onThumbPositionChange:T,onThumbPointerDown:_t(a),children:c.jsx(Ee.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:he(e.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),_(P))}),onPointerMove:he(e.onPointerMove,_),onPointerUp:he(e.onPointerUp,P=>{const j=P.target;j.hasPointerCapture(P.pointerId)&&j.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),si="ScrollAreaThumb",rp=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=tp(si,e.__scopeScrollArea);return c.jsx(Gt,{present:n||o.hasThumb,children:c.jsx(HC,{ref:t,...r})})}),HC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=rn(si,n),i=tp(si,n),{onThumbPositionChange:a}=i,l=We(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=VC(f,a);u.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),c.jsx(Ee.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:he(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:he(e.onPointerUp,i.onThumbPointerUp)})});rp.displayName=si;var fl="ScrollAreaCorner",op=m.forwardRef((e,t)=>{const n=rn(fl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(UC,{...e,ref:t}):null});op.displayName=fl;var UC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=rn(fl,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(Ee.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 sp(e,t){const n=e/t;return isNaN(n)?0:n}function ai(e){const t=sp(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function WC(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 ap([l,u],f)(e)}function ip(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=ll(e,l);return ap([0,i],[0,a])(u)}function ap(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 lp(e,t){return e>0&&e<t}var VC=(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=_t(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=_t(t);St(()=>{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 cp=Jh,KC=Qh,qC=op;const up=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(cp,{ref:r,className:re("relative overflow-hidden",e),...n,children:[c.jsx(KC,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(dp,{}),c.jsx(qC,{})]}));up.displayName=cp.displayName;const dp=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(ul,{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(rp,{className:"relative flex-1 rounded-full bg-border"})}));dp.displayName=ul.displayName;function hl({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}=Yo(),{loadThread:x}=Xo(),{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),[_,P]=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),P(M.title||`Thread ${M.threadId.slice(0,8)}`)},W=async M=>{if(_.trim())try{await b(M,_.trim()),I(null),P("")}catch(Y){console.error("Failed to update title:",Y)}},ne=()=>{I(null),P("")},$=(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""}},se=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(Ge,{onClick:U,disabled:j||p,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:j?"Creating...":"New Chat",children:c.jsx(me.MessageSquarePlus,{size:20})})}),c.jsx(up,{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(me.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(me.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=>P(Y.target.value),onKeyDown:Y=>$(Y,M.threadId),className:"h-6 text-sm",autoFocus:!0}),c.jsx(Ge,{variant:"ghost",size:"sm",onClick:()=>W(M.threadId),className:"h-6 w-6 p-0",children:c.jsx(me.Check,{size:12})}),c.jsx(Ge,{variant:"ghost",size:"sm",onClick:ne,className:"h-6 w-6 p-0",children:c.jsx(me.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:se(M)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(me.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(Ge,{variant:"ghost",size:"sm",onClick:Y=>G(M,Y),className:"h-6 w-6 p-0",title:"Edit title",children:c.jsx(me.Edit3,{size:12})}),n&&c.jsx(Ge,{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(me.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 GC(e){if(typeof e!="string")return;const t=e.trim();if(t)return Mn(t)}function fp(){const e=[Br("__API_BASE_URL__"),Br("__CHAT_API_BASE_URL__"),Br("__CHAT_API_URL__")];for(const t of e){const n=GC(t);if(n)return n}}function hp(){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 pp(...e){for(const t of e)if(typeof t=="string"&&t.trim())return Mn(t);return Mn()}function mp(){const e={},t=fp(),n=hp();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function gp(){const e=mp(),t=Hn.getAuthToken(),n=fp();return{apiBaseUrl:pp(e.baseUrl,Hn.baseUrl,n),apiKey:t||e.apiKey||hp()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const xp="chat-settings";function YC(){try{const e=localStorage.getItem(xp);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function XC(e){try{const t={...e,apiBaseUrl:Mn(e.apiBaseUrl)};localStorage.setItem(xp,JSON.stringify(t)),t.apiKey&&Hn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function JC(){const e=gp(),t=YC(),n=Hn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:pp(Hn.baseUrl,r,e.apiBaseUrl)}}function ZC(e){Hn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),XC(e)}var QC="Label",yp=m.forwardRef((e,t)=>c.jsx(Ee.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())}}));yp.displayName=QC;var vp=yp;const ek=Ro.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(vp,{ref:n,className:re(ek(),e),...t}));on.displayName=vp.displayName;function bp(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",[tk,TT]=Cn(ci),[nk,rk]=tk(ci),wp=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=We(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(nk,{scope:n,checked:y,disabled:a,children:[c.jsx(Ee.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":Tp(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:v,onClick:he(e.onClick,C=>{b(E=>!E),g&&(x.current=C.isPropagationStopped(),x.current||C.stopPropagation())})}),g&&c.jsx(kp,{control:h,bubbles:!x.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});wp.displayName=ci;var Sp="SwitchThumb",Cp=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=rk(Sp,n);return c.jsx(Ee.span,{"data-state":Tp(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Cp.displayName=Sp;var ok="SwitchBubbleInput",kp=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=We(i,s),l=bp(n),u=Mf(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}})});kp.displayName=ok;function Tp(e){return e?"checked":"unchecked"}var Ep=wp,sk=Cp;const Zn=m.forwardRef(({className:e,...t},n)=>c.jsx(Ep,{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(sk,{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")})}));Zn.displayName=Ep.displayName;var Ip=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"}),ik="VisuallyHidden",ak=m.forwardRef((e,t)=>c.jsx(Ee.span,{...e,ref:t,style:{...Ip,...e.style}}));ak.displayName=ik;var lk=[" ","Enter","ArrowUp","ArrowDown"],ck=[" ","Enter"],br="Select",[ui,di,uk]=La(br),[Hr,ET]=Cn(br,[uk,Js]),fi=Js(),[dk,Qn]=Hr(br),[fk,hk]=Hr(br),Ap=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:br}),[P,j]=hr({prop:i,defaultProp:a,onChange:l,caller:br}),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(Vf,{...x,children:c.jsxs(dk,{required:p,scope:t,trigger:g,onTriggerChange:y,valueNode:b,onValueNodeChange:C,valueNodeHasChildren:E,onValueNodeHasChildrenChange:k,contentId:kn(),value:P,onValueChange:j,open:I,onOpenChange:_,dir:T,triggerPointerDownPosRef:H,disabled:h,children:[c.jsx(ui.Provider,{scope:t,children:c.jsx(fk,{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(Zp,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:P,onChange:W=>j(W.target.value),disabled:h,form:v,children:[P===void 0?c.jsx("option",{value:""}):null,Array.from(U)]},G):null]})})};Ap.displayName=br;var Np="SelectTrigger",_p=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=fi(n),i=Qn(Np,n),a=i.disabled||r,l=We(t,i.onTriggerChange),u=di(n),d=m.useRef("touch"),[f,h,p]=em(x=>{const g=u().filter(C=>!C.disabled),y=g.find(C=>C.value===i.value),b=tm(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(Kf,{asChild:!0,...s,children:c.jsx(Ee.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":Qp(i.value)?"":void 0,...o,ref:l,onClick:he(o.onClick,x=>{x.currentTarget.focus(),d.current!=="mouse"&&v(x)}),onPointerDown:he(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:he(o.onKeyDown,x=>{const g=f.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&h(x.key),!(g&&x.key===" ")&&lk.includes(x.key)&&(v(),x.preventDefault())})})})});_p.displayName=Np;var jp="SelectValue",Rp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Qn(jp,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=We(t,l.onValueNodeChange);return St(()=>{u(d)},[u,d]),c.jsx(Ee.span,{...a,ref:f,style:{pointerEvents:"none"},children:Qp(l.value)?c.jsx(c.Fragment,{children:i}):s})});Rp.displayName=jp;var pk="SelectIcon",Pp=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(Ee.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Pp.displayName=pk;var mk="SelectPortal",Op=e=>c.jsx(ws,{asChild:!0,...e});Op.displayName=mk;var wr="SelectContent",Mp=m.forwardRef((e,t)=>{const n=Qn(wr,e.__scopeSelect),[r,o]=m.useState();if(St(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Po.createPortal(c.jsx(Dp,{scope:e.__scopeSelect,children:c.jsx(ui.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(Lp,{...e,ref:t})});Mp.displayName=wr;var mn=10,[Dp,er]=Hr(wr),gk="SelectContentImpl",xk=or.createSlot("SelectContent.RemoveScroll"),Lp=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=Qn(wr,n),[C,E]=m.useState(null),[k,T]=m.useState(null),I=We(t,K=>E(K)),[_,P]=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 Ra(C)},[C]),Ea();const W=m.useCallback(K=>{const[L,...Z]=F().map(oe=>oe.ref.current),[ee]=Z.slice(-1),pe=document.activeElement;for(const oe of K)if(oe===pe||(oe==null||oe.scrollIntoView({block:"nearest"}),oe===L&&k&&(k.scrollTop=0),oe===ee&&k&&(k.scrollTop=k.scrollHeight),oe==null||oe.focus(),document.activeElement!==pe))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 pe,oe;K={x:Math.abs(Math.round(ee.pageX)-(((pe=z.current)==null?void 0:pe.x)??0)),y:Math.abs(Math.round(ee.pageY)-(((oe=z.current)==null?void 0:oe.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[se,M]=em(K=>{const L=F().filter(pe=>!pe.disabled),Z=L.find(pe=>pe.ref.current===document.activeElement),ee=tm(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)&&(P(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"?pl:Fp,ye=ge===pl?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:x,avoidCollisions:g}:{};return c.jsx(Dp,{scope:n,content:C,viewport:k,onViewportChange:T,itemRefCallback:Y,selectedItem:_,onItemLeave:ce,itemTextRefCallback:be,focusSelectedItem:ne,selectedItemText:j,position:r,isPositioned:U,searchRef:se,children:c.jsx(Is,{as:xk,allowPinchZoom:!0,children:c.jsx(bs,{asChild:!0,trapped:b.open,onMountAutoFocus:K=>{K.preventDefault()},onUnmountAutoFocus:he(o,K=>{var L;(L=b.trigger)==null||L.focus({preventScroll:!0}),K.preventDefault()}),children:c.jsx(vs,{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:he(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(pe=>!pe.disabled).map(pe=>pe.ref.current);if(["ArrowUp","End"].includes(K.key)&&(ee=ee.slice().reverse()),["ArrowUp","ArrowDown"].includes(K.key)){const pe=K.target,oe=ee.indexOf(pe);ee=ee.slice(oe+1)}setTimeout(()=>W(ee)),K.preventDefault()}})})})})})})});Lp.displayName=gk;var yk="SelectItemAlignedPosition",Fp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Qn(wr,n),i=er(wr,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=We(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(),P=s.valueNode.getBoundingClientRect(),j=y.getBoundingClientRect();if(s.dir!=="rtl"){const pe=j.left-_.left,oe=P.left-pe,ie=I.left-oe,Be=I.width+ie,Je=Math.max(Be,_.width),je=window.innerWidth-mn,He=ll(oe,[mn,Math.max(mn,je-Je)]);a.style.minWidth=Be+"px",a.style.left=He+"px"}else{const pe=_.right-j.right,oe=window.innerWidth-P.right-pe,ie=window.innerWidth-I.right-oe,Be=I.width+ie,Je=Math.max(Be,_.width),je=window.innerWidth-mn,He=ll(oe,[mn,Math.max(mn,je-Je)]);a.style.minWidth=Be+"px",a.style.right=He+"px"}const H=h(),F=window.innerHeight-mn*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,se=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-mn,ge=F-be,ye=g.offsetHeight/2,K=g.offsetTop+ye,L=G+W+K,Z=z-L;if(L<=be){const pe=H.length>0&&g===H[H.length-1].ref.current;a.style.bottom="0px";const oe=u.clientHeight-x.offsetTop-x.offsetHeight,ie=Math.max(ge,ye+(pe?ce:0)+oe+ne),Be=L+ie;a.style.height=Be+"px"}else{const pe=H.length>0&&g===H[0].ref.current;a.style.top="0px";const ie=Math.max(be,G+x.offsetTop+(pe?Y:0)+ye)+Z;a.style.height=ie+"px",x.scrollTop=L-be+x.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=se+"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]);St(()=>C(),[C]);const[E,k]=m.useState();St(()=>{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(bk,{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(Ee.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Fp.displayName=yk;var vk="SelectPopperPosition",pl=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...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)"}})});pl.displayName=vk;var[bk,ml]=Hr(wr,{}),gl="SelectViewport",$p=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=er(gl,n),i=ml(gl,n),a=We(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(Ee.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:he(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-mn*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})})})]})});$p.displayName=gl;var zp="SelectGroup",[wk,Sk]=Hr(zp),Ck=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=kn();return c.jsx(wk,{scope:n,id:o,children:c.jsx(Ee.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Ck.displayName=zp;var Bp="SelectLabel",Hp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Sk(Bp,n);return c.jsx(Ee.div,{id:o.id,...r,ref:t})});Hp.displayName=Bp;var hi="SelectItem",[kk,Up]=Hr(hi),Wp=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Qn(hi,n),l=er(hi,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),v=We(t,b=>{var C;return(C=l.itemRefCallback)==null?void 0:C.call(l,b,r,o)}),x=kn(),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(kk,{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(Ee.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:he(i.onFocus,()=>p(!0)),onBlur:he(i.onBlur,()=>p(!1)),onClick:he(i.onClick,()=>{g.current!=="mouse"&&y()}),onPointerUp:he(i.onPointerUp,()=>{g.current==="mouse"&&y()}),onPointerDown:he(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:he(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:he(i.onPointerLeave,b=>{var C;b.currentTarget===document.activeElement&&((C=l.onItemLeave)==null||C.call(l))}),onKeyDown:he(i.onKeyDown,b=>{var E;((E=l.searchRef)==null?void 0:E.current)!==""&&b.key===" "||(ck.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});Wp.displayName=hi;var Eo="SelectItemText",Vp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Qn(Eo,n),a=er(Eo,n),l=Up(Eo,n),u=hk(Eo,n),[d,f]=m.useState(null),h=We(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 St(()=>(x(v),()=>g(v)),[x,g,v]),c.jsxs(c.Fragment,{children:[c.jsx(Ee.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Po.createPortal(s.children,i.valueNode):null]})});Vp.displayName=Eo;var Kp="SelectItemIndicator",qp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Up(Kp,n).isSelected?c.jsx(Ee.span,{"aria-hidden":!0,...r,ref:t}):null});qp.displayName=Kp;var xl="SelectScrollUpButton",Gp=m.forwardRef((e,t)=>{const n=er(xl,e.__scopeSelect),r=ml(xl,e.__scopeSelect),[o,s]=m.useState(!1),i=We(t,r.onScrollButtonChange);return St(()=>{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(Xp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Gp.displayName=xl;var yl="SelectScrollDownButton",Yp=m.forwardRef((e,t)=>{const n=er(yl,e.__scopeSelect),r=ml(yl,e.__scopeSelect),[o,s]=m.useState(!1),i=We(t,r.onScrollButtonChange);return St(()=>{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(Xp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Yp.displayName=yl;var Xp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=er("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]),St(()=>{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(Ee.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:he(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:he(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:he(o.onPointerLeave,()=>{l()})})}),Tk="SelectSeparator",Jp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(Ee.div,{"aria-hidden":!0,...r,ref:t})});Jp.displayName=Tk;var vl="SelectArrow",Ek=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=fi(n),s=Qn(vl,n),i=er(vl,n);return s.open&&i.position==="popper"?c.jsx(Gf,{...o,...r,ref:t}):null});Ek.displayName=vl;var Ik="SelectBubbleInput",Zp=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=We(r,o),i=bp(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(Ee.select,{...n,style:{...Ip,...n.style},ref:s,defaultValue:t})});Zp.displayName=Ik;function Qp(e){return e===""||e===void 0}function em(e){const t=_t(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 tm(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=Ak(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 Ak(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Nk=Ap,nm=_p,_k=Rp,jk=Pp,Rk=Op,rm=Mp,Pk=$p,om=Hp,sm=Wp,Ok=Vp,Mk=qp,im=Gp,am=Yp,lm=Jp;const cm=Nk,um=_k,bl=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(nm,{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(jk,{asChild:!0,children:c.jsx(me.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));bl.displayName=nm.displayName;const dm=m.forwardRef(({className:e,...t},n)=>c.jsx(im,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(me.ChevronUp,{className:"h-4 w-4"})}));dm.displayName=im.displayName;const fm=m.forwardRef(({className:e,...t},n)=>c.jsx(am,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(me.ChevronDown,{className:"h-4 w-4"})}));fm.displayName=am.displayName;const wl=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(Rk,{children:c.jsxs(rm,{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(dm,{}),c.jsx(Pk,{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(fm,{})]})}));wl.displayName=rm.displayName;const Dk=m.forwardRef(({className:e,...t},n)=>c.jsx(om,{ref:n,className:re("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Dk.displayName=om.displayName;const Sr=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(sm,{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(Mk,{children:c.jsx(me.Check,{className:"h-4 w-4"})})}),c.jsx(Ok,{children:t})]}));Sr.displayName=sm.displayName;const Lk=m.forwardRef(({className:e,...t},n)=>c.jsx(lm,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));Lk.displayName=lm.displayName;var Fk="Separator",hm="horizontal",$k=["horizontal","vertical"],pm=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=hm,...o}=e,s=zk(r)?r:hm,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(Ee.div,{"data-orientation":s,...a,...o,ref:t})});pm.displayName=Fk;function zk(e){return $k.includes(e)}var mm=pm;const gm=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(mm,{ref:o,decorative:n,orientation:t,className:re("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));gm.displayName=mm.displayName;const Bk=Zd,Hk=bw,Uk=Qd,xm=m.forwardRef(({className:e,...t},n)=>c.jsx(Rs,{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}));xm.displayName=Rs.displayName;const Wk=Ro.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"}}),ym=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(Uk,{children:[c.jsx(xm,{}),c.jsxs(Ps,{ref:o,className:re(Wk({side:e}),t),...r,children:[n,c.jsxs(ef,{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(me.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ym.displayName=Ps.displayName;const vm=({className:e,...t})=>c.jsx("div",{className:re("flex flex-col space-y-2 text-center sm:text-left",e),...t});vm.displayName="SheetHeader";const bm=m.forwardRef(({className:e,...t},n)=>c.jsx(gr,{ref:n,className:re("text-lg font-semibold text-foreground",e),...t}));bm.displayName=gr.displayName;const wm=m.forwardRef(({className:e,...t},n)=>c.jsx(Os,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));wm.displayName=Os.displayName;const Vk={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 Kk({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}=wa();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(Vk),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(Bk,{open:r,onOpenChange:o,children:[c.jsx(Hk,{asChild:!0,children:c.jsxs(Ge,{variant:"outline",size:"sm",className:n,children:[c.jsx(me.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(Uu,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(ym,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(vm,{children:[c.jsx(bm,{children:"Chat Settings"}),c.jsx(wm,{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(me.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(Ge,{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(Zn,{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(Ge,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(me.EyeOff,{className:"h-4 w-4"}):c.jsx(me.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(me.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(cm,{value:a.ui.layout,onValueChange:g=>l(y=>({...y,ui:{...y.ui,layout:g}})),children:[c.jsx(bl,{children:c.jsx(um,{})}),c.jsxs(wl,{children:[c.jsx(Sr,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(Sr,{value:"fullscreen",children:"Fullscreen"}),c.jsx(Sr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(on,{htmlFor:"theme",children:"Theme"}),c.jsxs(cm,{value:a.ui.theme,onValueChange:g=>l(y=>({...y,ui:{...y.ui,theme:g}})),children:[c.jsx(bl,{children:c.jsx(um,{})}),c.jsxs(wl,{children:[c.jsx(Sr,{value:"light",children:"Light"}),c.jsx(Sr,{value:"dark",children:"Dark"}),c.jsx(Sr,{value:"system",children:"System"})]})]})]}),c.jsx(gm,{}),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(Zn,{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(Zn,{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(Zn,{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(me.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(Zn,{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(Zn,{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(Zn,{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(Ge,{variant:"outline",onClick:p,children:[c.jsx(me.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ge,{variant:"outline",onClick:v,children:"Cancel"}),c.jsxs(Ge,{onClick:h,disabled:!u,children:[c.jsx(me.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function qk({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(Jo,{...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(Jo,{...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(hl,{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(Jo,{...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(hl,{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})})]})})}Ie.ChatApi=vc,Ie.ChatInterface=ri,Ie.ChatProviders=Jo,Ie.ChatSettings=Kk,Ie.MarkdownContent=ya,Ie.MessageComponent=uf,Ie.MessageList=Da,Ie.ThreadManager=hl,Ie.applySettings=ZC,Ie.chatApiClient=Hn,Ie.default=qk,Ie.del=yc,Ie.get=cn,Ie.getChatToken=pc,Ie.getCurrentSettings=JC,Ie.getDefaultApiConfig=mp,Ie.getDefaultChatSettings=gp,Ie.onChatTokenChanged=mc,Ie.post=gc,Ie.put=xc,Ie.setChatToken=Ai,Ie.useApi=Ni,Ie.useChatStream=Oc,Ie.useMessagesReducer=Ec,Ie.useStream=Uc,Ie.useThreadState=Xo,Ie.useThreads=Yo,Object.defineProperties(Ie,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});