teodor-new-chat-ui 4.3.47 → 4.3.48

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,pe,sr,Ro,Tm,Em,pi){"use strict";var Jk=Object.defineProperty;var Zk=(Ne,w,pe)=>w in Ne?Jk(Ne,w,{enumerable:!0,configurable:!0,writable:!0,value:pe}):Ne[w]=pe;var Cm=(Ne,w,pe)=>Zk(Ne,typeof w!="symbol"?w+"":w,pe);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 g=kl(w),Po=kl(pi);var mi={exports:{}},Vr={};/**
1
+ (function(Ae,b){typeof exports=="object"&&typeof module<"u"?b(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"],b):(Ae=typeof globalThis<"u"?globalThis:Ae||self,b(Ae.NewChatUI={},Ae.React,Ae.LucideReact,Ae.reactSlot,Ae.classVarianceAuthority,Ae.clsx,Ae.tailwindMerge,Ae.ReactDOM))})(this,function(Ae,b,he,sr,Ro,Cm,km,hi){"use strict";var Gk=Object.defineProperty;var Yk=(Ae,b,he)=>b in Ae?Gk(Ae,b,{enumerable:!0,configurable:!0,writable:!0,value:he}):Ae[b]=he;var bm=(Ae,b,he)=>Yk(Ae,typeof b!="symbol"?b+"":b,he);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 g=kl(b),Po=kl(hi);var pi={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 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={};/**
9
+ */var Tl;function Tm(){if(Tl)return Vr;Tl=1;var e=b,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,c){var d,f={},h=null,p=null;c!==void 0&&(h=""+c),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,51 +14,51 @@
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 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"),x=Symbol.iterator,v="@@iterator";function m(I){if(I===null||typeof I!="object")return null;var N=x&&I[x]||I[v];return typeof N=="function"?N:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(I){{for(var N=arguments.length,z=new Array(N>1?N-1:0),G=1;G<N;G++)z[G-1]=arguments[G];S("error",I,z)}}function S(I,N,z){{var G=y.ReactDebugCurrentFrame,ve=G.getStackAddendum();ve!==""&&(N+="%s",z=z.concat([ve]));var Ce=z.map(function(Ae){return String(Ae)});Ce.unshift("Warning: "+N),Function.prototype.apply.call(console[I],console,Ce)}}var T=!1,C=!1,k=!1,E=!1,R=!1,P;P=Symbol.for("react.module.reference");function j(I){return!!(typeof I=="string"||typeof I=="function"||I===r||I===s||R||I===o||I===u||I===d||E||I===p||T||C||k||typeof I=="object"&&I!==null&&(I.$$typeof===h||I.$$typeof===f||I.$$typeof===i||I.$$typeof===a||I.$$typeof===l||I.$$typeof===P||I.getModuleId!==void 0))}function H(I,N,z){var G=I.displayName;if(G)return G;var ve=N.displayName||N.name||"";return ve!==""?z+"("+ve+")":z}function $(I){return I.displayName||"Context"}function L(I){if(I==null)return null;if(typeof I.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof I=="function")return I.displayName||I.name||null;if(typeof I=="string")return I;switch(I){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 I=="object")switch(I.$$typeof){case a:var N=I;return $(N)+".Consumer";case i:var z=I;return $(z._context)+".Provider";case l:return H(I,I.render,"ForwardRef");case f:var G=I.displayName||null;return G!==null?G:L(I.type)||"Memo";case h:{var ve=I,Ce=ve._payload,Ae=ve._init;try{return L(Ae(Ce))}catch{return null}}}return null}var O=Object.assign,B=0,W,se,K,U,X,F,q;function me(){}me.__reactDisabledLog=!0;function ge(){{if(B===0){W=console.log,se=console.info,K=console.warn,U=console.error,X=console.group,F=console.groupCollapsed,q=console.groupEnd;var I={configurable:!0,enumerable:!0,value:me,writable:!0};Object.defineProperties(console,{info:I,log:I,warn:I,error:I,group:I,groupCollapsed:I,groupEnd:I})}B++}}function ke(){{if(B--,B===0){var I={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:O({},I,{value:W}),info:O({},I,{value:se}),warn:O({},I,{value:K}),error:O({},I,{value:U}),group:O({},I,{value:X}),groupCollapsed:O({},I,{value:F}),groupEnd:O({},I,{value:q})})}B<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Se=y.ReactCurrentDispatcher,J;function D(I,N,z){{if(J===void 0)try{throw Error()}catch(ve){var G=ve.stack.trim().match(/\n( *(at )?)/);J=G&&G[1]||""}return`
18
- `+J+I}}var ee=!1,re;{var ae=typeof WeakMap=="function"?WeakMap:Map;re=new ae}function le(I,N){if(!I||ee)return"";{var z=re.get(I);if(z!==void 0)return z}var G;ee=!0;var ve=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Ce;Ce=Se.current,Se.current=null,ge();try{if(N){var Ae=function(){throw Error()};if(Object.defineProperty(Ae.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ae,[])}catch(Rt){G=Rt}Reflect.construct(I,[],Ae)}else{try{Ae.call()}catch(Rt){G=Rt}I.call(Ae.prototype)}}else{try{throw Error()}catch(Rt){G=Rt}I()}}catch(Rt){if(Rt&&G&&typeof Rt.stack=="string"){for(var Oe=Rt.stack.split(`
17
+ */var El;function Em(){return El||(El=1,process.env.NODE_ENV!=="production"&&function(){var e=b,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"),c=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"),y=Symbol.iterator,v="@@iterator";function m(I){if(I===null||typeof I!="object")return null;var A=y&&I[y]||I[v];return typeof A=="function"?A:null}var x=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(I){{for(var A=arguments.length,z=new Array(A>1?A-1:0),G=1;G<A;G++)z[G-1]=arguments[G];S("error",I,z)}}function S(I,A,z){{var G=x.ReactDebugCurrentFrame,ye=G.getStackAddendum();ye!==""&&(A+="%s",z=z.concat([ye]));var Ce=z.map(function(Ne){return String(Ne)});Ce.unshift("Warning: "+A),Function.prototype.apply.call(console[I],console,Ce)}}var T=!1,C=!1,k=!1,E=!1,R=!1,P;P=Symbol.for("react.module.reference");function j(I){return!!(typeof I=="string"||typeof I=="function"||I===r||I===s||R||I===o||I===c||I===d||E||I===p||T||C||k||typeof I=="object"&&I!==null&&(I.$$typeof===h||I.$$typeof===f||I.$$typeof===i||I.$$typeof===a||I.$$typeof===l||I.$$typeof===P||I.getModuleId!==void 0))}function B(I,A,z){var G=I.displayName;if(G)return G;var ye=A.displayName||A.name||"";return ye!==""?z+"("+ye+")":z}function $(I){return I.displayName||"Context"}function L(I){if(I==null)return null;if(typeof I.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof I=="function")return I.displayName||I.name||null;if(typeof I=="string")return I;switch(I){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case c:return"Suspense";case d:return"SuspenseList"}if(typeof I=="object")switch(I.$$typeof){case a:var A=I;return $(A)+".Consumer";case i:var z=I;return $(z._context)+".Provider";case l:return B(I,I.render,"ForwardRef");case f:var G=I.displayName||null;return G!==null?G:L(I.type)||"Memo";case h:{var ye=I,Ce=ye._payload,Ne=ye._init;try{return L(Ne(Ce))}catch{return null}}}return null}var O=Object.assign,H=0,W,se,K,U,X,F,q;function pe(){}pe.__reactDisabledLog=!0;function ge(){{if(H===0){W=console.log,se=console.info,K=console.warn,U=console.error,X=console.group,F=console.groupCollapsed,q=console.groupEnd;var I={configurable:!0,enumerable:!0,value:pe,writable:!0};Object.defineProperties(console,{info:I,log:I,warn:I,error:I,group:I,groupCollapsed:I,groupEnd:I})}H++}}function ke(){{if(H--,H===0){var I={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:O({},I,{value:W}),info:O({},I,{value:se}),warn:O({},I,{value:K}),error:O({},I,{value:U}),group:O({},I,{value:X}),groupCollapsed:O({},I,{value:F}),groupEnd:O({},I,{value:q})})}H<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Se=x.ReactCurrentDispatcher,J;function D(I,A,z){{if(J===void 0)try{throw Error()}catch(ye){var G=ye.stack.trim().match(/\n( *(at )?)/);J=G&&G[1]||""}return`
18
+ `+J+I}}var ee=!1,re;{var ce=typeof WeakMap=="function"?WeakMap:Map;re=new ce}function ae(I,A){if(!I||ee)return"";{var z=re.get(I);if(z!==void 0)return z}var G;ee=!0;var ye=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Ce;Ce=Se.current,Se.current=null,ge();try{if(A){var Ne=function(){throw Error()};if(Object.defineProperty(Ne.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ne,[])}catch(Rt){G=Rt}Reflect.construct(I,[],Ne)}else{try{Ne.call()}catch(Rt){G=Rt}I.call(Ne.prototype)}}else{try{throw Error()}catch(Rt){G=Rt}I()}}catch(Rt){if(Rt&&G&&typeof Rt.stack=="string"){for(var Pe=Rt.stack.split(`
19
19
  `),dt=G.stack.split(`
20
- `),st=Oe.length-1,lt=dt.length-1;st>=1&&lt>=0&&Oe[st]!==dt[lt];)lt--;for(;st>=1&&lt>=0;st--,lt--)if(Oe[st]!==dt[lt]){if(st!==1||lt!==1)do if(st--,lt--,lt<0||Oe[st]!==dt[lt]){var bt=`
21
- `+Oe[st].replace(" at new "," at ");return I.displayName&&bt.includes("<anonymous>")&&(bt=bt.replace("<anonymous>",I.displayName)),typeof I=="function"&&re.set(I,bt),bt}while(st>=1&&lt>=0);break}}}finally{ee=!1,Se.current=Ce,ke(),Error.prepareStackTrace=ve}var zn=I?I.displayName||I.name:"",Bn=zn?D(zn):"";return typeof I=="function"&&re.set(I,Bn),Bn}function ie(I,N,z){return le(I,!1)}function Ge(I){var N=I.prototype;return!!(N&&N.isReactComponent)}function Je(I,N,z){if(I==null)return"";if(typeof I=="function")return le(I,Ge(I));if(typeof I=="string")return D(I);switch(I){case u:return D("Suspense");case d:return D("SuspenseList")}if(typeof I=="object")switch(I.$$typeof){case l:return ie(I.render);case f:return Je(I.type,N,z);case h:{var G=I,ve=G._payload,Ce=G._init;try{return Je(Ce(ve),N,z)}catch{}}}return""}var De=Object.prototype.hasOwnProperty,Ue={},at=y.ReactDebugCurrentFrame;function Ke(I){if(I){var N=I._owner,z=Je(I.type,I._source,N?N.type:null);at.setExtraStackFrame(z)}else at.setExtraStackFrame(null)}function je(I,N,z,G,ve){{var Ce=Function.call.bind(De);for(var Ae in I)if(Ce(I,Ae)){var Oe=void 0;try{if(typeof I[Ae]!="function"){var dt=Error((G||"React class")+": "+z+" type `"+Ae+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof I[Ae]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw dt.name="Invariant Violation",dt}Oe=I[Ae](N,Ae,G,z,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(st){Oe=st}Oe&&!(Oe instanceof Error)&&(Ke(ve),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).",G||"React class",z,Ae,typeof Oe),Ke(null)),Oe instanceof Error&&!(Oe.message in Ue)&&(Ue[Oe.message]=!0,Ke(ve),b("Failed %s type: %s",z,Oe.message),Ke(null))}}}var mt=Array.isArray;function gt(I){return mt(I)}function Ct(I){{var N=typeof Symbol=="function"&&Symbol.toStringTag,z=N&&I[Symbol.toStringTag]||I.constructor.name||"Object";return z}}function rt(I){try{return te(I),!1}catch{return!0}}function te(I){return""+I}function ue(I){if(rt(I))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ct(I)),te(I)}var xe=y.ReactCurrentOwner,ze={key:!0,ref:!0,__self:!0,__source:!0},Pe,et;function xt(I){if(De.call(I,"ref")){var N=Object.getOwnPropertyDescriptor(I,"ref").get;if(N&&N.isReactWarning)return!1}return I.ref!==void 0}function $t(I){if(De.call(I,"key")){var N=Object.getOwnPropertyDescriptor(I,"key").get;if(N&&N.isReactWarning)return!1}return I.key!==void 0}function un(I,N){typeof I.ref=="string"&&xe.current}function Nn(I,N){{var z=function(){Pe||(Pe=!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)",N))};z.isReactWarning=!0,Object.defineProperty(I,"key",{get:z,configurable:!0})}}function tr(I,N){{var z=function(){et||(et=!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)",N))};z.isReactWarning=!0,Object.defineProperty(I,"ref",{get:z,configurable:!0})}}var dn=function(I,N,z,G,ve,Ce,Ae){var Oe={$$typeof:t,type:I,key:N,ref:z,props:Ae,_owner:Ce};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:G}),Object.defineProperty(Oe,"_source",{configurable:!1,enumerable:!1,writable:!1,value:ve}),Object.freeze&&(Object.freeze(Oe.props),Object.freeze(Oe)),Oe};function fn(I,N,z,G,ve){{var Ce,Ae={},Oe=null,dt=null;z!==void 0&&(ue(z),Oe=""+z),$t(N)&&(ue(N.key),Oe=""+N.key),xt(N)&&(dt=N.ref,un(N,ve));for(Ce in N)De.call(N,Ce)&&!ze.hasOwnProperty(Ce)&&(Ae[Ce]=N[Ce]);if(I&&I.defaultProps){var st=I.defaultProps;for(Ce in st)Ae[Ce]===void 0&&(Ae[Ce]=st[Ce])}if(Oe||dt){var lt=typeof I=="function"?I.displayName||I.name||"Unknown":I;Oe&&Nn(Ae,lt),dt&&tr(Ae,lt)}return dn(I,Oe,dt,ve,G,xe.current,Ae)}}var Mt=y.ReactCurrentOwner,hn=y.ReactDebugCurrentFrame;function Kt(I){if(I){var N=I._owner,z=Je(I.type,I._source,N?N.type:null);hn.setExtraStackFrame(z)}else hn.setExtraStackFrame(null)}var kt;kt=!1;function kr(I){return typeof I=="object"&&I!==null&&I.$$typeof===t}function nr(){{if(Mt.current){var I=L(Mt.current.type);if(I)return`
20
+ `),st=Pe.length-1,lt=dt.length-1;st>=1&&lt>=0&&Pe[st]!==dt[lt];)lt--;for(;st>=1&&lt>=0;st--,lt--)if(Pe[st]!==dt[lt]){if(st!==1||lt!==1)do if(st--,lt--,lt<0||Pe[st]!==dt[lt]){var wt=`
21
+ `+Pe[st].replace(" at new "," at ");return I.displayName&&wt.includes("<anonymous>")&&(wt=wt.replace("<anonymous>",I.displayName)),typeof I=="function"&&re.set(I,wt),wt}while(st>=1&&lt>=0);break}}}finally{ee=!1,Se.current=Ce,ke(),Error.prepareStackTrace=ye}var zn=I?I.displayName||I.name:"",Bn=zn?D(zn):"";return typeof I=="function"&&re.set(I,Bn),Bn}function ie(I,A,z){return ae(I,!1)}function Ge(I){var A=I.prototype;return!!(A&&A.isReactComponent)}function Je(I,A,z){if(I==null)return"";if(typeof I=="function")return ae(I,Ge(I));if(typeof I=="string")return D(I);switch(I){case c:return D("Suspense");case d:return D("SuspenseList")}if(typeof I=="object")switch(I.$$typeof){case l:return ie(I.render);case f:return Je(I.type,A,z);case h:{var G=I,ye=G._payload,Ce=G._init;try{return Je(Ce(ye),A,z)}catch{}}}return""}var Me=Object.prototype.hasOwnProperty,He={},at=x.ReactDebugCurrentFrame;function Ke(I){if(I){var A=I._owner,z=Je(I.type,I._source,A?A.type:null);at.setExtraStackFrame(z)}else at.setExtraStackFrame(null)}function je(I,A,z,G,ye){{var Ce=Function.call.bind(Me);for(var Ne in I)if(Ce(I,Ne)){var Pe=void 0;try{if(typeof I[Ne]!="function"){var dt=Error((G||"React class")+": "+z+" type `"+Ne+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof I[Ne]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw dt.name="Invariant Violation",dt}Pe=I[Ne](A,Ne,G,z,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(st){Pe=st}Pe&&!(Pe instanceof Error)&&(Ke(ye),w("%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).",G||"React class",z,Ne,typeof Pe),Ke(null)),Pe instanceof Error&&!(Pe.message in He)&&(He[Pe.message]=!0,Ke(ye),w("Failed %s type: %s",z,Pe.message),Ke(null))}}}var mt=Array.isArray;function gt(I){return mt(I)}function Ct(I){{var A=typeof Symbol=="function"&&Symbol.toStringTag,z=A&&I[Symbol.toStringTag]||I.constructor.name||"Object";return z}}function rt(I){try{return te(I),!1}catch{return!0}}function te(I){return""+I}function me(I){if(rt(I))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ct(I)),te(I)}var ve=x.ReactCurrentOwner,We={key:!0,ref:!0,__self:!0,__source:!0},De,et;function xt(I){if(Me.call(I,"ref")){var A=Object.getOwnPropertyDescriptor(I,"ref").get;if(A&&A.isReactWarning)return!1}return I.ref!==void 0}function $t(I){if(Me.call(I,"key")){var A=Object.getOwnPropertyDescriptor(I,"key").get;if(A&&A.isReactWarning)return!1}return I.key!==void 0}function un(I,A){typeof I.ref=="string"&&ve.current}function An(I,A){{var z=function(){De||(De=!0,w("%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)",A))};z.isReactWarning=!0,Object.defineProperty(I,"key",{get:z,configurable:!0})}}function tr(I,A){{var z=function(){et||(et=!0,w("%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)",A))};z.isReactWarning=!0,Object.defineProperty(I,"ref",{get:z,configurable:!0})}}var dn=function(I,A,z,G,ye,Ce,Ne){var Pe={$$typeof:t,type:I,key:A,ref:z,props:Ne,_owner:Ce};return Pe._store={},Object.defineProperty(Pe._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Pe,"_self",{configurable:!1,enumerable:!1,writable:!1,value:G}),Object.defineProperty(Pe,"_source",{configurable:!1,enumerable:!1,writable:!1,value:ye}),Object.freeze&&(Object.freeze(Pe.props),Object.freeze(Pe)),Pe};function fn(I,A,z,G,ye){{var Ce,Ne={},Pe=null,dt=null;z!==void 0&&(me(z),Pe=""+z),$t(A)&&(me(A.key),Pe=""+A.key),xt(A)&&(dt=A.ref,un(A,ye));for(Ce in A)Me.call(A,Ce)&&!We.hasOwnProperty(Ce)&&(Ne[Ce]=A[Ce]);if(I&&I.defaultProps){var st=I.defaultProps;for(Ce in st)Ne[Ce]===void 0&&(Ne[Ce]=st[Ce])}if(Pe||dt){var lt=typeof I=="function"?I.displayName||I.name||"Unknown":I;Pe&&An(Ne,lt),dt&&tr(Ne,lt)}return dn(I,Pe,dt,ye,G,ve.current,Ne)}}var Mt=x.ReactCurrentOwner,hn=x.ReactDebugCurrentFrame;function Kt(I){if(I){var A=I._owner,z=Je(I.type,I._source,A?A.type:null);hn.setExtraStackFrame(z)}else hn.setExtraStackFrame(null)}var kt;kt=!1;function kr(I){return typeof I=="object"&&I!==null&&I.$$typeof===t}function nr(){{if(Mt.current){var I=L(Mt.current.type);if(I)return`
22
22
 
23
- Check the render method of \``+I+"`."}return""}}function vt(I){return""}var pn={};function _n(I){{var N=nr();if(!N){var z=typeof I=="string"?I:I.displayName||I.name;z&&(N=`
23
+ Check the render method of \``+I+"`."}return""}}function vt(I){return""}var pn={};function _n(I){{var A=nr();if(!A){var z=typeof I=="string"?I:I.displayName||I.name;z&&(A=`
24
24
 
25
- Check the top-level render call using <`+z+">.")}return N}}function $n(I,N){{if(!I._store||I._store.validated||I.key!=null)return;I._store.validated=!0;var z=_n(N);if(pn[z])return;pn[z]=!0;var G="";I&&I._owner&&I._owner!==Mt.current&&(G=" It was passed a child from "+L(I._owner.type)+"."),Kt(I),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',z,G),Kt(null)}}function qt(I,N){{if(typeof I!="object")return;if(gt(I))for(var z=0;z<I.length;z++){var G=I[z];kr(G)&&$n(G,N)}else if(kr(I))I._store&&(I._store.validated=!0);else if(I){var ve=m(I);if(typeof ve=="function"&&ve!==I.entries)for(var Ce=ve.call(I),Ae;!(Ae=Ce.next()).done;)kr(Ae.value)&&$n(Ae.value,N)}}}function Tr(I){{var N=I.type;if(N==null||typeof N=="string")return;var z;if(typeof N=="function")z=N.propTypes;else if(typeof N=="object"&&(N.$$typeof===l||N.$$typeof===f))z=N.propTypes;else return;if(z){var G=L(N);je(z,I.props,"prop",G,I)}else if(N.PropTypes!==void 0&&!kt){kt=!0;var ve=L(N);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ve||"Unknown")}typeof N.getDefaultProps=="function"&&!N.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function jn(I){{for(var N=Object.keys(I.props),z=0;z<N.length;z++){var G=N[z];if(G!=="children"&&G!=="key"){Kt(I),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",G),Kt(null);break}}I.ref!==null&&(Kt(I),b("Invalid attribute `ref` supplied to `React.Fragment`."),Kt(null))}}var mn={};function rr(I,N,z,G,ve,Ce){{var Ae=j(I);if(!Ae){var Oe="";(I===void 0||typeof I=="object"&&I!==null&&Object.keys(I).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 dt=vt();dt?Oe+=dt:Oe+=nr();var st;I===null?st="null":gt(I)?st="array":I!==void 0&&I.$$typeof===t?(st="<"+(L(I.type)||"Unknown")+" />",Oe=" Did you accidentally export a JSX literal instead of a component?"):st=typeof I,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",st,Oe)}var lt=fn(I,N,z,ve,Ce);if(lt==null)return lt;if(Ae){var bt=N.children;if(bt!==void 0)if(G)if(gt(bt)){for(var zn=0;zn<bt.length;zn++)qt(bt[zn],I);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 qt(bt,I)}if(De.call(N,"key")){var Bn=L(I),Rt=Object.keys(N).filter(function(_){return _!=="key"}),Ao=Rt.length>0?"{key: someKey, "+Rt.join(": ..., ")+": ...}":"{key: someKey}";if(!mn[Bn+Ao]){var A=Rt.length>0?"{"+Rt.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+z+">.")}return A}}function $n(I,A){{if(!I._store||I._store.validated||I.key!=null)return;I._store.validated=!0;var z=_n(A);if(pn[z])return;pn[z]=!0;var G="";I&&I._owner&&I._owner!==Mt.current&&(G=" It was passed a child from "+L(I._owner.type)+"."),Kt(I),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',z,G),Kt(null)}}function qt(I,A){{if(typeof I!="object")return;if(gt(I))for(var z=0;z<I.length;z++){var G=I[z];kr(G)&&$n(G,A)}else if(kr(I))I._store&&(I._store.validated=!0);else if(I){var ye=m(I);if(typeof ye=="function"&&ye!==I.entries)for(var Ce=ye.call(I),Ne;!(Ne=Ce.next()).done;)kr(Ne.value)&&$n(Ne.value,A)}}}function Tr(I){{var A=I.type;if(A==null||typeof A=="string")return;var z;if(typeof A=="function")z=A.propTypes;else if(typeof A=="object"&&(A.$$typeof===l||A.$$typeof===f))z=A.propTypes;else return;if(z){var G=L(A);je(z,I.props,"prop",G,I)}else if(A.PropTypes!==void 0&&!kt){kt=!0;var ye=L(A);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ye||"Unknown")}typeof A.getDefaultProps=="function"&&!A.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function jn(I){{for(var A=Object.keys(I.props),z=0;z<A.length;z++){var G=A[z];if(G!=="children"&&G!=="key"){Kt(I),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",G),Kt(null);break}}I.ref!==null&&(Kt(I),w("Invalid attribute `ref` supplied to `React.Fragment`."),Kt(null))}}var mn={};function rr(I,A,z,G,ye,Ce){{var Ne=j(I);if(!Ne){var Pe="";(I===void 0||typeof I=="object"&&I!==null&&Object.keys(I).length===0)&&(Pe+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var dt=vt();dt?Pe+=dt:Pe+=nr();var st;I===null?st="null":gt(I)?st="array":I!==void 0&&I.$$typeof===t?(st="<"+(L(I.type)||"Unknown")+" />",Pe=" Did you accidentally export a JSX literal instead of a component?"):st=typeof I,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",st,Pe)}var lt=fn(I,A,z,ye,Ce);if(lt==null)return lt;if(Ne){var wt=A.children;if(wt!==void 0)if(G)if(gt(wt)){for(var zn=0;zn<wt.length;zn++)qt(wt[zn],I);Object.freeze&&Object.freeze(wt)}else w("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 qt(wt,I)}if(Me.call(A,"key")){var Bn=L(I),Rt=Object.keys(A).filter(function(_){return _!=="key"}),No=Rt.length>0?"{key: someKey, "+Rt.join(": ..., ")+": ...}":"{key: someKey}";if(!mn[Bn+No]){var N=Rt.length>0?"{"+Rt.join(": ..., ")+": ...}":"{}";w(`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,Bn,A,Bn),mn[Bn+Ao]=!0}}return I===r?jn(lt):Tr(lt),lt}}function Io(I,N,z){return rr(I,N,z,!0)}function Ur(I,N,z){return rr(I,N,z,!1)}var Wr=Ur,or=Io;Kr.Fragment=r,Kr.jsx=Wr,Kr.jsxs=or}()),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)),tn=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)&&Dt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Nl=tn("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"),Dt=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=tn("Date"),Mm=tn("File"),Dm=tn("Blob"),Lm=tn("FileList"),Fm=e=>Gr(e)&&Dt(e.pipe),$m=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Dt(e.append)&&((t=Mo(e))==="formdata"||t==="object"&&Dt(e.toString)&&e.toString()==="[object FormData]"))},zm=tn("URLSearchParams"),[Bm,Hm,Um,Wm]=["ReadableStream","Request","Response","Headers"].map(tn),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 ir=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Rl=e=>!Ir(e)&&e!==ir;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&&Dt(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=tn("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=tn("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(Dt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Dt(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&&Dt(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=tn("AsyncFunction"),dg=e=>e&&(Gr(e)||Dt(e))&&Dt(e.then)&&Dt(e.catch),Ml=((e,t)=>e?setImmediate:t?((n,r)=>(ir.addEventListener("message",({source:o,data:s})=>{o===ir&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),ir.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Dt(ir.postMessage)),fg=typeof queueMicrotask<"u"?queueMicrotask.bind(ir):typeof process<"u"&&process.nextTick||Ml,M={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:Dt,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:tn,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:ir,isContextDefined:Rl,isSpecCompliantForm:lg,toJSONObject:cg,isAsyncFn:ug,isThenable:dg,setImmediate:Ml,asap:fg,isIterable:e=>e!=null&&Dt(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)}M.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:M.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);M.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 M.isPlainObject(e)||M.isArray(e)}function Fl(e){return M.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 M.isArray(e)&&!e.some(yi)}const mg=M.toFlatObject(M,{},null,function(t){return/^is[A-Z]/.test(t)});function Fo(e,t,n){if(!M.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=M.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,m){return!M.isUndefined(m[v])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&M.isSpecCompliantForm(t);if(!M.isFunction(o))throw new TypeError("visitor must be a function");function u(x){if(x===null)return"";if(M.isDate(x))return x.toISOString();if(M.isBoolean(x))return x.toString();if(!l&&M.isBlob(x))throw new Re("Blob is not supported. Use a Buffer instead.");return M.isArrayBuffer(x)||M.isTypedArray(x)?l&&typeof Blob=="function"?new Blob([x]):Buffer.from(x):x}function d(x,v,m){let y=x;if(x&&!m&&typeof x=="object"){if(M.endsWith(v,"{}"))v=r?v:v.slice(0,-2),x=JSON.stringify(x);else if(M.isArray(x)&&pg(x)||(M.isFileList(x)||M.endsWith(v,"[]"))&&(y=M.toArray(x)))return v=Fl(v),y.forEach(function(S,T){!(M.isUndefined(S)||S===null)&&t.append(i===!0?$l([v],T,s):i===null?v:v+"[]",u(S))}),!1}return yi(x)?!0:(t.append($l(m,v,s),u(x)),!1)}const f=[],h=Object.assign(mg,{defaultVisitor:d,convertValue:u,isVisitable:yi});function p(x,v){if(!M.isUndefined(x)){if(f.indexOf(x)!==-1)throw Error("Circular reference detected in "+v.join("."));f.push(x),M.forEach(x,function(y,b){(!(M.isUndefined(y)||y===null)&&o.call(t,y,M.isString(b)?b.trim():b,v,h))===!0&&p(y,v?v.concat(b):[b])}),f.pop()}}if(!M.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;M.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=M.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){M.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",At={...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 At.classes.URLSearchParams,{visitor:function(n,r,o,s){return At.isNode&&M.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Sg(e){return M.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&&M.isArray(o)?o.length:i,l?(M.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!M.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&M.isArray(o[i])&&(o[i]=Cg(o[i])),!a)}if(M.isFormData(e)&&M.isFunction(e.entries)){const n={};return M.forEachEntry(e,(r,o)=>{t(Sg(r),o,n,0)}),n}return null}function kg(e,t,n){if(M.isString(e))try{return(t||JSON.parse)(e),M.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=M.isObject(t);if(s&&M.isHTMLForm(t)&&(t=new FormData(t)),M.isFormData(t))return o?JSON.stringify(Vl(t)):t;if(M.isArrayBuffer(t)||M.isBuffer(t)||M.isStream(t)||M.isFile(t)||M.isBlob(t)||M.isReadableStream(t))return t;if(M.isArrayBufferView(t))return t.buffer;if(M.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=M.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(M.isResponse(t)||M.isReadableStream(t))return t;if(t&&M.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:At.classes.FormData,Blob:At.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};M.forEach(["delete","get","head","post","put","patch"],e=>{Xr.headers[e]={}});const Tg=M.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:M.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(M.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!M.isString(t)){if(M.isString(r))return t.indexOf(r)!==-1;if(M.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=M.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 Lt=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=M.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)=>M.forEach(a,(u,d)=>s(u,d,l));if(M.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(M.isString(t)&&(t=t.trim())&&!Ag(t))i(Eg(t),n);else if(M.isObject(t)&&M.isIterable(t)){let a={},l,u;for(const d of t){if(!M.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(l=a[u])?M.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=M.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Ig(o);if(M.isFunction(n))return n.call(this,o,r);if(M.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=M.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=M.findKey(r,i);a&&(!n||Si(r,r[a],a,n))&&(delete r[a],o=!0)}}return M.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 M.forEach(this,(o,s)=>{const i=M.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 M.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&M.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 M.isArray(t)?t.forEach(s):s(t),this}};Lt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),M.reduceDescriptors(Lt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),M.freezeMethods(Lt);function Ci(e,t){const n=this||Xr,r=t||n,o=Lt.from(r.headers);let s=r.data;return M.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"}M.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)=>M.asap(()=>e(...t)),Og=At.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,At.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(At.origin),At.navigator&&/(msie|trident)/i.test(At.navigator.userAgent)):()=>!0,Mg=At.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];M.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),M.isString(r)&&i.push("path="+r),M.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 Lt?{...e}:e;function ar(e,t){t=t||{};const n={};function r(u,d,f,h){return M.isPlainObject(u)&&M.isPlainObject(d)?M.merge.call({caseless:h},u,d):M.isPlainObject(d)?M.merge({},d):M.isArray(d)?d.slice():d}function o(u,d,f,h){if(M.isUndefined(d)){if(!M.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!M.isUndefined(d))return r(void 0,d)}function i(u,d){if(M.isUndefined(d)){if(!M.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 M.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,h=f(e[d],t[d],d);M.isUndefined(h)&&f!==a||(n[d]=h)}),n}const Ql=e=>{const t=ar({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Lt.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)):""))),M.isFormData(n)){if(At.hasStandardBrowserEnv||At.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(M.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(At.hasStandardBrowserEnv&&(r&&M.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=Lt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=o,d,f,h,p,x;function v(){p&&p(),x&&x(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let m=new XMLHttpRequest;m.open(o.method.toUpperCase(),o.url,!0),m.timeout=o.timeout;function y(){if(!m)return;const S=Lt.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:S,config:e,request:m};Gl(function(E){n(E),v()},function(E){r(E),v()},C),m=null}"onloadend"in m?m.onloadend=y:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(y)},m.onabort=function(){m&&(r(new Re("Request aborted",Re.ECONNABORTED,e,m)),m=null)},m.onerror=function(T){const C=T&&T.message?T.message:"Network Error",k=new Re(C,Re.ERR_NETWORK,e,m);k.event=T||null,r(k),m=null},m.ontimeout=function(){let T=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||Wl;o.timeoutErrorMessage&&(T=o.timeoutErrorMessage),r(new Re(T,C.clarifyTimeoutError?Re.ETIMEDOUT:Re.ECONNABORTED,e,m)),m=null},s===void 0&&i.setContentType(null),"setRequestHeader"in m&&M.forEach(i.toJSON(),function(T,C){m.setRequestHeader(C,T)}),M.isUndefined(o.withCredentials)||(m.withCredentials=!!o.withCredentials),a&&a!=="json"&&(m.responseType=o.responseType),u&&([h,x]=zo(u,!0),m.addEventListener("progress",h)),l&&m.upload&&([f,p]=zo(l),m.upload.addEventListener("progress",f),m.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=S=>{m&&(r(!S||S.type?new Ar(null,e,m):S),m.abort(),m=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&&At.protocols.indexOf(b)===-1){r(new Re("Unsupported protocol "+b+":",Re.ERR_BAD_REQUEST,e));return}m.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=()=>M.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}=M,Ug=(({Request:e,Response:t})=>({Request:e,Response:t}))(M.global),{ReadableStream:nc,TextEncoder:rc}=M.global,oc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Wg=e=>{e=M.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"?(x=>v=>x.encode(v))(new rc):async x=>new Uint8Array(await new n(x).arrayBuffer())),u=s&&a&&oc(()=>{let x=!1;const v=new n(At.origin,{body:new nc,method:"POST",get duplex(){return x=!0,"half"}}).headers.has("Content-Type");return x&&!v}),d=i&&a&&oc(()=>M.isReadableStream(new r("").body)),f={stream:d&&(x=>x.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(x=>{!f[x]&&(f[x]=(v,m)=>{let y=v&&v[x];if(y)return y.call(v);throw new Re(`Response type '${x}' is not supported`,Re.ERR_NOT_SUPPORT,m)})});const h=async x=>{if(x==null)return 0;if(M.isBlob(x))return x.size;if(M.isSpecCompliantForm(x))return(await new n(At.origin,{method:"POST",body:x}).arrayBuffer()).byteLength;if(M.isArrayBufferView(x)||M.isArrayBuffer(x))return x.byteLength;if(M.isURLSearchParams(x)&&(x=x+""),M.isString(x))return(await l(x)).byteLength},p=async(x,v)=>{const m=M.toFiniteNumber(x.getContentLength());return m??h(v)};return async x=>{let{url:v,method:m,data:y,signal:b,cancelToken:S,timeout:T,onDownloadProgress:C,onUploadProgress:k,responseType:E,headers:R,withCredentials:P="same-origin",fetchOptions:j}=Ql(x),H=t||fetch;E=E?(E+"").toLowerCase():"text";let $=$g([b,S&&S.toAbortSignal()],T),L=null;const O=$&&$.unsubscribe&&(()=>{$.unsubscribe()});let B;try{if(k&&u&&m!=="get"&&m!=="head"&&(B=await p(R,y))!==0){let F=new n(v,{method:"POST",body:y,duplex:"half"}),q;if(M.isFormData(y)&&(q=F.headers.get("content-type"))&&R.setContentType(q),F.body){const[me,ge]=Yl(B,zo(Xl(k)));y=ec(F.body,tc,me,ge)}}M.isString(P)||(P=P?"include":"omit");const W=s&&"credentials"in n.prototype,se={...j,signal:$,method:m.toUpperCase(),headers:R.normalize().toJSON(),body:y,duplex:"half",credentials:W?P:void 0};L=s&&new n(v,se);let K=await(s?H(L,j):H(v,se));const U=d&&(E==="stream"||E==="response");if(d&&(C||U&&O)){const F={};["status","statusText","headers"].forEach(ke=>{F[ke]=K[ke]});const q=M.toFiniteNumber(K.headers.get("content-length")),[me,ge]=C&&Yl(q,zo(Xl(C),!0))||[];K=new r(ec(K.body,tc,me,()=>{ge&&ge(),O&&O()}),F)}E=E||"text";let X=await f[M.findKey(f,E)||"text"](K,x);return!U&&O&&O(),await new Promise((F,q)=>{Gl(F,q,{data:X,headers:Lt.from(K.headers),status:K.status,statusText:K.statusText,config:x,request:L})})}catch(W){throw O&&O(),W&&W.name==="TypeError"&&/Load failed|fetch/i.test(W.message)?Object.assign(new Re("Network Error",Re.ERR_NETWORK,x,L),{cause:W.cause||W}):Re.from(W,W&&W.code,x,L)}}},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}};M.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=>M.isFunction(e)||e===null||e===!1,ac={getAdapter:(e,t)=>{e=M.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&&(M.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,u])=>`adapter ${l} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
30
+ <%s key={someKey} {...props} />`,No,Bn,N,Bn),mn[Bn+No]=!0}}return I===r?jn(lt):Tr(lt),lt}}function Io(I,A,z){return rr(I,A,z,!0)}function Ur(I,A,z){return rr(I,A,z,!1)}var Wr=Ur,or=Io;Kr.Fragment=r,Kr.jsx=Wr,Kr.jsxs=or}()),Kr}process.env.NODE_ENV==="production"?pi.exports=Tm():pi.exports=Em();var u=pi.exports;function Il(e,t){return function(){return e.apply(t,arguments)}}const{toString:Im}=Object.prototype,{getPrototypeOf:mi}=Object,{iterator:Oo,toStringTag:Nl}=Symbol,Mo=(e=>t=>{const n=Im.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),tn=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)&&Dt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Al=tn("ArrayBuffer");function Nm(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Al(e.buffer),t}const Am=Do("string"),Dt=Do("function"),_l=Do("number"),Gr=e=>e!==null&&typeof e=="object",_m=e=>e===!0||e===!1,Lo=e=>{if(Mo(e)!=="object")return!1;const t=mi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Nl in e)&&!(Oo in e)},jm=e=>{if(!Gr(e)||qr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Rm=tn("Date"),Pm=tn("File"),Om=tn("Blob"),Mm=tn("FileList"),Dm=e=>Gr(e)&&Dt(e.pipe),Lm=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Dt(e.append)&&((t=Mo(e))==="formdata"||t==="object"&&Dt(e.toString)&&e.toString()==="[object FormData]"))},Fm=tn("URLSearchParams"),[$m,zm,Bm,Hm]=["ReadableStream","Request","Response","Headers"].map(tn),Um=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 ir=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Rl=e=>!Ir(e)&&e!==ir;function gi(){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]=gi(n[i],o):Lo(o)?n[i]=gi({},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 Wm=(e,t,n,{allOwnKeys:r}={})=>(Yr(t,(o,s)=>{n&&Dt(o)?e[s]=Il(o,n):e[s]=o},{allOwnKeys:r}),e),Vm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Km=(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&&mi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Gm=(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},Ym=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},Xm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&mi(Uint8Array)),Jm=(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])}},Zm=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Qm=tn("HTMLFormElement"),eg=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),tg=tn("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)},ng=e=>{Ol(e,(t,n)=>{if(Dt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Dt(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+"'")})}})},rg=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return Er(e)?r(e):r(String(e).split(t)),n},og=()=>{},sg=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function ig(e){return!!(e&&Dt(e.append)&&e[Nl]==="FormData"&&e[Oo])}const ag=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)},lg=tn("AsyncFunction"),cg=e=>e&&(Gr(e)||Dt(e))&&Dt(e.then)&&Dt(e.catch),Ml=((e,t)=>e?setImmediate:t?((n,r)=>(ir.addEventListener("message",({source:o,data:s})=>{o===ir&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),ir.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Dt(ir.postMessage)),ug=typeof queueMicrotask<"u"?queueMicrotask.bind(ir):typeof process<"u"&&process.nextTick||Ml,M={isArray:Er,isArrayBuffer:Al,isBuffer:qr,isFormData:Lm,isArrayBufferView:Nm,isString:Am,isNumber:_l,isBoolean:_m,isObject:Gr,isPlainObject:Lo,isEmptyObject:jm,isReadableStream:$m,isRequest:zm,isResponse:Bm,isHeaders:Hm,isUndefined:Ir,isDate:Rm,isFile:Pm,isBlob:Om,isRegExp:tg,isFunction:Dt,isStream:Dm,isURLSearchParams:Fm,isTypedArray:Xm,isFileList:Mm,forEach:Yr,merge:gi,extend:Wm,trim:Um,stripBOM:Vm,inherits:Km,toFlatObject:qm,kindOf:Mo,kindOfTest:tn,endsWith:Gm,toArray:Ym,forEachEntry:Jm,matchAll:Zm,isHTMLForm:Qm,hasOwnProperty:Pl,hasOwnProp:Pl,reduceDescriptors:Ol,freezeMethods:ng,toObjectSet:rg,toCamelCase:eg,noop:og,toFiniteNumber:sg,findKey:jl,global:ir,isContextDefined:Rl,isSpecCompliantForm:ig,toJSONObject:ag,isAsyncFn:lg,isThenable:cg,setImmediate:Ml,asap:ug,isIterable:e=>e!=null&&Dt(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)}M.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:M.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);M.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="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 dg=null;function xi(e){return M.isPlainObject(e)||M.isArray(e)}function Fl(e){return M.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 fg(e){return M.isArray(e)&&!e.some(xi)}const hg=M.toFlatObject(M,{},null,function(t){return/^is[A-Z]/.test(t)});function Fo(e,t,n){if(!M.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=M.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,m){return!M.isUndefined(m[v])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&M.isSpecCompliantForm(t);if(!M.isFunction(o))throw new TypeError("visitor must be a function");function c(y){if(y===null)return"";if(M.isDate(y))return y.toISOString();if(M.isBoolean(y))return y.toString();if(!l&&M.isBlob(y))throw new Re("Blob is not supported. Use a Buffer instead.");return M.isArrayBuffer(y)||M.isTypedArray(y)?l&&typeof Blob=="function"?new Blob([y]):Buffer.from(y):y}function d(y,v,m){let x=y;if(y&&!m&&typeof y=="object"){if(M.endsWith(v,"{}"))v=r?v:v.slice(0,-2),y=JSON.stringify(y);else if(M.isArray(y)&&fg(y)||(M.isFileList(y)||M.endsWith(v,"[]"))&&(x=M.toArray(y)))return v=Fl(v),x.forEach(function(S,T){!(M.isUndefined(S)||S===null)&&t.append(i===!0?$l([v],T,s):i===null?v:v+"[]",c(S))}),!1}return xi(y)?!0:(t.append($l(m,v,s),c(y)),!1)}const f=[],h=Object.assign(hg,{defaultVisitor:d,convertValue:c,isVisitable:xi});function p(y,v){if(!M.isUndefined(y)){if(f.indexOf(y)!==-1)throw Error("Circular reference detected in "+v.join("."));f.push(y),M.forEach(y,function(x,w){(!(M.isUndefined(x)||x===null)&&o.call(t,x,M.isString(w)?w.trim():w,v,h))===!0&&p(x,v?v.concat(w):[w])}),f.pop()}}if(!M.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 yi(e,t){this._pairs=[],e&&Fo(e,this,t)}const Bl=yi.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 pg(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||pg;M.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=M.isURLSearchParams(t)?t.toString():new yi(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){M.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Wl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},mg={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:yi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},vi=typeof window<"u"&&typeof document<"u",wi=typeof navigator=="object"&&navigator||void 0,gg=vi&&(!wi||["ReactNative","NativeScript","NS"].indexOf(wi.product)<0),xg=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",yg=vi&&window.location.href||"http://localhost",Nt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:vi,hasStandardBrowserEnv:gg,hasStandardBrowserWebWorkerEnv:xg,navigator:wi,origin:yg},Symbol.toStringTag,{value:"Module"})),...mg};function vg(e,t){return Fo(e,new Nt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Nt.isNode&&M.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function wg(e){return M.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function bg(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&&M.isArray(o)?o.length:i,l?(M.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!M.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&M.isArray(o[i])&&(o[i]=bg(o[i])),!a)}if(M.isFormData(e)&&M.isFunction(e.entries)){const n={};return M.forEachEntry(e,(r,o)=>{t(wg(r),o,n,0)}),n}return null}function Sg(e,t,n){if(M.isString(e))try{return(t||JSON.parse)(e),M.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=M.isObject(t);if(s&&M.isHTMLForm(t)&&(t=new FormData(t)),M.isFormData(t))return o?JSON.stringify(Vl(t)):t;if(M.isArrayBuffer(t)||M.isBuffer(t)||M.isStream(t)||M.isFile(t)||M.isBlob(t)||M.isReadableStream(t))return t;if(M.isArrayBufferView(t))return t.buffer;if(M.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 vg(t,this.formSerializer).toString();if((a=M.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),Sg(t)):t}],transformResponse:[function(t){const n=this.transitional||Xr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(M.isResponse(t)||M.isReadableStream(t))return t;if(t&&M.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:Nt.classes.FormData,Blob:Nt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};M.forEach(["delete","get","head","post","put","patch"],e=>{Xr.headers[e]={}});const Cg=M.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"]),kg=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]&&Cg[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:M.isArray(e)?e.map($o):String(e)}function Tg(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 Eg=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function bi(e,t,n,r,o){if(M.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!M.isString(t)){if(M.isString(r))return t.indexOf(r)!==-1;if(M.isRegExp(r))return r.test(t)}}function Ig(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Ng(e,t){const n=M.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 Lt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=Jr(l);if(!d)throw new Error("header name must be a non-empty string");const f=M.findKey(o,d);(!f||o[f]===void 0||c===!0||c===void 0&&o[f]!==!1)&&(o[f||l]=$o(a))}const i=(a,l)=>M.forEach(a,(c,d)=>s(c,d,l));if(M.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(M.isString(t)&&(t=t.trim())&&!Eg(t))i(kg(t),n);else if(M.isObject(t)&&M.isIterable(t)){let a={},l,c;for(const d of t){if(!M.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?M.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=M.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Tg(o);if(M.isFunction(n))return n.call(this,o,r);if(M.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=M.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||bi(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=M.findKey(r,i);a&&(!n||bi(r,r[a],a,n))&&(delete r[a],o=!0)}}return M.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||bi(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return M.forEach(this,(o,s)=>{const i=M.findKey(r,s);if(i){n[i]=$o(o),delete n[s];return}const a=t?Ig(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 M.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&M.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]||(Ng(o,i),r[a]=!0)}return M.isArray(t)?t.forEach(s):s(t),this}};Lt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),M.reduceDescriptors(Lt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),M.freezeMethods(Lt);function Si(e,t){const n=this||Xr,r=t||n,o=Lt.from(r.headers);let s=r.data;return M.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 Nr(e,t,n){Re.call(this,e??"canceled",Re.ERR_CANCELED,t,n),this.name="CanceledError"}M.inherits(Nr,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 Ag(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function _g(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 c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;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),c-i<t)return;const p=d&&c-d;return p?Math.round(h*1e3/p):void 0}}function jg(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),f=d-n;f>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const zo=(e,t,n=3)=>{let r=0;const o=_g(50,250);return jg(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c: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)=>M.asap(()=>e(...t)),Rg=Nt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Nt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Nt.origin),Nt.navigator&&/(msie|trident)/i.test(Nt.navigator.userAgent)):()=>!0,Pg=Nt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];M.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),M.isString(r)&&i.push("path="+r),M.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 Og(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Mg(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Jl(e,t,n){let r=!Og(t);return e&&(r||n==!1)?Mg(e,t):t}const Zl=e=>e instanceof Lt?{...e}:e;function ar(e,t){t=t||{};const n={};function r(c,d,f,h){return M.isPlainObject(c)&&M.isPlainObject(d)?M.merge.call({caseless:h},c,d):M.isPlainObject(d)?M.merge({},d):M.isArray(d)?d.slice():d}function o(c,d,f,h){if(M.isUndefined(d)){if(!M.isUndefined(c))return r(void 0,c,f,h)}else return r(c,d,f,h)}function s(c,d){if(!M.isUndefined(d))return r(void 0,d)}function i(c,d){if(M.isUndefined(d)){if(!M.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,f){if(f in t)return r(c,d);if(f in e)return r(void 0,c)}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:(c,d,f)=>o(Zl(c),Zl(d),f,!0)};return M.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,h=f(e[d],t[d],d);M.isUndefined(h)&&f!==a||(n[d]=h)}),n}const Ql=e=>{const t=ar({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Lt.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)):""))),M.isFormData(n)){if(Nt.hasStandardBrowserEnv||Nt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(M.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{c.includes(d.toLowerCase())&&i.set(d,f)})}}if(Nt.hasStandardBrowserEnv&&(r&&M.isFunction(r)&&(r=r(t)),r||r!==!1&&Rg(t.url))){const l=o&&s&&Pg.read(s);l&&i.set(o,l)}return t},Dg=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Ql(e);let s=o.data;const i=Lt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,f,h,p,y;function v(){p&&p(),y&&y(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let m=new XMLHttpRequest;m.open(o.method.toUpperCase(),o.url,!0),m.timeout=o.timeout;function x(){if(!m)return;const S=Lt.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:S,config:e,request:m};Gl(function(E){n(E),v()},function(E){r(E),v()},C),m=null}"onloadend"in m?m.onloadend=x:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(x)},m.onabort=function(){m&&(r(new Re("Request aborted",Re.ECONNABORTED,e,m)),m=null)},m.onerror=function(T){const C=T&&T.message?T.message:"Network Error",k=new Re(C,Re.ERR_NETWORK,e,m);k.event=T||null,r(k),m=null},m.ontimeout=function(){let T=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||Wl;o.timeoutErrorMessage&&(T=o.timeoutErrorMessage),r(new Re(T,C.clarifyTimeoutError?Re.ETIMEDOUT:Re.ECONNABORTED,e,m)),m=null},s===void 0&&i.setContentType(null),"setRequestHeader"in m&&M.forEach(i.toJSON(),function(T,C){m.setRequestHeader(C,T)}),M.isUndefined(o.withCredentials)||(m.withCredentials=!!o.withCredentials),a&&a!=="json"&&(m.responseType=o.responseType),c&&([h,y]=zo(c,!0),m.addEventListener("progress",h)),l&&m.upload&&([f,p]=zo(l),m.upload.addEventListener("progress",f),m.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=S=>{m&&(r(!S||S.type?new Nr(null,e,m):S),m.abort(),m=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const w=Ag(o.url);if(w&&Nt.protocols.indexOf(w)===-1){r(new Re("Unsupported protocol "+w+":",Re.ERR_BAD_REQUEST,e));return}m.send(s||null)})},Lg=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,a();const d=c instanceof Error?c: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(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>M.asap(a),l}},Fg=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},$g=async function*(e,t){for await(const n of zg(e))yield*Fg(n,t)},zg=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=$g(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await o.next();if(c){a(),l.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},tc=64*1024,{isFunction:Bo}=M,Bg=(({Request:e,Response:t})=>({Request:e,Response:t}))(M.global),{ReadableStream:nc,TextEncoder:rc}=M.global,oc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Hg=e=>{e=M.merge.call({skipUndefined:!0},Bg,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"?(y=>v=>y.encode(v))(new rc):async y=>new Uint8Array(await new n(y).arrayBuffer())),c=s&&a&&oc(()=>{let y=!1;const v=new n(Nt.origin,{body:new nc,method:"POST",get duplex(){return y=!0,"half"}}).headers.has("Content-Type");return y&&!v}),d=i&&a&&oc(()=>M.isReadableStream(new r("").body)),f={stream:d&&(y=>y.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(y=>{!f[y]&&(f[y]=(v,m)=>{let x=v&&v[y];if(x)return x.call(v);throw new Re(`Response type '${y}' is not supported`,Re.ERR_NOT_SUPPORT,m)})});const h=async y=>{if(y==null)return 0;if(M.isBlob(y))return y.size;if(M.isSpecCompliantForm(y))return(await new n(Nt.origin,{method:"POST",body:y}).arrayBuffer()).byteLength;if(M.isArrayBufferView(y)||M.isArrayBuffer(y))return y.byteLength;if(M.isURLSearchParams(y)&&(y=y+""),M.isString(y))return(await l(y)).byteLength},p=async(y,v)=>{const m=M.toFiniteNumber(y.getContentLength());return m??h(v)};return async y=>{let{url:v,method:m,data:x,signal:w,cancelToken:S,timeout:T,onDownloadProgress:C,onUploadProgress:k,responseType:E,headers:R,withCredentials:P="same-origin",fetchOptions:j}=Ql(y),B=t||fetch;E=E?(E+"").toLowerCase():"text";let $=Lg([w,S&&S.toAbortSignal()],T),L=null;const O=$&&$.unsubscribe&&(()=>{$.unsubscribe()});let H;try{if(k&&c&&m!=="get"&&m!=="head"&&(H=await p(R,x))!==0){let F=new n(v,{method:"POST",body:x,duplex:"half"}),q;if(M.isFormData(x)&&(q=F.headers.get("content-type"))&&R.setContentType(q),F.body){const[pe,ge]=Yl(H,zo(Xl(k)));x=ec(F.body,tc,pe,ge)}}M.isString(P)||(P=P?"include":"omit");const W=s&&"credentials"in n.prototype,se={...j,signal:$,method:m.toUpperCase(),headers:R.normalize().toJSON(),body:x,duplex:"half",credentials:W?P:void 0};L=s&&new n(v,se);let K=await(s?B(L,j):B(v,se));const U=d&&(E==="stream"||E==="response");if(d&&(C||U&&O)){const F={};["status","statusText","headers"].forEach(ke=>{F[ke]=K[ke]});const q=M.toFiniteNumber(K.headers.get("content-length")),[pe,ge]=C&&Yl(q,zo(Xl(C),!0))||[];K=new r(ec(K.body,tc,pe,()=>{ge&&ge(),O&&O()}),F)}E=E||"text";let X=await f[M.findKey(f,E)||"text"](K,y);return!U&&O&&O(),await new Promise((F,q)=>{Gl(F,q,{data:X,headers:Lt.from(K.headers),status:K.status,statusText:K.statusText,config:y,request:L})})}catch(W){throw O&&O(),W&&W.name==="TypeError"&&/Load failed|fetch/i.test(W.message)?Object.assign(new Re("Network Error",Re.ERR_NETWORK,y,L),{cause:W.cause||W}):Re.from(W,W&&W.code,y,L)}}},Ug=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,c,d=Ug;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:Hg(t)),d=c;return c};sc();const Ci={http:dg,xhr:Dg,fetch:{get:sc}};M.forEach(Ci,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const ic=e=>`- ${e}`,Wg=e=>M.isFunction(e)||e===null||e===!1,ac={getAdapter:(e,t)=>{e=M.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,!Wg(r)&&(o=Ci[(a=String(r)).toLowerCase()],o===void 0))throw new Re(`Unknown adapter '${a}'`);if(o&&(M.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
33
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=Lt.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=Lt.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=Lt.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},gn=Uo.validators;let lr=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=ar(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Uo.assertOptions(r,{silentJSONParsing:gn.transitional(gn.boolean),forcedJSONParsing:gn.transitional(gn.boolean),clarifyTimeoutError:gn.transitional(gn.boolean)},!1),o!=null&&(M.isFunction(o)?n.paramsSerializer={serialize:o}:Uo.assertOptions(o,{encode:gn.function,serialize:gn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Uo.assertOptions(n,{baseUrl:gn.spelling("baseURL"),withXsrfToken:gn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&M.merge(s.common,s[n.method]);s&&M.forEach(["delete","get","head","post","put","patch","common"],x=>{delete s[x]}),n.headers=Lt.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(n)===!1||(l=l&&v.synchronous,a.unshift(v.fulfilled,v.rejected))});const u=[];this.interceptors.response.forEach(function(v){u.push(v.fulfilled,v.rejected)});let d,f=0,h;if(!l){const x=[lc.bind(this),void 0];for(x.unshift(...a),x.push(...u),h=x.length,d=Promise.resolve(n);f<h;)d=d.then(x[f++],x[f++]);return d}h=a.length;let p=n;for(;f<h;){const x=a[f++],v=a[f++];try{p=x(p)}catch(m){v.call(this,m);break}}try{d=lc.call(this,p)}catch(x){return Promise.reject(x)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=ar(this.defaults,t);const n=Jl(t.baseURL,t.url,t.allowAbsoluteUrls);return Hl(n,t.params,t.paramsSerializer)}};M.forEach(["delete","get","head","options"],function(t){lr.prototype[t]=function(n,r){return this.request(ar(r||{},{method:t,url:n,data:(r||{}).data}))}}),M.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(ar(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}lr.prototype[t]=n(),lr.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 M.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 lr(e),n=Il(lr.prototype.request,t);return M.extend(n,lr.prototype,t,{allOwnKeys:!0}),M.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return dc(ar(e,o))},n}const ct=dc(Xr);ct.Axios=lr,ct.CanceledError=Ar,ct.CancelToken=Gg,ct.isCancel=ql,ct.VERSION=cc,ct.toFormData=Fo,ct.AxiosError=Re,ct.Cancel=ct.CanceledError,ct.all=function(t){return Promise.all(t)},ct.spread=Yg,ct.isAxiosError=Xg,ct.mergeConfig=ar,ct.AxiosHeaders=Lt,ct.formToJSON=e=>Vl(M.isHTMLForm(e)?new FormData(e):e),ct.getAdapter=ac.getAdapter,ct.HttpStatusCode=Ei,ct.default=ct;const{Axios:sT,AxiosError:iT,CanceledError:aT,isCancel:lT,CancelToken:cT,VERSION:uT,all:dT,Cancel:fT,isAxiosError:hT,spread:pT,toFormData:mT,AxiosHeaders:gT,HttpStatusCode:xT,formToJSON:yT,getAdapter:vT,mergeConfig:bT}=ct,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 Gt=ct.create({...hc?{baseURL:hc}:{},timeout:3e4,withCredentials:!0});Gt.interceptors.request.use(e=>(Wo&&(e.headers.Authorization=`Bearer ${Wo}`),e)),Gt.interceptors.response.use(e=>e,e=>Promise.reject(e));async function nn(e,t){return Gt.defaults.baseURL?(await Gt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function gc(e,t,n){return Gt.defaults.baseURL?(await Gt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function xc(e,t,n){return Gt.defaults.baseURL?(await Gt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function yc(e,t){return Gt.defaults.baseURL?(await Gt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function xn(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class vc{get baseUrl(){const t=Gt.defaults.baseURL;return t?Mn(String(t)):""}updateConfig(t){t.baseUrl&&(Gt.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 nn("/threads"),n=xn(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 xn(r)}async updateThread(t,n){const r=await xc(`/threads/${t}`,{title:n});return xn(r)}async deleteThread(t){const n=await yc(`/threads/${t}`);return xn(n)}async threadInfo(t){const n=await nn(`/threads/${t}/info`);return xn(n)}async listAgents(){const t=await nn("/agents"),n=xn(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await nn(`/agents/${t}`);return xn(n)}async getAgentSchema(t){const n=await nn(`/agents/${t}/schema`);return xn(n)}async getState(t){const n=await nn(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return xn(n)}async getStateHistory(t){const n=await nn(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return xn(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=zt(e.config),f=zt(d==null?void 0:d.configurable),h=it(f,["checkpoint_id","checkpointId"]),p=it(f,["checkpoint_ns","checkpointNs"]),x=zt(e==null?void 0:e.parentConfig),v=zt(x==null?void 0:x.configurable),m=it(v,["checkpoint_id","checkpointId"])??null,y=it(v,["checkpoint_ns","checkpointNs"])??null,b=e==null?void 0:e.createdAt,S=typeof b=="string"&&b.trim()?b:new Date(Date.now()-t).toISOString(),T=u[u.length-1]??null,C=zt(e==null?void 0:e.metadata),k=it(C,["branch_label","branchLabel"]),E=it(v,["checkpoint_id","checkpointId"]),R=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:m,nextCursorNs:y,interrupt:tx(a,u,t),createdAt:S,parentId:E??null,branchLabel:k??null,lastMessageId:(T==null?void 0:T.id)??null,hasMessages:u.length>0,messagesLen:u.length,metadata:C??null,config:d??null,parentConfig:x??null,next:R??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,x=typeof l=="string"&&l.trim()?l:Array.isArray(u)&&typeof u[0]=="string"?String(u[0]):"task",v=Array.isArray(d)?d:void 0,m=h.length?h[h.length-1]:void 0;return{id:p,name:x,interrupts:v,state:m!==void 0?m:f}}const n=zt(e);if(!n)return null;const r=it(n,["id","task_id","taskId"])??t,o=it(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=it(n,["type","event","kind"]),o=it(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=zt(e)??{},o=zt(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=zt(o.additional_kwargs)??zt(o.additionalKwargs),d=zt(o.response_metadata)??zt(o.responseMetadata),f=it(u,["createdAt","created_at"])??it(o,["created_at","createdAt"]),h=it(u,["checkpointId","checkpoint_id"]),p=it(u,["checkpointNs","checkpoint_ns"]),x=dx(o.content),v={id:l,role:i,content:x};f&&(v.createdAt=f),typeof o.name=="string"&&o.name.trim()&&(v.name=o.name),typeof(d==null?void 0:d.model_name)=="string"&&(v.model=String(d.model_name)),!v.model&&typeof o.model=="string"&&(v.model=o.model),h&&(v.checkpointId=h),p&&(v.checkpointNs=p);const m=gx(u,["createdAt","created_at","checkpointId","checkpoint_id","checkpointNs","checkpoint_ns","tool_calls"]),y=d?{...d}:void 0;m&&Object.keys(m).length&&(v.additionalKwargs=m),y&&Object.keys(y).length&&(v.responseMetadata=y);const b=fx((u==null?void 0:u.tool_calls)??o.tool_calls);if(b.length&&(v.content=[...v.content,...b]),i==="tool"){const S=px(o,v.content);S&&(v.content=S)}return v}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=it(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=it(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=it(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=it(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=it(r,["id","call_id"]),s=zt(r.function),i=it(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=it(e,["id","call_id"]),n=it(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=it(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 zt(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function it(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(S=>S.id===i&&S.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:x,changed:v}=Cx(u.content,t.delta,f,h);if(!v)return e;const m={...u,content:p},y=Ac(a,l,m),b={...d,[i]:x};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??"",x={...h,text:p+l};u=[...u.slice(0,u.length-1),x]}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,x]=w.useState(null),[v,m]=w.useState(0),[y,b]=w.useState(!1),S=w.useRef(null),T=w.useRef(!0),C=w.useRef(0),k=w.useCallback(j=>{o(j)},[]),E=w.useCallback(()=>{var j;(j=S.current)==null||j.abort(),S.current=null,l(!1),b(!1),C.current=0,m(0)},[]),R=w.useCallback(()=>{h(""),x(null),d(null)},[]),P=w.useCallback((j,H,$)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h("");const L=new AbortController;return S.current=L,(async()=>{var B,W,se,K,U,X,F,q;const O=me=>{var ge;try{const ke=JSON.parse(JSON.stringify(me));return(ge=ke==null?void 0:ke.payload)!=null&&ge.files_info&&Array.isArray(ke.payload.files_info)&&(ke.payload.files_info=ke.payload.files_info.map(Se=>({...Se,data:Se!=null&&Se.data?`<base64 ${String(Se.data).length} chars>`:Se==null?void 0:Se.data}))),ke}catch{return me}};try{let me={};try{if(r)me={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ue=window.__AUTH_TOKEN__,at=((B=window.localStorage)==null?void 0:B.getItem("authToken"))||null;let Ke=null;try{const mt=(W=window.localStorage)==null?void 0:W.getItem("chat-settings");mt&&(Ke=((se=JSON.parse(mt))==null?void 0:se.apiKey)||null)}catch{}const je=Ue||at||Ke||null;je&&(me={Authorization:`Bearer ${je}`})}}catch{}console.debug("[use-chat] POST",t+n,O(j));const ge=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...me,...s.current},body:JSON.stringify(j),signal:L.signal,credentials:i});if(!ge.ok||!ge.body){const De=await ge.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",ge.status,De==null?void 0:De.slice(0,500)),new Error(`stream ${ge.status}${De?": "+De:""}`)}b(!0);const ke=ge.body.getReader(),Se=new TextDecoder;let J="",D=[];C.current=0,m(0);let ee=0,re=null;const ae=()=>{if(D.length){const De=D.join("");D=[],T.current&&h(Ue=>Ue+De)}re=null},le=()=>{typeof window<"u"&&re==null&&(re=requestAnimationFrame(ae))};let ie=Date.now();const Ge=setInterval(()=>{var De;if(Date.now()-ie>6e4){const Ue="Stream idle timeout";d(Ue),L.abort(),(De=$==null?void 0:$.onError)==null||De.call($,Ue)}},5e3),Je=1024*1024;try{const De=ge.headers.get("X-Thread-Id")||ge.headers.get("x-thread-id"),Ue=ge.headers.get("X-Thread-Created")||ge.headers.get("x-thread-created"),at=De??null,Ke=String(Ue??"").toLowerCase()==="true";for((K=$==null?void 0:$.onOpen)==null||K.call($,{threadId:at,created:Ke});;){const{value:je,done:mt}=await ke.read();if(mt)break;J+=Se.decode(je,{stream:!0}),J.length>Je&&(J="",console.warn("Stream buffer reset: exceeded 1MB"));let gt;for(;(gt=J.indexOf(`
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:Ci};function ki(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Nr(null,e)}function lc(e){return ki(e),e.headers=Lt.from(e.headers),e.data=Si.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 ki(e),r.data=Si.call(e,e.transformResponse,r),r.headers=Lt.from(r.headers),r},function(r){return ql(r)||(ki(e),r&&r.response&&(r.response.data=Si.call(e,e.transformResponse,r.response),r.response.headers=Lt.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 Vg(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:Vg,validators:Ho},gn=Uo.validators;let lr=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=ar(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Uo.assertOptions(r,{silentJSONParsing:gn.transitional(gn.boolean),forcedJSONParsing:gn.transitional(gn.boolean),clarifyTimeoutError:gn.transitional(gn.boolean)},!1),o!=null&&(M.isFunction(o)?n.paramsSerializer={serialize:o}:Uo.assertOptions(o,{encode:gn.function,serialize:gn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Uo.assertOptions(n,{baseUrl:gn.spelling("baseURL"),withXsrfToken:gn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&M.merge(s.common,s[n.method]);s&&M.forEach(["delete","get","head","post","put","patch","common"],y=>{delete s[y]}),n.headers=Lt.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(n)===!1||(l=l&&v.synchronous,a.unshift(v.fulfilled,v.rejected))});const c=[];this.interceptors.response.forEach(function(v){c.push(v.fulfilled,v.rejected)});let d,f=0,h;if(!l){const y=[lc.bind(this),void 0];for(y.unshift(...a),y.push(...c),h=y.length,d=Promise.resolve(n);f<h;)d=d.then(y[f++],y[f++]);return d}h=a.length;let p=n;for(;f<h;){const y=a[f++],v=a[f++];try{p=y(p)}catch(m){v.call(this,m);break}}try{d=lc.call(this,p)}catch(y){return Promise.reject(y)}for(f=0,h=c.length;f<h;)d=d.then(c[f++],c[f++]);return d}getUri(t){t=ar(this.defaults,t);const n=Jl(t.baseURL,t.url,t.allowAbsoluteUrls);return Hl(n,t.params,t.paramsSerializer)}};M.forEach(["delete","get","head","options"],function(t){lr.prototype[t]=function(n,r){return this.request(ar(r||{},{method:t,url:n,data:(r||{}).data}))}}),M.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(ar(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}lr.prototype[t]=n(),lr.prototype[t+"Form"]=n(!0)});let Kg=class Sm{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 Sm(function(o){t=o}),cancel:t}}};function qg(e){return function(n){return e.apply(null,n)}}function Gg(e){return M.isObject(e)&&e.isAxiosError===!0}const Ti={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(Ti).forEach(([e,t])=>{Ti[t]=e});function dc(e){const t=new lr(e),n=Il(lr.prototype.request,t);return M.extend(n,lr.prototype,t,{allOwnKeys:!0}),M.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return dc(ar(e,o))},n}const ct=dc(Xr);ct.Axios=lr,ct.CanceledError=Nr,ct.CancelToken=Kg,ct.isCancel=ql,ct.VERSION=cc,ct.toFormData=Fo,ct.AxiosError=Re,ct.Cancel=ct.CanceledError,ct.all=function(t){return Promise.all(t)},ct.spread=qg,ct.isAxiosError=Gg,ct.mergeConfig=ar,ct.AxiosHeaders=Lt,ct.formToJSON=e=>Vl(M.isHTMLForm(e)?new FormData(e):e),ct.getAdapter=ac.getAdapter,ct.HttpStatusCode=Ti,ct.default=ct;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}=ct,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 Ei=new Set;function pc(){return Wo}function Ii(e){Wo=e,Ei.forEach(t=>t(e))}function mc(e){return Ei.add(e),()=>Ei.delete(e)}const Gt=ct.create({...hc?{baseURL:hc}:{},timeout:3e4,withCredentials:!0});Gt.interceptors.request.use(e=>(Wo&&(e.headers.Authorization=`Bearer ${Wo}`),e)),Gt.interceptors.response.use(e=>e,e=>Promise.reject(e));async function nn(e,t){return Gt.defaults.baseURL?(await Gt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function gc(e,t,n){return Gt.defaults.baseURL?(await Gt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function xc(e,t,n){return Gt.defaults.baseURL?(await Gt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function yc(e,t){return Gt.defaults.baseURL?(await Gt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function xn(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class vc{get baseUrl(){const t=Gt.defaults.baseURL;return t?Mn(String(t)):""}updateConfig(t){t.baseUrl&&(Gt.defaults.baseURL=Mn(String(t.baseUrl))),t.authToken!==void 0&&Ii(t.authToken)}getAuthToken(){return pc()}setAuthToken(t){Ii(t)}onTokenChange(t){return mc(t)}async listThreads(){const t=await nn("/threads"),n=xn(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 xn(r)}async updateThread(t,n){const r=await xc(`/threads/${t}`,{title:n});return xn(r)}async deleteThread(t){const n=await yc(`/threads/${t}`);return xn(n)}async threadInfo(t){const n=await nn(`/threads/${t}/info`);return xn(n)}async listAgents(){const t=await nn("/agents"),n=xn(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await nn(`/agents/${t}`);return xn(n)}async getAgentSchema(t){const n=await nn(`/agents/${t}/schema`);return xn(n)}async getState(t){const n=await nn(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return xn(n)}async getStateHistory(t){const n=await nn(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return xn(n)}}const Hn=new vc,wc=b.createContext(null);function Yg({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 u.jsx(wc.Provider,{value:r,children:e})}function Ni(){const e=b.useContext(wc);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function Xg(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 Jg(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const c=await Xg(l);a.push({filename:l.name,data:c,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const Zg={human:"user",user:"user",ai:"assistant",assistant:"assistant",tool:"tool",function:"tool",system:"system"};function Ai(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 _i(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(!Ai(r))return{threadId:n,latest:null,checkpoints:[],interrupt:null,snapshots:{}};const{orderedSnapshots:o,snapshotMap:s}=ex(t),i=bc(r,0);return{threadId:n,latest:i,checkpoints:o,interrupt:(i==null?void 0:i.interrupt)??null,snapshots:s}}function bc(e,t){if(!Ai(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,c=r.map((P,j)=>lx(P,j)).filter(P=>!!P),d=zt(e.config),f=zt(d==null?void 0:d.configurable),h=it(f,["checkpoint_id","checkpointId"]),p=it(f,["checkpoint_ns","checkpointNs"]),y=zt(e==null?void 0:e.parentConfig),v=zt(y==null?void 0:y.configurable),m=it(v,["checkpoint_id","checkpointId"])??null,x=it(v,["checkpoint_ns","checkpointNs"])??null,w=e==null?void 0:e.createdAt,S=typeof w=="string"&&w.trim()?w:new Date(Date.now()-t).toISOString(),T=c[c.length-1]??null,C=zt(e==null?void 0:e.metadata),k=it(C,["branch_label","branchLabel"]),E=it(v,["checkpoint_id","checkpointId"]),R=Array.isArray(e.next)?[...e.next]:(e==null?void 0:e.next)===null?null:void 0;return{messages:c,checkpointId:h??null,checkpointNs:p??null,nextCursor:m,nextCursorNs:x,interrupt:Qg(a,c,t),createdAt:S,parentId:E??null,branchLabel:k??null,lastMessageId:(T==null?void 0:T.id)??null,hasMessages:c.length>0,messagesLen:c.length,metadata:C??null,config:d??null,parentConfig:y??null,next:R??null,tasks:l??null,values:i??null}}function Qg(e,t,n){const r=ix(e,n);return r||sx(t,n)}function ex(e){const t=new Map;e.forEach((o,s)=>{if(!Ai(o))return;const i=bc(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,tx(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 tx(e,t){const n=Vo(e.metadata,t.metadata),r=Vo(e.config,t.config),o=Vo(e.parentConfig,t.parentConfig),s=rx(e.next,t.next),i=ox(e.tasks,t.tasks),a=nx(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 nx(e,t){return Vo(e,t)}function rx(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 ox(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 sx(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 ix(e,t){if(!Array.isArray(e)||!e.length)return null;for(let n=e.length-1;n>=0;n--){const r=ax(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 ax(e,t){if(!e)return null;if(Array.isArray(e)){const[a,l,c,,d,,f,...h]=e,p=typeof a=="string"&&a.trim()?a:t,y=typeof l=="string"&&l.trim()?l:Array.isArray(c)&&typeof c[0]=="string"?String(c[0]):"task",v=Array.isArray(d)?d:void 0,m=h.length?h[h.length-1]:void 0;return{id:p,name:y,interrupts:v,state:m!==void 0?m:f}}const n=zt(e);if(!n)return null;const r=it(n,["id","task_id","taskId"])??t,o=it(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 c=Qr(l,t,n+1,r);if(c)return c}}return null}function Sc(e,t){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){const n=e,r=it(n,["type","event","kind"]),o=it(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 lx(e,t){if(!e||typeof e!="object")return null;const n=e,r=zt(e)??{},o=zt(n.data)??r,s=String(n.type??o.type??o.role??"").toLowerCase(),i=Zg[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}`,c=zt(o.additional_kwargs)??zt(o.additionalKwargs),d=zt(o.response_metadata)??zt(o.responseMetadata),f=it(c,["createdAt","created_at"])??it(o,["created_at","createdAt"]),h=it(c,["checkpointId","checkpoint_id"]),p=it(c,["checkpointNs","checkpoint_ns"]),y=cx(o.content),v={id:l,role:i,content:y};f&&(v.createdAt=f),typeof o.name=="string"&&o.name.trim()&&(v.name=o.name),typeof(d==null?void 0:d.model_name)=="string"&&(v.model=String(d.model_name)),!v.model&&typeof o.model=="string"&&(v.model=o.model),h&&(v.checkpointId=h),p&&(v.checkpointNs=p);const m=px(c,["createdAt","created_at","checkpointId","checkpoint_id","checkpointNs","checkpoint_ns","tool_calls"]),x=d?{...d}:void 0;m&&Object.keys(m).length&&(v.additionalKwargs=m),x&&Object.keys(x).length&&(v.responseMetadata=x);const w=ux((c==null?void 0:c.tool_calls)??o.tool_calls);if(w.length&&(v.content=[...v.content,...w]),i==="tool"){const S=fx(o,v.content);S&&(v.content=S)}return v}function cx(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=it(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=it(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 dx(t)??null;if(n==="tool_end"){const o=it(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=it(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 ux(e){return Array.isArray(e)?e.map((t,n)=>{if(!t||typeof t!="object")return null;const r=t,o=it(r,["id","call_id"]),s=zt(r.function),i=it(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 dx(e){const t=it(e,["id","call_id"]),n=it(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 fx(e,t){const n=it(e,["tool_call_id","toolCallId","id"]);if(!n)return t;const r=e.content??e.output,o=typeof r=="string"?hx(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 hx(e){try{return JSON.parse(e)}catch{return e}}function zt(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function it(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r}}function px(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 mx(e){return e.type!=="thread_info"&&e.type!=="token"}const gx={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,messagesStreamMeta:{},pendingInterrupt:null};function xx(e,t){var n;switch(t.type){case"reset":{console.log("[MessageReducer] 🔄 RESET action received"),console.log("[MessageReducer] 📊 Before reset - messages count:",e.messages.length);const r={messages:ji(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,pendingInterrupt:null};return console.log("[MessageReducer] 📊 After reset - messages count:",r.messages.length),r}case"seed":{const r=ji(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),console.log("[MessageReducer] seed action (REPLACE mode):",{incomingCount:t.payload.messages.length,sanitizedCount:r.length,previousCount:e.messages.length,checkpointId:o.lastCheckpointId}),o}case"prepend":{const r=ji(t.payload.messages);if(!r.length)return console.log("[MessageReducer] No incoming messages after sanitize - skipping"),e;const o=new Set(e.messages.map(i=>i.id)),s=r.filter(i=>!o.has(i.id));return console.log("[MessageReducer] After dedup:",{uniqueCount:s.length,duplicates:r.length-s.length,finalTotal:s.length+e.messages.length}),s.length?{...e,messages:[...s,...e.messages]}:(console.log("[MessageReducer] All messages were duplicates - skipping"),e)}case"user_message":{const r=t.payload.message;return e.messages.some(o=>o.id===r.id)?e:{...e,messages:[...e.messages,r]}}case"event":return 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:Ac(e.messages),pendingInterrupt:null};default:return e}}function Ec(e=[]){const[t,n]=b.useReducer(xx,{...gx,messages:e}),r=b.useRef([]),o=b.useRef(null),s=b.useRef(null),i=b.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=b.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=b.useCallback(d=>{r.current.push(d),a()},[a]);b.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=b.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,...c}}function Ic(e,t){var n,r,o,s;if(t.type==="message_start"&&t.role==="assistant"){const i=t.id,a=Cx(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 c={id:i,role:"assistant",name:a||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:i,messages:[...e.messages,c]}}if(t.type==="message_delta"){const i=e.assemblingId??_c(e.messages);if(!i)return e;const a=e.messages,l=a.findIndex(S=>S.id===i&&S.role==="assistant");if(l===-1)return e;const c=a[l],d=e.messagesStreamMeta??{},f=d[i]??{lastSeq:null,lastText:jc(c.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:y,changed:v}=bx(c.content,t.delta,f,h);if(!v)return e;const m={...c,content:p},x=Nc(a,l,m),w={...d,[i]:y};return{...e,messages:x,messagesStreamMeta:w}}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(c=>c.id===i&&c.role==="assistant");if(l>=0){const c=a[l];if(!((n=c.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:c.id,contentTypes:(r=c.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=c.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}`,c={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:[c]};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},c=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=c?vx(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=Sx(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=_i(t),a=i.interrupt,l=i.latest,c=a===null?Ac(e.messages):e.messages;return{...e,messages:c,pendingInterrupt:a,lastCheckpointId:(l==null?void 0:l.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(l==null?void 0:l.checkpointNs)??e.lastCheckpointNs}}return e}function ji(e){return e.filter(t=>{if(t.role!=="assistant")return!0;const n=(t.content||[]).some(o=>{var s;return o&&o.type==="text"&&((s=o.text)==null?void 0:s.trim())}),r=(t.content||[]).some(o=>o&&o.type==="image_url");return!!(n||r)})}function Nc(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Ac(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 yx(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 vx(e,t,n){return yx(e,t,r=>({...r,content:wx(r.content,n)}))}function wx(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 c=i(s),d=i(l);if(c.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(c.includes(d)){console.debug("[MessageReducer] incoming includes previous (normalized) - replacing",{incomingLength:s.length,previousLength:l.length}),a.text=s;continue}if(d.includes(c)&&c.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 bx(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="",c=e.slice();if(s){const f=Pc(a,s);if(f===""?l="":f===s?l=s:l=f,l){const h=c[c.length-1];if((h==null?void 0:h.type)==="text"){const p=h.text??"",y={...h,text:p+l};c=[...c.slice(0,c.length-1),y]}else c=[...c,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(c=[...c,...i]);const d=!!(l||i.length);return{newParts:c,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 Sx(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 Nc(e,r,s)}return e}function Cx(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Oc(e={}){const t=b.useMemo(()=>Mn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=b.useState(e.token??null),s=b.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=b.useState(!1),[c,d]=b.useState(null),[f,h]=b.useState(""),[p,y]=b.useState(null),[v,m]=b.useState(0),[x,w]=b.useState(!1),S=b.useRef(null),T=b.useRef(!0),C=b.useRef(0),k=b.useCallback(j=>{o(j)},[]),E=b.useCallback(()=>{var j;(j=S.current)==null||j.abort(),S.current=null,l(!1),w(!1),C.current=0,m(0)},[]),R=b.useCallback(()=>{h(""),y(null),d(null)},[]),P=b.useCallback((j,B,$)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h("");const L=new AbortController;return S.current=L,(async()=>{var H,W,se,K,U,X,F,q;const O=pe=>{var ge;try{const ke=JSON.parse(JSON.stringify(pe));return(ge=ke==null?void 0:ke.payload)!=null&&ge.files_info&&Array.isArray(ke.payload.files_info)&&(ke.payload.files_info=ke.payload.files_info.map(Se=>({...Se,data:Se!=null&&Se.data?`<base64 ${String(Se.data).length} chars>`:Se==null?void 0:Se.data}))),ke}catch{return pe}};try{let pe={};try{if(r)pe={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const He=window.__AUTH_TOKEN__,at=((H=window.localStorage)==null?void 0:H.getItem("authToken"))||null;let Ke=null;try{const mt=(W=window.localStorage)==null?void 0:W.getItem("chat-settings");mt&&(Ke=((se=JSON.parse(mt))==null?void 0:se.apiKey)||null)}catch{}const je=He||at||Ke||null;je&&(pe={Authorization:`Bearer ${je}`})}}catch{}console.debug("[use-chat] POST",t+n,O(j));const ge=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...pe,...s.current},body:JSON.stringify(j),signal:L.signal,credentials:i});if(!ge.ok||!ge.body){const Me=await ge.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",ge.status,Me==null?void 0:Me.slice(0,500)),new Error(`stream ${ge.status}${Me?": "+Me:""}`)}w(!0);const ke=ge.body.getReader(),Se=new TextDecoder;let J="",D=[];C.current=0,m(0);let ee=0,re=null;const ce=()=>{if(D.length){const Me=D.join("");D=[],T.current&&h(He=>He+Me)}re=null},ae=()=>{typeof window<"u"&&re==null&&(re=requestAnimationFrame(ce))};let ie=Date.now();const Ge=setInterval(()=>{var Me;if(Date.now()-ie>6e4){const He="Stream idle timeout";d(He),L.abort(),(Me=$==null?void 0:$.onError)==null||Me.call($,He)}},5e3),Je=1024*1024;try{const Me=ge.headers.get("X-Thread-Id")||ge.headers.get("x-thread-id"),He=ge.headers.get("X-Thread-Created")||ge.headers.get("x-thread-created"),at=Me??null,Ke=String(He??"").toLowerCase()==="true";for((K=$==null?void 0:$.onOpen)==null||K.call($,{threadId:at,created:Ke});;){const{value:je,done:mt}=await ke.read();if(mt)break;J+=Se.decode(je,{stream:!0}),J.length>Je&&(J="",console.warn("Stream buffer reset: exceeded 1MB"));let gt;for(;(gt=J.indexOf(`
36
36
 
37
- `))>=0;){const Ct=J.slice(0,gt);J=J.slice(gt+2);const rt=Ix(Ct);if(!rt)continue;let te;try{te=JSON.parse(rt)}catch{console.debug("[use-chat] malformed SSE:",rt.slice(0,200));continue}const ue=Ex(te)?te.data:te;ie=Date.now();const xe=ue.seq;if(xe!==void 0){if(xe<=ee){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:xe,lastProcessedSeq:ee,type:ue.type});continue}ee>0&&xe>ee+1&&((U=$==null?void 0:$.onGap)==null||U.call($,{from:ee,to:xe})),ee=xe,C.current=xe,m(xe)}if(console.debug("[use-chat] received event",{seq:ue.seq,type:ue.type,preview:(()=>{var ze;try{return ue.type==="message_delta"?{deltaTypes:(ze=ue.delta)==null?void 0:ze.map(Pe=>Pe.type),textLen:(ue.delta||[]).filter(Pe=>Pe.type==="text").map(Pe=>String(Pe.text||"").length)}:ue.content||ue.delta?{hasContent:!0}:{}}catch(Pe){return{err:String(Pe)}}})()}),H==null||H(ue),ue.type==="token"&&e.autoAppendAssistant!==!1)D.push(ue.content),le();else if(ue.type==="message_delta"){const ze=ue.delta.filter(Pe=>Pe.type==="text").map(Pe=>Pe.text).join("");ze&&e.autoAppendAssistant!==!1&&(D.push(ze),le())}else ue.type==="heartbeat"?console.debug("[use-chat] heartbeat received"):(re!==null&&cancelAnimationFrame(re),ae(),ue.type==="checkpoint"?x(ue.checkpointId):ue.type==="error"&&d(ue.message))}}ae()}catch(De){if(De.name!=="AbortError"){const Ue=De.message||String(De);d(Ue),(X=$==null?void 0:$.onError)==null||X.call($,Ue)}}finally{try{await ke.cancel()}catch{}finally{(F=ke.releaseLock)==null||F.call(ke)}re!==null&&typeof window<"u"&&window.cancelAnimationFrame(re),clearInterval(Ge),l(!1),b(!1),S.current=null,C.current=0,m(0)}}catch(me){if(me.name!=="AbortError"){const ge=me.message||String(me);d(ge),(q=$==null?void 0:$.onError)==null||q.call($,ge)}}finally{l(!1),b(!1),S.current=null,C.current=0,m(0)}})(),{close:()=>L.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var j;T.current=!1,(j=S.current)==null||j.abort()},[]),{isStreaming:a,error:u,assistantText:f,lastCheckpointId:p,lastSeq:v,connected:y,stream:P,stop:E,clear:R,setToken:k}}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 x=p.seq??null;if(x!==null){const v=s.current;if(v!==null){if(x<=v)return;x>v+1&&(o==null||o({from:v,to:x}))}s.current=x}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,x)=>{s.current=null,a(p,i,{onOpen:x==null?void 0:x.onOpen,onError:v=>{var m;(m=x==null?void 0:x.onError)==null||m.call(x,v)},onGap:(x==null?void 0:x.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 Yt(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 cr(){return typeof window<"u"&&typeof window.localStorage<"u"}function Oi(e){if(!cr())return null;try{return window.localStorage.getItem(e)}catch{return null}}function Mi(e,t){if(!cr())return!1;try{return window.localStorage.setItem(e,t),!0}catch{return!1}}function Di(e){if(cr())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:Yt(r.snapshot,{cloneMessages:!0}),updatedAt:typeof r.updatedAt=="number"?r.updatedAt:void 0}}catch{return null}}function $x(e,t,n=100){if(!cr())return;const r=Yt(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(cr())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]),x=w.useCallback((A,_=100)=>{$x(h,A,_)},[h]),v=w.useCallback(A=>{zx(h,A)},[h]),m=w.useCallback(()=>{Bx(h)},[h]),[y,b]=w.useState(()=>{var A;return Fi(f,(A=l.getAuthToken)==null?void 0:A.call(l))}),[S,T]=w.useState(()=>{var _;const A=zi(Fi(f,(_=l.getAuthToken)==null?void 0:_.call(l)));return qo(A)}),C=w.useMemo(()=>Bi(S),[S]),[k,E]=w.useState(t),[R,P]=w.useState(!1),[j,H]=w.useState(!1),[$,L]=w.useState(null),[O,B]=w.useState(null),[W,se]=w.useState(null),[K,U]=w.useState([]),X=w.useCallback(()=>{const A=zi(y);w.startTransition(()=>{T(qo(A))})},[y]),[F,q]=w.useState(!1),[me,ge]=w.useState(!1),[ke,Se]=w.useState(null),[J,D]=w.useState(void 0),[ee,re]=w.useState(void 0),[ae,le]=w.useState(void 0),{state:ie,dispatch:Ge,seed:Je,prepend:De,pushUser:Ue,onEvent:at,reset:Ke}=Ec(),je=w.useRef(k);w.useEffect(()=>{je.current=k},[k]);const mt=w.useRef(!1),gt=w.useRef([]),Ct=w.useRef(null),rt=w.useRef(null),te=w.useRef(new Map),ue=w.useRef(k),xe=w.useRef(!1),ze=w.useRef(null),Pe=w.useRef(new Map),et=w.useRef(new Map),xt=w.useRef(new Map),$t=w.useRef(new Map),un=w.useCallback(A=>{if(!A){U([]);return}const _=Pe.current.get(A);if(!_||!_.length){U([]);return}U(_.map(Y=>Yt(Y,{cloneMessages:!0})))},[]);w.useEffect(()=>{un(k)},[k,un]);const Nn=w.useCallback(()=>{var ne;const A=$t.current;if(A.size<=zc)return;const _=Array.from(A.entries()).sort((ce,Q)=>ce[1].timestamp-Q[1].timestamp),Y=A.size-zc;for(let ce=0;ce<Y;ce++){const Q=(ne=_[ce])==null?void 0:ne[0];Q&&A.delete(Q)}},[]),tr=w.useCallback((A,_,Y)=>{if(!A)return;const ne=Y==="replace"?[]:Pe.current.get(A)??[],ce=Y==="replace"?_:[..._,...ne];if(!ce.length){Y==="replace"&&Pe.current.set(A,[]);return}const Q=new Map;for(const Be of ce){if(!(Be!=null&&Be.checkpointId))continue;const Le=`${Be.checkpointId}::${Be.checkpointNs??""}`,Xe=Yt(Be,{cloneMessages:!0}),ft=Q.get(Le);if(!ft){Q.set(Le,Xe);continue}const Tt=Hc(ft,Xe);Q.set(Le,{...ft,...Tt})}const $e=Array.from(Q.values()).sort((Be,Le)=>{const Xe=Number.isFinite(Date.parse(Be.createdAt??""))?Date.parse(Be.createdAt??""):0;return(Number.isFinite(Date.parse(Le.createdAt??""))?Date.parse(Le.createdAt??""):0)-Xe});Pe.current.set(A,$e),A===je.current&&un(A)},[un]),dn=w.useCallback((A,_,Y)=>{if(!A)return;const ne=et.current.get(A),ce=Y==="replace"||!ne?new Map:new Map(ne);if(_&&typeof _=="object")for(const[Q,$e]of Object.entries(_)){if(!($e!=null&&$e.checkpointId))continue;const Be=Q||Zr($e.checkpointId,$e.checkpointNs??null);ce.set(Be,Yt($e,{cloneMessages:!0}))}et.current.set(A,ce)},[]),fn=w.useCallback((A,_)=>{const{threadId:Y,checkpointId:ne=null,checkpointNs:ce=null}=A,Q=Bc(Y,ne,ce);if(_!=null&&_.force)xt.current.delete(Q),$t.current.delete(Q);else{if(_!=null&&_.preferCache){const Xe=$t.current.get(Q);if(Xe)return Promise.resolve(Xe.payload)}const Le=xt.current.get(Q);if(Le)return Le}const Be=l.getStateHistory({threadId:Y,checkpointId:ne??void 0,checkpointNs:ce??void 0}).then(Le=>($t.current.set(Q,{payload:Le,timestamp:Date.now()}),Nn(),Le)).finally(()=>{xt.current.get(Q)===Be&&xt.current.delete(Q)});return xt.current.set(Q,Be),Be},[l,Nn]),Mt=w.useCallback((A,_)=>new Promise((Y,ne)=>{const ce=async()=>{mt.current=!0;try{await A(),Y()}catch(Q){ne(Q)}finally{mt.current=!1;const Q=gt.current.shift();Q&&Q().catch(()=>{})}};mt.current?gt.current.push(ce):ce().catch(Q=>{ne(Q)})}),[]),hn=w.useRef(C.length),Kt=w.useRef(!1);w.useEffect(()=>{hn.current=C.length},[C.length]),w.useEffect(()=>{const A=ie.pendingInterrupt??Rx(ie.messages);Mc(W,A)||se(A??null)},[W,ie.messages,ie.pendingInterrupt]);const kt=w.useCallback(async()=>{const A=hn.current>0;A||P(!0);try{const _=await l.listThreads();w.startTransition(()=>{T(Y=>{const ne=$e=>$e.map(Be=>`${Be.threadId}:${Be.updatedAt??""}:${Be.messageCount??""}`).join("|"),ce=Bi(Y);return ne(ce)===ne(_)||_.length===0&&ce.length>0&&!Kt.current?Y:qo(_)})}),L(null),Kt.current||(Kt.current=!0)}catch(_){i==null||i(String(_)),console.error("[ChatSessionProvider] Failed to refresh threads:",_),L(String(_))}finally{A||P(!1)}},[l,i]),kr=w.useRef(!1),nr=w.useRef(null),vt=w.useRef(null),pn=w.useRef(""),_n=w.useCallback((A,_)=>{if(!cr())return;vt.current!==null&&(window.clearTimeout(vt.current),vt.current=null);const Y=A.map(ce=>`${ce.threadId}:${ce.updatedAt??""}:${ce.messageCount??""}`).join("|");if(A.length===0){try{Di(y)}catch{}pn.current="";return}if(Y===pn.current)return;const ne=()=>{try{const ce=A.slice(0,Li);$i(y,ce),pn.current=Y}catch{}finally{vt.current=null}};if(_!=null&&_.immediate){ne();return}vt.current=window.setTimeout(()=>{Dc(ne)},Ko)},[y]),$n=w.useCallback(()=>{_n(C,{immediate:!0})},[_n,C]),qt=w.useCallback((A,_,Y,ne)=>{var Sm;const ce=Y??je.current;if(!ce)return;const Q=Yt(A),$e=ce===je.current,Be=(ne==null?void 0:ne.persist)!==!1;if(_==="replace"){if(Be){const wt={threadId:ce,snapshot:Yt(A,{cloneMessages:!0})};te.current.set(ce,wt),ue.current=ce}if(!$e)return;Je(Q.messages,{checkpointId:Q.checkpointId??null,checkpointNs:Q.checkpointNs??null,pendingInterrupt:Q.interrupt??null}),se(Q.interrupt??null),Se(Q.nextCursor??null),q(!!Q.nextCursor),D(Q.checkpointId??void 0),re(Q.checkpointNs??void 0),le(Q.nextCursorNs??void 0);return}const Le=te.current.get(ce),Xe=(Le==null?void 0:Le.snapshot)??null,ft=Array.isArray(Xe==null?void 0:Xe.messages)?Xe.messages:[],Tt=Yt(Xe),Rn=Array.isArray(A==null?void 0:A.messages)?A.messages:[],Et=new Set,It=[...Rn,...ft].filter(wt=>{const Cl=wt==null?void 0:wt.id;return Cl?Et.has(Cl)?!1:(Et.add(Cl),!0):!0}),No=Hc(Tt,Q),_o={checkpointId:Tt.checkpointId??Q.checkpointId??null,checkpointNs:Tt.checkpointNs??Q.checkpointNs??null,createdAt:Q.createdAt??Tt.createdAt??null,parentId:Q.parentId??Tt.parentId??null,branchLabel:Q.branchLabel??Tt.branchLabel??null,lastMessageId:((Sm=It[It.length-1])==null?void 0:Sm.id)??null,messagesLen:It.length,hasMessages:It.length>0,messages:It,nextCursor:Q.nextCursor??Tt.nextCursor??null,nextCursorNs:Q.nextCursorNs??Tt.nextCursorNs??null,interrupt:Tt.interrupt??Q.interrupt??null,...No};if(te.current.set(ce,{threadId:ce,snapshot:Yt(_o,{cloneMessages:!0})}),!$e)return;Rn.length&&De(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;Se(wt=>On!==void 0?On??wt??null:wt??null),q(wt=>On!==void 0?!!On:wt),D(wt=>Pn!==void 0?Pn??wt??void 0:wt??void 0),re(wt=>jo!==void 0?jo??wt??void 0:wt??void 0),le(wt=>Sl!==void 0?Sl??void 0:wt)},[De,Je,se]),Tr=w.useCallback(A=>{if(A.threadId!=null&&A.threadId!==je.current)return;const _=Yt(A.snapshot,{cloneMessages:!0});Je(_.messages,{checkpointId:_.checkpointId??null,checkpointNs:_.checkpointNs??null,pendingInterrupt:_.interrupt??null}),se(_.interrupt??null),Se(_.nextCursor??null),q(!!_.nextCursor),D(_.checkpointId??void 0),re(_.checkpointNs??void 0),le(_.nextCursorNs??void 0),ue.current=A.threadId,un(A.threadId??je.current??null)},[Je,se,un]),jn=w.useCallback(A=>{if(!A)return;te.current.delete(A),v(A),Pe.current.delete(A),et.current.delete(A),A===je.current&&U([]);const _=`${A}__`;for(const Y of xt.current.keys())Y.startsWith(_)&&xt.current.delete(Y);for(const Y of $t.current.keys())Y.startsWith(_)&&$t.current.delete(Y);ue.current===A&&(ue.current=null)},[v]),mn=w.useCallback(()=>{const A=je.current;A&&jn(A),Ke([]),q(!1),ge(!1),Se(null),D(void 0),re(void 0),le(void 0)},[jn,Ke]),rr=w.useCallback(({from:A,to:_})=>{const Y=je.current;Y&&console.warn(`[ChatSessionProvider] Stream sequence gap detected (${A} -> ${_}) for thread ${Y}`)},[]),Io=w.useCallback(A=>{const _=A.threadId;console.log("[ChatSessionProvider] 📥 Handling thread_info event:",{threadId:_,title:A.title,created:A.created,currentThreads:C.length});const Y={threadId:_,title:A.title||`Thread ${_.slice(0,8)}`,createdAt:A.createdAt||new Date().toISOString(),updatedAt:A.updatedAt||new Date().toISOString(),messageCount:A.messageCount||0};je.current!==_&&(!je.current&&ie.messages.length<=1&&(rt.current=_),E(_)),w.startTransition(()=>{T(ne=>{const ce=ne.byId[_];return ce?ce.title===Y.title&&ce.updatedAt===Y.updatedAt&&ce.messageCount===Y.messageCount?ne:{byId:{...ne.byId,[_]:Y},order:ne.order}:{byId:{...ne.byId,[_]:Y},order:[_,...ne.order]}})})},[ie.messages.length]),{startStream:Ur,stop:Wr,isStreaming:or,error:I,setAuthToken:N}=Ax({baseUrl:d,onThreadInfo:Io,onMessageEvent:at,onUnhandledEvent:A=>{console.warn(`[ChatSessionProvider] Unhandled stream event: ${A.type}`,A)},onSequenceGap:rr});w.useEffect(()=>{kr.current=or},[or]),w.useEffect(()=>{if(!cr())return;vt.current!==null&&(window.clearTimeout(vt.current),vt.current=null);const A=C.map(Y=>`${Y.threadId}:${Y.updatedAt??""}:${Y.messageCount??""}`).join("|");if(C.length===0){try{Di(y)}catch{}pn.current="";return}if(A===pn.current)return;const _=()=>{try{const Y=C.slice(0,Li);$i(y,Y),pn.current=A}catch{}finally{vt.current=null}};return vt.current=window.setTimeout(()=>{Dc(_),vt.current=null},Ko),()=>{vt.current!==null&&(window.clearTimeout(vt.current),vt.current=null)}},[C,_n]),w.useEffect(()=>{var ne;const A=l.getAuthToken();N(A);const _=ce=>{const Q=Fi(f,ce);ze.current!==Q&&(ze.current=Q,xe.current=!1),b(Q);const $e=zi(Q);w.startTransition(()=>{T(qo($e))}),xe.current||(xe.current=!0,kt().catch(()=>{}))};_(A);const Y=(ne=l.onTokenChange)==null?void 0:ne.call(l,ce=>{N(ce),m(),xt.current.clear(),$t.current.clear(),_(ce)});return()=>{Y==null||Y()}},[l,f,N,m,kt]);const z=w.useCallback(async A=>{var ne;const _=`Thread ${(ne=crypto.randomUUID)==null?void 0:ne.call(crypto)}`,Y={threadId:_,title:A||"New Chat",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messageCount:0};T(ce=>({byId:{...ce.byId,[_]:Y},order:[_,...ce.order]})),E(_);try{const ce=await l.createThread(A),Q=typeof ce=="string"?ce:ce.threadId;return T($e=>{const Be=$e.byId[_];if(!Be)return $e;const Le={...$e.byId};delete Le[_],Le[Q]={...Be,threadId:Q};const Xe=$e.order.map(ft=>ft===_?Q:ft);return{byId:Le,order:Xe}}),E(Q),setTimeout(()=>kt(),10),L(null),Q}catch(ce){throw T(Q=>{if(!Q.byId[_])return Q;const $e={...Q.byId};delete $e[_];const Be=Q.order.filter(Le=>Le!==_);return{byId:$e,order:Be}}),E(null),L(String(ce)),ce}},[l,kt]),G=w.useCallback(async A=>{try{await l.deleteThread(A);let _=null;T(Y=>{if(!Y.byId[A])return Y;const ne={...Y.byId};delete ne[A];const ce=Y.order.filter($e=>$e!==A),Q={byId:ne,order:ce};return _=Bi(Q),Q}),_&&_n(_,{immediate:!0}),jn(A),je.current===A&&(rt.current=A,E(null),je.current=null,ue.current=null,mn()),await kt(),L(null)}catch(_){throw L(String(_)),_}},[l,mn,jn,kt,_n]),ve=w.useCallback(async(A,_)=>{try{await l.updateThread(A,_),T(Y=>{const ne=Y.byId[A];return ne?{byId:{...Y.byId,[A]:{...ne,title:_}},order:Y.order}:Y}),L(null)}catch(Y){throw await kt(),L(String(Y)),Y}},[l,kt]),Ce=w.useCallback(async(A,_,Y,ne=!1)=>{await Mt(async()=>{if(rt.current===A&&!ne){rt.current=null;return}if(Ct.current===A&&!ne)return;E(Et=>Et===A?Et:A),je.current=A;const $e=Bc(A,_??null,Y??null),Be=$t.current.get($e),Le=!ne&&!_&&!Y&&Be&&Date.now()-Be.timestamp<Ux,Xe=!ne&&!_&&!Y;let ft=!1;if(Xe){const Et=te.current.get(A);if(Et)Tr(Et),ft=!0;else{const It=p(A);It&&(te.current.set(A,It),Tr(It),ft=!0)}}const Tt=ne||!ft||!!_||!!Y,Rn=async Et=>{Et&&H(!0),Ct.current=A;try{const It=await fn({threadId:A,checkpointId:_,checkpointNs:Y},{force:ne}),{latest:No,checkpoints:_o,snapshots:Pn}=ji(It);qt(No,"replace",A),tr(A,_o,"replace"),dn(A,Pn,"replace"),B(null)}catch(It){throw(!ft||ne||Et)&&(i==null||i(String(It))),B(String(It)),It}finally{Ct.current=null,Et&&H(!1)}};Tt?await Rn(!0):Xe&&ft&&!Le&&Rn(!1).catch(Et=>{console.warn("[ChatSessionProvider] Background refresh failed:",Et)})},`loadThread-${A}`)},[Tr,qt,Mt,fn,i,tr,dn]),Ae=w.useCallback(async()=>{await Mt(async()=>{const A=je.current;A&&jn(A),rt.current=null,E(null),je.current=null,ue.current=null,mn(),D(void 0),re(void 0),le(void 0),U([]);try{localStorage.removeItem("lastThreadId")}catch(_){console.warn("[ChatSessionProvider] Failed to clear lastThreadId:",_)}},"clearCurrentThread")},[mn,jn,Mt]),Oe=w.useCallback(async(A,_)=>{var Q;const Y=je.current;if(!Y)throw new Error("No active thread");const ne=Zr(A,_??null),ce=(Q=et.current.get(Y))==null?void 0:Q.get(ne);if(ce){await Mt(async()=>{qt(ce,"replace",Y,{persist:!1})},`navigateToCheckpoint-${Y}-${ne}`);return}await Ce(Y,A,_??void 0,!0)},[qt,Mt,Ce]),dt=w.useCallback(async()=>{if(!je.current)throw new Error("No active thread");await Ce(je.current,void 0,void 0,!0)},[Ce]),st=w.useCallback(async()=>{if(!je.current)throw new Error("No active thread");if(me||!F)return;const A=ke;if(A){ge(!0);try{const _=je.current,Y=await fn({threadId:_,checkpointId:A??J??null,checkpointNs:ae??ee??null}),{latest:ne,checkpoints:ce,snapshots:Q}=ji(Y),$e=_?et.current.get(_):null;let Be=ce.length>0;if(Be&&$e&&$e.size>0&&(Be=ce.some(Le=>{if(!(Le!=null&&Le.checkpointId))return!1;const Xe=Zr(Le.checkpointId,Le.checkpointNs??null);return!$e.has(Xe)})),!Be){Se(null),le(void 0),q(!1),B(null);return}qt(ne,"prepend",_??void 0),_&&(tr(_,ce,"prepend"),dn(_,Q,"prepend")),B(null)}catch(_){throw B(String(_)),_}finally{ge(!1)}}},[qt,fn,F,J,ee,ae,ke,me,tr,dn]),lt=w.useCallback(A=>{if(A!=null&&A.threadId){if(A.checkpointId){const _=Zr(A.checkpointId,A.checkpointNs??null),Y=Yt({...A,interrupt:A.interrupt??null},{cloneMessages:!0});dn(A.threadId,{[_]:Y},"prepend")}qt(A,"replace",A.threadId)}},[qt,dn]),bt=w.useCallback(async(A,_)=>{var jo;const Y=je.current,ne=(A==null?void 0:A.text)??"",ce=(A==null?void 0:A.attachments)??[],Q=ce.length?ce:(_==null?void 0:_.attachments)??[],$e={...(_==null?void 0:_.payloadExtras)??{},...(A==null?void 0:A.payload)??{}};if(!Y&&!Object.keys($e).length&&Q.length===0&&!ne.trim()){console.warn("[ChatSessionProvider] Nothing to submit - skipping");return}!Y&&!$e.messages&&console.warn("[ChatSessionProvider] No thread ID - message will create new thread");const{contentParts:Be,filesInfo:Le}=await Qg(l,Q),Xe=[...Be];ne&&ne.trim()&&Xe.push({type:"text",text:ne.trim()});const ft=!!Y,Tt=ft?(_==null?void 0:_.checkpointId)??ie.lastCheckpointId??void 0:void 0,Rn=ft?(_==null?void 0:_.checkpointNs)??ie.lastCheckpointNs??void 0:void 0,Et={id:((jo=crypto.randomUUID)==null?void 0:jo.call(crypto))||`user-${Date.now()}`,role:"user",content:Xe,createdAt:new Date().toISOString(),...Tt!=null?{checkpointId:Tt}:{},...Rn!=null?{checkpointNs:Rn}:{}};Xe.length>0&&Ue(Et);const It={...Et,content:Xe},No=Q.length>0,_o={messages:Xe.length>0?[It]:[],files_info:Le,...o&&No&&s?{active_agent:s}:{},...$e},Pn={threadId:Y??null,payload:_o,checkpointId:Tt??null,checkpointNs:Rn??null,nodeFilter:(_==null?void 0:_.nodeFilter)??null,config:_==null?void 0:_.config,command:(_==null?void 0:_.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})=>{!je.current&&On&&(ie.messages.length<=1&&(rt.current=On),E(On))},onGap:rr})},[l,o,s,rr,ie.lastCheckpointId,ie.lastCheckpointNs,ie.messages.length,Ue,Ur]),zn=w.useCallback(async(A,_,Y)=>{if(!je.current)throw new Error("No active thread to handle interrupt");const ce=_?Y??!0:!1;try{try{Ge({type:"interrupt_response",payload:{interruptId:A}})}catch(Q){console.warn("[ChatSessionProvider] optimistic interrupt_response dispatch failed:",Q)}await bt({payload:{}},{checkpointId:ie.lastCheckpointId??void 0,checkpointNs:ie.lastCheckpointNs??void 0,command:{kind:"resume",value:ce}}),se(null)}catch(Q){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${A}:`,Q),Q}},[Ge,ie.lastCheckpointId,ie.lastCheckpointNs,bt]);w.useEffect(()=>{if(a==null||a(k),k)try{localStorage.setItem("lastThreadId",k)}catch(A){console.warn("[ChatSessionProvider] Failed to persist lastThreadId:",A)}},[k,a]),w.useEffect(()=>((async()=>{try{if(kt().catch(_=>{console.error("[ChatSessionProvider] Failed to refresh threads (background):",_),i==null||i(String(_))}),!r&&!t)try{const _=localStorage.getItem("lastThreadId");_&&(E(_),n&&await Ce(_))}catch(_){console.warn("[ChatSessionProvider] Failed to restore last thread:",_)}else t&&n&&await Ce(t)}catch(_){console.error("[ChatSessionProvider] Initialization failed:",_),i==null||i(String(_))}})(),()=>{}),[]),w.useEffect(()=>{const A=je.current;if(!A||ue.current!==A)return;ie.messages.length&&ie.messages[ie.messages.length-1];const _=Yt({checkpointId:ie.lastCheckpointId??null,checkpointNs:ie.lastCheckpointNs??null,messages:ie.messages.slice(),nextCursor:ke??null,nextCursorNs:ae??null,interrupt:ie.pendingInterrupt??W??null}),Y=te.current.get(A),ne=Y==null?void 0:Y.snapshot,ce=!ne||ne.messages.length!==_.messages.length||ne.messages.some((Le,Xe)=>{var ft;return(Le==null?void 0:Le.id)!==((ft=_.messages[Xe])==null?void 0:ft.id)}),Q=((ne==null?void 0:ne.checkpointId)??null)!==_.checkpointId||((ne==null?void 0:ne.checkpointNs)??null)!==_.checkpointNs,$e=((ne==null?void 0:ne.nextCursor)??null)!==_.nextCursor||((ne==null?void 0:ne.nextCursorNs)??null)!==_.nextCursorNs,Be=!Mc((ne==null?void 0:ne.interrupt)??null,_.interrupt??null);if(ce||Q||$e||Be){const Le={threadId:A,snapshot:_};te.current.set(A,Le),nr.current&&window.clearTimeout(nr.current),nr.current=window.setTimeout(()=>{try{x(Le,100)}catch(Xe){console.warn("[ChatSessionProvider] Failed to persist thread payload:",Xe)}},Ko)}},[ke,ae,ie.lastCheckpointId,ie.lastCheckpointNs,ie.messages,ie.pendingInterrupt,W,x]);const Bn=w.useMemo(()=>({threads:C,currentThreadId:k,setCurrentThreadId:E,isLoading:R,error:$,actions:{createThread:z,deleteThread:G,renameThread:ve,refreshThreads:()=>kt()},persistThreadsCache:$n,hydrateFromCache:X}),[C,k,R,$,z,G,ve,kt,$n,X,E]),Rt=w.useMemo(()=>{const A=ie.lastBranch??null,_=ie.assemblingId??null,Y=A||_?{branchLabel:(A==null?void 0:A.branchLabel)??null,lastBranch:A,assemblingMessageId:_}:null;return{threadId:k,messages:ie.messages,interrupt:W,checkpoint:{id:ie.lastCheckpointId??null,namespace:ie.lastCheckpointNs??null},checkpoints:K,metadata:Y,isLoading:j,isHistoryLoading:me,error:O,hasMore:F,loadOlder:st,seedFromSnapshot:lt,clearState:mn,navigateToCheckpoint:Oe,returnToLatest:dt,loadThread:Ce,clearThread:Ae,respondToInterrupt:zn}},[Ae,mn,k,W,F,me,j,st,Ce,ie.assemblingId,ie.lastBranch,ie.lastCheckpointId,ie.lastCheckpointNs,ie.messages,Oe,zn,dt,lt,O,K]),Ao=w.useMemo(()=>({isStreaming:or,error:I,submit:bt,send:bt,stop:Wr,setAuthToken:N}),[or,I,bt,Wr,N]);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:Rt,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 oe(...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"}}),qe=g.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?sr.Slot:"button";return c.jsx(i,{className:oe(Gx({variant:t,size:n,className:e})),ref:s,...o})});qe.displayName="Button";const Wc=g.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:oe("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),[x,v]=w.useTransition(),m=w.useRef(null),y=w.useRef(0),b=w.useRef(null);w.useEffect(()=>{p(e??""),b.current=null,m.current&&(m.current.style.height="auto",m.current.style.height=`${m.current.scrollHeight}px`)},[e,t]);const S=w.useCallback(()=>{const j=m.current;j&&(j.style.height="auto",j.style.height=`${j.scrollHeight}px`)},[]);w.useEffect(()=>{S()},[S]);const T=w.useCallback(async j=>{j&&j.preventDefault();const H=(h??"").trim();if(!H&&!f)return;const $=++y.current;b.current={id:$,shouldClear:!0},v(()=>{var L,O,B;try{const W=i(H);W&&typeof W.then=="function"?W.then(()=>{var se,K;((se=b.current)==null?void 0:se.id)===$&&b.current.shouldClear&&(p(""),m.current&&(m.current.style.height="auto")),((K=b.current)==null?void 0:K.id)===$&&(b.current=null)}).catch(()=>{var se;((se=b.current)==null?void 0:se.id)===$&&(b.current=null)}):(((L=b.current)==null?void 0:L.id)===$&&b.current.shouldClear&&(p(""),m.current&&(m.current.style.height="auto")),((O=b.current)==null?void 0:O.id)===$&&(b.current=null))}catch{((B=b.current)==null?void 0:B.id)===$&&(b.current=null)}})},[h,i,f]),C=w.useCallback(j=>{p(j.target.value),b.current&&(b.current.shouldClear=!1),m.current&&(m.current.style.height="auto",m.current.style.height=`${m.current.scrollHeight}px`)},[]),k=w.useCallback(j=>{j.key==="Enter"&&!j.shiftKey?(j.preventDefault(),T()):j.key==="Escape"&&t&&(j.preventDefault(),a==null||a())},[T,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 T(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:m,value:h,onChange:C,onKeyDown:k,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(qe,{type:"button",onClick:()=>{l==null||l()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!l,children:c.jsx(pe.Square,{size:16})}):c.jsx(qe,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||x,children:c.jsx(pe.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 tt(...e){return e}function Ye(e,t){return e(Un,t)}function Me(e,t){e(Zo,t)}function Wi(e){e(Nr)}function ut(e){return e(Vc)}function ye(e,t){return Ye(e,Zx(t,Zo))}function rn(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 nt(e=Xc){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ee(e){return t=>n=>{e(n)&&t(n)}}function de(e){return t=>qc(t,e)}function yn(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 vn(e,t){return n=>r=>{n(t=e(t,r))}}function ur(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 Z(e){let t=e;const n=We();return(r,o)=>{switch(r){case Zo:t=o;break;case Un:{o(t);break}case Vc:return t}return n(r,o)}}function Nt(e,t){return Qo(Z(t),n=>ye(e,n))}function We(){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 Bt(e){return Qo(We(),t=>ye(e,t))}function Ve(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 ht(...e){const t=We(),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 Te(e,t=Xc){return V(e,nt(t))}function Vi(...e){return function(t,n){switch(t){case Nr:return;case Un:return Qx(...e.map(r=>Ye(r,n)))}}}var Ft=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ft||{});const sy={0:"debug",3:"error",1:"log",2:"warn"},iy=()=>typeof globalThis>"u"?window:globalThis,Wn=Ve(()=>{const e=Z(3);return{log:Z((t,n,r=1)=>{var o;const s=(o=iy().VIRTUOSO_LOG_LEVEL)!=null?o:ut(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 dr(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 x;p&&(x=h.ownerDocument.defaultView);const v=i?a?i.scrollLeft:i.scrollTop:p?a?x.scrollX||x.document.documentElement.scrollLeft:x.scrollY||x.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,m=i?a?i.scrollWidth:i.scrollHeight:p?a?x.document.documentElement.scrollWidth:x.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:p?a?x.innerWidth:x.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:m,scrollTop:Math.max(v,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},Ft.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,Ft.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(),x=u.top-p.top;h=p.height-Math.max(0,x),f=x+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 Pt=Ve(()=>{const e=We(),t=We(),n=Z(0),r=We(),o=Z(0),s=We(),i=We(),a=Z(0),l=Z(0),u=Z(0),d=Z(0),f=We(),h=We(),p=Z(!1),x=Z(!1),v=Z(!1);return ye(V(e,de(({scrollTop:m})=>m)),t),ye(V(e,de(({scrollHeight:m})=>m)),i),ye(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:x,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:v,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 Ze(e){return e===eo}function to(e,t){if(!Ze(e))return t===e.k?e.v:t<e.k?to(e.l,t):to(e.r,t)}function on(e,t,n="k"){if(Ze(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=on(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return on(e.l,t,n)}function Ht(e,t,n){return Ze(e)?nu(t,n,1):t===e.k?pt(e,{k:t,v:n}):t<e.k?ru(pt(e,{l:Ht(e.l,t,n)})):ru(pt(e,{r:Ht(e.r,t,n)}))}function jr(){return eo}function es(e,t,n){if(Ze(e))return[];const r=on(e,t)[0];return cy(Gi(e,r,n))}function qi(e,t){if(Ze(e))return eo;const{k:n,l:r,r:o}=e;if(t===n){if(Ze(r))return o;if(Ze(o))return r;{const[s,i]=tu(r);return ts(pt(e,{k:s,l:eu(r),v:i}))}}else return t<n?ts(pt(e,{l:qi(r,t)})):ts(pt(e,{r:qi(o,t)}))}function fr(e){return Ze(e)?[]:[...fr(e.l),{k:e.k,v:e.v},...fr(e.r)]}function Gi(e,t,n){if(Ze(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(pt(e,{lvl:n-1}));if(!Ze(t)&&!Ze(t.r))return pt(t.r,{l:pt(t,{r:t.r.l}),lvl:n,r:pt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Yi(e))return Xi(pt(e,{lvl:n-1}));if(!Ze(r)&&!Ze(r.l)){const o=r.l,s=Yi(o)?r.lvl-1:r.lvl;return pt(o,{l:pt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Xi(pt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function pt(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 Ze(e.r)?e.l:ts(pt(e,{r:eu(e.r)}))}function Yi(e){return Ze(e)||e.lvl>e.r.lvl}function tu(e){return Ze(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!Ze(t)&&t.lvl===e.lvl?pt(t,{r:pt(e,{l:t.r})}):e}function Xi(e){const{lvl:t,r:n}=e;return!Ze(n)&&!Ze(n.r)&&n.lvl===t&&n.r.lvl===t?pt(n,{l:pt(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=Ve(()=>({recalcInProgress:Z(!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!Ze(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=Ze(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Ze(e)){e=Ht(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=Ht(e,o+1,h));u&&(e=Ht(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,Ft.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&Ze(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((x,v)=>Ht(Ht(x,v,h),v+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)=>Ht(h,p,ro(p,f,o)),jr()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function xy(e){return fr(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=on(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===on(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"},bn=Ve(([{log:e},{recalcInProgress:t}])=>{const n=We(),r=We(),o=Nt(r,0),s=We(),i=We(),a=Z(0),l=Z([]),u=Z(void 0),d=Z(void 0),f=Z((C,k)=>Vn(C,by[k])),h=Z(void 0),p=Z(0),x=dy(),v=Nt(V(n,Fe(l,e,p),vn(gy,x),nt()),x),m=Nt(V(l,nt(),vn((C,k)=>({current:k,prev:C.current}),{current:[],prev:[]}),de(({prev:C})=>C)),[]);ye(V(l,Ee(C=>C.length>0),Fe(v,p),de(([C,k,E])=>{const R=C.reduce((P,j,H)=>Ht(P,j,ro(j,k.offsetTree,E)||H),jr());return{...k,groupIndices:C,groupOffsetTree:R}})),v),ye(V(r,Fe(v),Ee(([C,{lastIndex:k}])=>C<k),de(([C,{lastIndex:k,lastSize:E}])=>[{endIndex:k,size:E,startIndex:C}])),n),ye(u,d);const y=Nt(V(u,de(C=>C===void 0)),!0);ye(V(d,Ee(C=>C!==void 0&&Ze(ut(v).sizeTree)),de(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=Bt(V(n,Fe(v),vn(({sizes:C},[k,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:x}),de(C=>C.changed)));Ye(V(a,vn((C,k)=>({diff:C.prev-k,prev:k}),{diff:0,prev:0}),de(C=>C.diff)),C=>{const{groupIndices:k}=ut(v);if(C>0)Me(t,!0),Me(s,C+cu(C,k));else if(C<0){const E=ut(m);E.length>0&&(C-=cu(-C,E)),Me(i,C)}}),Ye(V(a,Fe(e)),([C,k])=>{C<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},Ft.ERROR)});const S=Bt(s);ye(V(s,Fe(v),de(([C,k])=>{const E=k.groupIndices.length>0,R=[],P=k.lastSize;if(E){const j=to(k.sizeTree,0);let H=0,$=0;for(;H<C;){const O=k.groupIndices[$],B=k.groupIndices.length===$+1?1/0:k.groupIndices[$+1]-O-1;R.push({endIndex:O,size:j,startIndex:O}),R.push({endIndex:O+1+B-1,size:P,startIndex:O+1}),$++,H+=B+1}const L=fr(k.sizeTree);return H!==C&&L.shift(),L.reduce((O,{k:B,v:W})=>{let se=O.ranges;return O.prevSize!==0&&(se=[...O.ranges,{endIndex:B+C-1,size:O.prevSize,startIndex:O.prevIndex}]),{prevIndex:B+C,prevSize:W,ranges:se}},{prevIndex:C,prevSize:0,ranges:R}).ranges}return fr(k.sizeTree).reduce((j,{k:H,v:$})=>({prevIndex:H+C,prevSize:$,ranges:[...j.ranges,{endIndex:H+C-1,size:j.prevSize,startIndex:j.prevIndex}]}),{prevIndex:0,prevSize:P,ranges:[]}).ranges})),n);const T=Bt(V(i,Fe(v,p),de(([C,{offsetTree:k},E])=>{const R=-C;return ro(R,k,E)})));return ye(V(i,Fe(v,p),de(([C,k,E])=>{if(k.groupIndices.length>0){if(Ze(k.sizeTree))return k;let R=jr();const P=ut(m);let j=0,H=0,$=0;for(;j<-C;){$=P[H];const L=P[H+1]-$-1;H++,j+=L+1}if(R=fr(k.sizeTree).reduce((L,{k:O,v:B})=>Ht(L,Math.max(0,O+C),B),R),j!==-C){const L=to(k.sizeTree,$);R=Ht(R,0,L);const O=on(k.sizeTree,-C+1)[1];R=Ht(R,1,O)}return{...k,sizeTree:R,...Qi(k.offsetTree,0,R,E)}}else{const R=fr(k.sizeTree).reduce((P,{k:j,v:H})=>Ht(P,Math.max(0,j+C),H),jr());return{...k,sizeTree:R,...Qi(k.offsetTree,0,R,E)}}})),v),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:T,sizeRanges:n,sizes:v,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},tt(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=Ve(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=We(),i=We(),a=Bt(V(s,de(wy)));return ye(V(a,de(l=>l.totalCount)),n),ye(V(a,de(l=>l.groupIndices)),e),ye(V(ht(o,t,r),Ee(([l,u])=>rs(u)),de(([l,u,d])=>on(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),nt(),de(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},tt(bn,Pt)),Kn=Ve(([{log:e}])=>{const t=Z(!1),n=Bt(V(t,Ee(r=>r),nt()));return Ye(t,r=>{r&&ut(e)("props updated",{},Ft.DEBUG)}),{didMount:n,propsReady:t}},tt(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=Ve(([{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=We(),x=We(),v=Z(0);let m=null,y=null,b=null;function S(){m&&(m(),m=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),Me(l,!1)}return ye(V(p,Fe(n,f,r,v,a,i,h),Fe(e,s,o),de(([[T,C,k,E,R,P,j,H],$,L,O])=>{const B=du(T),{align:W,behavior:se,offset:K}=B,U=E-1,X=lu(B,C,U);let F=ro(X,C.offsetTree,$)+P;W==="end"?(F+=L+on(C.sizeTree,X)[1]-k+O,X===U&&(F+=j)):W==="center"?F+=(L+on(C.sizeTree,X)[1]-k+O)/2:F-=R,K&&(F+=K);const q=me=>{S(),me?(H("retrying to scroll to",{location:T},Ft.DEBUG),Me(p,T)):(Me(x,!0),H("list did not change, scroll successful",{},Ft.DEBUG))};if(S(),se==="smooth"){let me=!1;b=Ye(t,ge=>{me=me||ge}),m=rn(d,()=>{q(me)})}else m=rn(V(t,Cy(150)),q);return y=setTimeout(()=>{S()},1200),Me(l,!0),H("scrolling from index to",{behavior:se,index:X,top:F},Ft.DEBUG),{behavior:se,top:F}})),u),{scrollTargetReached:x,scrollToIndex:p,topListHeight:v}},tt(bn,Pt,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=Ve(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=Z(!0),l=Z(0),u=Z(!0);return ye(V(i,Fe(l),Ee(([d,f])=>!!f),yn(!1)),a),ye(V(i,Fe(l),Ee(([d,f])=>!!f),yn(!1)),u),Ye(V(ht(t,i),Fe(a,n,e,u),Ee(([[,d],f,{sizeTree:h},p,x])=>d&&(!Ze(h)||Ui(p))&&!f&&!x),Fe(l)),([,d])=>{rn(o,()=>{Me(u,!0)}),ea(4,()=>{rn(r,()=>{Me(a,!0)}),Me(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},tt(bn,Pt,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=Ve(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=Z(!1),a=Z(!0),l=We(),u=We(),d=Z(4),f=Z(Ey),h=Nt(V(Vi(V(Te(o),ur(1),yn(!0)),V(Te(o),ur(1),yn(!1),Yc(100))),nt()),!1),p=Nt(V(Vi(V(n,yn(!0)),V(n,yn(!1),Yc(200))),nt()),!1);ye(V(ht(Te(o),Te(f)),de(([b,S])=>b<=S),nt()),a),ye(V(a,Dn(50)),u);const x=Bt(V(ht(r,Te(s),Te(t),Te(e),Te(d)),vn((b,[{scrollHeight:S,scrollTop:T},C,k,E,R])=>{const P=T+C-S>-R,j={scrollHeight:S,scrollTop:T,viewportHeight:C};if(P){let $,L;return T>b.state.scrollTop?($="SCROLLED_DOWN",L=b.state.scrollTop-T):($="SIZE_DECREASED",L=b.state.scrollTop-T||b.scrollTopDelta),{atBottom:!0,atBottomBecause:$,scrollTopDelta:L,state:j}}let H;return j.scrollHeight>b.state.scrollHeight?H="SIZE_INCREASED":C<b.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":T<b.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:j}},Ty),nt((b,S)=>b&&b.atBottom===S.atBottom))),v=Nt(V(r,vn((b,{scrollHeight:S,scrollTop:T,viewportHeight:C})=>{if(fu(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:T};{const k=S-(T+C)<1;return b.scrollTop!==T&&k?{changed:!0,jump:b.scrollTop-T,scrollHeight:S,scrollTop:T}:{changed:!0,jump:0,scrollHeight:S,scrollTop:T}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ee(b=>b.changed),de(b=>b.jump)),0);ye(V(x,de(b=>b.atBottom)),i),ye(V(i,Dn(50)),l);const m=Z(ao);ye(V(r,de(({scrollTop:b})=>b),nt(),vn((b,S)=>ut(p)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?io:ao,prevScrollTop:S},{direction:ao,prevScrollTop:0}),de(b=>b.direction)),m),ye(V(r,Dn(50),yn(ky)),m);const y=Z(0);return ye(V(h,Ee(b=>!b),yn(0)),y),ye(V(o,Dn(100),Fe(h),Ee(([b,S])=>!!S),vn(([b,S],[T])=>[S,T],[0,0]),de(([b,S])=>S-b)),y),{atBottomState:x,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:v,scrollDirection:m,scrollVelocity:y}},tt(Pt)),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=Ve(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=We(),i=Z(0),a=Z(0),l=Z(0),u=Nt(V(ht(Te(r),Te(o),Te(n),Te(s,no),Te(l),Te(i),Te(t),Te(e),Te(a)),de(([d,f,h,[p,x],v,m,y,b,S])=>{const T=d-b,C=m+y,k=Math.max(h-T,0);let E=hu;const R=mu(S,os),P=mu(S,ss);return p-=b,p+=h+y,x+=h+y,x-=b,p>d+C-R&&(E=io),x<d-k+f+P&&(E=ao),E!==hu?[Math.max(T-h-pu(v,os,E)-R,0),T-k-y+f+pu(v,ss,E)+P]:null}),Ee(d=>d!=null),nt(no)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},tt(Pt),{singleton:!0});function Iy(e,t,n){if(rs(t)){const r=au(e,t);return[{index:on(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 v=e[e.length-1];d=v.offset+v.size}const f=n-i,h=a+f*l+(f-1)*r,p=u,x=h-d;return{bottom:d,firstItemIndex:s,items:xu(e,o,s),offsetBottom:x,offsetTop:u,top:p,topItems:xu(t,o,s),topListHeight:t.reduce((v,m)=>m.size+v,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 hr=Ve(([{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:x}])=>{const v=Z([]),m=Z(0),y=We();ye(s.topItemsIndexes,v);const b=Nt(V(ht(p,x,Te(l,no),Te(o),Te(r),Te(u),d,Te(v),Te(t),Te(n),e),Ee(([k,E,,R,,,,,,,P])=>{const j=P&&P.length!==R;return k&&!E&&!j}),de(([,,[k,E],R,P,j,H,$,L,O,B])=>{const W=P,{offsetTree:se,sizeTree:K}=W,U=ut(m);if(R===0)return{...ra,totalCount:R};if(k===0&&E===0)return U===0?{...ra,totalCount:R}:gu(U,j,P,L,O,B||[]);if(Ze(K))return U>0?null:is(Iy(ta(j,R),W,B),[],R,O,W,L);const X=[];if($.length>0){const ke=$[0],Se=$[$.length-1];let J=0;for(const D of es(K,ke,Se)){const ee=D.value,re=Math.max(D.start,ke),ae=Math.min(D.end,Se);for(let le=re;le<=ae;le++)X.push({data:B==null?void 0:B[le],index:le,offset:J,size:ee}),J+=ee}}if(!H)return is([],X,R,O,W,L);const F=$.length>0?$[$.length-1]+1:0,q=my(se,k,E,F);if(q.length===0)return null;const me=R-1,ge=Qo([],ke=>{for(const Se of q){const J=Se.value;let D=J.offset,ee=Se.start;const re=J.size;if(J.offset<k){ee+=Math.floor((k-J.offset+O)/(re+O));const le=ee-Se.start;D+=le*re+le*O}ee<F&&(D+=(F-ee)*re,ee=F);const ae=Math.min(Se.end,me);for(let le=ee;le<=ae&&!(D>=E);le++)ke.push({data:B==null?void 0:B[le],index:le,offset:D,size:re}),D+=re+O}});return is(ge,X,R,O,W,L)}),Ee(k=>k!==null),nt()),ra);ye(V(e,Ee(Ui),de(k=>k==null?void 0:k.length)),o),ye(V(b,de(k=>k.topListHeight)),f),ye(f,a),ye(V(b,de(k=>[k.top,k.bottom])),i),ye(V(b,de(k=>k.items)),y);const S=Bt(V(b,Ee(({items:k})=>k.length>0),Fe(o,e),Ee(([{items:k},E])=>k[k.length-1].originalIndex===E-1),de(([,k,E])=>[k-1,E]),nt(no),de(([k])=>k))),T=Bt(V(b,Dn(200),Ee(({items:k,topItems:E})=>k.length>0&&k[0].originalIndex===E.length),de(({items:k})=>k[0].index),nt())),C=Bt(V(b,Ee(({items:k})=>k.length>0),de(({items:k})=>{let E=0,R=k.length-1;for(;k[E].type==="group"&&E<R;)E++;for(;k[R].type==="group"&&R>E;)R--;return{endIndex:k[R].index,startIndex:k[E].index}}),nt(su)));return{endReached:S,initialItemCount:m,itemsRendered:y,listState:b,rangeChanged:C,startReached:T,topItemsIndexes:v,...h}},tt(bn,uu,na,so,oo,lo,Kn,Ji),{singleton:!0}),yu=Ve(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=We(),i=Nt(V(ht(n,e,r,t,o),de(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return ye(Te(i),s),{totalListHeight:i,totalListHeightChanged:s}},tt(Pt,hr),{singleton:!0}),Ay=Ve(([{viewportHeight:e},{totalListHeight:t}])=>{const n=Z(!1),r=Nt(V(ht(n,e,t),Ee(([o])=>o),de(([,o,s])=>Math.max(0,o-s)),Dn(0),nt()),0);return{alignToBottom:n,paddingTopAddition:r}},tt(Pt,yu),{singleton:!0}),vu=Ve(()=>({context:Z(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=Ve(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:u}])=>{const d=We();return ye(V(d,Fe(t,l,n,s,o,r,a),Fe(e),de(([[f,h,p,x,v,m,y,b],S])=>{const{align:T,behavior:C,calculateViewLocation:k=Ny,done:E,...R}=f,P=lu(f,h,x-1),j=ro(P,h.offsetTree,S)+v+m,H=j+on(h.sizeTree,P)[1],$=b+m,L=b+p-y,O=k({itemBottom:H,itemTop:j,locationParams:{align:T,behavior:C,...R},viewportBottom:L,viewportTop:$});return O?E&&rn(V(i,Ee(B=>!B),ur(ut(i)?1:2)),E):E&&E(),O}),Ee(f=>f!==null)),u),{scrollIntoView:d}},tt(bn,Pt,oo,hr,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=Ve(([{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 x=Z(!1),v=We();let m=null;function y(C){Me(i,{align:"end",behavior:C,index:"LAST"})}Ye(V(ht(V(Te(t),ur(1)),l),Fe(Te(x),s,a,f),de(([[C,k],E,R,P,j])=>{let H=k&&P,$="auto";return H&&($=_y(E,R||j),H=H&&!!$),{followOutputBehavior:$,shouldFollow:H,totalCount:C}}),Ee(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:k})=>{m&&(m(),m=null),ut(n)?requestAnimationFrame(()=>{ut(d)("following output to ",{totalCount:k},Ft.DEBUG),y(C)}):m=rn(e,()=>{ut(d)("following output to ",{totalCount:k},Ft.DEBUG),y(C),m=null})});function b(C){const k=rn(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!m&&(ut(d)("scrolling to bottom due to increased size",{},Ft.DEBUG),y("auto"))});setTimeout(k,100)}Ye(V(ht(Te(x),t,u),Ee(([C,,k])=>C&&k),vn(({value:C},[,k])=>({refreshed:C===k,value:k}),{refreshed:!1,value:0}),Ee(({refreshed:C})=>C),Fe(x,t)),([,C])=>{ut(a)&&b(C!==!1)}),Ye(v,()=>{b(ut(x)!==!1)}),Ye(ht(Te(x),o),([C,k])=>{C&&!k.atBottom&&k.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=Z(null),T=We();return ye(Vi(V(Te(r),de(C=>{var k;return(k=C==null?void 0:C.length)!=null?k:0})),V(Te(t))),T),Ye(V(ht(V(T,ur(1)),l),Fe(Te(S),a,f,h),de(([[C,k],E,R,P,j])=>k&&R&&(E==null?void 0:E({context:j,totalCount:C,scrollingInProgress:P}))),Ee(C=>!!C),Dn(0)),C=>{m&&(m(),m=null),ut(n)?requestAnimationFrame(()=>{ut(d)("scrolling into view",{}),Me(p,C)}):m=rn(e,()=>{ut(d)("scrolling into view",{}),Me(p,C),m=null})}),{autoscrollToBottom:v,followOutput:x,scrollIntoViewOnChange:S}},tt(bn,lo,oo,so,Kn,Wn,Pt,vu,bu)),Ry=Ve(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ye(V(a,Fe(s),Ee(([,l])=>l!==0),Fe(o,r,t,n,e),de(([[,l],u,d,f,h,p=[]])=>gu(l,u,d,f,h,p))),i),{}),tt(bn,so,hr,Kn),{singleton:!0}),Py=Ve(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=Z(0);return Ye(V(e,Fe(r),Ee(([,o])=>o!==0),de(([,o])=>({top:o}))),o=>{rn(V(n,ur(1),Ee(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Me(t,o)})})}),{initialScrollTop:r}},tt(Kn,Pt,hr),{singleton:!0}),Su=Ve(([{scrollVelocity:e}])=>{const t=Z(!1),n=We(),r=Z(!1);return ye(V(e,Fe(r,t,n),Ee(([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}),nt()),t),Ye(V(ht(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}},tt(lo),{singleton:!0}),oa=Ve(([{scrollContainerState:e,scrollTo:t}])=>{const n=We(),r=We(),o=We(),s=Z(!1),i=Z(void 0);return ye(V(ht(n,r),de(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),ye(V(t,Fe(r),de(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},tt(Pt)),Oy=Ve(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=We(),d=Z(void 0),f=Z(null),h=Z(null);return ye(a,f),ye(l,h),Ye(V(u,Fe(t,r,i,f,h,n)),([p,x,v,m,y,b,S])=>{const T=xy(x.sizeTree);m&&y!==null&&b!==null&&(v=y.scrollTop-b.offsetTop),v-=S,p({ranges:T,scrollTop:v})}),ye(V(d,Ee(Ui),de(My)),o),ye(V(s,Fe(d),Ee(([,p])=>p!==void 0),nt(),de(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},tt(bn,Pt,so,Kn,oa));function My(e){return{align:"start",index:0,offset:e.scrollTop}}const Dy=Ve(([{topItemsIndexes:e}])=>{const t=Z(0);return ye(V(t,Ee(n=>n>=0),de(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},tt(hr));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=Ve(([{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:x}])=>{const v=Bt(V(l,Fe(i),vn(([,y,b,S],[{bottom:T,items:C,offsetBottom:k,totalCount:E},R])=>{const P=T+k;let j=0;return b===E&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(j=P-S,j!==0&&(j+=R))),[j,C,E,P]},[0,[],0,0]),Ee(([y])=>y!==0),Fe(r,a,n,o,p,x),Ee(([,y,b,S,,,T])=>!T&&!S&&y!==0&&b===io),de(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},Ft.DEBUG),y))));function m(y){y>0?(Me(t,{behavior:"auto",top:-y}),Me(e,0)):(Me(e,0),Me(t,{behavior:"auto",top:-y}))}return Ye(V(v,Fe(e,s)),([y,b,S])=>{S&&Ly()?Me(e,b-y):m(-y)}),Ye(V(ht(Nt(s,!1),e,x),Ee(([y,b,S])=>!y&&!S&&b!==0),de(([y,b])=>b),Dn(1)),m),ye(V(f,de(y=>({top:-y}))),t),Ye(V(u,Fe(h,d),de(([y,{groupIndices:b,lastSize:S,sizeTree:T},C])=>{function k(E){return E*(S+C)}if(b.length===0)return k(y);{let E=0;const R=to(T,0);let P=0,j=0;for(;P<y;){P++,E+=R;let H=b.length===j+1?1/0:b[j+1]-b[j]-1;P+H>y&&(E-=R,H=y-P+1),P+=H,E+=k(H),j++}return E}})),y=>{Me(e,y),requestAnimationFrame(()=>{Me(t,{top:y}),requestAnimationFrame(()=>{Me(e,0),Me(x,!1)})})}),{deviation:e}},tt(Pt,lo,hr,bn,Wn,Ji)),$y=Ve(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),tt(na,Ry,Kn,Su,yu,Py,Ay,oa,bu,Wn,vu)),ku=Ve(([{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:x},v,m,y,{listState:b,topItemsIndexes:S,...T},{scrollToIndex:C},k,{topItemCount:E},{groupCounts:R},P])=>(ye(T.rangeChanged,P.scrollSeekRangeChanged),ye(V(P.windowViewportRect,de(j=>j.visibleHeight)),v.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:R,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:x,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...T,...P,...v,sizes:l,...m}),tt(bn,so,Pt,Oy,jy,hr,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(m,y){m.propsReady&&Me(m.propsReady,!1);for(const b of r){const S=m[t.required[b]];Me(S,y[b])}for(const b of o)if(b in y){const S=m[t.optional[b]];Me(S,y[b])}m.propsReady&&Me(m.propsReady,!0)}function u(m){return s.reduce((y,b)=>(y[b]=S=>{const T=m[t.methods[b]];Me(T,S)},y),{})}function d(m){return i.reduce((y,b)=>(y[b]=ny(m[t.events[b]]),y),{})}const f=w.forwardRef((m,y)=>{const{children:b,...S}=m,[T]=w.useState(()=>Qo(oy(e),E=>{l(E,S)})),[C]=w.useState(Gc(d,T));as(()=>{for(const E of i)E in S&&Ye(C[E],S[E]);return()=>{Object.values(C).map(Wi)}},[S,C,T]),as(()=>{l(T,S)}),w.useImperativeHandle(y,Kc(u(T)));const k=n;return c.jsx(a.Provider,{value:T,children:n?c.jsx(k,{...zy([...r,...o,...i],S),children:b}):b})}),h=m=>{const y=w.useContext(a);return w.useCallback(b=>{Me(y[m],b)},[y,m])},p=m=>{const y=w.useContext(a)[m],b=w.useCallback(S=>Ye(y,S),[y]);return w.useSyncExternalStore(b,()=>ut(y),()=>ut(y))},x=m=>{const y=w.useContext(a)[m],[b,S]=w.useState(Gc(ut,y));return as(()=>Ye(y,T=>{T!==b&&S(Kc(T))}),[y,b]),b},v=w.version.startsWith("18")?p:x;return{Component:f,useEmitter:(m,y)=>{const b=w.useContext(a)[m];as(()=>Ye(b,y),[y,b])},useEmitterValue:v,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,x,v;const m=h.target;if(By(m)||sa(m)){const b=sa(m)?m:m.defaultView;v=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,x=s?b.innerWidth:b.innerHeight}else v=s?m.scrollLeft:m.scrollTop,p=s?m.scrollWidth:m.scrollHeight,x=s?m.offsetWidth:m.offsetHeight;const y=()=>{e({scrollHeight:p,scrollTop:Math.max(v,0),viewportHeight:x})};h.suppressFlushSync?y():pi.flushSync(y),a.current!==null&&(v===a.current||v<=0||v===p-x)&&(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 x=h.behavior==="smooth";let v,m,y;sa(p)?(m=Math.max(Vn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),v=s?p.innerWidth:p.innerHeight,y=s?window.scrollX:window.scrollY):(m=p[s?"scrollWidth":"scrollHeight"],v=Vn(p,s?"width":"height"),y=p[s?"scrollLeft":"scrollTop"]);const b=m-v;if(h.top=Math.ceil(Math.max(Math.min(b,h.top),0)),fu(v,m)||h.top===y){e({scrollHeight:m,scrollTop:y,viewportHeight:v}),x&&t(!0);return}x?(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=Ve(()=>{const e=Z(a=>`Item ${a}`),t=Z(a=>`Group ${a}`),n=Z({}),r=Z(la),o=Z("div"),s=Z(_r),i=(a,l=null)=>Nt(V(n,de(u=>u[a]),nt()),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=Ve(([e,t])=>({...e,...t}),tt(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=_e("listState"),n=Xt("sizeRanges"),r=_e("useWindowScroll"),o=_e("customScrollParent"),s=Xt("windowScrollContainerState"),i=Xt("scrollContainerState"),a=o||r?s:i,l=_e("itemContent"),u=_e("context"),d=_e("groupContent"),f=_e("trackItemSizes"),h=_e("itemSize"),p=_e("log"),x=Xt("gap"),v=_e("horizontalDirection"),{callbackRef:m}=ay(n,h,f,e?_r:a,p,x,o,v,_e("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);ca("deviation",O=>{y!==O&&b(O)});const S=_e("EmptyPlaceholder"),T=_e("ScrollSeekPlaceholder")||Wy,C=_e("ListComponent"),k=_e("ItemComponent"),E=_e("GroupComponent"),R=_e("computeItemKey"),P=_e("isSeeking"),j=_e("groupIndices").length>0,H=_e("alignToBottom"),$=_e("initialItemFinalLocationReached"),L=e?{}:{boxSizing:"border-box",...v?{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},...$?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?c.jsx(S,{..._t(S,u)}):c.jsx(C,{..._t(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:m,style:L,children:(e?t.topItems:t.items).map(O=>{const B=O.originalIndex,W=R(B+t.firstItemIndex,O.data,u);return P?w.createElement(T,{..._t(T,u),height:O.size,index:O.index,key:W,type:O.type||"item",...O.type==="group"?{}:{groupIndex:O.groupIndex}}):O.type==="group"?w.createElement(E,{..._t(E,u),"data-index":B,"data-item-index":O.index,"data-known-size":O.size,key:W,style:Vy},d(O.index,u)):w.createElement(k,{..._t(k,u),...Xy(k,O.data),"data-index":B,"data-item-group-index":O.groupIndex,"data-item-index":O.index,"data-known-size":O.size,key:W,style:v?Ky:ju},j?l(O.index,O.groupIndex,O.data,u):l(O.index,O.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 _t(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=_e("HeaderComponent"),t=Xt("headerHeight"),n=_e("HeaderFooterTag"),r=dr(w.useMemo(()=>s=>{t(Vn(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{..._t(e,o)})}):null}),Zy=w.memo(function(){const e=_e("FooterComponent"),t=Xt("footerHeight"),n=_e("HeaderFooterTag"),r=dr(w.useMemo(()=>s=>{t(Vn(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{..._t(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:x}=Nu(a,u,l,d,void 0,f);return e("scrollTo",x),e("scrollBy",h),c.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?Gy:qy,...o},tabIndex:0,...i,..._t(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),x=t("scrollerRef"),{scrollByCallback:v,scrollerRef:m,scrollToCallback:y}=Nu(a,u,l,x,h);return Au(()=>{var b;return m.current=h||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{m.current=null}},[m,h]),e("windowScrollTo",y),e("scrollBy",v),c.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,..._t(l,s),children:r})})}const Qy=({children:e})=>{const t=w.useContext(Eu),n=Xt("viewportHeight"),r=Xt("fixedItemHeight"),o=_e("alignToBottom"),s=_e("horizontalDirection"),i=w.useMemo(()=>qc(n,l=>Vn(l,s?"width":"height")),[n,s]),a=dr(i,!0,_e("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=Xt("windowViewportRect"),r=Xt("fixedItemHeight"),o=_e("customScrollParent"),s=Zc(n,o,_e("skipAnimationFrameInResizeObserver")),i=_e("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=_e("TopItemListComponent")||"div",n=_e("headerHeight"),r={...Yy,marginTop:`${n}px`},o=_e("context");return c.jsx(t,{style:r,..._t(t,o),children:e})},nv=w.memo(function(e){const t=_e("useWindowScroll"),n=_e("topItemsIndexes").length>0,r=_e("customScrollParent"),o=_e("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:_e,usePublisher:Xt}=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:_e,usePublisher:Xt}),sv=Ou({useEmitter:ca,useEmitterValue:_e,usePublisher:Xt}),iv=rv;tt(ku,Ve(()=>{const e=Z(u=>c.jsxs("td",{children:["Item $",u]})),t=Z(null),n=Z(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=Z(null),o=Z(null),s=Z({}),i=Z(la),a=Z(_r),l=(u,d=null)=>Nt(V(s,de(f=>f[u]),nt()),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=Ve(([{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:x,propsReady:v},{customScrollParent:m,useWindowScroll:y,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:T},C])=>{const k=Z(0),E=Z(0),R=Z(Mu),P=Z({height:0,width:0}),j=Z({height:0,width:0}),H=We(),$=We(),L=Z(0),O=Z(null),B=Z({column:0,row:0}),W=We(),se=We(),K=Z(!1),U=Z(0),X=Z(!0),F=Z(!1),q=Z(!1);Ye(V(x,Fe(U),Ee(([D,ee])=>!!ee)),()=>{Me(X,!1)}),Ye(V(ht(x,X,j,P,U,F),Ee(([D,ee,re,ae,,le])=>D&&!ee&&re.height!==0&&ae.height!==0&&!le)),([,,,,D])=>{Me(F,!0),ea(1,()=>{Me(H,D)}),rn(V(u),()=>{Me(t,[0,0]),Me(X,!0)})}),ye(V(se,Ee(D=>D!=null&&D.scrollTop>0),yn(0)),E),Ye(V(x,Fe(se),Ee(([,D])=>D!=null)),([,D])=>{D&&(Me(P,D.viewport),Me(j,D.item),Me(B,D.gap),D.scrollTop>0&&(Me(K,!0),rn(V(u,ur(1)),ee=>{Me(K,!1)}),Me(l,{top:D.scrollTop})))}),ye(V(P,de(({height:D})=>D)),f),ye(V(ht(Te(P,us),Te(j,us),Te(B,(D,ee)=>D&&D.column===ee.column&&D.row===ee.row),Te(u)),de(([D,ee,re,ae])=>({gap:re,item:ee,scrollTop:ae,viewport:D}))),W),ye(V(ht(Te(k),r,Te(B,cv),Te(j,us),Te(P,us),Te(O),Te(E),Te(K),Te(X),Te(U)),Ee(([,,,,,,,D])=>!D),de(([D,[ee,re],ae,le,ie,Ge,Je,,De,Ue])=>{const{column:at,row:Ke}=ae,{height:je,width:mt}=le,{width:gt}=ie;if(Je===0&&(D===0||gt===0))return Mu;if(mt===0){const xt=ta(Ue,D),$t=xt+Math.max(Je-1,0);return lv(Fu(xt,$t,Ge))}const Ct=$u(gt,mt,at);let rt,te;De?ee===0&&re===0&&Je>0?(rt=0,te=Je-1):(rt=Ct*cs((ee+Ke)/(je+Ke)),te=Ct*Du((re+Ke)/(je+Ke))-1,te=ua(D-1,co(te,Ct-1)),rt=ua(te,co(0,rt))):(rt=0,te=-1);const ue=Fu(rt,te,Ge),{bottom:xe,top:ze}=zu(ie,ae,le,ue),Pe=Du(D/Ct),et=Pe*je+(Pe-1)*Ke-xe;return{bottom:xe,itemHeight:je,items:ue,itemWidth:mt,offsetBottom:et,offsetTop:ze,top:ze}})),R),ye(V(O,Ee(D=>D!==null),de(D=>D.length)),k),ye(V(ht(P,j,R,B),Ee(([D,ee,{items:re}])=>re.length>0&&ee.height!==0&&D.height!==0),de(([D,ee,{items:re},ae])=>{const{bottom:le,top:ie}=zu(D,ae,ee,re);return[ie,le]}),nt(no)),t);const me=Z(!1);ye(V(u,Fe(me),de(([D,ee])=>ee||D!==0)),me);const ge=Bt(V(ht(R,k),Ee(([{items:D}])=>D.length>0),Fe(me),Ee(([[D,ee],re])=>{const ae=D.items[D.items.length-1].index===ee-1;return(re||D.bottom>0&&D.itemHeight>0&&D.offsetBottom===0&&D.items.length===ee)&&ae}),de(([[,D]])=>D-1),nt())),ke=Bt(V(Te(R),Ee(({items:D})=>D.length>0&&D[0].index===0),yn(0),nt())),Se=Bt(V(Te(R),Fe(K),Ee(([{items:D},ee])=>D.length>0&&!ee),de(([{items:D}])=>({endIndex:D[D.length-1].index,startIndex:D[0].index})),nt(su),Dn(0)));ye(Se,p.scrollSeekRangeChanged),ye(V(H,Fe(P,j,k,B),de(([D,ee,re,ae,le])=>{const ie=du(D),{align:Ge,behavior:Je,offset:De}=ie;let Ue=ie.index;Ue==="LAST"&&(Ue=ae-1),Ue=co(0,Ue,ua(ae-1,Ue));let at=da(ee,le,re,Ue);return Ge==="end"?at=Lu(at-ee.height+re.height):Ge==="center"&&(at=Lu(at-ee.height/2+re.height/2)),De&&(at+=De),{behavior:Je,top:at}})),l);const J=Nt(V(R,de(D=>D.offsetBottom+D.bottom)),0);return ye(V(T,de(D=>({height:D.visibleHeight,width:D.visibleWidth}))),P),{customScrollParent:m,data:O,deviation:L,footerHeight:o,gap:B,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:j,overscan:n,restoreStateFrom:se,scrollBy:i,scrollContainerState:a,scrollHeight:$,scrollTo:l,scrollToIndex:H,scrollTop:u,smoothScrollTargetReached:d,totalCount:k,useWindowScroll:y,viewportDimensions:P,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:T,...p,gridState:R,horizontalDirection:q,initialTopMostItemIndex:U,totalListHeight:J,...h,endReached:ge,propsReady:v,rangeChanged:Se,startReached:ke,stateChanged:W,stateRestoreInProgress:K,...C}},tt(na,Pt,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=Ve(()=>{const e=Z(f=>`Item ${f}`),t=Z({}),n=Z(null),r=Z("virtuoso-grid-item"),o=Z("virtuoso-grid-list"),s=Z(la),i=Z("div"),a=Z(_r),l=(f,h=null)=>Nt(V(t,de(p=>p[f]),nt()),h),u=Z(!1),d=Z(!1);return ye(Te(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=Ve(([e,t])=>({...e,...t}),tt(uv,dv)),hv=w.memo(function(){const e=ot("gridState"),t=ot("listClassName"),n=ot("itemClassName"),r=ot("itemContent"),o=ot("computeItemKey"),s=ot("isSeeking"),i=Jt("scrollHeight"),a=ot("ItemComponent"),l=ot("ListComponent"),u=ot("ScrollSeekPlaceholder"),d=ot("context"),f=Jt("itemDimensions"),h=Jt("gap"),p=ot("log"),x=ot("stateRestoreInProgress"),v=Jt("reportReadyState"),m=dr(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);const S=y.firstChild;if(S){const{height:T,width:C}=S.getBoundingClientRect();f({height:T,width:C})}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&&v(!0)},[e]),x?null:c.jsx(l,{className:t,ref:m,..._t(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,{..._t(u,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{..._t(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),pv=w.memo(function(){const e=ot("HeaderComponent"),t=Jt("headerHeight"),n=ot("headerFooterTag"),r=dr(w.useMemo(()=>s=>{t(Vn(s,"height"))},[t]),!0,!1),o=ot("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{..._t(e,o)})}):null}),mv=w.memo(function(){const e=ot("FooterComponent"),t=Jt("footerHeight"),n=ot("headerFooterTag"),r=dr(w.useMemo(()=>s=>{t(Vn(s,"height"))},[t]),!0,!1),o=ot("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{..._t(e,o)})}):null}),gv=({children:e})=>{const t=w.useContext(Iu),n=Jt("itemDimensions"),r=Jt("viewportDimensions"),o=dr(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=Jt("windowViewportRect"),r=Jt("itemDimensions"),o=ot("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=ot("useWindowScroll"),n=ot("customScrollParent"),r=n||t?bv:vv,o=n||t?xv:gv,s=ot("context");return c.jsx(r,{...e,..._t(r,s),children:c.jsxs(o,{children:[c.jsx(pv,{}),c.jsx(hv,{}),c.jsx(mv,{})]})})}),{useEmitter:Bu,useEmitterValue:ot,usePublisher:Jt}=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:ot,usePublisher:Jt}),bv=Ou({useEmitter:Bu,useEmitterValue:ot,usePublisher:Jt});function Hu(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ft.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:oe(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=g.createContext(t),r=s=>{const{children:i,...a}=s,l=g.useMemo(()=>a,Object.values(a));return c.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=g.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 wn(e,t=[]){let n=[];function r(s,i){const a=g.createContext(i),l=n.length;n=[...n,i];const u=f=>{var y;const{scope:h,children:p,...x}=f,v=((y=h==null?void 0:h[e])==null?void 0:y[l])||a,m=g.useMemo(()=>x,Object.values(x));return c.jsx(v.Provider,{value:m,children:p})};u.displayName=s+"Provider";function d(f,h){var v;const p=((v=h==null?void 0:h[e])==null?void 0:v[l])||a,x=g.useContext(p);if(x)return x;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=>g.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return g.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 g.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var yt=globalThis!=null&&globalThis.document?g.useLayoutEffect:()=>{},kv=g[" useInsertionEffect ".trim().toString()]||yt;function pr({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=g.useRef(e!==void 0);g.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=g.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]=g.useState(e),o=g.useRef(n),s=g.useRef(t);return kv(()=>{s.current=t},[t]),g.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 He(...e){return g.useCallback(fa(...e),e)}var Iv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ie=Iv.reduce((e,t)=>{const n=sr.createSlot(`Primitive.${t}`),r=g.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 g.useReducer((n,r)=>t[n][r]??n,e)}var Ut=e=>{const{present:t,children:n}=e,r=Nv(t),o=typeof n=="function"?n({present:r.isPresent}):g.Children.only(n),s=He(r.ref,_v(o));return typeof n=="function"||r.isPresent?g.cloneElement(o,{ref:s}):null};Ut.displayName="Presence";function Nv(e){const[t,n]=g.useState(),r=g.useRef(null),o=g.useRef(e),s=g.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 g.useEffect(()=>{const u=ds(r.current);s.current=a==="mounted"?u:"none"},[a]),yt(()=>{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]),yt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const v=ds(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&v&&(l("ANIMATION_END"),!o.current)){const m=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=m)})}},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:g.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=g[" useId ".trim().toString()]||(()=>{}),Rv=0;function Sn(e){const[t,n]=g.useState(jv());return yt(()=>{n(r=>r??String(Rv++))},[e]),e||(t?`radix-${t}`:"")}var fs="Collapsible",[Pv,ST]=wn(fs),[Ov,ha]=Pv(fs),Ku=g.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,u]=pr({prop:r,defaultProp:o??!1,onChange:i,caller:fs});return c.jsx(Ov,{scope:n,disabled:s,contentId:Sn(),open:l,onOpenToggle:g.useCallback(()=>u(d=>!d),[u]),children:c.jsx(Ie.div,{"data-state":ma(l),"data-disabled":s?"":void 0,...a,ref:t})})});Ku.displayName=fs;var qu="CollapsibleTrigger",Gu=g.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=ha(qu,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:he(e.onClick,o.onOpenToggle)})});Gu.displayName=qu;var pa="CollapsibleContent",Mv=g.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=ha(pa,e.__scopeCollapsible);return c.jsx(Ut,{present:n||o.open,children:({present:s})=>c.jsx(Dv,{...r,ref:t,present:s})})});Mv.displayName=pa;var Dv=g.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=ha(pa,n),[a,l]=g.useState(r),u=g.useRef(null),d=He(t,u),f=g.useRef(0),h=f.current,p=g.useRef(0),x=p.current,v=i.open||a,m=g.useRef(v),y=g.useRef(void 0);return g.useEffect(()=>{const b=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(b)},[]),yt(()=>{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 S=b.getBoundingClientRect();f.current=S.height,p.current=S.width,m.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:!v,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":x?`${x}px`:void 0,...e.style},children:v&&o})});function ma(e){return e?"open":"closed"}var Lv=Ku;const Fv=Lv,$v=Gu,uo=g.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:oe("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));uo.displayName="Card";const fo=g.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:oe("flex flex-col space-y-1.5 p-6",e),...t}));fo.displayName="CardHeader";const ho=g.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:oe("text-2xl font-semibold leading-none tracking-tight",e),...t}));ho.displayName="CardTitle";const Yu=g.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));Yu.displayName="CardDescription";const po=g.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:oe("p-6 pt-0",e),...t}));po.displayName="CardContent";const Xu=g.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:oe("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 mr=Ju();function zv(e){mr=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 jt(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 Qe(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?jt(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:jt(i)}}function eb(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
37
+ `))>=0;){const Ct=J.slice(0,gt);J=J.slice(gt+2);const rt=Tx(Ct);if(!rt)continue;let te;try{te=JSON.parse(rt)}catch{console.debug("[use-chat] malformed SSE:",rt.slice(0,200));continue}const me=kx(te)?te.data:te;ie=Date.now();const ve=me.seq;if(ve!==void 0){if(ve<=ee){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:ve,lastProcessedSeq:ee,type:me.type});continue}ee>0&&ve>ee+1&&((U=$==null?void 0:$.onGap)==null||U.call($,{from:ee,to:ve})),ee=ve,C.current=ve,m(ve)}if(console.debug("[use-chat] received event",{seq:me.seq,type:me.type,preview:(()=>{var We;try{return me.type==="message_delta"?{deltaTypes:(We=me.delta)==null?void 0:We.map(De=>De.type),textLen:(me.delta||[]).filter(De=>De.type==="text").map(De=>String(De.text||"").length)}:me.content||me.delta?{hasContent:!0}:{}}catch(De){return{err:String(De)}}})()}),B==null||B(me),me.type==="token"&&e.autoAppendAssistant!==!1)D.push(me.content),ae();else if(me.type==="message_delta"){const We=me.delta.filter(De=>De.type==="text").map(De=>De.text).join("");We&&e.autoAppendAssistant!==!1&&(D.push(We),ae())}else me.type==="heartbeat"?console.debug("[use-chat] heartbeat received"):(re!==null&&cancelAnimationFrame(re),ce(),me.type==="checkpoint"?y(me.checkpointId):me.type==="error"&&d(me.message))}}ce()}catch(Me){if(Me.name!=="AbortError"){const He=Me.message||String(Me);d(He),(X=$==null?void 0:$.onError)==null||X.call($,He)}}finally{try{await ke.cancel()}catch{}finally{(F=ke.releaseLock)==null||F.call(ke)}re!==null&&typeof window<"u"&&window.cancelAnimationFrame(re),clearInterval(Ge),l(!1),w(!1),S.current=null,C.current=0,m(0)}}catch(pe){if(pe.name!=="AbortError"){const ge=pe.message||String(pe);d(ge),(q=$==null?void 0:$.onError)==null||q.call($,ge)}}finally{l(!1),w(!1),S.current=null,C.current=0,m(0)}})(),{close:()=>L.abort()}},[t,n,r,e.autoAppendAssistant]);return b.useEffect(()=>()=>{var j;T.current=!1,(j=S.current)==null||j.abort()},[]),{isStreaming:a,error:c,assistantText:f,lastCheckpointId:p,lastSeq:v,connected:x,stream:P,stop:E,clear:R,setToken:k}}function kx(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function Tx(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 Ex({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onUnhandledEvent:r,onSequenceGap:o}){const s=b.useRef(null),i=b.useCallback(p=>{const y=p.seq??null;if(y!==null){const v=s.current;if(v!==null){if(y<=v)return;y>v+1&&(o==null||o({from:v,to:y}))}s.current=y}if(p.type==="thread_info"){console.log("[useChatStreamingService] 🎯 Received thread_info event:",p),t(p);return}if(mx(p)){n(p);return}r==null||r(p)},[n,o,t,r]),{stream:a,stop:l,isStreaming:c,error:d,setToken:f}=Oc({baseUrl:e,token:null}),h=b.useCallback((p,y)=>{s.current=null,a(p,i,{onOpen:y==null?void 0:y.onOpen,onError:v=>{var m;(m=y==null?void 0:y.onError)==null||m.call(y,v)},onGap:(y==null?void 0:y.onGap)??o})},[i,o,a]);return b.useMemo(()=>({startStream:h,stop:l,isStreaming:c,error:d,setAuthToken:f}),[h,l,c,d,f])}function Ri(e){return e==null?e:{...e}}function Ix(e){return e==null?e:{...e}}function Nx(e){if(Array.isArray(e))return e.slice();if(e==null)return e}function Ax(e){if(Array.isArray(e))return e.map(t=>({...t}));if(e==null)return e}function Yt(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=Nx(e==null?void 0:e.next),l=Ax(e==null?void 0:e.tasks),c=Ix(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),c!==void 0&&(d.values=c),d}function _x(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 cr(){return typeof window<"u"&&typeof window.localStorage<"u"}function Pi(e){if(!cr())return null;try{return window.localStorage.getItem(e)}catch{return null}}function Oi(e,t){if(!cr())return!1;try{return window.localStorage.setItem(e,t),!0}catch{return!1}}function Mi(e){if(cr())try{window.localStorage.removeItem(e)}catch{}}const jx="cachedThreads",Rx="v1",Di=200;function Px(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}:${Px(t||"anon")}`}function Ox(){const e=Pi(jx);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 Mx(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=Mx(e);if(t.length>0)return t;const n=Ox();if(n.length>0)try{Fi(e,n.slice(0,Di))}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 zi(e){return e.order.map(t=>e.byId[t]).filter(Boolean)}function Bi(e,t){return`${e}${t}`}function Dx(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:Yt(r.snapshot,{cloneMessages:!0}),updatedAt:typeof r.updatedAt=="number"?r.updatedAt:void 0}}catch{return null}}function Lx(e,t,n=100){if(!cr())return;const r=Yt(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 c=window.localStorage.key(l);if(!c||c===s||!c.startsWith(e))continue;const d=window.localStorage.getItem(c);if(!d){a.push({key:c,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:c,updatedAt:h})}catch{a.push({key:c,updatedAt:0})}}a.sort((l,c)=>l.updatedAt-c.updatedAt);for(const l of a)if(window.localStorage.removeItem(l.key),Oi(s,i))break}catch{}}function Fx(e,t){Mi(Bi(e,t))}function $x(e){if(cr())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=b.createContext(null),Fc=b.createContext(null),$c=b.createContext(null),zx=b.createContext(!1),zc=50,Bx=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 Hx(e,t){return Go(e,t)}function Ux(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 Wx(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=Ux(e.next,t.next),i=Wx(e.tasks,t.tasks),a=Hx(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 Vx({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:c}=Ni(),d=b.useMemo(()=>Mn(c),[c]),f=b.useMemo(()=>{try{return new URL(c).host}catch{return"unknown"}},[c]),h=b.useMemo(()=>`threadPayload:${Rx}:${f}:`,[f]),p=b.useCallback(N=>Dx(h,N),[h]),y=b.useCallback((N,_=100)=>{Lx(h,N,_)},[h]),v=b.useCallback(N=>{Fx(h,N)},[h]),m=b.useCallback(()=>{$x(h)},[h]),[x,w]=b.useState(()=>{var N;return Li(f,(N=l.getAuthToken)==null?void 0:N.call(l))}),[S,T]=b.useState(()=>{var _;const N=$i(Li(f,(_=l.getAuthToken)==null?void 0:_.call(l)));return qo(N)}),C=b.useMemo(()=>zi(S),[S]),[k,E]=b.useState(t),[R,P]=b.useState(!1),[j,B]=b.useState(!1),[$,L]=b.useState(null),[O,H]=b.useState(null),[W,se]=b.useState(null),[K,U]=b.useState([]),X=b.useCallback(()=>{const N=$i(x);b.startTransition(()=>{T(qo(N))})},[x]),[F,q]=b.useState(!1),[pe,ge]=b.useState(!1),[ke,Se]=b.useState(null),[J,D]=b.useState(void 0),[ee,re]=b.useState(void 0),[ce,ae]=b.useState(void 0),{state:ie,dispatch:Ge,seed:Je,prepend:Me,pushUser:He,onEvent:at,reset:Ke}=Ec(),je=b.useRef(k);b.useEffect(()=>{je.current=k},[k]);const mt=b.useRef(!1),gt=b.useRef([]),Ct=b.useRef(null),rt=b.useRef(null),te=b.useRef(new Map),me=b.useRef(k),ve=b.useRef(!1),We=b.useRef(null),De=b.useRef(new Map),et=b.useRef(new Map),xt=b.useRef(new Map),$t=b.useRef(new Map),un=b.useCallback(N=>{if(!N){U([]);return}const _=De.current.get(N);if(!_||!_.length){U([]);return}U(_.map(Y=>Yt(Y,{cloneMessages:!0})))},[]);b.useEffect(()=>{un(k)},[k,un]);const An=b.useCallback(()=>{var ne;const N=$t.current;if(N.size<=zc)return;const _=Array.from(N.entries()).sort((le,Q)=>le[1].timestamp-Q[1].timestamp),Y=N.size-zc;for(let le=0;le<Y;le++){const Q=(ne=_[le])==null?void 0:ne[0];Q&&N.delete(Q)}},[]),tr=b.useCallback((N,_,Y)=>{if(!N)return;const ne=Y==="replace"?[]:De.current.get(N)??[],le=Y==="replace"?_:[..._,...ne];if(!le.length){Y==="replace"&&De.current.set(N,[]);return}const Q=new Map;for(const ze of le){if(!(ze!=null&&ze.checkpointId))continue;const Le=`${ze.checkpointId}::${ze.checkpointNs??""}`,Xe=Yt(ze,{cloneMessages:!0}),ft=Q.get(Le);if(!ft){Q.set(Le,Xe);continue}const Tt=Hc(ft,Xe);Q.set(Le,{...ft,...Tt})}const $e=Array.from(Q.values()).sort((ze,Le)=>{const Xe=Number.isFinite(Date.parse(ze.createdAt??""))?Date.parse(ze.createdAt??""):0;return(Number.isFinite(Date.parse(Le.createdAt??""))?Date.parse(Le.createdAt??""):0)-Xe});De.current.set(N,$e),N===je.current&&un(N)},[un]),dn=b.useCallback((N,_,Y)=>{if(!N)return;const ne=et.current.get(N),le=Y==="replace"||!ne?new Map:new Map(ne);if(_&&typeof _=="object")for(const[Q,$e]of Object.entries(_)){if(!($e!=null&&$e.checkpointId))continue;const ze=Q||Zr($e.checkpointId,$e.checkpointNs??null);le.set(ze,Yt($e,{cloneMessages:!0}))}et.current.set(N,le)},[]),fn=b.useCallback((N,_)=>{const{threadId:Y,checkpointId:ne=null,checkpointNs:le=null}=N,Q=Bc(Y,ne,le);if(_!=null&&_.force)xt.current.delete(Q),$t.current.delete(Q);else{if(_!=null&&_.preferCache){const Xe=$t.current.get(Q);if(Xe)return Promise.resolve(Xe.payload)}const Le=xt.current.get(Q);if(Le)return Le}const ze=l.getStateHistory({threadId:Y,checkpointId:ne??void 0,checkpointNs:le??void 0}).then(Le=>($t.current.set(Q,{payload:Le,timestamp:Date.now()}),An(),Le)).finally(()=>{xt.current.get(Q)===ze&&xt.current.delete(Q)});return xt.current.set(Q,ze),ze},[l,An]),Mt=b.useCallback((N,_)=>new Promise((Y,ne)=>{const le=async()=>{mt.current=!0;try{await N(),Y()}catch(Q){ne(Q)}finally{mt.current=!1;const Q=gt.current.shift();Q&&Q().catch(()=>{})}};mt.current?gt.current.push(le):le().catch(Q=>{ne(Q)})}),[]),hn=b.useRef(C.length),Kt=b.useRef(!1);b.useEffect(()=>{hn.current=C.length},[C.length]),b.useEffect(()=>{const N=ie.pendingInterrupt??_x(ie.messages);Mc(W,N)||se(N??null)},[W,ie.messages,ie.pendingInterrupt]);const kt=b.useCallback(async()=>{const N=hn.current>0;N||P(!0);try{const _=await l.listThreads();b.startTransition(()=>{T(Y=>{const ne=$e=>$e.map(ze=>`${ze.threadId}:${ze.updatedAt??""}:${ze.messageCount??""}`).join("|"),le=zi(Y);return ne(le)===ne(_)||_.length===0&&le.length>0&&!Kt.current?Y:qo(_)})}),L(null),Kt.current||(Kt.current=!0)}catch(_){i==null||i(String(_)),console.error("[ChatSessionProvider] Failed to refresh threads:",_),L(String(_))}finally{N||P(!1)}},[l,i]),kr=b.useRef(!1),nr=b.useRef(null),vt=b.useRef(null),pn=b.useRef(""),_n=b.useCallback((N,_)=>{if(!cr())return;vt.current!==null&&(window.clearTimeout(vt.current),vt.current=null);const Y=N.map(le=>`${le.threadId}:${le.updatedAt??""}:${le.messageCount??""}`).join("|");if(N.length===0){try{Mi(x)}catch{}pn.current="";return}if(Y===pn.current)return;const ne=()=>{try{const le=N.slice(0,Di);Fi(x,le),pn.current=Y}catch{}finally{vt.current=null}};if(_!=null&&_.immediate){ne();return}vt.current=window.setTimeout(()=>{Dc(ne)},Ko)},[x]),$n=b.useCallback(()=>{_n(C,{immediate:!0})},[_n,C]),qt=b.useCallback((N,_,Y,ne)=>{var wm;const le=Y??je.current;if(!le)return;const Q=Yt(N),$e=le===je.current,ze=(ne==null?void 0:ne.persist)!==!1;if(_==="replace"){if(ze){const bt={threadId:le,snapshot:Yt(N,{cloneMessages:!0})};te.current.set(le,bt),me.current=le}if(!$e)return;Je(Q.messages,{checkpointId:Q.checkpointId??null,checkpointNs:Q.checkpointNs??null,pendingInterrupt:Q.interrupt??null}),se(Q.interrupt??null),Se(Q.nextCursor??null),q(!!Q.nextCursor),D(Q.checkpointId??void 0),re(Q.checkpointNs??void 0),ae(Q.nextCursorNs??void 0);return}const Le=te.current.get(le),Xe=(Le==null?void 0:Le.snapshot)??null,ft=Array.isArray(Xe==null?void 0:Xe.messages)?Xe.messages:[],Tt=Yt(Xe),Rn=Array.isArray(N==null?void 0:N.messages)?N.messages:[],Et=new Set,It=[...Rn,...ft].filter(bt=>{const Cl=bt==null?void 0:bt.id;return Cl?Et.has(Cl)?!1:(Et.add(Cl),!0):!0}),Ao=Hc(Tt,Q),_o={checkpointId:Tt.checkpointId??Q.checkpointId??null,checkpointNs:Tt.checkpointNs??Q.checkpointNs??null,createdAt:Q.createdAt??Tt.createdAt??null,parentId:Q.parentId??Tt.parentId??null,branchLabel:Q.branchLabel??Tt.branchLabel??null,lastMessageId:((wm=It[It.length-1])==null?void 0:wm.id)??null,messagesLen:It.length,hasMessages:It.length>0,messages:It,nextCursor:Q.nextCursor??Tt.nextCursor??null,nextCursorNs:Q.nextCursorNs??Tt.nextCursorNs??null,interrupt:Tt.interrupt??Q.interrupt??null,...Ao};if(te.current.set(le,{threadId:le,snapshot:Yt(_o,{cloneMessages:!0})}),!$e)return;Rn.length&&Me(Rn);const Pn=N&&Object.prototype.hasOwnProperty.call(N,"checkpointId")?N.checkpointId:void 0,jo=N&&Object.prototype.hasOwnProperty.call(N,"checkpointNs")?N.checkpointNs:void 0,On=N&&Object.prototype.hasOwnProperty.call(N,"nextCursor")?N.nextCursor:void 0,Sl=N&&Object.prototype.hasOwnProperty.call(N,"nextCursorNs")?N.nextCursorNs:void 0;Se(bt=>On!==void 0?On??bt??null:bt??null),q(bt=>On!==void 0?!!On:bt),D(bt=>Pn!==void 0?Pn??bt??void 0:bt??void 0),re(bt=>jo!==void 0?jo??bt??void 0:bt??void 0),ae(bt=>Sl!==void 0?Sl??void 0:bt)},[Me,Je,se]),Tr=b.useCallback(N=>{if(N.threadId!=null&&N.threadId!==je.current)return;const _=Yt(N.snapshot,{cloneMessages:!0});Je(_.messages,{checkpointId:_.checkpointId??null,checkpointNs:_.checkpointNs??null,pendingInterrupt:_.interrupt??null}),se(_.interrupt??null),Se(_.nextCursor??null),q(!!_.nextCursor),D(_.checkpointId??void 0),re(_.checkpointNs??void 0),ae(_.nextCursorNs??void 0),me.current=N.threadId,un(N.threadId??je.current??null)},[Je,se,un]),jn=b.useCallback(N=>{if(!N)return;te.current.delete(N),v(N),De.current.delete(N),et.current.delete(N),N===je.current&&U([]);const _=`${N}__`;for(const Y of xt.current.keys())Y.startsWith(_)&&xt.current.delete(Y);for(const Y of $t.current.keys())Y.startsWith(_)&&$t.current.delete(Y);me.current===N&&(me.current=null)},[v]),mn=b.useCallback(()=>{const N=je.current;N&&jn(N),Ke([]),q(!1),ge(!1),Se(null),D(void 0),re(void 0),ae(void 0)},[jn,Ke]),rr=b.useCallback(({from:N,to:_})=>{const Y=je.current;Y&&console.warn(`[ChatSessionProvider] Stream sequence gap detected (${N} -> ${_}) for thread ${Y}`)},[]),Io=b.useCallback(N=>{const _=N.threadId;console.log("[ChatSessionProvider] 📥 Handling thread_info event:",{threadId:_,title:N.title,created:N.created,currentThreads:C.length});const Y={threadId:_,title:N.title||`Thread ${_.slice(0,8)}`,createdAt:N.createdAt||new Date().toISOString(),updatedAt:N.updatedAt||new Date().toISOString(),messageCount:N.messageCount||0};je.current!==_&&(!je.current&&ie.messages.length<=1&&(rt.current=_),E(_)),b.startTransition(()=>{T(ne=>{const le=ne.byId[_];return le?le.title===Y.title&&le.updatedAt===Y.updatedAt&&le.messageCount===Y.messageCount?ne:{byId:{...ne.byId,[_]:Y},order:ne.order}:{byId:{...ne.byId,[_]:Y},order:[_,...ne.order]}})})},[ie.messages.length]),{startStream:Ur,stop:Wr,isStreaming:or,error:I,setAuthToken:A}=Ex({baseUrl:d,onThreadInfo:Io,onMessageEvent:at,onUnhandledEvent:N=>{console.warn(`[ChatSessionProvider] Unhandled stream event: ${N.type}`,N)},onSequenceGap:rr});b.useEffect(()=>{kr.current=or},[or]),b.useEffect(()=>{if(!cr())return;vt.current!==null&&(window.clearTimeout(vt.current),vt.current=null);const N=C.map(Y=>`${Y.threadId}:${Y.updatedAt??""}:${Y.messageCount??""}`).join("|");if(C.length===0){try{Mi(x)}catch{}pn.current="";return}if(N===pn.current)return;const _=()=>{try{const Y=C.slice(0,Di);Fi(x,Y),pn.current=N}catch{}finally{vt.current=null}};return vt.current=window.setTimeout(()=>{Dc(_),vt.current=null},Ko),()=>{vt.current!==null&&(window.clearTimeout(vt.current),vt.current=null)}},[C,_n]),b.useEffect(()=>{var ne;const N=l.getAuthToken();A(N);const _=le=>{const Q=Li(f,le);We.current!==Q&&(We.current=Q,ve.current=!1),w(Q);const $e=$i(Q);b.startTransition(()=>{T(qo($e))}),ve.current||(ve.current=!0,kt().catch(()=>{}))};_(N);const Y=(ne=l.onTokenChange)==null?void 0:ne.call(l,le=>{A(le),m(),xt.current.clear(),$t.current.clear(),_(le)});return()=>{Y==null||Y()}},[l,f,A,m,kt]);const z=b.useCallback(async N=>{var ne;const _=`Thread ${(ne=crypto.randomUUID)==null?void 0:ne.call(crypto)}`,Y={threadId:_,title:N||"New Chat",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messageCount:0};T(le=>({byId:{...le.byId,[_]:Y},order:[_,...le.order]})),E(_);try{const le=await l.createThread(N),Q=typeof le=="string"?le:le.threadId;return T($e=>{const ze=$e.byId[_];if(!ze)return $e;const Le={...$e.byId};delete Le[_],Le[Q]={...ze,threadId:Q};const Xe=$e.order.map(ft=>ft===_?Q:ft);return{byId:Le,order:Xe}}),E(Q),setTimeout(()=>kt(),10),L(null),Q}catch(le){throw T(Q=>{if(!Q.byId[_])return Q;const $e={...Q.byId};delete $e[_];const ze=Q.order.filter(Le=>Le!==_);return{byId:$e,order:ze}}),E(null),L(String(le)),le}},[l,kt]),G=b.useCallback(async N=>{try{await l.deleteThread(N);let _=null;T(Y=>{if(!Y.byId[N])return Y;const ne={...Y.byId};delete ne[N];const le=Y.order.filter($e=>$e!==N),Q={byId:ne,order:le};return _=zi(Q),Q}),_&&_n(_,{immediate:!0}),jn(N),je.current===N&&(rt.current=N,E(null),je.current=null,me.current=null,mn()),await kt(),L(null)}catch(_){throw L(String(_)),_}},[l,mn,jn,kt,_n]),ye=b.useCallback(async(N,_)=>{try{await l.updateThread(N,_),T(Y=>{const ne=Y.byId[N];return ne?{byId:{...Y.byId,[N]:{...ne,title:_}},order:Y.order}:Y}),L(null)}catch(Y){throw await kt(),L(String(Y)),Y}},[l,kt]),Ce=b.useCallback(async(N,_,Y,ne=!1)=>{await Mt(async()=>{if(rt.current===N&&!ne){rt.current=null;return}if(Ct.current===N&&!ne)return;E(Et=>Et===N?Et:N),je.current=N;const $e=Bc(N,_??null,Y??null),ze=$t.current.get($e),Le=!ne&&!_&&!Y&&ze&&Date.now()-ze.timestamp<Bx,Xe=!ne&&!_&&!Y;let ft=!1;if(Xe){const Et=te.current.get(N);if(Et)Tr(Et),ft=!0;else{const It=p(N);It&&(te.current.set(N,It),Tr(It),ft=!0)}}const Tt=ne||!ft||!!_||!!Y,Rn=async Et=>{Et&&B(!0),Ct.current=N;try{const It=await fn({threadId:N,checkpointId:_,checkpointNs:Y},{force:ne}),{latest:Ao,checkpoints:_o,snapshots:Pn}=_i(It);qt(Ao,"replace",N),tr(N,_o,"replace"),dn(N,Pn,"replace"),H(null)}catch(It){throw(!ft||ne||Et)&&(i==null||i(String(It))),H(String(It)),It}finally{Ct.current=null,Et&&B(!1)}};Tt?await Rn(!0):Xe&&ft&&!Le&&Rn(!1).catch(Et=>{console.warn("[ChatSessionProvider] Background refresh failed:",Et)})},`loadThread-${N}`)},[Tr,qt,Mt,fn,i,tr,dn]),Ne=b.useCallback(async()=>{await Mt(async()=>{const N=je.current;N&&jn(N),rt.current=null,E(null),je.current=null,me.current=null,mn(),D(void 0),re(void 0),ae(void 0),U([]);try{localStorage.removeItem("lastThreadId")}catch(_){console.warn("[ChatSessionProvider] Failed to clear lastThreadId:",_)}},"clearCurrentThread")},[mn,jn,Mt]),Pe=b.useCallback(async(N,_)=>{var Q;const Y=je.current;if(!Y)throw new Error("No active thread");const ne=Zr(N,_??null),le=(Q=et.current.get(Y))==null?void 0:Q.get(ne);if(le){await Mt(async()=>{qt(le,"replace",Y,{persist:!1})},`navigateToCheckpoint-${Y}-${ne}`);return}await Ce(Y,N,_??void 0,!0)},[qt,Mt,Ce]),dt=b.useCallback(async()=>{if(!je.current)throw new Error("No active thread");await Ce(je.current,void 0,void 0,!0)},[Ce]),st=b.useCallback(async()=>{if(!je.current)throw new Error("No active thread");if(pe||!F)return;const N=ke;if(N){ge(!0);try{const _=je.current,Y=await fn({threadId:_,checkpointId:N??J??null,checkpointNs:ce??ee??null}),{latest:ne,checkpoints:le,snapshots:Q}=_i(Y),$e=_?et.current.get(_):null;let ze=le.length>0;if(ze&&$e&&$e.size>0&&(ze=le.some(Le=>{if(!(Le!=null&&Le.checkpointId))return!1;const Xe=Zr(Le.checkpointId,Le.checkpointNs??null);return!$e.has(Xe)})),!ze){Se(null),ae(void 0),q(!1),H(null);return}qt(ne,"prepend",_??void 0),_&&(tr(_,le,"prepend"),dn(_,Q,"prepend")),H(null)}catch(_){throw H(String(_)),_}finally{ge(!1)}}},[qt,fn,F,J,ee,ce,ke,pe,tr,dn]),lt=b.useCallback(N=>{if(N!=null&&N.threadId){if(N.checkpointId){const _=Zr(N.checkpointId,N.checkpointNs??null),Y=Yt({...N,interrupt:N.interrupt??null},{cloneMessages:!0});dn(N.threadId,{[_]:Y},"prepend")}qt(N,"replace",N.threadId)}},[qt,dn]),wt=b.useCallback(async(N,_)=>{var jo;const Y=je.current,ne=(N==null?void 0:N.text)??"",le=(N==null?void 0:N.attachments)??[],Q=le.length?le:(_==null?void 0:_.attachments)??[],$e={...(_==null?void 0:_.payloadExtras)??{},...(N==null?void 0:N.payload)??{}};if(!Y&&!Object.keys($e).length&&Q.length===0&&!ne.trim()){console.warn("[ChatSessionProvider] Nothing to submit - skipping");return}!Y&&!$e.messages&&console.warn("[ChatSessionProvider] No thread ID - message will create new thread");const{contentParts:ze,filesInfo:Le}=await Jg(l,Q),Xe=[...ze];ne&&ne.trim()&&Xe.push({type:"text",text:ne.trim()});const ft=!!Y,Tt=ft?(_==null?void 0:_.checkpointId)??ie.lastCheckpointId??void 0:void 0,Rn=ft?(_==null?void 0:_.checkpointNs)??ie.lastCheckpointNs??void 0:void 0,Et={id:((jo=crypto.randomUUID)==null?void 0:jo.call(crypto))||`user-${Date.now()}`,role:"user",content:Xe,createdAt:new Date().toISOString(),...Tt!=null?{checkpointId:Tt}:{},...Rn!=null?{checkpointNs:Rn}:{}};Xe.length>0&&He(Et);const It={...Et,content:Xe},Ao=Q.length>0,_o={messages:Xe.length>0?[It]:[],files_info:Le,...o&&Ao&&s?{active_agent:s}:{},...$e},Pn={threadId:Y??null,payload:_o,checkpointId:Tt??null,checkpointNs:Rn??null,nodeFilter:(_==null?void 0:_.nodeFilter)??null,config:_==null?void 0:_.config,command:(_==null?void 0:_.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})=>{!je.current&&On&&(ie.messages.length<=1&&(rt.current=On),E(On))},onGap:rr})},[l,o,s,rr,ie.lastCheckpointId,ie.lastCheckpointNs,ie.messages.length,He,Ur]),zn=b.useCallback(async(N,_,Y)=>{if(!je.current)throw new Error("No active thread to handle interrupt");const le=_?Y??!0:!1;try{try{Ge({type:"interrupt_response",payload:{interruptId:N}})}catch(Q){console.warn("[ChatSessionProvider] optimistic interrupt_response dispatch failed:",Q)}await wt({payload:{}},{checkpointId:ie.lastCheckpointId??void 0,checkpointNs:ie.lastCheckpointNs??void 0,command:{kind:"resume",value:le}}),se(null)}catch(Q){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${N}:`,Q),Q}},[Ge,ie.lastCheckpointId,ie.lastCheckpointNs,wt]);b.useEffect(()=>{if(a==null||a(k),k)try{localStorage.setItem("lastThreadId",k)}catch(N){console.warn("[ChatSessionProvider] Failed to persist lastThreadId:",N)}},[k,a]),b.useEffect(()=>((async()=>{try{if(kt().catch(_=>{console.error("[ChatSessionProvider] Failed to refresh threads (background):",_),i==null||i(String(_))}),!r&&!t)try{const _=localStorage.getItem("lastThreadId");_&&(E(_),n&&await Ce(_))}catch(_){console.warn("[ChatSessionProvider] Failed to restore last thread:",_)}else t&&n&&await Ce(t)}catch(_){console.error("[ChatSessionProvider] Initialization failed:",_),i==null||i(String(_))}})(),()=>{}),[]),b.useEffect(()=>{const N=je.current;if(!N||me.current!==N)return;ie.messages.length&&ie.messages[ie.messages.length-1];const _=Yt({checkpointId:ie.lastCheckpointId??null,checkpointNs:ie.lastCheckpointNs??null,messages:ie.messages.slice(),nextCursor:ke??null,nextCursorNs:ce??null,interrupt:ie.pendingInterrupt??W??null}),Y=te.current.get(N),ne=Y==null?void 0:Y.snapshot,le=!ne||ne.messages.length!==_.messages.length||ne.messages.some((Le,Xe)=>{var ft;return(Le==null?void 0:Le.id)!==((ft=_.messages[Xe])==null?void 0:ft.id)}),Q=((ne==null?void 0:ne.checkpointId)??null)!==_.checkpointId||((ne==null?void 0:ne.checkpointNs)??null)!==_.checkpointNs,$e=((ne==null?void 0:ne.nextCursor)??null)!==_.nextCursor||((ne==null?void 0:ne.nextCursorNs)??null)!==_.nextCursorNs,ze=!Mc((ne==null?void 0:ne.interrupt)??null,_.interrupt??null);if(le||Q||$e||ze){const Le={threadId:N,snapshot:_};te.current.set(N,Le),nr.current&&window.clearTimeout(nr.current),nr.current=window.setTimeout(()=>{try{y(Le,100)}catch(Xe){console.warn("[ChatSessionProvider] Failed to persist thread payload:",Xe)}},Ko)}},[ke,ce,ie.lastCheckpointId,ie.lastCheckpointNs,ie.messages,ie.pendingInterrupt,W,y]);const Bn=b.useMemo(()=>({threads:C,currentThreadId:k,setCurrentThreadId:E,isLoading:R,error:$,actions:{createThread:z,deleteThread:G,renameThread:ye,refreshThreads:()=>kt()},persistThreadsCache:$n,hydrateFromCache:X}),[C,k,R,$,z,G,ye,kt,$n,X,E]),Rt=b.useMemo(()=>{const N=ie.lastBranch??null,_=ie.assemblingId??null,Y=N||_?{branchLabel:(N==null?void 0:N.branchLabel)??null,lastBranch:N,assemblingMessageId:_}:null;return{threadId:k,messages:ie.messages,interrupt:W,checkpoint:{id:ie.lastCheckpointId??null,namespace:ie.lastCheckpointNs??null},checkpoints:K,metadata:Y,isLoading:j,isHistoryLoading:pe,error:O,hasMore:F,loadOlder:st,seedFromSnapshot:lt,clearState:mn,navigateToCheckpoint:Pe,returnToLatest:dt,loadThread:Ce,clearThread:Ne,respondToInterrupt:zn}},[Ne,mn,k,W,F,pe,j,st,Ce,ie.assemblingId,ie.lastBranch,ie.lastCheckpointId,ie.lastCheckpointNs,ie.messages,Pe,zn,dt,lt,O,K]),No=b.useMemo(()=>({isStreaming:or,error:I,submit:wt,send:wt,stop:Wr,setAuthToken:A}),[or,I,wt,Wr,A]);return u.jsx(zx.Provider,{value:!0,children:u.jsx($c.Provider,{value:No,children:u.jsx(Lc.Provider,{value:Bn,children:u.jsx(Fc.Provider,{value:Rt,children:e})})})})}function Yo(){const e=b.useContext(Lc);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Xo(){const e=b.useContext(Fc);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function Uc(){const e=b.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 u.jsx(Yg,{apiConfig:t,children:u.jsx(Vx,{initialThreadId:n,autoLoadInitial:r,disableAutoRestore:o,enableFileAgentRouting:s,fileAgentId:i,onError:a,onThreadChange:l,children:e})})}function oe(...e){return km.twMerge(Cm.clsx(e))}const Kx=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"}}),qe=g.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?sr.Slot:"button";return u.jsx(i,{className:oe(Kx({variant:t,size:n,className:e})),ref:s,...o})});qe.displayName="Button";const Wc=g.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:oe("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 qx({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,onSend:i,onCancelEdit:a,onStop:l,className:c="",textareaClassName:d="",allowEmptySend:f=!1}){const[h,p]=b.useState(e),[y,v]=b.useTransition(),m=b.useRef(null),x=b.useRef(0),w=b.useRef(null);b.useEffect(()=>{p(e??""),w.current=null,m.current&&(m.current.style.height="auto",m.current.style.height=`${m.current.scrollHeight}px`)},[e,t]);const S=b.useCallback(()=>{const j=m.current;j&&(j.style.height="auto",j.style.height=`${j.scrollHeight}px`)},[]);b.useEffect(()=>{S()},[S]);const T=b.useCallback(async j=>{j&&j.preventDefault();const B=(h??"").trim();if(!B&&!f)return;const $=++x.current;w.current={id:$,shouldClear:!0},v(()=>{var L,O,H;try{const W=i(B);W&&typeof W.then=="function"?W.then(()=>{var se,K;((se=w.current)==null?void 0:se.id)===$&&w.current.shouldClear&&(p(""),m.current&&(m.current.style.height="auto")),((K=w.current)==null?void 0:K.id)===$&&(w.current=null)}).catch(()=>{var se;((se=w.current)==null?void 0:se.id)===$&&(w.current=null)}):(((L=w.current)==null?void 0:L.id)===$&&w.current.shouldClear&&(p(""),m.current&&(m.current.style.height="auto")),((O=w.current)==null?void 0:O.id)===$&&(w.current=null))}catch{((H=w.current)==null?void 0:H.id)===$&&(w.current=null)}})},[h,i,f]),C=b.useCallback(j=>{p(j.target.value),w.current&&(w.current.shouldClear=!1),m.current&&(m.current.style.height="auto",m.current.style.height=`${m.current.scrollHeight}px`)},[]),k=b.useCallback(j=>{j.key==="Enter"&&!j.shiftKey?(j.preventDefault(),T()):j.key==="Escape"&&t&&(j.preventDefault(),a==null||a())},[T,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 u.jsx("form",{onSubmit:j=>void T(j),className:`w-full ${c}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsx("div",{className:"flex-1",children:u.jsx(Wc,{ref:m,value:h,onChange:C,onKeyDown:k,placeholder:t?"Edit your message...":n,className:P,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),u.jsx("div",{children:r?u.jsx(qe,{type:"button",onClick:()=>{l==null||l()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!l,children:u.jsx(he.Square,{size:16})}):u.jsx(qe,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||y,children:u.jsx(he.Send,{size:16})})})]})})}const Gx=b.memo(qx),Zo=0,Un=1,Ar=2,Vc=4;function Kc(e){return()=>e}function Yx(e){e()}function qc(e,t){return n=>e(t(n))}function Gc(e,t){return()=>e(t)}function Xx(e,t){return n=>e(t,n)}function Hi(e){return e!==void 0}function Jx(...e){return()=>{e.map(Yx)}}function _r(){}function Qo(e,t){return t(e),e}function Zx(e,t){return t(e)}function tt(...e){return e}function Ye(e,t){return e(Un,t)}function Oe(e,t){e(Zo,t)}function Ui(e){e(Ar)}function ut(e){return e(Vc)}function xe(e,t){return Ye(e,Xx(t,Zo))}function rn(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 nt(e=Xc){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ee(e){return t=>n=>{e(n)&&t(n)}}function ue(e){return t=>qc(t,e)}function yn(e){return t=>()=>{t(e)}}function V(e,...t){const n=Qx(...t);return(r,o)=>{switch(r){case Ar:Ui(e);return;case Un:return Ye(e,n(o))}}}function vn(e,t){return n=>r=>{n(t=e(t,r))}}function ur(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 c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function Qx(...e){return t=>e.reduceRight(Zx,t)}function ey(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 Ar:r(),n=null;return}}}function Z(e){let t=e;const n=Ue();return(r,o)=>{switch(r){case Zo:t=o;break;case Un:{o(t);break}case Vc:return t}return n(r,o)}}function At(e,t){return Qo(Z(t),n=>xe(e,n))}function Ue(){const e=[];return(t,n)=>{switch(t){case Zo:e.slice().forEach(r=>{r(n)});return;case Ar:e.splice(0,e.length);return;case Un:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Bt(e){return Qo(Ue(),t=>xe(e,t))}function Ve(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:ty(),singleton:n}}const ty=()=>Symbol();function ny(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 ht(...e){const t=Ue(),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 Un:return r===o&&i(n),Ye(t,i)}}}function Te(e,t=Xc){return V(e,nt(t))}function Wi(...e){return function(t,n){switch(t){case Ar:return;case Un:return Jx(...e.map(r=>Ye(r,n)))}}}var Ft=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ft||{});const ry={0:"debug",3:"error",1:"log",2:"warn"},oy=()=>typeof globalThis>"u"?window:globalThis,Wn=Ve(()=>{const e=Z(3);return{log:Z((t,n,r=1)=>{var o;const s=(o=oy().VIRTUOSO_LOG_LEVEL)!=null?o:ut(e);r>=s&&console[ry[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function dr(e,t,n){return Vi(e,t,n).callbackRef}function Vi(e,t,n){const r=b.useRef(null);let o=i=>{};const s=b.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 sy(e,t,n,r,o,s,i,a,l){const c=b.useCallback(d=>{const f=iy(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 y;p&&(y=h.ownerDocument.defaultView);const v=i?a?i.scrollLeft:i.scrollTop:p?a?y.scrollX||y.document.documentElement.scrollLeft:y.scrollY||y.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,m=i?a?i.scrollWidth:i.scrollHeight:p?a?y.document.documentElement.scrollWidth:y.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,x=i?a?i.offsetWidth:i.offsetHeight:p?a?y.innerWidth:y.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:m,scrollTop:Math.max(v,0),viewportHeight:x}),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 Vi(c,n,l)}function iy(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),c=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Ft.ERROR),d===c)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,Ft.WARN),t==="normal"?0:parseInt(t??"0",10)}function Zc(e,t,n){const r=b.useRef(null),o=b.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let f,h;if(t){const p=t.getBoundingClientRect(),y=c.top-p.top;h=p.height-Math.max(0,y),f=y+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;h=p.innerHeight-Math.max(0,c.top),f=c.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=b.useCallback(()=>{o(i.current)},[o,i]);return b.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const Pt=Ve(()=>{const e=Ue(),t=Ue(),n=Z(0),r=Ue(),o=Z(0),s=Ue(),i=Ue(),a=Z(0),l=Z(0),c=Z(0),d=Z(0),f=Ue(),h=Ue(),p=Z(!1),y=Z(!1),v=Z(!1);return xe(V(e,ue(({scrollTop:m})=>m)),t),xe(V(e,ue(({scrollHeight:m})=>m)),i),xe(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:y,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:v,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 Ze(e){return e===eo}function to(e,t){if(!Ze(e))return t===e.k?e.v:t<e.k?to(e.l,t):to(e.r,t)}function on(e,t,n="k"){if(Ze(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=on(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return on(e.l,t,n)}function Ht(e,t,n){return Ze(e)?nu(t,n,1):t===e.k?pt(e,{k:t,v:n}):t<e.k?ru(pt(e,{l:Ht(e.l,t,n)})):ru(pt(e,{r:Ht(e.r,t,n)}))}function jr(){return eo}function es(e,t,n){if(Ze(e))return[];const r=on(e,t)[0];return ay(qi(e,r,n))}function Ki(e,t){if(Ze(e))return eo;const{k:n,l:r,r:o}=e;if(t===n){if(Ze(r))return o;if(Ze(o))return r;{const[s,i]=tu(r);return ts(pt(e,{k:s,l:eu(r),v:i}))}}else return t<n?ts(pt(e,{l:Ki(r,t)})):ts(pt(e,{r:Ki(o,t)}))}function fr(e){return Ze(e)?[]:[...fr(e.l),{k:e.k,v:e.v},...fr(e.r)]}function qi(e,t,n){if(Ze(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 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(Gi(t))return ou(pt(e,{lvl:n-1}));if(!Ze(t)&&!Ze(t.r))return pt(t.r,{l:pt(t,{r:t.r.l}),lvl:n,r:pt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Gi(e))return Yi(pt(e,{lvl:n-1}));if(!Ze(r)&&!Ze(r.l)){const o=r.l,s=Gi(o)?r.lvl-1:r.lvl;return pt(o,{l:pt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Yi(pt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function pt(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 Ze(e.r)?e.l:ts(pt(e,{r:eu(e.r)}))}function Gi(e){return Ze(e)||e.lvl>e.r.lvl}function tu(e){return Ze(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 Yi(ou(e))}function ou(e){const{l:t}=e;return!Ze(t)&&t.lvl===e.lvl?pt(t,{r:pt(e,{l:t.r})}):e}function Yi(e){const{lvl:t,r:n}=e;return!Ze(n)&&!Ze(n.r)&&n.lvl===t&&n.r.lvl===t?pt(n,{l:pt(e,{r:n.l}),lvl:t+1}):e}function ay(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 Xi=Ve(()=>({recalcInProgress:Z(!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 ly(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!Ze(e.groupOffsetTree)}function Ji({index:e},t){return t===e?0:t<e?-1:1}function cy(){return{groupIndices:[],groupOffsetTree:jr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:jr()}}function uy(e,t){let n=Ze(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Ze(e)){e=Ht(e,0,s);continue}const a=es(e,i-1,o+1);if(a.some(xy(r)))continue;let l=!1,c=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=Ki(e,f)):(c=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=Ht(e,o+1,h));c&&(e=Ht(e,i,s))}return[e,n]}function dy(e){return typeof e.groupIndex<"u"}function fy({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,Ji),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(dy(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 hy(e,t,n,r=0){return r>0&&(t=Math.max(t,iu(e,r,Ji).offset)),Qc(ly(e,t,n,fy),gy)}function py(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ft.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&Ze(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((y,v)=>Ht(Ht(y,v,h),v+1,p),i)}else[i,a]=uy(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f}=Zi(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>Ht(h,p,ro(p,f,o)),jr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f,sizeTree:i}}function my(e){return fr(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 Zi(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=ns(o,t-1,Ji),a=o[l].offset;const c=on(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===on(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of es(n,t,1/0)){const f=c-s,h=f*i+a+f*r;o.push({index:c,offset:h,size:d}),s=c,a=h,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function gy(e){return{index:e.index,value:e}}function xy(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 yy={offsetHeight:"height",offsetWidth:"width"},wn=Ve(([{log:e},{recalcInProgress:t}])=>{const n=Ue(),r=Ue(),o=At(r,0),s=Ue(),i=Ue(),a=Z(0),l=Z([]),c=Z(void 0),d=Z(void 0),f=Z((C,k)=>Vn(C,yy[k])),h=Z(void 0),p=Z(0),y=cy(),v=At(V(n,Fe(l,e,p),vn(py,y),nt()),y),m=At(V(l,nt(),vn((C,k)=>({current:k,prev:C.current}),{current:[],prev:[]}),ue(({prev:C})=>C)),[]);xe(V(l,Ee(C=>C.length>0),Fe(v,p),ue(([C,k,E])=>{const R=C.reduce((P,j,B)=>Ht(P,j,ro(j,k.offsetTree,E)||B),jr());return{...k,groupIndices:C,groupOffsetTree:R}})),v),xe(V(r,Fe(v),Ee(([C,{lastIndex:k}])=>C<k),ue(([C,{lastIndex:k,lastSize:E}])=>[{endIndex:k,size:E,startIndex:C}])),n),xe(c,d);const x=At(V(c,ue(C=>C===void 0)),!0);xe(V(d,Ee(C=>C!==void 0&&Ze(ut(v).sizeTree)),ue(C=>[{endIndex:0,size:C,startIndex:0}])),n);const w=Bt(V(n,Fe(v),vn(({sizes:C},[k,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:y}),ue(C=>C.changed)));Ye(V(a,vn((C,k)=>({diff:C.prev-k,prev:k}),{diff:0,prev:0}),ue(C=>C.diff)),C=>{const{groupIndices:k}=ut(v);if(C>0)Oe(t,!0),Oe(s,C+cu(C,k));else if(C<0){const E=ut(m);E.length>0&&(C-=cu(-C,E)),Oe(i,C)}}),Ye(V(a,Fe(e)),([C,k])=>{C<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},Ft.ERROR)});const S=Bt(s);xe(V(s,Fe(v),ue(([C,k])=>{const E=k.groupIndices.length>0,R=[],P=k.lastSize;if(E){const j=to(k.sizeTree,0);let B=0,$=0;for(;B<C;){const O=k.groupIndices[$],H=k.groupIndices.length===$+1?1/0:k.groupIndices[$+1]-O-1;R.push({endIndex:O,size:j,startIndex:O}),R.push({endIndex:O+1+H-1,size:P,startIndex:O+1}),$++,B+=H+1}const L=fr(k.sizeTree);return B!==C&&L.shift(),L.reduce((O,{k:H,v:W})=>{let se=O.ranges;return O.prevSize!==0&&(se=[...O.ranges,{endIndex:H+C-1,size:O.prevSize,startIndex:O.prevIndex}]),{prevIndex:H+C,prevSize:W,ranges:se}},{prevIndex:C,prevSize:0,ranges:R}).ranges}return fr(k.sizeTree).reduce((j,{k:B,v:$})=>({prevIndex:B+C,prevSize:$,ranges:[...j.ranges,{endIndex:B+C-1,size:j.prevSize,startIndex:j.prevIndex}]}),{prevIndex:0,prevSize:P,ranges:[]}).ranges})),n);const T=Bt(V(i,Fe(v,p),ue(([C,{offsetTree:k},E])=>{const R=-C;return ro(R,k,E)})));return xe(V(i,Fe(v,p),ue(([C,k,E])=>{if(k.groupIndices.length>0){if(Ze(k.sizeTree))return k;let R=jr();const P=ut(m);let j=0,B=0,$=0;for(;j<-C;){$=P[B];const L=P[B+1]-$-1;B++,j+=L+1}if(R=fr(k.sizeTree).reduce((L,{k:O,v:H})=>Ht(L,Math.max(0,O+C),H),R),j!==-C){const L=to(k.sizeTree,$);R=Ht(R,0,L);const O=on(k.sizeTree,-C+1)[1];R=Ht(R,1,O)}return{...k,sizeTree:R,...Zi(k.offsetTree,0,R,E)}}else{const R=fr(k.sizeTree).reduce((P,{k:j,v:B})=>Ht(P,Math.max(0,j+C),B),jr());return{...k,sizeTree:R,...Zi(k.offsetTree,0,R,E)}}})),v),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:p,groupIndices:l,itemSize:f,listRefresh:w,shiftWith:i,shiftWithOffset:T,sizeRanges:n,sizes:v,statefulTotalCount:o,totalCount:r,trackItemSizes:x,unshiftWith:s}},tt(Wn,Xi),{singleton:!0});function vy(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const uu=Ve(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Ue(),i=Ue(),a=Bt(V(s,ue(vy)));return xe(V(a,ue(l=>l.totalCount)),n),xe(V(a,ue(l=>l.groupIndices)),e),xe(V(ht(o,t,r),Ee(([l,c])=>rs(c)),ue(([l,c,d])=>on(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),nt(),ue(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},tt(wn,Pt)),Kn=Ve(([{log:e}])=>{const t=Z(!1),n=Bt(V(t,Ee(r=>r),nt()));return Ye(t,r=>{r&&ut(e)("props updated",{},Ft.DEBUG)}),{didMount:n,propsReady:t}},tt(Wn),{singleton:!0}),wy=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||!wy)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const oo=Ve(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const p=Ue(),y=Ue(),v=Z(0);let m=null,x=null,w=null;function S(){m&&(m(),m=null),w&&(w(),w=null),x&&(clearTimeout(x),x=null),Oe(l,!1)}return xe(V(p,Fe(n,f,r,v,a,i,h),Fe(e,s,o),ue(([[T,C,k,E,R,P,j,B],$,L,O])=>{const H=du(T),{align:W,behavior:se,offset:K}=H,U=E-1,X=lu(H,C,U);let F=ro(X,C.offsetTree,$)+P;W==="end"?(F+=L+on(C.sizeTree,X)[1]-k+O,X===U&&(F+=j)):W==="center"?F+=(L+on(C.sizeTree,X)[1]-k+O)/2:F-=R,K&&(F+=K);const q=pe=>{S(),pe?(B("retrying to scroll to",{location:T},Ft.DEBUG),Oe(p,T)):(Oe(y,!0),B("list did not change, scroll successful",{},Ft.DEBUG))};if(S(),se==="smooth"){let pe=!1;w=Ye(t,ge=>{pe=pe||ge}),m=rn(d,()=>{q(pe)})}else m=rn(V(t,by(150)),q);return x=setTimeout(()=>{S()},1200),Oe(l,!0),B("scrolling from index to",{behavior:se,index:X,top:F},Ft.DEBUG),{behavior:se,top:F}})),c),{scrollTargetReached:y,scrollToIndex:p,topListHeight:v}},tt(wn,Pt,Wn),{singleton:!0});function by(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=Ve(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=Z(!0),l=Z(0),c=Z(!0);return xe(V(i,Fe(l),Ee(([d,f])=>!!f),yn(!1)),a),xe(V(i,Fe(l),Ee(([d,f])=>!!f),yn(!1)),c),Ye(V(ht(t,i),Fe(a,n,e,c),Ee(([[,d],f,{sizeTree:h},p,y])=>d&&(!Ze(h)||Hi(p))&&!f&&!y),Fe(l)),([,d])=>{rn(o,()=>{Oe(c,!0)}),Qi(4,()=>{rn(r,()=>{Oe(a,!0)}),Oe(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},tt(wn,Pt,oo,Kn),{singleton:!0});function fu(e,t){return Math.abs(e-t)<1.01}const io="up",ao="down",Sy="none",Cy={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},ky=0,lo=Ve(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=Z(!1),a=Z(!0),l=Ue(),c=Ue(),d=Z(4),f=Z(ky),h=At(V(Wi(V(Te(o),ur(1),yn(!0)),V(Te(o),ur(1),yn(!1),Yc(100))),nt()),!1),p=At(V(Wi(V(n,yn(!0)),V(n,yn(!1),Yc(200))),nt()),!1);xe(V(ht(Te(o),Te(f)),ue(([w,S])=>w<=S),nt()),a),xe(V(a,Dn(50)),c);const y=Bt(V(ht(r,Te(s),Te(t),Te(e),Te(d)),vn((w,[{scrollHeight:S,scrollTop:T},C,k,E,R])=>{const P=T+C-S>-R,j={scrollHeight:S,scrollTop:T,viewportHeight:C};if(P){let $,L;return T>w.state.scrollTop?($="SCROLLED_DOWN",L=w.state.scrollTop-T):($="SIZE_DECREASED",L=w.state.scrollTop-T||w.scrollTopDelta),{atBottom:!0,atBottomBecause:$,scrollTopDelta:L,state:j}}let B;return j.scrollHeight>w.state.scrollHeight?B="SIZE_INCREASED":C<w.state.viewportHeight?B="VIEWPORT_HEIGHT_DECREASING":T<w.state.scrollTop?B="SCROLLING_UPWARDS":B="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:B,state:j}},Cy),nt((w,S)=>w&&w.atBottom===S.atBottom))),v=At(V(r,vn((w,{scrollHeight:S,scrollTop:T,viewportHeight:C})=>{if(fu(w.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:T};{const k=S-(T+C)<1;return w.scrollTop!==T&&k?{changed:!0,jump:w.scrollTop-T,scrollHeight:S,scrollTop:T}:{changed:!0,jump:0,scrollHeight:S,scrollTop:T}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ee(w=>w.changed),ue(w=>w.jump)),0);xe(V(y,ue(w=>w.atBottom)),i),xe(V(i,Dn(50)),l);const m=Z(ao);xe(V(r,ue(({scrollTop:w})=>w),nt(),vn((w,S)=>ut(p)?{direction:w.direction,prevScrollTop:S}:{direction:S<w.prevScrollTop?io:ao,prevScrollTop:S},{direction:ao,prevScrollTop:0}),ue(w=>w.direction)),m),xe(V(r,Dn(50),yn(Sy)),m);const x=Z(0);return xe(V(h,Ee(w=>!w),yn(0)),x),xe(V(o,Dn(100),Fe(h),Ee(([w,S])=>!!S),vn(([w,S],[T])=>[S,T],[0,0]),ue(([w,S])=>S-w)),x),{atBottomState:y,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:v,scrollDirection:m,scrollVelocity:x}},tt(Pt)),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 ta=Ve(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Ue(),i=Z(0),a=Z(0),l=Z(0),c=At(V(ht(Te(r),Te(o),Te(n),Te(s,no),Te(l),Te(i),Te(t),Te(e),Te(a)),ue(([d,f,h,[p,y],v,m,x,w,S])=>{const T=d-w,C=m+x,k=Math.max(h-T,0);let E=hu;const R=mu(S,os),P=mu(S,ss);return p-=w,p+=h+x,y+=h+x,y-=w,p>d+C-R&&(E=io),y<d-k+f+P&&(E=ao),E!==hu?[Math.max(T-h-pu(v,os,E)-R,0),T-k-x+f+pu(v,ss,E)+P]:null}),Ee(d=>d!=null),nt(no)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},tt(Pt),{singleton:!0});function Ty(e,t,n){if(rs(t)){const r=au(e,t);return[{index:on(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 is(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const v=e[e.length-1];d=v.offset+v.size}const f=n-i,h=a+f*l+(f-1)*r,p=c,y=h-d;return{bottom:d,firstItemIndex:s,items:xu(e,o,s),offsetBottom:y,offsetTop:c,top:p,topItems:xu(t,o,s),topListHeight:t.reduce((v,m)=>m.size+v,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=ea(t,a),c=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return is(c,[],a,o,n,r)}function xu(e,t,n){if(e.length===0)return[];if(!rs(t))return e.map(c=>({...c,index:c.index+n,originalIndex:c.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 c of e){(!a||a.end<c.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;c.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},s.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}const hr=Ve(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:p},{recalcInProgress:y}])=>{const v=Z([]),m=Z(0),x=Ue();xe(s.topItemsIndexes,v);const w=At(V(ht(p,y,Te(l,no),Te(o),Te(r),Te(c),d,Te(v),Te(t),Te(n),e),Ee(([k,E,,R,,,,,,,P])=>{const j=P&&P.length!==R;return k&&!E&&!j}),ue(([,,[k,E],R,P,j,B,$,L,O,H])=>{const W=P,{offsetTree:se,sizeTree:K}=W,U=ut(m);if(R===0)return{...na,totalCount:R};if(k===0&&E===0)return U===0?{...na,totalCount:R}:gu(U,j,P,L,O,H||[]);if(Ze(K))return U>0?null:is(Ty(ea(j,R),W,H),[],R,O,W,L);const X=[];if($.length>0){const ke=$[0],Se=$[$.length-1];let J=0;for(const D of es(K,ke,Se)){const ee=D.value,re=Math.max(D.start,ke),ce=Math.min(D.end,Se);for(let ae=re;ae<=ce;ae++)X.push({data:H==null?void 0:H[ae],index:ae,offset:J,size:ee}),J+=ee}}if(!B)return is([],X,R,O,W,L);const F=$.length>0?$[$.length-1]+1:0,q=hy(se,k,E,F);if(q.length===0)return null;const pe=R-1,ge=Qo([],ke=>{for(const Se of q){const J=Se.value;let D=J.offset,ee=Se.start;const re=J.size;if(J.offset<k){ee+=Math.floor((k-J.offset+O)/(re+O));const ae=ee-Se.start;D+=ae*re+ae*O}ee<F&&(D+=(F-ee)*re,ee=F);const ce=Math.min(Se.end,pe);for(let ae=ee;ae<=ce&&!(D>=E);ae++)ke.push({data:H==null?void 0:H[ae],index:ae,offset:D,size:re}),D+=re+O}});return is(ge,X,R,O,W,L)}),Ee(k=>k!==null),nt()),na);xe(V(e,Ee(Hi),ue(k=>k==null?void 0:k.length)),o),xe(V(w,ue(k=>k.topListHeight)),f),xe(f,a),xe(V(w,ue(k=>[k.top,k.bottom])),i),xe(V(w,ue(k=>k.items)),x);const S=Bt(V(w,Ee(({items:k})=>k.length>0),Fe(o,e),Ee(([{items:k},E])=>k[k.length-1].originalIndex===E-1),ue(([,k,E])=>[k-1,E]),nt(no),ue(([k])=>k))),T=Bt(V(w,Dn(200),Ee(({items:k,topItems:E})=>k.length>0&&k[0].originalIndex===E.length),ue(({items:k})=>k[0].index),nt())),C=Bt(V(w,Ee(({items:k})=>k.length>0),ue(({items:k})=>{let E=0,R=k.length-1;for(;k[E].type==="group"&&E<R;)E++;for(;k[R].type==="group"&&R>E;)R--;return{endIndex:k[R].index,startIndex:k[E].index}}),nt(su)));return{endReached:S,initialItemCount:m,itemsRendered:x,listState:w,rangeChanged:C,startReached:T,topItemsIndexes:v,...h}},tt(wn,uu,ta,so,oo,lo,Kn,Xi),{singleton:!0}),yu=Ve(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Ue(),i=At(V(ht(n,e,r,t,o),ue(([a,l,c,d,f])=>a+l+c+d+f.offsetBottom+f.bottom)),0);return xe(Te(i),s),{totalListHeight:i,totalListHeightChanged:s}},tt(Pt,hr),{singleton:!0}),Ey=Ve(([{viewportHeight:e},{totalListHeight:t}])=>{const n=Z(!1),r=At(V(ht(n,e,t),Ee(([o])=>o),ue(([,o,s])=>Math.max(0,o-s)),Dn(0),nt()),0);return{alignToBottom:n,paddingTopAddition:r}},tt(Pt,yu),{singleton:!0}),vu=Ve(()=>({context:Z(null)})),Iy=({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,wu=Ve(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=Ue();return xe(V(d,Fe(t,l,n,s,o,r,a),Fe(e),ue(([[f,h,p,y,v,m,x,w],S])=>{const{align:T,behavior:C,calculateViewLocation:k=Iy,done:E,...R}=f,P=lu(f,h,y-1),j=ro(P,h.offsetTree,S)+v+m,B=j+on(h.sizeTree,P)[1],$=w+m,L=w+p-x,O=k({itemBottom:B,itemTop:j,locationParams:{align:T,behavior:C,...R},viewportBottom:L,viewportTop:$});return O?E&&rn(V(i,Ee(H=>!H),ur(ut(i)?1:2)),E):E&&E(),O}),Ee(f=>f!==null)),c),{scrollIntoView:d}},tt(wn,Pt,oo,hr,Wn),{singleton:!0});function bu(e){return e?e==="smooth"?"smooth":"auto":!1}const Ny=(e,t)=>typeof e=="function"?bu(e(t)):t&&bu(e),Ay=Ve(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:p}])=>{const y=Z(!1),v=Ue();let m=null;function x(C){Oe(i,{align:"end",behavior:C,index:"LAST"})}Ye(V(ht(V(Te(t),ur(1)),l),Fe(Te(y),s,a,f),ue(([[C,k],E,R,P,j])=>{let B=k&&P,$="auto";return B&&($=Ny(E,R||j),B=B&&!!$),{followOutputBehavior:$,shouldFollow:B,totalCount:C}}),Ee(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:k})=>{m&&(m(),m=null),ut(n)?requestAnimationFrame(()=>{ut(d)("following output to ",{totalCount:k},Ft.DEBUG),x(C)}):m=rn(e,()=>{ut(d)("following output to ",{totalCount:k},Ft.DEBUG),x(C),m=null})});function w(C){const k=rn(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!m&&(ut(d)("scrolling to bottom due to increased size",{},Ft.DEBUG),x("auto"))});setTimeout(k,100)}Ye(V(ht(Te(y),t,c),Ee(([C,,k])=>C&&k),vn(({value:C},[,k])=>({refreshed:C===k,value:k}),{refreshed:!1,value:0}),Ee(({refreshed:C})=>C),Fe(y,t)),([,C])=>{ut(a)&&w(C!==!1)}),Ye(v,()=>{w(ut(y)!==!1)}),Ye(ht(Te(y),o),([C,k])=>{C&&!k.atBottom&&k.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&x("auto")});const S=Z(null),T=Ue();return xe(Wi(V(Te(r),ue(C=>{var k;return(k=C==null?void 0:C.length)!=null?k:0})),V(Te(t))),T),Ye(V(ht(V(T,ur(1)),l),Fe(Te(S),a,f,h),ue(([[C,k],E,R,P,j])=>k&&R&&(E==null?void 0:E({context:j,totalCount:C,scrollingInProgress:P}))),Ee(C=>!!C),Dn(0)),C=>{m&&(m(),m=null),ut(n)?requestAnimationFrame(()=>{ut(d)("scrolling into view",{}),Oe(p,C)}):m=rn(e,()=>{ut(d)("scrolling into view",{}),Oe(p,C),m=null})}),{autoscrollToBottom:v,followOutput:y,scrollIntoViewOnChange:S}},tt(wn,lo,oo,so,Kn,Wn,Pt,vu,wu)),_y=Ve(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(xe(V(a,Fe(s),Ee(([,l])=>l!==0),Fe(o,r,t,n,e),ue(([[,l],c,d,f,h,p=[]])=>gu(l,c,d,f,h,p))),i),{}),tt(wn,so,hr,Kn),{singleton:!0}),jy=Ve(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=Z(0);return Ye(V(e,Fe(r),Ee(([,o])=>o!==0),ue(([,o])=>({top:o}))),o=>{rn(V(n,ur(1),Ee(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Oe(t,o)})})}),{initialScrollTop:r}},tt(Kn,Pt,hr),{singleton:!0}),Su=Ve(([{scrollVelocity:e}])=>{const t=Z(!1),n=Ue(),r=Z(!1);return xe(V(e,Fe(r,t,n),Ee(([o,s])=>!!s),ue(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),nt()),t),Ye(V(ht(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}},tt(lo),{singleton:!0}),ra=Ve(([{scrollContainerState:e,scrollTo:t}])=>{const n=Ue(),r=Ue(),o=Ue(),s=Z(!1),i=Z(void 0);return xe(V(ht(n,r),ue(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),xe(V(t,Fe(r),ue(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},tt(Pt)),Ry=Ve(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=Ue(),d=Z(void 0),f=Z(null),h=Z(null);return xe(a,f),xe(l,h),Ye(V(c,Fe(t,r,i,f,h,n)),([p,y,v,m,x,w,S])=>{const T=my(y.sizeTree);m&&x!==null&&w!==null&&(v=x.scrollTop-w.offsetTop),v-=S,p({ranges:T,scrollTop:v})}),xe(V(d,Ee(Hi),ue(Py)),o),xe(V(s,Fe(d),Ee(([,p])=>p!==void 0),nt(),ue(([,p])=>p.ranges)),e),{getState:c,restoreStateFrom:d}},tt(wn,Pt,so,Kn,ra));function Py(e){return{align:"start",index:0,offset:e.scrollTop}}const Oy=Ve(([{topItemsIndexes:e}])=>{const t=Z(0);return xe(V(t,Ee(n=>n>=0),ue(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},tt(hr));function Cu(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const My=Cu(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Dy=Ve(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:f,sizes:h},{log:p},{recalcInProgress:y}])=>{const v=Bt(V(l,Fe(i),vn(([,x,w,S],[{bottom:T,items:C,offsetBottom:k,totalCount:E},R])=>{const P=T+k;let j=0;return w===E&&x.length>0&&C.length>0&&(C[0].originalIndex===0&&x[0].originalIndex===0||(j=P-S,j!==0&&(j+=R))),[j,C,E,P]},[0,[],0,0]),Ee(([x])=>x!==0),Fe(r,a,n,o,p,y),Ee(([,x,w,S,,,T])=>!T&&!S&&x!==0&&w===io),ue(([[x],,,,,w])=>(w("Upward scrolling compensation",{amount:x},Ft.DEBUG),x))));function m(x){x>0?(Oe(t,{behavior:"auto",top:-x}),Oe(e,0)):(Oe(e,0),Oe(t,{behavior:"auto",top:-x}))}return Ye(V(v,Fe(e,s)),([x,w,S])=>{S&&My()?Oe(e,w-x):m(-x)}),Ye(V(ht(At(s,!1),e,y),Ee(([x,w,S])=>!x&&!S&&w!==0),ue(([x,w])=>w),Dn(1)),m),xe(V(f,ue(x=>({top:-x}))),t),Ye(V(c,Fe(h,d),ue(([x,{groupIndices:w,lastSize:S,sizeTree:T},C])=>{function k(E){return E*(S+C)}if(w.length===0)return k(x);{let E=0;const R=to(T,0);let P=0,j=0;for(;P<x;){P++,E+=R;let B=w.length===j+1?1/0:w[j+1]-w[j]-1;P+B>x&&(E-=R,B=x-P+1),P+=B,E+=k(B),j++}return E}})),x=>{Oe(e,x),requestAnimationFrame(()=>{Oe(t,{top:x}),requestAnimationFrame(()=>{Oe(e,0),Oe(y,!1)})})}),{deviation:e}},tt(Pt,lo,hr,wn,Wn,Xi)),Ly=Ve(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),tt(ta,_y,Kn,Su,yu,jy,Ey,ra,wu,Wn,vu)),ku=Ve(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:y},v,m,x,{listState:w,topItemsIndexes:S,...T},{scrollToIndex:C},k,{topItemCount:E},{groupCounts:R},P])=>(xe(T.rangeChanged,P.scrollSeekRangeChanged),xe(V(P.windowViewportRect,ue(j=>j.visibleHeight)),v.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:R,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:y,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...x,groupIndices:s,itemSize:i,listState:w,scrollToIndex:C,statefulTotalCount:c,trackItemSizes:f,...T,...P,...v,sizes:l,...m}),tt(wn,so,Pt,Ry,Ay,hr,oo,Dy,Oy,uu,Ly));function Fy(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"?b.useLayoutEffect:b.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=b.createContext({});function l(m,x){m.propsReady&&Oe(m.propsReady,!1);for(const w of r){const S=m[t.required[w]];Oe(S,x[w])}for(const w of o)if(w in x){const S=m[t.optional[w]];Oe(S,x[w])}m.propsReady&&Oe(m.propsReady,!0)}function c(m){return s.reduce((x,w)=>(x[w]=S=>{const T=m[t.methods[w]];Oe(T,S)},x),{})}function d(m){return i.reduce((x,w)=>(x[w]=ey(m[t.events[w]]),x),{})}const f=b.forwardRef((m,x)=>{const{children:w,...S}=m,[T]=b.useState(()=>Qo(ny(e),E=>{l(E,S)})),[C]=b.useState(Gc(d,T));as(()=>{for(const E of i)E in S&&Ye(C[E],S[E]);return()=>{Object.values(C).map(Ui)}},[S,C,T]),as(()=>{l(T,S)}),b.useImperativeHandle(x,Kc(c(T)));const k=n;return u.jsx(a.Provider,{value:T,children:n?u.jsx(k,{...Fy([...r,...o,...i],S),children:w}):w})}),h=m=>{const x=b.useContext(a);return b.useCallback(w=>{Oe(x[m],w)},[x,m])},p=m=>{const x=b.useContext(a)[m],w=b.useCallback(S=>Ye(x,S),[x]);return b.useSyncExternalStore(w,()=>ut(x),()=>ut(x))},y=m=>{const x=b.useContext(a)[m],[w,S]=b.useState(Gc(ut,x));return as(()=>Ye(x,T=>{T!==w&&S(Kc(T))}),[x,w]),w},v=b.version.startsWith("18")?p:y;return{Component:f,useEmitter:(m,x)=>{const w=b.useContext(a)[m];as(()=>Ye(w,x),[x,w])},useEmitterValue:v,usePublisher:h}}const Eu=b.createContext(void 0),Iu=b.createContext(void 0),Nu=typeof document<"u"?b.useLayoutEffect:b.useEffect;function oa(e){return"self"in e}function $y(e){return"body"in e}function Au(e,t,n,r=_r,o,s){const i=b.useRef(null),a=b.useRef(null),l=b.useRef(null),c=b.useCallback(h=>{let p,y,v;const m=h.target;if($y(m)||oa(m)){const w=oa(m)?m:m.defaultView;v=s?w.scrollX:w.scrollY,p=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,y=s?w.innerWidth:w.innerHeight}else v=s?m.scrollLeft:m.scrollTop,p=s?m.scrollWidth:m.scrollHeight,y=s?m.offsetWidth:m.offsetHeight;const x=()=>{e({scrollHeight:p,scrollTop:Math.max(v,0),viewportHeight:y})};h.suppressFlushSync?x():hi.flushSync(x),a.current!==null&&(v===a.current||v<=0||v===p-y)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);b.useEffect(()=>{const h=o||i.current;return r(o||i.current),c({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",c,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",c)}},[i,c,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 y=h.behavior==="smooth";let v,m,x;oa(p)?(m=Math.max(Vn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),v=s?p.innerWidth:p.innerHeight,x=s?window.scrollX:window.scrollY):(m=p[s?"scrollWidth":"scrollHeight"],v=Vn(p,s?"width":"height"),x=p[s?"scrollLeft":"scrollTop"]);const w=m-v;if(h.top=Math.ceil(Math.max(Math.min(w,h.top),0)),fu(v,m)||h.top===x){e({scrollHeight:m,scrollTop:x,viewportHeight:v}),y&&t(!0);return}y?(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",_u="sticky",ia=Cu(()=>{if(typeof document>"u")return _u;const e=document.createElement("div");return e.style.position=sa,e.style.position===sa?sa:_u});function aa(e){return e}const zy=Ve(()=>{const e=Z(a=>`Item ${a}`),t=Z(a=>`Group ${a}`),n=Z({}),r=Z(aa),o=Z("div"),s=Z(_r),i=(a,l=null)=>At(V(n,ue(c=>c[a]),nt()),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")}}),By=Ve(([e,t])=>({...e,...t}),tt(ku,zy)),Hy=({height:e})=>u.jsx("div",{style:{height:e}}),Uy={overflowAnchor:"none",position:ia(),zIndex:1},ju={overflowAnchor:"none"},Wy={...ju,display:"inline-block",height:"100%"},Ru=b.memo(function({showTopList:e=!1}){const t=_e("listState"),n=Xt("sizeRanges"),r=_e("useWindowScroll"),o=_e("customScrollParent"),s=Xt("windowScrollContainerState"),i=Xt("scrollContainerState"),a=o||r?s:i,l=_e("itemContent"),c=_e("context"),d=_e("groupContent"),f=_e("trackItemSizes"),h=_e("itemSize"),p=_e("log"),y=Xt("gap"),v=_e("horizontalDirection"),{callbackRef:m}=sy(n,h,f,e?_r:a,p,y,o,v,_e("skipAnimationFrameInResizeObserver")),[x,w]=b.useState(0);la("deviation",O=>{x!==O&&w(O)});const S=_e("EmptyPlaceholder"),T=_e("ScrollSeekPlaceholder")||Hy,C=_e("ListComponent"),k=_e("ItemComponent"),E=_e("GroupComponent"),R=_e("computeItemKey"),P=_e("isSeeking"),j=_e("groupIndices").length>0,B=_e("alignToBottom"),$=_e("initialItemFinalLocationReached"),L=e?{}:{boxSizing:"border-box",...v?{display:"inline-block",height:"100%",marginLeft:x!==0?x:B?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:x!==0?x:B?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...$?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{..._t(S,c)}):u.jsx(C,{..._t(C,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:m,style:L,children:(e?t.topItems:t.items).map(O=>{const H=O.originalIndex,W=R(H+t.firstItemIndex,O.data,c);return P?b.createElement(T,{..._t(T,c),height:O.size,index:O.index,key:W,type:O.type||"item",...O.type==="group"?{}:{groupIndex:O.groupIndex}}):O.type==="group"?b.createElement(E,{..._t(E,c),"data-index":H,"data-item-index":O.index,"data-known-size":O.size,key:W,style:Uy},d(O.index,c)):b.createElement(k,{..._t(k,c),...Gy(k,O.data),"data-index":H,"data-item-group-index":O.groupIndex,"data-item-index":O.index,"data-known-size":O.size,key:W,style:v?Wy:ju},j?l(O.index,O.groupIndex,O.data,c):l(O.index,O.data,c))})})}),Vy={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Ky={outline:"none",overflowX:"auto",position:"relative"},ls=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),qy={position:ia(),top:0,width:"100%",zIndex:1};function _t(e,t){if(typeof e!="string")return{context:t}}function Gy(e,t){return{item:typeof e=="string"?void 0:t}}const Yy=b.memo(function(){const e=_e("HeaderComponent"),t=Xt("headerHeight"),n=_e("HeaderFooterTag"),r=dr(b.useMemo(()=>s=>{t(Vn(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{..._t(e,o)})}):null}),Xy=b.memo(function(){const e=_e("FooterComponent"),t=Xt("footerHeight"),n=_e("HeaderFooterTag"),r=dr(b.useMemo(()=>s=>{t(Vn(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{..._t(e,o)})}):null});function Pu({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:y}=Au(a,c,l,d,void 0,f);return e("scrollTo",y),e("scrollBy",h),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?Ky:Vy,...o},tabIndex:0,...i,..._t(l,s),children:r})})}function Ou({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=b.useRef(null),y=t("scrollerRef"),{scrollByCallback:v,scrollerRef:m,scrollToCallback:x}=Au(a,c,l,y,h);return Nu(()=>{var w;return m.current=h||((w=p.current)==null?void 0:w.ownerDocument.defaultView),()=>{m.current=null}},[m,h]),e("windowScrollTo",x),e("scrollBy",v),u.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,..._t(l,s),children:r})})}const Jy=({children:e})=>{const t=b.useContext(Eu),n=Xt("viewportHeight"),r=Xt("fixedItemHeight"),o=_e("alignToBottom"),s=_e("horizontalDirection"),i=b.useMemo(()=>qc(n,l=>Vn(l,s?"width":"height")),[n,s]),a=dr(i,!0,_e("skipAnimationFrameInResizeObserver"));return b.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:ls(o),children:e})},Zy=({children:e})=>{const t=b.useContext(Eu),n=Xt("windowViewportRect"),r=Xt("fixedItemHeight"),o=_e("customScrollParent"),s=Zc(n,o,_e("skipAnimationFrameInResizeObserver")),i=_e("alignToBottom");return b.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:s,style:ls(i),children:e})},Qy=({children:e})=>{const t=_e("TopItemListComponent")||"div",n=_e("headerHeight"),r={...qy,marginTop:`${n}px`},o=_e("context");return u.jsx(t,{style:r,..._t(t,o),children:e})},ev=b.memo(function(e){const t=_e("useWindowScroll"),n=_e("topItemsIndexes").length>0,r=_e("customScrollParent"),o=_e("context");return u.jsxs(r||t?rv:nv,{...e,context:o,children:[n&&u.jsx(Qy,{children:u.jsx(Ru,{showTopList:!0})}),u.jsxs(r||t?Zy:Jy,{children:[u.jsx(Yy,{}),u.jsx(Ru,{}),u.jsx(Xy,{})]})]})}),{Component:tv,useEmitter:la,useEmitterValue:_e,usePublisher:Xt}=Tu(By,{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"}},ev),nv=Pu({useEmitter:la,useEmitterValue:_e,usePublisher:Xt}),rv=Ou({useEmitter:la,useEmitterValue:_e,usePublisher:Xt}),ov=tv;tt(ku,Ve(()=>{const e=Z(c=>u.jsxs("td",{children:["Item $",c]})),t=Z(null),n=Z(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=Z(null),o=Z(null),s=Z({}),i=Z(aa),a=Z(_r),l=(c,d=null)=>At(V(s,ue(f=>f[c]),nt()),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 Mu={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},sv={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Du,floor:cs,max:co,min:ca,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 iv(e){return{...sv,items:e}}function us(e,t){return e&&e.width===t.width&&e.height===t.height}function av(e,t){return e&&e.column===t.column&&e.row===t.row}const lv=Ve(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:f},h,p,{didMount:y,propsReady:v},{customScrollParent:m,useWindowScroll:x,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:T},C])=>{const k=Z(0),E=Z(0),R=Z(Mu),P=Z({height:0,width:0}),j=Z({height:0,width:0}),B=Ue(),$=Ue(),L=Z(0),O=Z(null),H=Z({column:0,row:0}),W=Ue(),se=Ue(),K=Z(!1),U=Z(0),X=Z(!0),F=Z(!1),q=Z(!1);Ye(V(y,Fe(U),Ee(([D,ee])=>!!ee)),()=>{Oe(X,!1)}),Ye(V(ht(y,X,j,P,U,F),Ee(([D,ee,re,ce,,ae])=>D&&!ee&&re.height!==0&&ce.height!==0&&!ae)),([,,,,D])=>{Oe(F,!0),Qi(1,()=>{Oe(B,D)}),rn(V(c),()=>{Oe(t,[0,0]),Oe(X,!0)})}),xe(V(se,Ee(D=>D!=null&&D.scrollTop>0),yn(0)),E),Ye(V(y,Fe(se),Ee(([,D])=>D!=null)),([,D])=>{D&&(Oe(P,D.viewport),Oe(j,D.item),Oe(H,D.gap),D.scrollTop>0&&(Oe(K,!0),rn(V(c,ur(1)),ee=>{Oe(K,!1)}),Oe(l,{top:D.scrollTop})))}),xe(V(P,ue(({height:D})=>D)),f),xe(V(ht(Te(P,us),Te(j,us),Te(H,(D,ee)=>D&&D.column===ee.column&&D.row===ee.row),Te(c)),ue(([D,ee,re,ce])=>({gap:re,item:ee,scrollTop:ce,viewport:D}))),W),xe(V(ht(Te(k),r,Te(H,av),Te(j,us),Te(P,us),Te(O),Te(E),Te(K),Te(X),Te(U)),Ee(([,,,,,,,D])=>!D),ue(([D,[ee,re],ce,ae,ie,Ge,Je,,Me,He])=>{const{column:at,row:Ke}=ce,{height:je,width:mt}=ae,{width:gt}=ie;if(Je===0&&(D===0||gt===0))return Mu;if(mt===0){const xt=ea(He,D),$t=xt+Math.max(Je-1,0);return iv(Fu(xt,$t,Ge))}const Ct=$u(gt,mt,at);let rt,te;Me?ee===0&&re===0&&Je>0?(rt=0,te=Je-1):(rt=Ct*cs((ee+Ke)/(je+Ke)),te=Ct*Du((re+Ke)/(je+Ke))-1,te=ca(D-1,co(te,Ct-1)),rt=ca(te,co(0,rt))):(rt=0,te=-1);const me=Fu(rt,te,Ge),{bottom:ve,top:We}=zu(ie,ce,ae,me),De=Du(D/Ct),et=De*je+(De-1)*Ke-ve;return{bottom:ve,itemHeight:je,items:me,itemWidth:mt,offsetBottom:et,offsetTop:We,top:We}})),R),xe(V(O,Ee(D=>D!==null),ue(D=>D.length)),k),xe(V(ht(P,j,R,H),Ee(([D,ee,{items:re}])=>re.length>0&&ee.height!==0&&D.height!==0),ue(([D,ee,{items:re},ce])=>{const{bottom:ae,top:ie}=zu(D,ce,ee,re);return[ie,ae]}),nt(no)),t);const pe=Z(!1);xe(V(c,Fe(pe),ue(([D,ee])=>ee||D!==0)),pe);const ge=Bt(V(ht(R,k),Ee(([{items:D}])=>D.length>0),Fe(pe),Ee(([[D,ee],re])=>{const ce=D.items[D.items.length-1].index===ee-1;return(re||D.bottom>0&&D.itemHeight>0&&D.offsetBottom===0&&D.items.length===ee)&&ce}),ue(([[,D]])=>D-1),nt())),ke=Bt(V(Te(R),Ee(({items:D})=>D.length>0&&D[0].index===0),yn(0),nt())),Se=Bt(V(Te(R),Fe(K),Ee(([{items:D},ee])=>D.length>0&&!ee),ue(([{items:D}])=>({endIndex:D[D.length-1].index,startIndex:D[0].index})),nt(su),Dn(0)));xe(Se,p.scrollSeekRangeChanged),xe(V(B,Fe(P,j,k,H),ue(([D,ee,re,ce,ae])=>{const ie=du(D),{align:Ge,behavior:Je,offset:Me}=ie;let He=ie.index;He==="LAST"&&(He=ce-1),He=co(0,He,ca(ce-1,He));let at=ua(ee,ae,re,He);return Ge==="end"?at=Lu(at-ee.height+re.height):Ge==="center"&&(at=Lu(at-ee.height/2+re.height/2)),Me&&(at+=Me),{behavior:Je,top:at}})),l);const J=At(V(R,ue(D=>D.offsetBottom+D.bottom)),0);return xe(V(T,ue(D=>({height:D.visibleHeight,width:D.visibleWidth}))),P),{customScrollParent:m,data:O,deviation:L,footerHeight:o,gap:H,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:j,overscan:n,restoreStateFrom:se,scrollBy:i,scrollContainerState:a,scrollHeight:$,scrollTo:l,scrollToIndex:B,scrollTop:c,smoothScrollTargetReached:d,totalCount:k,useWindowScroll:x,viewportDimensions:P,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:T,...p,gridState:R,horizontalDirection:q,initialTopMostItemIndex:U,totalListHeight:J,...h,endReached:ge,propsReady:v,rangeChanged:Se,startReached:ke,stateChanged:W,stateRestoreInProgress:K,...C}},tt(ta,Pt,lo,Su,Kn,ra,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=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=$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 cv=Ve(()=>{const e=Z(f=>`Item ${f}`),t=Z({}),n=Z(null),r=Z("virtuoso-grid-item"),o=Z("virtuoso-grid-list"),s=Z(aa),i=Z("div"),a=Z(_r),l=(f,h=null)=>At(V(t,ue(p=>p[f]),nt()),h),c=Z(!1),d=Z(!1);return xe(Te(d),c),{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:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),uv=Ve(([e,t])=>({...e,...t}),tt(lv,cv)),dv=b.memo(function(){const e=ot("gridState"),t=ot("listClassName"),n=ot("itemClassName"),r=ot("itemContent"),o=ot("computeItemKey"),s=ot("isSeeking"),i=Jt("scrollHeight"),a=ot("ItemComponent"),l=ot("ListComponent"),c=ot("ScrollSeekPlaceholder"),d=ot("context"),f=Jt("itemDimensions"),h=Jt("gap"),p=ot("log"),y=ot("stateRestoreInProgress"),v=Jt("reportReadyState"),m=dr(b.useMemo(()=>x=>{const w=x.parentElement.parentElement.scrollHeight;i(w);const S=x.firstChild;if(S){const{height:T,width:C}=S.getBoundingClientRect();f({height:T,width:C})}h({column:Hu("column-gap",getComputedStyle(x).columnGap,p),row:Hu("row-gap",getComputedStyle(x).rowGap,p)})},[i,f,h,p]),!0,!1);return Nu(()=>{e.itemHeight>0&&e.itemWidth>0&&v(!0)},[e]),y?null:u.jsx(l,{className:t,ref:m,..._t(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(x=>{const w=o(x.index,x.data,d);return s?u.jsx(c,{..._t(c,d),height:e.itemHeight,index:x.index,width:e.itemWidth},w):b.createElement(a,{..._t(a,d),className:n,"data-index":x.index,key:w},r(x.index,x.data,d))})})}),fv=b.memo(function(){const e=ot("HeaderComponent"),t=Jt("headerHeight"),n=ot("headerFooterTag"),r=dr(b.useMemo(()=>s=>{t(Vn(s,"height"))},[t]),!0,!1),o=ot("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{..._t(e,o)})}):null}),hv=b.memo(function(){const e=ot("FooterComponent"),t=Jt("footerHeight"),n=ot("headerFooterTag"),r=dr(b.useMemo(()=>s=>{t(Vn(s,"height"))},[t]),!0,!1),o=ot("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{..._t(e,o)})}):null}),pv=({children:e})=>{const t=b.useContext(Iu),n=Jt("itemDimensions"),r=Jt("viewportDimensions"),o=dr(b.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return b.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),u.jsx("div",{ref:o,style:ls(!1),children:e})},mv=({children:e})=>{const t=b.useContext(Iu),n=Jt("windowViewportRect"),r=Jt("itemDimensions"),o=ot("customScrollParent"),s=Zc(n,o,!1);return b.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),u.jsx("div",{ref:s,style:ls(!1),children:e})},gv=b.memo(function({...e}){const t=ot("useWindowScroll"),n=ot("customScrollParent"),r=n||t?yv:xv,o=n||t?mv:pv,s=ot("context");return u.jsx(r,{...e,..._t(r,s),children:u.jsxs(o,{children:[u.jsx(fv,{}),u.jsx(dv,{}),u.jsx(hv,{})]})})}),{useEmitter:Bu,useEmitterValue:ot,usePublisher:Jt}=Tu(uv,{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"}},gv),xv=Pu({useEmitter:Bu,useEmitterValue:ot,usePublisher:Jt}),yv=Ou({useEmitter:Bu,useEmitterValue:ot,usePublisher:Jt});function Hu(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ft.WARN),t==="normal"?0:parseInt(t??"0",10)}const vv=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 u.jsx("div",{className:oe(vv({variant:t}),e),...n})}function fe(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 wv(e,t){const n=g.createContext(t),r=s=>{const{children:i,...a}=s,l=g.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=g.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 bn(e,t=[]){let n=[];function r(s,i){const a=g.createContext(i),l=n.length;n=[...n,i];const c=f=>{var x;const{scope:h,children:p,...y}=f,v=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,m=g.useMemo(()=>y,Object.values(y));return u.jsx(v.Provider,{value:m,children:p})};c.displayName=s+"Provider";function d(f,h){var v;const p=((v=h==null?void 0:h[e])==null?void 0:v[l])||a,y=g.useContext(p);if(y)return y;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>g.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return g.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,bv(o,...t)]}function bv(...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:c})=>{const f=l(s)[`__scope${c}`];return{...a,...f}},{});return g.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var yt=globalThis!=null&&globalThis.document?g.useLayoutEffect:()=>{},Sv=g[" useInsertionEffect ".trim().toString()]||yt;function pr({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Cv({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=g.useRef(e!==void 0);g.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 c=g.useCallback(d=>{var f;if(a){const h=kv(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[l,c]}function Cv({defaultProp:e,onChange:t}){const[n,r]=g.useState(e),o=g.useRef(n),s=g.useRef(t);return Sv(()=>{s.current=t},[t]),g.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function kv(e){return typeof e=="function"}function Wu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function da(...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 Be(...e){return g.useCallback(da(...e),e)}var Tv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ie=Tv.reduce((e,t)=>{const n=sr.createSlot(`Primitive.${t}`),r=g.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Vu(e,t){e&&Po.flushSync(()=>e.dispatchEvent(t))}function Ev(e,t){return g.useReducer((n,r)=>t[n][r]??n,e)}var Ut=e=>{const{present:t,children:n}=e,r=Iv(t),o=typeof n=="function"?n({present:r.isPresent}):g.Children.only(n),s=Be(r.ref,Nv(o));return typeof n=="function"||r.isPresent?g.cloneElement(o,{ref:s}):null};Ut.displayName="Presence";function Iv(e){const[t,n]=g.useState(),r=g.useRef(null),o=g.useRef(e),s=g.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Ev(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const c=ds(r.current);s.current=a==="mounted"?c:"none"},[a]),yt(()=>{const c=r.current,d=o.current;if(d!==e){const h=s.current,p=ds(c);e?l("MOUNT"):p==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),yt(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,f=p=>{const v=ds(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&v&&(l("ANIMATION_END"),!o.current)){const m=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=m)})}},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(c),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:g.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function ds(e){return(e==null?void 0:e.animationName)||"none"}function Nv(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 Av=g[" useId ".trim().toString()]||(()=>{}),_v=0;function Sn(e){const[t,n]=g.useState(Av());return yt(()=>{n(r=>r??String(_v++))},[e]),e||(t?`radix-${t}`:"")}var fs="Collapsible",[jv,vT]=bn(fs),[Rv,fa]=jv(fs),Ku=g.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,c]=pr({prop:r,defaultProp:o??!1,onChange:i,caller:fs});return u.jsx(Rv,{scope:n,disabled:s,contentId:Sn(),open:l,onOpenToggle:g.useCallback(()=>c(d=>!d),[c]),children:u.jsx(Ie.div,{"data-state":pa(l),"data-disabled":s?"":void 0,...a,ref:t})})});Ku.displayName=fs;var qu="CollapsibleTrigger",Gu=g.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=fa(qu,n);return u.jsx(Ie.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":pa(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:fe(e.onClick,o.onOpenToggle)})});Gu.displayName=qu;var ha="CollapsibleContent",Pv=g.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=fa(ha,e.__scopeCollapsible);return u.jsx(Ut,{present:n||o.open,children:({present:s})=>u.jsx(Ov,{...r,ref:t,present:s})})});Pv.displayName=ha;var Ov=g.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=fa(ha,n),[a,l]=g.useState(r),c=g.useRef(null),d=Be(t,c),f=g.useRef(0),h=f.current,p=g.useRef(0),y=p.current,v=i.open||a,m=g.useRef(v),x=g.useRef(void 0);return g.useEffect(()=>{const w=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(w)},[]),yt(()=>{const w=c.current;if(w){x.current=x.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const S=w.getBoundingClientRect();f.current=S.height,p.current=S.width,m.current||(w.style.transitionDuration=x.current.transitionDuration,w.style.animationName=x.current.animationName),l(r)}},[i.open,r]),u.jsx(Ie.div,{"data-state":pa(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!v,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":y?`${y}px`:void 0,...e.style},children:v&&o})});function pa(e){return e?"open":"closed"}var Mv=Ku;const Dv=Mv,Lv=Gu,uo=g.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));uo.displayName="Card";const fo=g.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("flex flex-col space-y-1.5 p-6",e),...t}));fo.displayName="CardHeader";const ho=g.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:oe("text-2xl font-semibold leading-none tracking-tight",e),...t}));ho.displayName="CardTitle";const Yu=g.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));Yu.displayName="CardDescription";const po=g.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("p-6 pt-0",e),...t}));po.displayName="CardContent";const Xu=g.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("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 mr=Ju();function Fv(e){mr=e}const Zu=/[&<>"']/,$v=new RegExp(Zu.source,"g"),Qu=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,zv=new RegExp(Qu.source,"g"),Bv={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ed=e=>Bv[e];function jt(e,t){if(t){if(Zu.test(e))return e.replace($v,ed)}else if(Qu.test(e))return e.replace(zv,ed);return e}const Hv=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function td(e){return e.replace(Hv,(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 Uv=/(^|[^\[])\^/g;function Qe(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(Uv,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const Wv=/[^\w:]/g,Vv=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function nd(e,t,n){if(e){let r;try{r=decodeURIComponent(td(n)).replace(Wv,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!Vv.test(n)&&(n=Yv(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const hs={},Kv=/^[^:]+:\/*[^/]*$/,qv=/^([^:]+:)[\s\S]*$/,Gv=/^([^:]+:\/*[^/]*)[\s\S]*$/;function Yv(e,t){hs[" "+e]||(Kv.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(qv,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(Gv,"$1")+t:e+t}const ps={exec:function(){}};function rd(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,c=i;for(;--c>=0&&a[c]==="\\";)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 Xv(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 Jv(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?jt(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:jt(i)}}function Zv(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||mr}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,x,v=n[1].trim();const m=v.length>1,y={type:"list",raw:"",ordered:m,start:m?+v.slice(0,-1):"",loose:!1,items:[]};v=m?`\\d{1,9}\\${v.slice(-1)}`:`\\${v}`,this.options.pedantic&&(v=m?v:"[*+-]");const b=new RegExp(`^( {0,3}${v})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(x=!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 ma{constructor(t){this.options=t||mr}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=Zv(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,c,d,f,h,p,y,v=n[1].trim();const m=v.length>1,x={type:"list",raw:"",ordered:m,start:m?+v.slice(0,-1):"",loose:!1,items:[]};v=m?`\\d{1,9}\\${v.slice(-1)}`:`\\${v}`,this.options.pedantic&&(v=m?v:"[*+-]");const w=new RegExp(`^( {0,3}${v})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(y=!1,!(!(n=w.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+/,T=>" ".repeat(3*T.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),x=!0),!x){const T=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),C=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),E=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(h=t.split(`
44
+ `,t=t.substring(f.length+1),y=!0),!y){const T=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),C=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),E=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(h=t.split(`
45
45
  `,1)[0],f=h,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(k.test(f)||E.test(f)||T.test(f)||C.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())p+=`
46
46
  `+f.slice(i);else{if(l||d.search(/[^ ]/)>=4||k.test(d)||E.test(d)||C.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 S=y.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const T=y.items[a].tokens.filter(k=>k.type==="space"),C=T.length>0&&T.some(k=>/\n.*\n/.test(k.raw));y.loose=C}if(y.loose)for(a=0;a<S;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]):jt(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:jt(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]):jt(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 x=h.slice(1,-1);return{type:"em",raw:h,text:x,tokens:this.lexer.inlineTokens(x)}}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=jt(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=jt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=jt(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=jt(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=jt(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]):jt(r[0]):r[0]:o=jt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const be={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]+/};be._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,be._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,be.def=Qe(be.def).replace("label",be._label).replace("title",be._title).getRegex(),be.bullet=/(?:[*+-]|\d{1,9}[.)])/,be.listItemStart=Qe(/^( *)(bull) */).replace("bull",be.bullet).getRegex(),be.list=Qe(be.list).replace(/bull/g,be.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+be.def.source+")").getRegex(),be._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",be._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,be.html=Qe(be.html,"i").replace("comment",be._comment).replace("tag",be._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),be.paragraph=Qe(be._paragraph).replace("hr",be.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",be._tag).getRegex(),be.blockquote=Qe(be.blockquote).replace("paragraph",be.paragraph).getRegex(),be.normal={...be},be.gfm={...be.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},be.gfm.table=Qe(be.gfm.table).replace("hr",be.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",be._tag).getRegex(),be.gfm.paragraph=Qe(be._paragraph).replace("hr",be.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",be.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",be._tag).getRegex(),be.pedantic={...be.normal,html:Qe(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",be._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:Qe(be.normal._paragraph).replace("hr",be.hr).replace("heading",` *#{1,6} *[^
51
- ]`).replace("lheading",be.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=Qe(fe.punctuation).replace(/punctuation/g,fe._punctuation).getRegex(),fe.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,fe.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,fe._comment=Qe(be._comment).replace("(?:-->|$)","-->").getRegex(),fe.emStrong.lDelim=Qe(fe.emStrong.lDelim).replace(/punct/g,fe._punctuation).getRegex(),fe.emStrong.rDelimAst=Qe(fe.emStrong.rDelimAst,"g").replace(/punct/g,fe._punctuation).getRegex(),fe.emStrong.rDelimUnd=Qe(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=Qe(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=Qe(fe.tag).replace("comment",fe._comment).replace("attribute",fe._attribute).getRegex(),fe._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,fe._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,fe._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,fe.link=Qe(fe.link).replace("label",fe._label).replace("href",fe._href).replace("title",fe._title).getRegex(),fe.reflink=Qe(fe.reflink).replace("label",fe._label).replace("ref",be._label).getRegex(),fe.nolink=Qe(fe.nolink).replace("ref",be._label).getRegex(),fe.reflinkSearch=Qe(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:Qe(/^!?\[(label)\]\((.*?)\)/).replace("label",fe._label).getRegex(),reflink:Qe(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",fe._label).getRegex()},fe.gfm={...fe.normal,escape:Qe(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=Qe(fe.gfm.url,"i").replace("email",fe.gfm._extended_email).getRegex(),fe.breaks={...fe.gfm,br:Qe(fe.br).replace("{2,}","*").getRegex(),text:Qe(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||mr,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:be.normal,inline:fe.normal};this.options.pedantic?(n.block=be.pedantic,n.inline=fe.pedantic):this.options.gfm&&(n.block=be.gfm,this.options.breaks?n.inline=fe.breaks:n.inline=fe.gfm),this.tokenizer.rules=n}static get rules(){return{block:be,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
- `),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+=`
48
+ `,t=t.substring(h.length+1),d=f.slice(i)}}x.loose||(c?x.loose=!0:/\n *\n *$/.test(r)&&(c=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),x.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),x.raw+=r}x.items[x.items.length-1].raw=r.trimRight(),x.items[x.items.length-1].text=p.trimRight(),x.raw=x.raw.trimRight();const S=x.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,x.items[a].tokens=this.lexer.blockTokens(x.items[a].text,[]),!x.loose){const T=x.items[a].tokens.filter(k=>k.type==="space"),C=T.length>0&&T.some(k=>/\n.*\n/.test(k.raw));x.loose=C}if(x.loose)for(a=0;a<S;a++)x.items[a].loose=!0;return x}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):jt(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(c=>({text:c}));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:jt(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]):jt(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=Xv(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,c=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]){c+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c+d);const h=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const y=h.slice(1,-1);return{type:"em",raw:h,text:y,tokens:this.lexer.inlineTokens(y)}}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=jt(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=jt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=jt(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=jt(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=jt(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]):jt(r[0]):r[0]:o=jt(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=Qe(we.def).replace("label",we._label).replace("title",we._title).getRegex(),we.bullet=/(?:[*+-]|\d{1,9}[.)])/,we.listItemStart=Qe(/^( *)(bull) */).replace("bull",we.bullet).getRegex(),we.list=Qe(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=Qe(we.html,"i").replace("comment",we._comment).replace("tag",we._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),we.paragraph=Qe(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=Qe(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=Qe(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=Qe(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:Qe(`^ *(?: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:Qe(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 de={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])/};de._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",de.punctuation=Qe(de.punctuation).replace(/punctuation/g,de._punctuation).getRegex(),de.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,de.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,de._comment=Qe(we._comment).replace("(?:-->|$)","-->").getRegex(),de.emStrong.lDelim=Qe(de.emStrong.lDelim).replace(/punct/g,de._punctuation).getRegex(),de.emStrong.rDelimAst=Qe(de.emStrong.rDelimAst,"g").replace(/punct/g,de._punctuation).getRegex(),de.emStrong.rDelimUnd=Qe(de.emStrong.rDelimUnd,"g").replace(/punct/g,de._punctuation).getRegex(),de._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,de._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,de._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])?)+(?![-_])/,de.autolink=Qe(de.autolink).replace("scheme",de._scheme).replace("email",de._email).getRegex(),de._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,de.tag=Qe(de.tag).replace("comment",de._comment).replace("attribute",de._attribute).getRegex(),de._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,de._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,de._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,de.link=Qe(de.link).replace("label",de._label).replace("href",de._href).replace("title",de._title).getRegex(),de.reflink=Qe(de.reflink).replace("label",de._label).replace("ref",we._label).getRegex(),de.nolink=Qe(de.nolink).replace("ref",we._label).getRegex(),de.reflinkSearch=Qe(de.reflinkSearch,"g").replace("reflink",de.reflink).replace("nolink",de.nolink).getRegex(),de.normal={...de},de.pedantic={...de.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:Qe(/^!?\[(label)\]\((.*?)\)/).replace("label",de._label).getRegex(),reflink:Qe(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",de._label).getRegex()},de.gfm={...de.normal,escape:Qe(de.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},de.gfm.url=Qe(de.gfm.url,"i").replace("email",de.gfm._extended_email).getRegex(),de.breaks={...de.gfm,br:Qe(de.br).replace("{2,}","*").getRegex(),text:Qe(de.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function Qv(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||mr,this.options.tokenizer=this.options.tokenizer||new ma,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:de.normal};this.options.pedantic?(n.block=we.pedantic,n.inline=de.pedantic):this.options.gfm&&(n.block=we.gfm,this.options.breaks?n.inline=de.breaks:n.inline=de.gfm),this.tokenizer.rules=n}static get rules(){return{block:we,inline:de}}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
+ `),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,c)=>l+" ".repeat(c.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+=`
55
55
  `+r.text,this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(r=this.tokenizer.fences(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.heading(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.hr(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.blockquote(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.list(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.html(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.def(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&(o.type==="paragraph"||o.type==="text")?(o.raw+=`
56
56
  `+r.raw,o.text+=`
57
- `+r.raw,this.inlineQueue[this.inlineQueue.length-1].src=o.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if(r=this.tokenizer.table(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(t)){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startBlock){let a=1/0;const l=t.slice(1);let u;this.options.extensions.startBlock.forEach(function(d){u=d.call({lexer:this},l),typeof u=="number"&&u>=0&&(a=Math.min(a,u))}),a<1/0&&a>=0&&(s=t.substring(0,a+1))}if(this.state.top&&(r=this.tokenizer.paragraph(s))){o=n[n.length-1],i&&o.type==="paragraph"?(o.raw+=`
57
+ `+r.raw,this.inlineQueue[this.inlineQueue.length-1].src=o.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if(r=this.tokenizer.table(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(t)){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startBlock){let a=1/0;const l=t.slice(1);let c;this.options.extensions.startBlock.forEach(function(d){c=d.call({lexer:this},l),typeof c=="number"&&c>=0&&(a=Math.min(a,c))}),a<1/0&&a>=0&&(s=t.substring(0,a+1))}if(this.state.top&&(r=this.tokenizer.paragraph(s))){o=n[n.length-1],i&&o.type==="paragraph"?(o.raw+=`
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)+"["+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||mr}code(t,n,r){const o=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(t,o);s!=null&&s!==t&&(r=!0,t=s)}return t=t.replace(/\n$/,"")+`
61
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,l,c;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||(c=""),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,c)){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,Qv)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(c=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 ga{constructor(t){this.options=t||mr}code(t,n,r){const o=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(t,o);s!=null&&s!==t&&(r=!0,t=s)}return t=t.replace(/\n$/,"")+`
62
62
  `,o?'<pre><code class="'+this.options.langPrefix+jt(o)+'">'+(r?t:jt(t,!0))+`</code></pre>
63
63
  `:"<pre><code>"+(r?t:jt(t,!0))+`</code></pre>
64
64
  `}blockquote(t){return`<blockquote>
@@ -78,10 +78,10 @@ ${t}</blockquote>
78
78
  `}tablerow(t){return`<tr>
79
79
  ${t}</tr>
80
80
  `}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
81
- `}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=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||mr,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,x,v,m,y,b,S,T,C,k;const E=t.length;for(o=0;o<E;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,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(x=p.ordered,v=p.start,m=p.loose,a=p.items.length,h="",s=0;s<a;s++)b=p.items[s],S=b.checked,T=b.task,y="",b.task&&(C=this.renderer.checkbox(S),m?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=C+" "+b.tokens[0].text,b.tokens[0].tokens&&b.tokens[0].tokens.length>0&&b.tokens[0].tokens[0].type==="text"&&(b.tokens[0].tokens[0].text=C+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:C}):y+=C),y+=this.parse(b.tokens,m),h+=this.renderer.listitem(y,T,S);r+=this.renderer.list(h,x,v);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<E&&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 R='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(R);return}else throw new Error(R)}}}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||mr}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>"+jt(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={...we.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&&we.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;we.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(we.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&&we.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function we(e,t,n){return cd(qn.lex,Gn.parse)(e,t,n)}we.options=we.setOptions=function(e){return we.defaults={...we.defaults,...e},zv(we.defaults),we},we.getDefaults=Ju,we.defaults=mr,we.use=function(...e){const t=we.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=we.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=we.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=we.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=we.defaults.hooks||new gs;for(const s in n.hooks){const i=o[s];gs.passThroughHooks.has(s)?o[s]=a=>{if(we.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=we.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}}we.setOptions(r)})},we.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(we,r)),r.type){case"table":{for(const o of r.header)n=n.concat(we.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(we.walkTokens(s.tokens,t));break}case"list":{n=n.concat(we.walkTokens(r.items,t));break}default:we.defaults.extensions&&we.defaults.extensions.childTokens&&we.defaults.extensions.childTokens[r.type]?we.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(we.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(we.walkTokens(r.tokens,t)))}return n},we.parseInline=cd(qn.lexInline,Gn.parseInline),we.Parser=Gn,we.parser=Gn.parse,we.Renderer=xa,we.TextRenderer=ad,we.Lexer=qn,we.lexer=qn.lex,we.Tokenizer=ga,we.Slugger=ld,we.Hooks=gs,we.parse=we,we.options,we.setOptions,we.use,we.walkTokens,we.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 we.parse(i)}return we.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:oe("markdown prose max-w-none break-words dark:prose-invert",t),style:s,dangerouslySetInnerHTML:{__html:o}})}async function ud(e,t){return await nn(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 nn(`/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 nn("/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]=g.useState(ys);return g.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 St(e){const t=g.useRef(e);return g.useEffect(()=>{t.current=e}),g.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=St(e);g.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=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),vs=g.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=g.useContext(pd),[d,f]=g.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=g.useState({}),x=He(t,E=>f(E)),v=Array.from(u.layers),[m]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(m),b=d?v.indexOf(d):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,T=b>=y,C=gb(E=>{const R=E.target,P=[...u.branches].some(j=>j.contains(R));!T||P||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},h),k=xb(E=>{const R=E.target;[...u.branches].some(j=>j.contains(R))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},h);return ub(E=>{b===u.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},h),g.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]),g.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),md())},[d,u]),g.useEffect(()=>{const E=()=>p({});return document.addEventListener(Sa,E),()=>document.removeEventListener(Sa,E)},[]),c.jsx(Ie.div,{...l,ref:x,style:{pointerEvents:S?T?"auto":"none":void 0,...e.style},onFocusCapture:he(e.onFocusCapture,k.onFocusCapture),onBlurCapture:he(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:he(e.onPointerDownCapture,C.onPointerDownCapture)})});vs.displayName=db;var pb="DismissableLayerBranch",mb=g.forwardRef((e,t)=>{const n=g.useContext(pd),r=g.useRef(null),o=He(t,r);return g.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})});mb.displayName=pb;function gb(e,t=globalThis==null?void 0:globalThis.document){const n=St(e),r=g.useRef(!1),o=g.useRef(()=>{});return g.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=St(e),r=g.useRef(!1);return g.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=g.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=g.useState(null),u=St(o),d=St(s),f=g.useRef(null),h=He(t,v=>l(v)),p=g.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;g.useEffect(()=>{if(r){let v=function(S){if(p.paused||!a)return;const T=S.target;a.contains(T)?f.current=T:Yn(f.current,{select:!0})},m=function(S){if(p.paused||!a)return;const T=S.relatedTarget;T!==null&&(a.contains(T)||Yn(f.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Yn(a)};document.addEventListener("focusin",v),document.addEventListener("focusout",m);const b=new MutationObserver(y);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",m),b.disconnect()}}},[r,a,p.paused]),g.useEffect(()=>{if(a){bd.add(p);const v=document.activeElement;if(!a.contains(v)){const y=new CustomEvent(Ca,xd);a.addEventListener(Ca,u),a.dispatchEvent(y),y.defaultPrevented||(vb(kb(yd(a)),{select:!0}),document.activeElement===v&&Yn(a))}return()=>{a.removeEventListener(Ca,u),setTimeout(()=>{const y=new CustomEvent(ka,xd);a.addEventListener(ka,d),a.dispatchEvent(y),y.defaultPrevented||Yn(v??document.body,{select:!0}),a.removeEventListener(ka,d),bd.remove(p)},0)}}},[a,u,d,p]);const x=g.useCallback(v=>{if(!n&&!r||p.paused)return;const m=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,y=document.activeElement;if(m&&y){const b=v.currentTarget,[S,T]=bb(b);S&&T?!v.shiftKey&&y===T?(v.preventDefault(),n&&Yn(S,{select:!0})):v.shiftKey&&y===S&&(v.preventDefault(),n&&Yn(T,{select:!0})):y===b&&v.preventDefault()}},[n,r,p.paused]);return c.jsx(Ie.div,{tabIndex:-1,...i,ref:h,onKeyDown:x})});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=g.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=g.useState(!1);yt(()=>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});ws.displayName=Tb;var Ta=0;function Ea(){g.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 Cn=function(){return Cn=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},Cn.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"?g.useLayoutEffect:g.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=Cn({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 g.createElement(r,Cn({},n))};Td.isSideCarExport=!0;function Mb(e,t){return e.useMedium(t),Td}var Ed=Ob(),Aa=function(){},ks=g.forwardRef(function(e,t){var n=g.useRef(null),r=g.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,x=e.noIsolation,v=e.inert,m=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,S=e.gapMode,T=Cd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,k=jb([n,t]),E=Cn(Cn({},T),o);return g.createElement(g.Fragment,null,d&&g.createElement(C,{sideCar:Ed,removeScrollBar:u,shards:f,noRelative:p,noIsolation:x,inert:v,setCallbacks:s,allowPinchZoom:!!m,lockRef:n,gapMode:S}),i?g.cloneElement(g.Children.only(a),Cn(Cn({},E),{ref:k})):g.createElement(b,Cn({},E,{className:l,ref:k}),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){g.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,` {
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||mr,this.options.renderer=this.options.renderer||new ga,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,c,d,f,h,p,y,v,m,x,w,S,T,C,k;const E=t.length;for(o=0;o<E;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,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(c=p.rows[s],d="",l=c.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(c[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(y=p.ordered,v=p.start,m=p.loose,a=p.items.length,h="",s=0;s<a;s++)w=p.items[s],S=w.checked,T=w.task,x="",w.task&&(C=this.renderer.checkbox(S),m?w.tokens.length>0&&w.tokens[0].type==="paragraph"?(w.tokens[0].text=C+" "+w.tokens[0].text,w.tokens[0].tokens&&w.tokens[0].tokens.length>0&&w.tokens[0].tokens[0].type==="text"&&(w.tokens[0].tokens[0].text=C+" "+w.tokens[0].tokens[0].text)):w.tokens.unshift({type:"text",text:C}):x+=C),x+=this.parse(w.tokens,m),h+=this.renderer.listitem(x,T,S);r+=this.renderer.list(h,y,v);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<E&&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 R='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(R);return}else throw new Error(R)}}}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||mr}preprocess(t){return t}postprocess(t){return t}}bm(gs,"passThroughHooks",new Set(["preprocess","postprocess"]));function ew(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>"+jt(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={...be.defaults,...s};const i=ew(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(Jv(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 c=function(f){let h;if(!f)try{r.walkTokens&&be.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 c();let d=0;be.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(h,p){if(h)return c(h);p!=null&&p!==f.text&&(f.text=p,f.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();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(be.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&&be.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function be(e,t,n){return cd(qn.lex,Gn.parse)(e,t,n)}be.options=be.setOptions=function(e){return be.defaults={...be.defaults,...e},Fv(be.defaults),be},be.getDefaults=Ju,be.defaults=mr,be.use=function(...e){const t=be.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=be.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=be.defaults.renderer||new ga;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=be.defaults.tokenizer||new ma;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=be.defaults.hooks||new gs;for(const s in n.hooks){const i=o[s];gs.passThroughHooks.has(s)?o[s]=a=>{if(be.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));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=be.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}}be.setOptions(r)})},be.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(be,r)),r.type){case"table":{for(const o of r.header)n=n.concat(be.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(be.walkTokens(s.tokens,t));break}case"list":{n=n.concat(be.walkTokens(r.items,t));break}default:be.defaults.extensions&&be.defaults.extensions.childTokens&&be.defaults.extensions.childTokens[r.type]?be.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(be.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(be.walkTokens(r.tokens,t)))}return n},be.parseInline=cd(qn.lexInline,Gn.parseInline),be.Parser=Gn,be.parser=Gn.parse,be.Renderer=ga,be.TextRenderer=ad,be.Lexer=qn,be.lexer=qn.lex,be.Tokenizer=ma,be.Slugger=ld,be.Hooks=gs,be.parse=be,be.options,be.setOptions,be.use,be.walkTokens,be.parseInline,Gn.parse,qn.lex;function xa({content:e,className:t="",allowHtml:n=!1,style:r}){const o=b.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 be.parse(i)}return be.parse(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre>Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=b.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 u.jsx("div",{className:oe("markdown prose max-w-none break-words dark:prose-invert",t),style:s,dangerouslySetInnerHTML:{__html:o}})}async function ud(e,t){return await nn(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 tw(e,t){const n=await ud(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await nn(`/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 nw(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await nn("/files",{params:r})}const rw=1,ow=1e6;let ya=0;function sw(){return ya=(ya+1)%Number.MAX_SAFE_INTEGER,ya.toString()}const va=new Map,fd=e=>{if(va.has(e))return;const t=setTimeout(()=>{va.delete(e),mo({type:"REMOVE_TOAST",toastId:e})},ow);va.set(e,t)},iw=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,rw)};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=iw(ys,e),xs.forEach(t=>{t(ys)})}function aw({...e}){const t=sw(),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]=g.useState(ys);return g.useEffect(()=>(xs.push(t),()=>{const n=xs.indexOf(t);n>-1&&xs.splice(n,1)}),[e]),{...e,toast:aw,dismiss:n=>mo({type:"DISMISS_TOAST",toastId:n})}}function St(e){const t=g.useRef(e);return g.useEffect(()=>{t.current=e}),g.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function lw(e,t=globalThis==null?void 0:globalThis.document){const n=St(e);g.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 cw="DismissableLayer",ba="dismissableLayer.update",uw="dismissableLayer.pointerDownOutside",dw="dismissableLayer.focusOutside",hd,pd=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),vs=g.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=g.useContext(pd),[d,f]=g.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=g.useState({}),y=Be(t,E=>f(E)),v=Array.from(c.layers),[m]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),x=v.indexOf(m),w=d?v.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,T=w>=x,C=pw(E=>{const R=E.target,P=[...c.branches].some(j=>j.contains(R));!T||P||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},h),k=mw(E=>{const R=E.target;[...c.branches].some(j=>j.contains(R))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},h);return lw(E=>{w===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},h),g.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(hd=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),md(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=hd)}},[d,h,n,c]),g.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),md())},[d,c]),g.useEffect(()=>{const E=()=>p({});return document.addEventListener(ba,E),()=>document.removeEventListener(ba,E)},[]),u.jsx(Ie.div,{...l,ref:y,style:{pointerEvents:S?T?"auto":"none":void 0,...e.style},onFocusCapture:fe(e.onFocusCapture,k.onFocusCapture),onBlurCapture:fe(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:fe(e.onPointerDownCapture,C.onPointerDownCapture)})});vs.displayName=cw;var fw="DismissableLayerBranch",hw=g.forwardRef((e,t)=>{const n=g.useContext(pd),r=g.useRef(null),o=Be(t,r);return g.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(Ie.div,{...e,ref:o})});hw.displayName=fw;function pw(e,t=globalThis==null?void 0:globalThis.document){const n=St(e),r=g.useRef(!1),o=g.useRef(()=>{});return g.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){gd(uw,n,c,{discrete:!0})};const c={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 mw(e,t=globalThis==null?void 0:globalThis.document){const n=St(e),r=g.useRef(!1);return g.useEffect(()=>{const o=s=>{s.target&&!r.current&&gd(dw,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(ba);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 Sa="focusScope.autoFocusOnMount",Ca="focusScope.autoFocusOnUnmount",xd={bubbles:!1,cancelable:!0},gw="FocusScope",ws=g.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=g.useState(null),c=St(o),d=St(s),f=g.useRef(null),h=Be(t,v=>l(v)),p=g.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;g.useEffect(()=>{if(r){let v=function(S){if(p.paused||!a)return;const T=S.target;a.contains(T)?f.current=T:Yn(f.current,{select:!0})},m=function(S){if(p.paused||!a)return;const T=S.relatedTarget;T!==null&&(a.contains(T)||Yn(f.current,{select:!0}))},x=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Yn(a)};document.addEventListener("focusin",v),document.addEventListener("focusout",m);const w=new MutationObserver(x);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",m),w.disconnect()}}},[r,a,p.paused]),g.useEffect(()=>{if(a){wd.add(p);const v=document.activeElement;if(!a.contains(v)){const x=new CustomEvent(Sa,xd);a.addEventListener(Sa,c),a.dispatchEvent(x),x.defaultPrevented||(xw(Sw(yd(a)),{select:!0}),document.activeElement===v&&Yn(a))}return()=>{a.removeEventListener(Sa,c),setTimeout(()=>{const x=new CustomEvent(Ca,xd);a.addEventListener(Ca,d),a.dispatchEvent(x),x.defaultPrevented||Yn(v??document.body,{select:!0}),a.removeEventListener(Ca,d),wd.remove(p)},0)}}},[a,c,d,p]);const y=g.useCallback(v=>{if(!n&&!r||p.paused)return;const m=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,x=document.activeElement;if(m&&x){const w=v.currentTarget,[S,T]=yw(w);S&&T?!v.shiftKey&&x===T?(v.preventDefault(),n&&Yn(S,{select:!0})):v.shiftKey&&x===S&&(v.preventDefault(),n&&Yn(T,{select:!0})):x===w&&v.preventDefault()}},[n,r,p.paused]);return u.jsx(Ie.div,{tabIndex:-1,...i,ref:h,onKeyDown:y})});ws.displayName=gw;function xw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Yn(r,{select:t}),document.activeElement!==n)return}function yw(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(!vw(n,{upTo:t}))return n}function vw(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 ww(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&&ww(e)&&t&&e.select()}}var wd=bw();function bw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=bd(e,t),e.unshift(t)},remove(t){var n;e=bd(e,t),(n=e[0])==null||n.resume()}}}function bd(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Sw(e){return e.filter(t=>t.tagName!=="A")}var Cw="Portal",bs=g.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=g.useState(!1);yt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?hi.createPortal(u.jsx(Ie.div,{...r,ref:t}),i):null});bs.displayName=Cw;var ka=0;function Ta(){g.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Sd()),document.body.insertAdjacentElement("beforeend",e[1]??Sd()),ka++,()=>{ka===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),ka--}},[])}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 Cn=function(){return Cn=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},Cn.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 kw(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",Tw="with-scroll-bars-hidden",Ew="--removed-body-scroll-bar-size";function Ea(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Iw(e,t){var n=b.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 Nw=typeof window<"u"?g.useLayoutEffect:g.useEffect,kd=new WeakMap;function Aw(e,t){var n=Iw(null,function(r){return e.forEach(function(o){return Ea(o,r)})});return Nw(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)||Ea(a,null)}),s.forEach(function(a){o.has(a)||Ea(a,i)})}kd.set(n,e)},[e]),n}function _w(e){return e}function jw(e,t){t===void 0&&(t=_w);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)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(d){i.push(d),c()},filter:function(d){return i=i.filter(d),n}}}};return o}function Rw(e){e===void 0&&(e={});var t=jw(null);return t.options=Cn({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 g.createElement(r,Cn({},n))};Td.isSideCarExport=!0;function Pw(e,t){return e.useMedium(t),Td}var Ed=Rw(),Ia=function(){},ks=g.forwardRef(function(e,t){var n=g.useRef(null),r=g.useState({onScrollCapture:Ia,onWheelCapture:Ia,onTouchMoveCapture:Ia}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,p=e.noRelative,y=e.noIsolation,v=e.inert,m=e.allowPinchZoom,x=e.as,w=x===void 0?"div":x,S=e.gapMode,T=Cd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,k=Aw([n,t]),E=Cn(Cn({},T),o);return g.createElement(g.Fragment,null,d&&g.createElement(C,{sideCar:Ed,removeScrollBar:c,shards:f,noRelative:p,noIsolation:y,inert:v,setCallbacks:s,allowPinchZoom:!!m,lockRef:n,gapMode:S}),i?g.cloneElement(g.Children.only(a),Cn(Cn({},E),{ref:k})):g.createElement(w,Cn({},E,{className:l,ref:k}),a))});ks.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ks.classNames={fullWidth:Cs,zeroRight:Ss};var Ow=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Mw(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Ow();return t&&e.setAttribute("nonce",t),e}function Dw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Lw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Fw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Mw())&&(Dw(t,n),Lw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},$w=function(){var e=Fw();return function(t,n){g.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Id=function(){var e=$w(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},zw={left:0,top:0,right:0,gap:0},Na=function(e){return parseInt(e||"",10)||0},Bw=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)]},Hw=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return zw;var t=Bw(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])}},Uw=Id(),Rr="data-scroll-locked",Ww=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(Tw,` {
85
85
  overflow: hidden `).concat(r,`;
86
86
  padding-right: `).concat(a,"px ").concat(r,`;
87
87
  }
@@ -115,19 +115,19 @@ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An err
115
115
  }
116
116
 
117
117
  body[`).concat(Rr,`] {
118
- `).concat(Ab,": ").concat(a,`px;
118
+ `).concat(Ew,": ").concat(a,`px;
119
119
  }
120
- `)},Ad=function(){var e=parseInt(document.body.getAttribute(Rr)||"0",10);return isFinite(e)?e:0},qb=function(){g.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=g.useMemo(function(){return Wb(o)},[o]);return g.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),x=p[0],v=p[1],m=p[2],y=v-m-s*x;(x||y)&&jd(e,a)&&(f+=y,h+=x);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`
120
+ `)},Nd=function(){var e=parseInt(document.body.getAttribute(Rr)||"0",10);return isFinite(e)?e:0},Vw=function(){g.useEffect(function(){return document.body.setAttribute(Rr,(Nd()+1).toString()),function(){var e=Nd()-1;e<=0?document.body.removeAttribute(Rr):document.body.setAttribute(Rr,e.toString())}},[])},Kw=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Vw();var s=g.useMemo(function(){return Hw(o)},[o]);return g.createElement(Uw,{styles:Ww(s,!t,o,n?"":"!important")})},Aa=!1;if(typeof window<"u")try{var Ts=Object.defineProperty({},"passive",{get:function(){return Aa=!0,!0}});window.addEventListener("test",Ts,Ts),window.removeEventListener("test",Ts,Ts)}catch{Aa=!1}var Pr=Aa?{passive:!1}:!1,qw=function(e){return e.tagName==="TEXTAREA"},Ad=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!qw(e)&&n[t]==="visible")},Gw=function(e){return Ad(e,"overflowY")},Yw=function(e){return Ad(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},Xw=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Jw=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},jd=function(e,t){return e==="v"?Gw(t):Yw(t)},Rd=function(e,t){return e==="v"?Xw(t):Jw(t)},Zw=function(e,t){return e==="h"&&t==="rtl"?-1:1},Qw=function(e,t,n,r,o){var s=Zw(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,f=0,h=0;do{if(!a)break;var p=Rd(e,a),y=p[0],v=p[1],m=p[2],x=v-m-s*y;(y||x)&&jd(e,a)&&(f+=x,h+=y);var w=a.parentNode;a=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(c=!0),c},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},eb=function(e,t){return e[0]===t[0]&&e[1]===t[1]},tb=function(e){return`
121
121
  .block-interactivity-`.concat(e,` {pointer-events: none;}
122
122
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
123
- `)},ow=0,Or=[];function sw(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),o=g.useState(ow++)[0],s=g.useState(Id)[0],i=g.useRef(e);g.useEffect(function(){i.current=e},[e]),g.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var v=Eb([e.lockRef.current],(e.shards||[]).map(Od),!0).filter(Boolean);return v.forEach(function(m){return m.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),v.forEach(function(m){return m.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(v,m){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!i.current.allowPinchZoom;var y=Es(v),b=n.current,S="deltaX"in v?v.deltaX:b[0]-y[0],T="deltaY"in v?v.deltaY:b[1]-y[1],C,k=v.target,E=Math.abs(S)>Math.abs(T)?"h":"v";if("touches"in v&&E==="h"&&k.type==="range")return!1;var R=_d(E,k);if(!R)return!0;if(R?C=E:(C=E==="v"?"h":"v",R=_d(E,k)),!R)return!1;if(!r.current&&"changedTouches"in v&&(S||T)&&(r.current=C),!C)return!0;var P=r.current||C;return tw(P,m,v,P==="h"?S:T)},[]),l=g.useCallback(function(v){var m=v;if(!(!Or.length||Or[Or.length-1]!==s)){var y="deltaY"in m?Pd(m):Es(m),b=t.current.filter(function(C){return C.name===m.type&&(C.target===m.target||m.target===C.shadowParent)&&nw(C.delta,y)})[0];if(b&&b.should){m.cancelable&&m.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Od).filter(Boolean).filter(function(C){return C.contains(m.target)}),T=S.length>0?a(m,S[0]):!i.current.noIsolation;T&&m.cancelable&&m.preventDefault()}}},[]),u=g.useCallback(function(v,m,y,b){var S={name:v,delta:m,target:y,should:b,shadowParent:iw(y)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(T){return T!==S})},1)},[]),d=g.useCallback(function(v){n.current=Es(v),r.current=void 0},[]),f=g.useCallback(function(v){u(v.type,Pd(v),v.target,a(v,e.lockRef.current))},[]),h=g.useCallback(function(v){u(v.type,Es(v),v.target,a(v,e.lockRef.current))},[]);g.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(v){return v!==s}),document.removeEventListener("wheel",l,Pr),document.removeEventListener("touchmove",l,Pr),document.removeEventListener("touchstart",d,Pr)}},[]);var p=e.removeScrollBar,x=e.inert;return g.createElement(g.Fragment,null,x?g.createElement(s,{styles:rw(o)}):null,p?g.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=g.forwardRef(function(e,t){return g.createElement(ks,Cn({},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),x=p!==null&&p!=="false",v=(Mr.get(h)||0)+1,m=(s.get(h)||0)+1;Mr.set(h,v),s.set(h,m),i.push(h),v===1&&x&&As.set(h,!0),m===1&&h.setAttribute(n,"true"),x||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,CT]=wn(_s),[dw,sn]=Dd(_s),Ld=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=g.useRef(null),l=g.useRef(null),[u,d]=pr({prop:r,defaultProp:o??!1,onChange:s,caller:_s});return c.jsx(dw,{scope:t,triggerRef:a,contentRef:l,contentId:Sn(),titleId:Sn(),descriptionId:Sn(),open:u,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Ld.displayName=_s;var Fd="DialogTrigger",$d=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=sn(Fd,n),s=He(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: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=sn(Pa,t);return c.jsx(fw,{scope:t,forceMount:n,children:g.Children.map(r,i=>c.jsx(Ut,{present:n||s.open,children:c.jsx(ws,{asChild:!0,container:o,children:i})}))})};Bd.displayName=Pa;var js="DialogOverlay",Hd=g.forwardRef((e,t)=>{const n=zd(js,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=sn(js,e.__scopeDialog);return s.modal?c.jsx(Ut,{present:r||s.open,children:c.jsx(pw,{...o,ref:t})}):null});Hd.displayName=js;var hw=sr.createSlot("DialogOverlay.RemoveScroll"),pw=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=sn(js,n);return c.jsx(Is,{as:hw,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(Ie.div,{"data-state":Ma(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),gr="DialogContent",Ud=g.forwardRef((e,t)=>{const n=zd(gr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=sn(gr,e.__scopeDialog);return c.jsx(Ut,{present:r||s.open,children:s.modal?c.jsx(mw,{...o,ref:t}):c.jsx(gw,{...o,ref:t})})});Ud.displayName=gr;var mw=g.forwardRef((e,t)=>{const n=sn(gr,e.__scopeDialog),r=g.useRef(null),o=He(t,n.contentRef,r);return g.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=g.forwardRef((e,t)=>{const n=sn(gr,e.__scopeDialog),r=g.useRef(!1),o=g.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=g.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=sn(gr,n),l=g.useRef(null),u=He(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=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=sn(Oa,n);return c.jsx(Ie.h2,{id:o.titleId,...r,ref:t})});Vd.displayName=Oa;var Kd="DialogDescription",qd=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=sn(Kd,n);return c.jsx(Ie.p,{id:o.descriptionId,...r,ref:t})});qd.displayName=Kd;var Gd="DialogClose",Yd=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=sn(Gd,n);return c.jsx(Ie.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",[kT,Jd]=Sv(Xd,{contentName:gr,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.
123
+ `)},nb=0,Or=[];function rb(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),o=g.useState(nb++)[0],s=g.useState(Id)[0],i=g.useRef(e);g.useEffect(function(){i.current=e},[e]),g.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var v=kw([e.lockRef.current],(e.shards||[]).map(Od),!0).filter(Boolean);return v.forEach(function(m){return m.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),v.forEach(function(m){return m.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(v,m){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!i.current.allowPinchZoom;var x=Es(v),w=n.current,S="deltaX"in v?v.deltaX:w[0]-x[0],T="deltaY"in v?v.deltaY:w[1]-x[1],C,k=v.target,E=Math.abs(S)>Math.abs(T)?"h":"v";if("touches"in v&&E==="h"&&k.type==="range")return!1;var R=_d(E,k);if(!R)return!0;if(R?C=E:(C=E==="v"?"h":"v",R=_d(E,k)),!R)return!1;if(!r.current&&"changedTouches"in v&&(S||T)&&(r.current=C),!C)return!0;var P=r.current||C;return Qw(P,m,v,P==="h"?S:T)},[]),l=g.useCallback(function(v){var m=v;if(!(!Or.length||Or[Or.length-1]!==s)){var x="deltaY"in m?Pd(m):Es(m),w=t.current.filter(function(C){return C.name===m.type&&(C.target===m.target||m.target===C.shadowParent)&&eb(C.delta,x)})[0];if(w&&w.should){m.cancelable&&m.preventDefault();return}if(!w){var S=(i.current.shards||[]).map(Od).filter(Boolean).filter(function(C){return C.contains(m.target)}),T=S.length>0?a(m,S[0]):!i.current.noIsolation;T&&m.cancelable&&m.preventDefault()}}},[]),c=g.useCallback(function(v,m,x,w){var S={name:v,delta:m,target:x,should:w,shadowParent:ob(x)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(T){return T!==S})},1)},[]),d=g.useCallback(function(v){n.current=Es(v),r.current=void 0},[]),f=g.useCallback(function(v){c(v.type,Pd(v),v.target,a(v,e.lockRef.current))},[]),h=g.useCallback(function(v){c(v.type,Es(v),v.target,a(v,e.lockRef.current))},[]);g.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(v){return v!==s}),document.removeEventListener("wheel",l,Pr),document.removeEventListener("touchmove",l,Pr),document.removeEventListener("touchstart",d,Pr)}},[]);var p=e.removeScrollBar,y=e.inert;return g.createElement(g.Fragment,null,y?g.createElement(s,{styles:tb(o)}):null,p?g.createElement(Kw,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ob(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const sb=Pw(Ed,rb);var Is=g.forwardRef(function(e,t){return g.createElement(ks,Cn({},e,{ref:t,sideCar:sb}))});Is.classNames=ks.classNames;var ib=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Mr=new WeakMap,Ns=new WeakMap,As={},_a=0,Md=function(e){return e&&(e.host||Md(e.parentNode))},ab=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})},lb=function(e,t,n,r){var o=ab(t,Array.isArray(e)?e:[e]);As[n]||(As[n]=new WeakMap);var s=As[n],i=[],a=new Set,l=new Set(o),c=function(f){!f||a.has(f)||(a.add(f),c(f.parentNode))};o.forEach(c);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),y=p!==null&&p!=="false",v=(Mr.get(h)||0)+1,m=(s.get(h)||0)+1;Mr.set(h,v),s.set(h,m),i.push(h),v===1&&y&&Ns.set(h,!0),m===1&&h.setAttribute(n,"true"),y||h.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",h,x)}})};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||(Ns.has(f)||f.removeAttribute(r),Ns.delete(f)),p||f.removeAttribute(n)}),_a--,_a||(Mr=new WeakMap,Mr=new WeakMap,Ns=new WeakMap,As={})}},ja=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=ib(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),lb(r,o,n,"aria-hidden")):function(){return null}},_s="Dialog",[Dd,wT]=bn(_s),[cb,sn]=Dd(_s),Ld=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=g.useRef(null),l=g.useRef(null),[c,d]=pr({prop:r,defaultProp:o??!1,onChange:s,caller:_s});return u.jsx(cb,{scope:t,triggerRef:a,contentRef:l,contentId:Sn(),titleId:Sn(),descriptionId:Sn(),open:c,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Ld.displayName=_s;var Fd="DialogTrigger",$d=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=sn(Fd,n),s=Be(t,o.triggerRef);return u.jsx(Ie.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Oa(o.open),...r,ref:s,onClick:fe(e.onClick,o.onOpenToggle)})});$d.displayName=Fd;var Ra="DialogPortal",[ub,zd]=Dd(Ra,{forceMount:void 0}),Bd=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=sn(Ra,t);return u.jsx(ub,{scope:t,forceMount:n,children:g.Children.map(r,i=>u.jsx(Ut,{present:n||s.open,children:u.jsx(bs,{asChild:!0,container:o,children:i})}))})};Bd.displayName=Ra;var js="DialogOverlay",Hd=g.forwardRef((e,t)=>{const n=zd(js,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=sn(js,e.__scopeDialog);return s.modal?u.jsx(Ut,{present:r||s.open,children:u.jsx(fb,{...o,ref:t})}):null});Hd.displayName=js;var db=sr.createSlot("DialogOverlay.RemoveScroll"),fb=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=sn(js,n);return u.jsx(Is,{as:db,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(Ie.div,{"data-state":Oa(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),gr="DialogContent",Ud=g.forwardRef((e,t)=>{const n=zd(gr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=sn(gr,e.__scopeDialog);return u.jsx(Ut,{present:r||s.open,children:s.modal?u.jsx(hb,{...o,ref:t}):u.jsx(pb,{...o,ref:t})})});Ud.displayName=gr;var hb=g.forwardRef((e,t)=>{const n=sn(gr,e.__scopeDialog),r=g.useRef(null),o=Be(t,n.contentRef,r);return g.useEffect(()=>{const s=r.current;if(s)return ja(s)},[]),u.jsx(Wd,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:fe(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:fe(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:fe(e.onFocusOutside,s=>s.preventDefault())})}),pb=g.forwardRef((e,t)=>{const n=sn(gr,e.__scopeDialog),r=g.useRef(!1),o=g.useRef(!1);return u.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,c;(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;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Wd=g.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=sn(gr,n),l=g.useRef(null),c=Be(t,l);return Ta(),u.jsxs(u.Fragment,{children:[u.jsx(ws,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(vs,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Oa(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(mb,{titleId:a.titleId}),u.jsx(xb,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Pa="DialogTitle",Vd=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=sn(Pa,n);return u.jsx(Ie.h2,{id:o.titleId,...r,ref:t})});Vd.displayName=Pa;var Kd="DialogDescription",qd=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=sn(Kd,n);return u.jsx(Ie.p,{id:o.descriptionId,...r,ref:t})});qd.displayName=Kd;var Gd="DialogClose",Yd=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=sn(Gd,n);return u.jsx(Ie.button,{type:"button",...r,ref:t,onClick:fe(e.onClick,()=>o.onOpenChange(!1))})});Yd.displayName=Gd;function Oa(e){return e?"open":"closed"}var Xd="DialogTitleWarning",[bT,Jd]=wv(Xd,{contentName:gr,titleName:Pa,docsSlug:"dialog"}),mb=({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 g.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 g.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,xr=Vd,Os=qd,ef=Yd;const ww=Zd,Sw=Qd,tf=g.forwardRef(({className:e,...t},n)=>c.jsx(Rs,{ref:n,className:oe("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=g.forwardRef(({className:e,children:t,...n},r)=>{const o=g.useMemo(()=>{let s=!1;function i(a){g.Children.forEach(a,l=>{if(s||!g.isValidElement(l))return;const u=l.type;if(u===xr||(u==null?void 0:u.displayName)===xr.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:oe("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(xr,{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(pe.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:oe("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});rf.displayName="DialogHeader";const of=g.forwardRef(({className:e,...t},n)=>c.jsx(xr,{ref:n,className:oe("text-lg font-semibold leading-none tracking-tight",e),...t}));of.displayName=xr.displayName;const Cw=g.forwardRef(({className:e,...t},n)=>c.jsx(Os,{ref:n,className:oe("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"})}},x=async()=>{if(n)try{const y=await dd(n),b=new Blob([y],{type:o}),S=URL.createObjectURL(b);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(y){console.error("Failed to open file externally:",y),f({title:"Failed to open file",description:String(y),variant:"destructive"})}},v=()=>s?c.jsxs("div",{className:"flex items-center justify-center py-12",children:[c.jsx(pe.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(pe.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"})}),m=()=>o.startsWith("image/")?c.jsx(pe.Image,{className:"h-5 w-5"}):c.jsx(pe.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:[m(),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(qe,{variant:"outline",size:"sm",onClick:x,className:"flex items-center gap-2",children:[c.jsx(pe.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(pe.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),c.jsx("div",{className:"flex-1 overflow-hidden",children:v()})]})})}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),x=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(h),v=p?p[2].trim():"",m=x?x[2].trim():"";n[i].push({title:v,description:m})}}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:oe("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",truncateUserMessages:u=!0,userMessagePreviewLength:d=200,showToolMessages:f=!0,customStyles:h={},onEdit:p,onRegenerate:x,onCancelEdit:v,onCopy:m,activeInterrupt:y,disableInterruptActions:b=!1,onInterruptActionStart:S,onInterruptActionEnd:T}){const[C,k]=w.useState(!1),[E,R]=w.useState("preview"),[P,j]=w.useState(!1),{currentThreadId:H}=Yo(),{respondToInterrupt:$}=Xo(),L=l==="phone"||l==="half-screen",O=t.role,B=O==="tool",W=!(r&&O!=="user"),{uploadingFiles:se,handleFileClick:K,fileViewerOpen:U,currentFileInfo:X,closeFileViewer:F}=Dw({allowFileOpen:W,currentThreadId:H}),q=w.useMemo(()=>{switch(O){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))]"}},[O]),me=w.useMemo(()=>Tw(t.content),[t.content]),ge=w.useMemo(()=>Ew(t.content),[t.content]),ke=w.useMemo(()=>t.content.filter(te=>te.type==="image_url"),[t.content]),Se=w.useMemo(()=>t.content.filter(te=>te.type==="file"),[t.content]),J=w.useMemo(()=>t.content.filter(te=>te.type==="interrupt"),[t.content]),D=(y==null?void 0:y.id)??(y==null?void 0:y.interrupt_id),ee=Fs(D),re=y==null?void 0:y.value,ae=w.useMemo(()=>Aw(t.content),[t.content]);w.useMemo(()=>Nw(t.content),[t.content]);const le=w.useMemo(()=>ae.length<=Ls?ae:`${ae.slice(0,Ls)}
129
- … [truncated ${ae.length-Ls} chars]`,[ae]),ie=w.useCallback(async(te="all")=>{const xe=te==="visible"&&B?le:B?ae:me;async function ze(Pe){try{await navigator.clipboard.writeText(Pe)}catch{try{const et=document.createElement("textarea");et.value=Pe,et.setAttribute("readonly",""),et.style.position="absolute",et.style.left="-9999px",document.body.appendChild(et),et.select(),document.execCommand("copy"),document.body.removeChild(et)}catch(et){throw console.error("Failed to copy:",et),et}}}try{await ze(xe),k(!0),setTimeout(()=>k(!1),2e3),m==null||m(xe)}catch(Pe){console.error("Failed to copy:",Pe)}},[B,ae,me,le,m]),Ge=w.useCallback(()=>{if(!p)return;const te=B?ae:me;p(t.id,te)},[p,t.id,B,ae,me]),Je=w.useCallback(()=>{x==null||x(n)},[x,n]),De=w.useCallback(()=>{const ue=oe(L?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",q);switch(O){case"user":return c.jsx(pe.User,{className:ue});case"assistant":return c.jsx(pe.Bot,{className:ue});case"tool":return c.jsx(pe.Wrench,{className:ue});default:return c.jsx(pe.Bot,{className:ue})}},[L,q,O]),Ue=w.useCallback(()=>{const te="group relative mb-4 flex w-full";switch(O){case"user":return oe(te,"justify-end");case"assistant":case"tool":case"system":return oe(te,"justify-start");default:return te}},[O]),at=w.useCallback(()=>{const te=oe("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",L&&"px-3 py-2 text-sm");switch(O){case"user":return oe(te,"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 oe(te,"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 oe(te,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return oe(te,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return oe(te,"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")}},[L,O]),Ke=w.useCallback(async te=>{if(b)return;const ue=Fs((te==null?void 0:te.id)??(te==null?void 0:te.interrupt_id));if(!ue){console.warn("Interrupt part missing id",te);return}try{S==null||S(),await $(ue,!0)}catch(xe){console.error("Failed to approve interrupt:",xe)}finally{T==null||T()}},[b,T,S,$]),je=w.useCallback(async te=>{if(b)return;const ue=Fs((te==null?void 0:te.id)??(te==null?void 0:te.interrupt_id));if(!ue){console.warn("Interrupt part missing id",te);return}try{S==null||S(),await $(ue,!1)}catch(xe){console.error("Failed to reject interrupt:",xe)}finally{T==null||T()}},[b,T,S,$]),mt=w.useCallback(({part:te,i:ue})=>{if(te.type==="text"){const xe=te.text??"",ze=xe.trim(),Pe=sf(ze);return Pe&&O!=="tool"?c.jsx(Rw,{data:Pe},ue):O==="user"&&u&&ze.length>d?c.jsx(Lw,{text:ze,expanded:P,onExpandedChange:j,previewLength:d,isCompact:L},ue):c.jsx(ya,{content:xe,allowHtml:!1},ue)}if(te.type==="image_url"){const xe=te;return c.jsx("div",{className:"my-2",children:c.jsx("img",{src:xe.url,alt:xe.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},ue)}if(te.type==="file"){const xe=te,ze=xe.name||"file";return c.jsxs("a",{href:xe.url,onClick:Pe=>K(Pe,xe,ue),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:[se[ue]?c.jsx(pe.Loader,{className:"h-4 w-4 animate-spin"}):null,c.jsxs("span",{className:"truncate max-w-[180px]",children:[ze,se[ue]?" (processing)":""]})]},ue)}if(te.type==="interrupt"){const xe=te,ze=Fs((xe==null?void 0:xe.id)??(xe==null?void 0:xe.interrupt_id)),Pe=!!(ee&&ze&&ze===ee),et=Pe?re??(xe==null?void 0:xe.value):xe==null?void 0:xe.value,xt=ze?{...xe,id:ze,interrupt_id:ze}:xe;return c.jsx(Ow,{interruptPart:xt,onApprove:Ke,onReject:je,disabled:b,isActive:Pe,payload:et},ue)}return null},[K,se,Ke,je,O,u,d,P,L,ee,re,y,b,J]),gt=w.useCallback(()=>c.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[c.jsx(pe.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 te=me.trim().length>0||ke.length>0||Se.length>0||J.length>0;if(!B&&!te&&!r)return gt();if(t.model==="reflection"){const ue=me.trim(),xe=sf(ue);if(xe&&typeof xe=="object")return c.jsx(Mw,{data:xe})}if(B&&ge.name==="get_issues"){const ue=t.content.find(Pe=>Pe.type==="tool_end"),xe=(ue==null?void 0:ue.output)??ae,ze=lf(xe);if(ze)return c.jsx($w,{issues:ze})}if(B)return c.jsx(Fw,{message:t,viewMode:E},t.id);if(!B){const ue=c.jsx("div",{className:"space-y-2",children:t.content.map((xe,ze)=>c.jsx(mt,{part:xe,i:ze},ze))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[ue,c.jsx(jw,{className:q})]}):ue}},[me,ke.length,Se.length,J.length,r,t.model,B,ge.name,ae,E,gt,q]),rt=w.useMemo(()=>_w(t),[t]);return B&&!f?null:c.jsxs(c.Fragment,{children:[c.jsx("div",{className:oe(Ue(),h.container),children:c.jsxs("div",{className:oe(at(),h.content),children:[(i||a||B)&&c.jsxs("div",{className:oe("flex items-center justify-between mb-2 pb-2 border-b border-current/10",L&&"mb-1 pb-1",q,h.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[De(),a&&rt&&c.jsx("span",{className:oe("font-medium",L?"text-xs":"text-sm"),children:rt}),B&&c.jsxs(Uu,{variant:"outline",className:oe("text-xs flex items-center gap-1 cursor-pointer select-none",q,"border border-current/40",L&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":E==="expanded",onClick:()=>R(te=>te==="expanded"?"preview":"expanded"),onKeyDown:te=>{(te.key==="Enter"||te.key===" ")&&(te.preventDefault(),R(ue=>ue==="expanded"?"preview":"expanded"))},children:[c.jsx("span",{children:ge.name??"Tool Output"}),ge.toolCallId&&c.jsx("span",{className:"opacity-70",children:ge.toolCallId.slice(0,8)}),E==="expanded"?c.jsx(pe.ChevronUp,{className:"h-3 w-3"}):c.jsx(pe.ChevronDown,{className:"h-3 w-3"})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.createdAt&&c.jsx("time",{className:oe("text-xs opacity-60",q,L&&"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:oe("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",h.actions),children:[c.jsxs("div",{className:"relative",children:[c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>ie(B?"visible":"all"),className:oe("h-6 w-6 p-0 hover:bg-foreground/10",q,L&&"h-5 w-5"),"aria-label":B?"Copy visible":"Copy message",title:B?"Copy visible portion":"Copy message",children:c.jsx(pe.Copy,{className:oe(C?"text-success":q,L?"h-3 w-3":"h-4 w-4")})}),B&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>ie("all"),className:oe("h-6 px-1 text-xs hover:bg-foreground/10",q),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),O==="user"&&p&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:Ge,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",q,L&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(pe.Edit,{className:oe(q,L?"h-3 w-3":"h-4 w-4")})}),O==="assistant"&&x&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:Je,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",q,L&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(pe.RotateCcw,{className:oe(q,L?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsx("div",{className:"relative",children:Ct()}),B&&E==="expanded"&&(ge.toolCallId||ge.name)&&c.jsxs("div",{className:oe("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",L&&"text-xs"),children:[ge.name&&c.jsxs("div",{children:["Function: ",ge.name]}),ge.toolCallId&&c.jsxs("div",{children:["Call ID: ",ge.toolCallId]})]}),!(i||a||B)&&s&&!o&&c.jsxs("div",{className:oe("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",h.actions),children:[c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>ie(),className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",L&&"h-5 w-5"),children:c.jsx(pe.Copy,{className:oe(C?"text-success":"text-current",L?"h-3 w-3":"h-4 w-4")})}),O==="user"&&p&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:Ge,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",L&&"h-5 w-5"),children:c.jsx(pe.Edit,{className:oe("text-current",L?"h-3 w-3":"h-4 w-4")})}),O==="assistant"&&x&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:Je,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",L&&"h-5 w-5"),children:c.jsx(pe.RotateCcw,{className:oe("text-current",L?"h-3 w-3":"h-4 w-4")})})]})]})}),X&&c.jsx(kw,{isOpen:U,onClose:F,fileId:X.id,fileName:X.name,mimeType:X.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","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(x=>e[x]===t[x]),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:oe("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(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 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(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=wa(),[o,s]=w.useState({}),[i,a]=w.useState(null),[l,u]=w.useState(!1),d=w.useCallback(()=>{u(!1),a(null)},[]),f=w.useCallback(p=>{a(p),u(!0)},[]),h=w.useCallback(async(p,x,v)=>{var m,y;if(!t){p.preventDefault();return}if(o[v]){p.preventDefault();return}try{const b=String(x.url??""),S=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){p.preventDefault();const T=S[1],C=x.name||`file_${T}`,k=x.mimeType||"application/octet-stream";f({id:T,name:C,mimeType:k});return}if(b.startsWith("data:")){p.preventDefault(),s(C=>({...C,[v]:!0}));const T=r({title:"Fetching file...",description:"",open:!0});try{const C=await ob(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const k=C.find(E=>!E||typeof E!="object"||!((E.filename??"")===(x.name??""))?!1:typeof x.size=="number"&&typeof E.size=="number"?E.size===x.size:!0);if(!(k!=null&&k.id))throw new Error(`File "${x.name}" is not yet available on the server`);if(!k.id||!k.filename)throw new Error("Invalid file data received from server");f({id:k.id,name:x.name||k.filename||`file_${k.id}`,mimeType:x.mimeType||k.mime_type||"application/octet-stream"}),(m=T.update)==null||m.call(T,{id:T.id,title:"Success",description:`Opened ${x.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const k=C instanceof Error?C.message:"Unknown error occurred";(y=T.update)==null||y.call(T,{id:T.id,title:"Failed",description:k}),r({title:"Failed to fetch file",description:k,open:!0})}finally{s(C=>({...C,[v]:!1}))}}}catch(b){console.error("File click error:",b),s(S=>({...S,[v]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:h,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Lw({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){return c.jsxs(Fv,{open:t,onOpenChange:n,children:[c.jsx("div",{className:oe("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?c.jsx(ya,{content:e,allowHtml:!1}):c.jsxs("pre",{className:oe("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[e.substring(0,r),"..."]})}),c.jsx($v,{asChild:!0,children:c.jsx(qe,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:t?c.jsxs(c.Fragment,{children:[c.jsx(pe.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(pe.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",e.length-r," chars)"]})})})]})}function Fw({message:e,viewMode:t}){const n=Iw(e.content);return t!=="expanded"||n.length===0?null:c.jsx("div",{className:"space-y-3",children:n.map((r,o)=>{const s=typeof r.output=="string"?r.output:Ms(r.output??"");return c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:c.jsx("span",{children:r.name??"tool"})}),c.jsx("div",{className:"font-mono text-sm mt-1",children:c.jsx("pre",{className:"whitespace-pre-wrap break-words",children:s})})]},r.toolCallId??o)})})}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: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:x=!0,isNavigatingCheckpoint:v=!1,onScrollAway:m,onAtBottom:y,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:T,onInterruptActionEnd:C,showToolMessages:k=!0},E)=>{const R=w.useRef(null),P=w.useRef(null),j=w.useRef(!1),[H,$]=w.useState(!0),L=w.useMemo(()=>b?e.some(X=>Array.isArray(X==null?void 0:X.content)&&X.content.some(F=>F&&F.type==="interrupt"&&(F.id??F.interrupt_id)===b.id)):!1,[b,e]),O=w.useMemo(()=>{if(!b||L)return null;const X=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let F;const q=b.value;if(q&&typeof q=="object"&&!Array.isArray(q)){const me=q.title;typeof me=="string"&&me.trim()&&(F=me.trim())}return{id:`interrupt-${X}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:X,value:q,title:F}]}},[b,L]),B=w.useMemo(()=>O?[...e,O]:e,[e,O]),W=w.useMemo(()=>k?B:B.filter(X=>(X==null?void 0:X.role)!=="tool"),[B,k]),se=w.useCallback(X=>{$(X),m&&m(!X),y&&y(X)},[m,y]),K=w.useMemo(()=>{if(a)return async()=>{if(!j.current){j.current=!0;try{await a()}finally{j.current=!1}}}},[a]),U=w.useMemo(()=>!x||v?!1:H?"auto":!1,[H,x,v]);return W.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:X=>{R.current=X},scrollerRef:X=>{P.current=X instanceof HTMLDivElement?X:null},data:W,followOutput:U,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{K&&K()},atBottomStateChange:se,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(X,F)=>df(F,X),itemContent:(X,F)=>{const q=df(F,X);return c.jsx("div",{className:"mb-4 last:mb-0","data-message-id":q,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(uf,{message:F,messageIndex:X,isStreamingMessage:t&&n===F.id,streamingDebounceMs:r,isEditing:i===F.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:l,onRegenerate:()=>u(X),onCancelEdit:d,activeInterrupt:b,disableInterruptActions:S,onInterruptActionStart:T,onInterruptActionEnd:C,showToolMessages:k})})}})})});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 g.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},gb="DialogDescriptionWarning",xb=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Jd(gb).contentName}}.`;return g.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,yb=$d,Qd=Bd,Rs=Hd,Ps=Ud,xr=Vd,Os=qd,ef=Yd;const vb=Zd,wb=Qd,tf=g.forwardRef(({className:e,...t},n)=>u.jsx(Rs,{ref:n,className:oe("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=g.forwardRef(({className:e,children:t,...n},r)=>{const o=g.useMemo(()=>{let s=!1;function i(a){g.Children.forEach(a,l=>{if(s||!g.isValidElement(l))return;const c=l.type;if(c===xr||(c==null?void 0:c.displayName)===xr.displayName||(c==null?void 0:c.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return u.jsxs(wb,{children:[u.jsx(tf,{}),u.jsxs(Ps,{ref:r,className:oe("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&&u.jsx(xr,{className:"sr-only",children:"Dialog"}),t,u.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:[u.jsx(he.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});nf.displayName=Ps.displayName;const rf=({className:e,...t})=>u.jsx("div",{className:oe("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});rf.displayName="DialogHeader";const of=g.forwardRef(({className:e,...t},n)=>u.jsx(xr,{ref:n,className:oe("text-lg font-semibold leading-none tracking-tight",e),...t}));of.displayName=xr.displayName;const bb=g.forwardRef(({className:e,...t},n)=>u.jsx(Os,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));bb.displayName=Os.displayName;function Sb({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=b.useState(!1),[a,l]=b.useState(null),[c,d]=b.useState(null),{toast:f}=wa(),h=b.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const x=await dd(n);l(x)}catch(x){console.error("Failed to load file:",x),d(x instanceof Error?x.message:"Failed to load file")}finally{i(!1)}}},[n]);b.useEffect(()=>{e&&n&&h()},[e,n,h]);const p=async()=>{if(n)try{await tw(n),f({title:"Download started",description:`Downloading ${r}`})}catch(x){console.error("Failed to download file:",x),f({title:"Download failed",description:String(x),variant:"destructive"})}},y=async()=>{if(n)try{const x=await dd(n),w=new Blob([x],{type:o}),S=URL.createObjectURL(w);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(x){console.error("Failed to open file externally:",x),f({title:"Failed to open file",description:String(x),variant:"destructive"})}},v=()=>s?u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(he.Loader,{className:"h-8 w-8 animate-spin mr-3"}),u.jsx("span",{children:"Loading file..."})]}):c?u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),u.jsx("p",{className:"text-red-600 mb-4",children:c}),u.jsx(qe,{onClick:h,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?u.jsx("div",{className:"flex justify-center",children:u.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?u.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:u.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?u.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:u.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx(he.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),u.jsx("p",{className:"text-lg font-medium mb-2",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):u.jsx("div",{className:"flex items-center justify-center py-12",children:u.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),m=()=>o.startsWith("image/")?u.jsx(he.Image,{className:"h-5 w-5"}):u.jsx(he.FileText,{className:"h-5 w-5"});return u.jsx(vb,{open:e,onOpenChange:t,children:u.jsxs(nf,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(rf,{children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[m(),u.jsxs("div",{children:[u.jsx(of,{className:"text-left",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(qe,{variant:"outline",size:"sm",onClick:y,className:"flex items-center gap-2",children:[u.jsx(he.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(qe,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[u.jsx(he.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:v()})]})})}function Cb(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 sf(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(sf(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(sf(e))return"";try{const t=go(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}const Ma="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",Ds=1e5;function kb(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Tb(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 Eb(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 Ls(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function Ib(e){const t=(r,o=Ds)=>{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 Nb(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 Ab(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function af(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 _b({className:e}){const[t,n]=b.useState(0);return b.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:oe("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const lf=b.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=200,showToolMessages:f=!0,customStyles:h={},onEdit:p,onRegenerate:y,onCancelEdit:v,onCopy:m,activeInterrupt:x,disableInterruptActions:w=!1,onInterruptActionStart:S,onInterruptActionEnd:T}){const[C,k]=b.useState(!1),[E,R]=b.useState("preview"),[P,j]=b.useState(!1),{currentThreadId:B}=Yo(),{respondToInterrupt:$}=Xo(),L=l==="phone"||l==="half-screen",O=t.role,H=O==="tool",W=!(r&&O!=="user"),{uploadingFiles:se,handleFileClick:K,fileViewerOpen:U,currentFileInfo:X,closeFileViewer:F}=Ob({allowFileOpen:W,currentThreadId:B}),q=b.useMemo(()=>{switch(O){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))]"}},[O]),pe=b.useMemo(()=>kb(t.content),[t.content]),ge=b.useMemo(()=>Tb(t.content),[t.content]),ke=b.useMemo(()=>t.content.filter(te=>te.type==="image_url"),[t.content]),Se=b.useMemo(()=>t.content.filter(te=>te.type==="file"),[t.content]),J=b.useMemo(()=>t.content.filter(te=>te.type==="interrupt"),[t.content]),D=(x==null?void 0:x.id)??(x==null?void 0:x.interrupt_id),ee=Ls(D),re=x==null?void 0:x.value,ce=b.useMemo(()=>Ib(t.content),[t.content]);b.useMemo(()=>Nb(t.content),[t.content]);const ae=b.useMemo(()=>ce.length<=Ds?ce:`${ce.slice(0,Ds)}
129
+ … [truncated ${ce.length-Ds} chars]`,[ce]),ie=b.useCallback(async(te="all")=>{const ve=te==="visible"&&H?ae:H?ce:pe;async function We(De){try{await navigator.clipboard.writeText(De)}catch{try{const et=document.createElement("textarea");et.value=De,et.setAttribute("readonly",""),et.style.position="absolute",et.style.left="-9999px",document.body.appendChild(et),et.select(),document.execCommand("copy"),document.body.removeChild(et)}catch(et){throw console.error("Failed to copy:",et),et}}}try{await We(ve),k(!0),setTimeout(()=>k(!1),2e3),m==null||m(ve)}catch(De){console.error("Failed to copy:",De)}},[H,ce,pe,ae,m]),Ge=b.useCallback(()=>{if(!p)return;const te=H?ce:pe;p(t.id,te)},[p,t.id,H,ce,pe]),Je=b.useCallback(()=>{y==null||y(n)},[y,n]),Me=b.useCallback(()=>{const me=oe(L?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",q);switch(O){case"user":return u.jsx(he.User,{className:me});case"assistant":return u.jsx(he.Bot,{className:me});case"tool":return u.jsx(he.Wrench,{className:me});default:return u.jsx(he.Bot,{className:me})}},[L,q,O]),He=b.useCallback(()=>{const te="group relative mb-4 flex w-full";switch(O){case"user":return oe(te,"justify-end");case"assistant":case"tool":case"system":return oe(te,"justify-start");default:return te}},[O]),at=b.useCallback(()=>{const te=oe("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",L&&"px-3 py-2 text-sm");switch(O){case"user":return oe(te,"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 oe(te,"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 oe(te,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return oe(te,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return oe(te,"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")}},[L,O]),Ke=b.useCallback(async te=>{if(w)return;const me=Ls((te==null?void 0:te.id)??(te==null?void 0:te.interrupt_id));if(!me){console.warn("Interrupt part missing id",te);return}try{S==null||S(),await $(me,!0)}catch(ve){console.error("Failed to approve interrupt:",ve)}finally{T==null||T()}},[w,T,S,$]),je=b.useCallback(async te=>{if(w)return;const me=Ls((te==null?void 0:te.id)??(te==null?void 0:te.interrupt_id));if(!me){console.warn("Interrupt part missing id",te);return}try{S==null||S(),await $(me,!1)}catch(ve){console.error("Failed to reject interrupt:",ve)}finally{T==null||T()}},[w,T,S,$]),mt=b.useCallback(({part:te,i:me})=>{if(te.type==="text"){const ve=te.text??"",We=ve.trim(),De=Cb(We);return De&&O!=="tool"?u.jsx(jb,{data:De},me):O==="user"&&c&&We.length>d?u.jsx(Mb,{text:We,expanded:P,onExpandedChange:j,previewLength:d,isCompact:L},me):u.jsx(xa,{content:ve,allowHtml:!1},me)}if(te.type==="image_url"){const ve=te;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:ve.url,alt:ve.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},me)}if(te.type==="file"){const ve=te,We=ve.name||"file";return u.jsxs("a",{href:ve.url,onClick:De=>K(De,ve,me),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:[se[me]?u.jsx(he.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[We,se[me]?" (processing)":""]})]},me)}if(te.type==="interrupt"){const ve=te,We=Ls((ve==null?void 0:ve.id)??(ve==null?void 0:ve.interrupt_id)),De=!!(ee&&We&&We===ee),et=De?re??(ve==null?void 0:ve.value):ve==null?void 0:ve.value,xt=We?{...ve,id:We,interrupt_id:We}:ve;return u.jsx(Pb,{interruptPart:xt,onApprove:Ke,onReject:je,disabled:w,isActive:De,payload:et},me)}return null},[K,se,Ke,je,O,c,d,P,L,ee,re,x,w,J]),gt=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(he.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),Ct=b.useCallback(()=>{const te=pe.trim().length>0||ke.length>0||Se.length>0||J.length>0;if(!H&&!te&&!r)return gt();if(H)return u.jsx(Db,{message:t,viewMode:E},t.id);if(!H){const me=u.jsx("div",{className:"space-y-2",children:t.content.map((ve,We)=>u.jsx(mt,{part:ve,i:We},We))});return r?u.jsxs("div",{"aria-busy":"true",role:"status",children:[me,u.jsx(_b,{className:q})]}):me}},[pe,ke.length,Se.length,J.length,r,H,E,gt,q]),rt=b.useMemo(()=>Ab(t),[t]);return H&&!f?null:u.jsxs(u.Fragment,{children:[u.jsx("div",{className:oe(He(),h.container),children:u.jsxs("div",{className:oe(at(),h.content),children:[(i||a||H)&&u.jsxs("div",{className:oe("flex items-center justify-between mb-2 pb-2 border-b border-current/10",L&&"mb-1 pb-1",q,h.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[Me(),a&&rt&&u.jsx("span",{className:oe("font-medium",L?"text-xs":"text-sm"),children:rt}),H&&u.jsxs(Uu,{variant:"outline",className:oe("text-xs flex items-center gap-1 cursor-pointer select-none",q,"border border-current/40",L&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":E==="expanded",onClick:()=>R(te=>te==="expanded"?"preview":"expanded"),onKeyDown:te=>{(te.key==="Enter"||te.key===" ")&&(te.preventDefault(),R(me=>me==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:ge.name??"Tool Output"}),ge.toolCallId&&u.jsx("span",{className:"opacity-70",children:ge.toolCallId.slice(0,8)}),E==="expanded"?u.jsx(he.ChevronUp,{className:"h-3 w-3"}):u.jsx(he.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.createdAt&&u.jsx("time",{className:oe("text-xs opacity-60",q,L&&"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&&u.jsxs("div",{className:oe("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",h.actions),children:[u.jsxs("div",{className:"relative",children:[u.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>ie(H?"visible":"all"),className:oe("h-6 w-6 p-0 hover:bg-foreground/10",q,L&&"h-5 w-5"),"aria-label":H?"Copy visible":"Copy message",title:H?"Copy visible portion":"Copy message",children:u.jsx(he.Copy,{className:oe(C?"text-success":q,L?"h-3 w-3":"h-4 w-4")})}),H&&u.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>ie("all"),className:oe("h-6 px-1 text-xs hover:bg-foreground/10",q),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),O==="user"&&p&&u.jsx(qe,{variant:"ghost",size:"sm",onClick:Ge,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",q,L&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(he.Edit,{className:oe(q,L?"h-3 w-3":"h-4 w-4")})}),O==="assistant"&&y&&u.jsx(qe,{variant:"ghost",size:"sm",onClick:Je,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",q,L&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(he.RotateCcw,{className:oe(q,L?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsx("div",{className:"relative",children:Ct()}),H&&E==="expanded"&&(ge.toolCallId||ge.name)&&u.jsxs("div",{className:oe("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",L&&"text-xs"),children:[ge.name&&u.jsxs("div",{children:["Function: ",ge.name]}),ge.toolCallId&&u.jsxs("div",{children:["Call ID: ",ge.toolCallId]})]}),!(i||a||H)&&s&&!o&&u.jsxs("div",{className:oe("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",h.actions),children:[u.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>ie(),className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",L&&"h-5 w-5"),children:u.jsx(he.Copy,{className:oe(C?"text-success":"text-current",L?"h-3 w-3":"h-4 w-4")})}),O==="user"&&p&&u.jsx(qe,{variant:"ghost",size:"sm",onClick:Ge,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",L&&"h-5 w-5"),children:u.jsx(he.Edit,{className:oe("text-current",L?"h-3 w-3":"h-4 w-4")})}),O==="assistant"&&y&&u.jsx(qe,{variant:"ghost",size:"sm",onClick:Je,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",L&&"h-5 w-5"),children:u.jsx(he.RotateCcw,{className:oe("text-current",L?"h-3 w-3":"h-4 w-4")})})]})]})}),X&&u.jsx(Sb,{isOpen:U,onClose:F,fileId:X.id,fileName:X.name,mimeType:X.mimeType})]})},(e,t)=>{var i,a,l,c,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&af(e.message)===af(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(y=>e[y]===t[y]),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)===((c=t.customStyles)==null?void 0:c.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 jb({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:Ma,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.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 u.jsxs("div",{className:Ma,children:[typeof r=="boolean"&&u.jsxs("p",{children:[u.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&u.jsxs("div",{children:[u.jsx("p",{children:u.jsx("strong",{children:"Follow-up queries:"})}),u.jsx("ul",{className:"list-disc pl-5",children:n.map((s,i)=>u.jsx("li",{children:String(s)},i))})]}),t&&t.length>0&&u.jsxs("div",{children:[u.jsx("p",{children:u.jsx("strong",{children:"Facts:"})}),u.jsx("ul",{className:"list-disc pl-5",children:t.map((s,i)=>u.jsx("li",{children:String(s)},i))})]})]});const o=Object.entries(e);return u.jsx("div",{className:Ma,children:u.jsx("dl",{className:"mt-0",children:o.map(([s,i])=>u.jsxs("div",{className:"mb-1",children:[u.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),u.jsx("dd",{className:"inline",children:Rb(i)})]},s))})})}return u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Ms(e)})}function Rb(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 u.jsx("code",{className:"text-xs",children:JSON.stringify(go(e))})}catch{return String(e)}}function Pb({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=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=Ms(s);a=u.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:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(uo,{className:oe("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:[u.jsxs(fo,{className:"pb-3",children:[u.jsx(ho,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(Yu,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(po,{className:"pt-0 pb-3",children:a}),u.jsx(Xu,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.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"}),u.jsx(qe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}function Ob(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=wa(),[o,s]=b.useState({}),[i,a]=b.useState(null),[l,c]=b.useState(!1),d=b.useCallback(()=>{c(!1),a(null)},[]),f=b.useCallback(p=>{a(p),c(!0)},[]),h=b.useCallback(async(p,y,v)=>{var m,x;if(!t){p.preventDefault();return}if(o[v]){p.preventDefault();return}try{const w=String(y.url??""),S=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){p.preventDefault();const T=S[1],C=y.name||`file_${T}`,k=y.mimeType||"application/octet-stream";f({id:T,name:C,mimeType:k});return}if(w.startsWith("data:")){p.preventDefault(),s(C=>({...C,[v]:!0}));const T=r({title:"Fetching file...",description:"",open:!0});try{const C=await nw(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const k=C.find(E=>!E||typeof E!="object"||!((E.filename??"")===(y.name??""))?!1:typeof y.size=="number"&&typeof E.size=="number"?E.size===y.size:!0);if(!(k!=null&&k.id))throw new Error(`File "${y.name}" is not yet available on the server`);if(!k.id||!k.filename)throw new Error("Invalid file data received from server");f({id:k.id,name:y.name||k.filename||`file_${k.id}`,mimeType:y.mimeType||k.mime_type||"application/octet-stream"}),(m=T.update)==null||m.call(T,{id:T.id,title:"Success",description:`Opened ${y.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const k=C instanceof Error?C.message:"Unknown error occurred";(x=T.update)==null||x.call(T,{id:T.id,title:"Failed",description:k}),r({title:"Failed to fetch file",description:k,open:!0})}finally{s(C=>({...C,[v]:!1}))}}}catch(w){console.error("File click error:",w),s(S=>({...S,[v]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:h,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Mb({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){return u.jsxs(Dv,{open:t,onOpenChange:n,children:[u.jsx("div",{className:oe("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(xa,{content:e,allowHtml:!1}):u.jsxs("pre",{className:oe("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[e.substring(0,r),"..."]})}),u.jsx(Lv,{asChild:!0,children:u.jsx(qe,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:t?u.jsxs(u.Fragment,{children:[u.jsx(he.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(he.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",e.length-r," chars)"]})})})]})}function Db({message:e,viewMode:t}){const n=Eb(e.content);return t!=="expanded"||n.length===0?null:u.jsx("div",{className:"space-y-3",children:n.map((r,o)=>{const s=typeof r.output=="string"?r.output:Ms(r.output??"");return u.jsx("div",{className:"space-y-1",children:u.jsx("div",{className:"font-mono text-sm mt-1",children:u.jsx("pre",{className:"whitespace-pre-wrap break-words",children:s})})},r.toolCallId??o)})})}const cf=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Da=b.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:y=!0,isNavigatingCheckpoint:v=!1,onScrollAway:m,onAtBottom:x,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:T,onInterruptActionEnd:C,showToolMessages:k=!0},E)=>{const R=b.useRef(null),P=b.useRef(null),j=b.useRef(!1),[B,$]=b.useState(!0),L=b.useMemo(()=>w?e.some(X=>Array.isArray(X==null?void 0:X.content)&&X.content.some(F=>F&&F.type==="interrupt"&&(F.id??F.interrupt_id)===w.id)):!1,[w,e]),O=b.useMemo(()=>{if(!w||L)return null;const X=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let F;const q=w.value;if(q&&typeof q=="object"&&!Array.isArray(q)){const pe=q.title;typeof pe=="string"&&pe.trim()&&(F=pe.trim())}return{id:`interrupt-${X}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:X,value:q,title:F}]}},[w,L]),H=b.useMemo(()=>O?[...e,O]:e,[e,O]),W=b.useMemo(()=>k?H:H.filter(X=>(X==null?void 0:X.role)!=="tool"),[H,k]),se=b.useCallback(X=>{$(X),m&&m(!X),x&&x(X)},[m,x]),K=b.useMemo(()=>{if(a)return async()=>{if(!j.current){j.current=!0;try{await a()}finally{j.current=!1}}}},[a]),U=b.useMemo(()=>!y||v?!1:B?"auto":!1,[B,y,v]);return W.length===0?u.jsx("div",{className:f,style:h,children:u.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!"})}):u.jsx("div",{className:f,style:h,children:u.jsx(ov,{ref:X=>{R.current=X},scrollerRef:X=>{P.current=X instanceof HTMLDivElement?X:null},data:W,followOutput:U,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{K&&K()},atBottomStateChange:se,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(X,F)=>cf(F,X),itemContent:(X,F)=>{const q=cf(F,X);return u.jsx("div",{className:"mb-4 last:mb-0","data-message-id":q,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(lf,{message:F,messageIndex:X,isStreamingMessage:t&&n===F.id,streamingDebounceMs:r,isEditing:i===F.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:l,onRegenerate:()=>c(X),onCancelEdit:d,activeInterrupt:w,disableInterruptActions:S,onInterruptActionStart:T,onInterruptActionEnd:C,showToolMessages:k})})}})})});Da.displayName="MessageList";const Fs=1e4;function Lb(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,`
131
131
  `).replace(/<p>(.*?)<\/p>/gi,`$1
132
132
 
133
133
  `).replace(/<h([1-6])>(.*?)<\/h[1-6]>/gi,(o,s,i)=>`${"#".repeat(parseInt(s))} ${i}
@@ -135,4 +135,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
135
135
  `).replace(/<ul>/gi,"").replace(/<\/ul>/gi,`
136
136
  `).replace(/<ol>/gi,"").replace(/<\/ol>/gi,`
137
137
  `).replace(/<li>(.*?)<\/li>/gi,`- $1
138
- `).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]=wn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=v=>{const{scope:m,children:y}=v,b=w.useRef(null),S=w.useRef(new Map).current;return c.jsx(o,{scope:m,itemMap:S,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=sr.createSlot(a),u=w.forwardRef((v,m)=>{const{scope:y,children:b}=v,S=s(a,y),T=He(m,S.collectionRef);return c.jsx(l,{ref:T,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=sr.createSlot(d),p=w.forwardRef((v,m)=>{const{scope:y,children:b,...S}=v,T=w.useRef(null),C=He(m,T),k=s(d,y);return w.useEffect(()=>(k.itemMap.set(T,{ref:T,...S}),()=>void k.itemMap.delete(T))),c.jsx(h,{[f]:"",ref:C,children:b})});p.displayName=d;function x(v){const m=s(e+"CollectionConsumer",v);return w.useCallback(()=>{const b=m.collectionRef.current;if(!b)return[];const S=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(m.itemMap.values()).sort((k,E)=>S.indexOf(k.ref.current)-S.indexOf(E.ref.current))},[m.collectionRef,m.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},x,r]}var Uw=g.createContext(void 0);function zs(e){const t=g.useContext(Uw);return e||t||"ltr"}const Ww=["top","right","bottom","left"],Xn=Math.min,Wt=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 Wt(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 qw=new Set(["top","bottom"]);function Tn(e){return qw.has(Fn(e))?"y":"x"}function Ba(e){return $a(Tn(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 ff=["left","right"],hf=["right","left"],Xw=["top","bottom"],Jw=["bottom","top"];function Zw(e,t,n){switch(e){case"top":case"bottom":return n?t?hf:ff:t?ff:hf;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 pf(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 mf(e,t,n){let{reference:r,floating:o}=e;const s=Tn(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}=mf(u,r,l),h=r,p={},x=0;for(let v=0;v<a.length;v++){const{name:m,fn:y}=a[v],{x:b,y:S,data:T,reset:C}=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=S??f,p={...p,[m]:{...p[m],...T}},C&&x<=50&&(x++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=mf(u,h,l)),v=-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),x=pf(p),m=a[h?f==="floating"?"reference":"floating":f],y=Ws(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(m)))==null||n?m:m.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,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),T=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=Ws(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(y.top-C.top+x.top)/T.y,bottom:(C.bottom-y.bottom+x.bottom)/T.y,left:(y.left-C.left+x.left)/T.x,right:(C.right-y.right+x.right)/T.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=pf(d),h={x:n,y:r},p=Ba(o),x=za(p),v=await i.getDimensions(u),m=p==="y",y=m?"top":"left",b=m?"bottom":"right",S=m?"clientHeight":"clientWidth",T=s.reference[x]+s.reference[p]-h[p]-s.floating[x],C=h[p]-s.reference[p],k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let E=k?k[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(k)))&&(E=a.floating[S]||s.floating[x]);const R=T/2-C/2,P=E/2-v[x]/2-1,j=Xn(f[y],P),H=Xn(f[b],P),$=j,L=E-v[x]-H,O=E/2-v[x]/2+R,B=Fa($,O,L),W=!l.arrow&&Dr(o)!=null&&O!==B&&s.reference[x]/2-(O<$?j:H)-v[x]/2<0,se=W?O<$?O-$:O-L:0;return{[p]:h[p]+se,data:{[p]:B,centerOffset:O-B-se,...W&&{alignmentOffset:se}},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:x="none",flipAlignment:v=!0,...m}=Ln(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=Fn(o),b=Tn(a),S=Fn(a)===a,T=await(l.isRTL==null?void 0:l.isRTL(u.floating)),C=h||(S||!v?[Us(a)]:Yw(a)),k=x!=="none";!h&&k&&C.push(...Qw(a,v,x,T));const E=[a,...C],R=await xo(t,m),P=[];let j=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&P.push(R[y]),f){const O=Gw(o,i,T);P.push(R[O[0]],R[O[1]])}if(j=[...j,{placement:o,overflows:P}],!P.every(O=>O<=0)){var H,$;const O=(((H=s.flip)==null?void 0:H.index)||0)+1,B=E[O];if(B&&(!(f==="alignment"?b!==Tn(B):!1)||j.every(K=>Tn(K.placement)===b?K.overflows[0]>0:!0)))return{data:{index:O,overflows:j},reset:{placement:B}};let W=($=j.filter(se=>se.overflows[0]<=0).sort((se,K)=>se.overflows[1]-K.overflows[1])[0])==null?void 0:$.placement;if(!W)switch(p){case"bestFit":{var L;const se=(L=j.filter(K=>{if(k){const U=Tn(K.placement);return U===b||U==="y"}return!0}).map(K=>[K.placement,K.overflows.filter(U=>U>0).reduce((U,X)=>U+X,0)]).sort((K,U)=>K[1]-U[1])[0])==null?void 0:L[0];se&&(W=se);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 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=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 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=Tn(n)==="y",u=yf.has(i)?-1:1,d=s&&l?-1:1,f=Ln(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:x}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof x=="number"&&(p=a==="end"?x*-1:x),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:m=>{let{x:y,y:b}=m;return{x:y,y:b}}},...l}=Ln(e,t),u={x:n,y:r},d=await xo(t,l),f=Tn(Fn(o)),h=$a(f);let p=u[h],x=u[f];if(s){const m=h==="y"?"top":"left",y=h==="y"?"bottom":"right",b=p+d[m],S=p-d[y];p=Fa(b,p,S)}if(i){const m=f==="y"?"top":"left",y=f==="y"?"bottom":"right",b=x+d[m],S=x-d[y];x=Fa(b,x,S)}const v=a.fn({...t,[h]:p,[f]:x});return{...v,data:{x:v.x-n,y:v.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=Tn(o),h=$a(f);let p=d[h],x=d[f];const v=Ln(a,t),m=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(l){const S=h==="y"?"height":"width",T=s.reference[h]-s.floating[S]+m.mainAxis,C=s.reference[h]+s.reference[S]-m.mainAxis;p<T?p=T:p>C&&(p=C)}if(u){var y,b;const S=h==="y"?"width":"height",T=yf.has(Fn(o)),C=s.reference[f]-s.floating[S]+(T&&((y=i.offset)==null?void 0:y[f])||0)+(T?0:m.crossAxis),k=s.reference[f]+s.reference[S]+(T?0:((b=i.offset)==null?void 0:b[f])||0)-(T?m.crossAxis:0);x<C?x=C:x>k&&(x=k)}return{[h]:p,[f]:x}}}},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=Tn(o)==="y",{width:x,height:v}=s.floating;let m,y;f==="top"||f==="bottom"?(m=f,y=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=f,m=h==="end"?"top":"bottom");const b=v-d.top-d.bottom,S=x-d.left-d.right,T=Xn(v-d[m],b),C=Xn(x-d[y],S),k=!t.middlewareData.shift;let E=T,R=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(R=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),k&&!h){const j=Wt(d.left,0),H=Wt(d.right,0),$=Wt(d.top,0),L=Wt(d.bottom,0);p?R=x-2*(j!==0||H!==0?j+H:Wt(d.left,d.right)):E=v-2*($!==0||L!==0?$+L:Wt(d.top,d.bottom))}await l({...t,availableWidth:R,availableHeight:E});const P=await i.getDimensions(a.floating);return x!==P.width||v!==P.height?{reset:{rects:!0}}:{}}}};function Vs(){return typeof window<"u"}function Lr(e){return vf(e)?(e.nodeName||"").toLowerCase():"#document"}function Vt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function En(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 Vt(e).Node:!1}function an(e){return Vs()?e instanceof Element||e instanceof Vt(e).Element:!1}function In(e){return Vs()?e instanceof HTMLElement||e instanceof Vt(e).HTMLElement:!1}function bf(e){return!Vs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Vt(e).ShadowRoot}const u0=new Set(["inline","contents"]);function yo(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=ln(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=an(e)?ln(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=Jn(e);for(;In(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 y0=new Set(["html","body","#document"]);function Fr(e){return y0.has(Lr(e))}function ln(e){return Vt(e).getComputedStyle(e)}function qs(e){return an(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||En(e);return bf(t)?t.host:t}function wf(e){const t=Jn(e);return Fr(t)?e.ownerDocument?e.ownerDocument.body:e.body:In(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=Vt(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=ln(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=In(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 an(e)?e:e.contextElement}function $r(e){const t=Ka(e);if(!In(t))return kn(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 v0=kn(0);function Cf(e){const t=Vt(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!==Vt(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?an(r)&&(i=$r(r)):i=$r(e));const a=b0(s,n,r)?Cf(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=Vt(s),p=r&&an(r)?Vt(r):r;let x=h,v=Va(x);for(;v&&r&&p!==x;){const m=$r(v),y=v.getBoundingClientRect(),b=ln(v),S=y.left+(v.clientLeft+parseFloat(b.paddingLeft))*m.x,T=y.top+(v.clientTop+parseFloat(b.paddingTop))*m.y;l*=m.x,u*=m.y,d*=m.x,f*=m.y,l+=S,u+=T,x=Vt(v),v=Va(x)}}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(En(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 w0(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=En(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=In(r);if((f||!f&&!s)&&((Lr(r)!=="body"||yo(i))&&(l=qs(r)),In(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?kf(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=En(e),n=qs(e),r=e.ownerDocument.body,o=Wt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Wt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Gs(e);const a=-n.scrollTop;return ln(r).direction==="rtl"&&(i+=Wt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Tf=25;function k0(e,t){const n=Vt(e),r=En(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,x=Math.abs(r.clientWidth-f.clientWidth-p);x<=Tf&&(s-=x)}else u<=Tf&&(s+=u);return{width:s,height:i,x:a,y:l}}const T0=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=In(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 Ef(e,t,n){let r;if(t==="viewport")r=k0(e,n);else if(t==="document")r=C0(En(e));else if(an(t))r=E0(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||!an(n)||Fr(n)?!1:ln(n).position==="fixed"||If(n,t)}function I0(e,t){const n=t.get(e);if(n)return n;let r=vo(e,[],!1).filter(a=>an(a)&&Lr(a)!=="body"),o=null;const s=ln(e).position==="fixed";let i=s?Jn(e):e;for(;an(i)&&!Fr(i);){const a=ln(i),l=Ua(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&T0.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 A0(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=Ef(t,d,o);return u.top=Wt(f.top,u.top),u.right=Xn(f.right,u.right),u.bottom=Xn(f.bottom,u.bottom),u.left=Wt(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 N0(e){const{width:t,height:n}=Sf(e);return{width:t,height:n}}function _0(e,t,n){const r=In(t),o=En(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?kf(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 ln(e).position==="static"}function Af(e,t){if(!In(e)||ln(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return En(e)===n&&(n=n.ownerDocument.body),n}function Nf(e,t){const n=Vt(e);if(Ks(e))return n;if(!In(e)){let o=Jn(e);for(;o&&!Fr(o);){if(an(o)&&!qa(o))return o;o=Jn(o)}return n}let r=Af(e,t);for(;r&&f0(r)&&qa(r);)r=Af(r,t);return r&&Fr(r)&&qa(r)&&!Ua(r)?n:r||x0(e)||n}const j0=async function(e){const t=this.getOffsetParent||Nf,n=this.getDimensions,r=await n(e.floating);return{reference:_0(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function R0(e){return ln(e).direction==="rtl"}const P0={convertOffsetParentRelativeRectToViewportRelativeRect:w0,getDocumentElement:En,getClippingRect:A0,getOffsetParent:Nf,getElementRects:j0,getClientRects:S0,getDimensions:N0,getScale:$r,isElement:an,isRTL:R0};function _f(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=En(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 x=Hs(f),v=Hs(o.clientWidth-(d+h)),m=Hs(o.clientHeight-(f+p)),y=Hs(d),S={rootMargin:-x+"px "+-v+"px "+-m+"px "+-y+"px",threshold:Wt(0,Xn(1,l))||1};let T=!0;function C(k){const E=k[0].intersectionRatio;if(E!==l){if(!T)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!_f(u,e.getBoundingClientRect())&&i(),T=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}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 S;(S=p)==null||S.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let x,v=l?yr(e):null;l&&m();function m(){const y=yr(e);v&&!_f(v,y)&&n(),v=y,x=requestAnimationFrame(m)}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(x)}}const D0=i0,L0=a0,F0=r0,$0=c0,z0=o0,jf=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 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=g.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]=g.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=g.useState(r);Xs(h,r)||p(r);const[x,v]=g.useState(null),[m,y]=g.useState(null),b=g.useCallback(K=>{K!==k.current&&(k.current=K,v(K))},[]),S=g.useCallback(K=>{K!==E.current&&(E.current=K,y(K))},[]),T=s||x,C=i||m,k=g.useRef(null),E=g.useRef(null),R=g.useRef(d),P=l!=null,j=Ga(l),H=Ga(o),$=Ga(u),L=g.useCallback(()=>{if(!k.current||!E.current)return;const K={placement:t,strategy:n,middleware:h};H.current&&(K.platform=H.current),H0(k.current,E.current,K).then(U=>{const X={...U,isPositioned:$.current!==!1};O.current&&!Xs(R.current,X)&&(R.current=X,Po.flushSync(()=>{f(X)}))})},[h,t,n,H,$]);Ys(()=>{u===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,f(K=>({...K,isPositioned:!1})))},[u]);const O=g.useRef(!1);Ys(()=>(O.current=!0,()=>{O.current=!1}),[]),Ys(()=>{if(T&&(k.current=T),C&&(E.current=C),T&&C){if(j.current)return j.current(T,C,L);L()}},[T,C,L,j,P]);const B=g.useMemo(()=>({reference:k,floating:E,setReference:b,setFloating:S}),[b,S]),W=g.useMemo(()=>({reference:T,floating:C}),[T,C]),se=g.useMemo(()=>{const K={position:n,left:0,top:0};if(!W.floating)return K;const U=Pf(W.floating,d.x),X=Pf(W.floating,d.y);return a?{...K,transform:"translate("+U+"px, "+X+"px)",...Rf(W.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:U,top:X}},[n,a,W.floating,d.x,d.y]);return g.useMemo(()=>({...d,update:L,refs:B,elements:W,floatingStyles:se}),[d,L,B,W,se])}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?jf({element:r.current,padding:o}).fn(n):{}:r?jf({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",Of=g.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"})})});Of.displayName=eS;var tS=Of;function Mf(e){const[t,n]=g.useState(void 0);return yt(()=>{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]=wn(Ya),[nS,Lf]=Df(Ya),Ff=e=>{const{__scopePopper:t,children:n}=e,[r,o]=g.useState(null);return c.jsx(nS,{scope:t,anchor:r,onAnchorChange:o,children:n})};Ff.displayName=Ya;var $f="PopperAnchor",zf=g.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Lf($f,n),i=g.useRef(null),a=He(t,i),l=g.useRef(null);return g.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})});zf.displayName=$f;var Xa="PopperContent",[rS,oS]=Df(Xa),Bf=g.forwardRef((e,t)=>{var J,D,ee,re,ae,le;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:x,...v}=e,m=Lf(Xa,n),[y,b]=g.useState(null),S=He(t,ie=>b(ie)),[T,C]=g.useState(null),k=Mf(T),E=(k==null?void 0:k.width)??0,R=(k==null?void 0:k.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],$=H.length>0,L={padding:j,boundary:H.filter(iS),altBoundary:$},{refs:O,floatingStyles:B,placement:W,isPositioned:se,middlewareData:K}=V0({strategy:"fixed",placement:P,whileElementsMounted:(...ie)=>M0(...ie,{animationFrame:p==="always"}),elements:{reference:m.anchor},middleware:[q0({mainAxis:o+R,alignmentAxis:i}),l&&G0({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Y0():void 0,...L}),l&&X0({...L}),J0({...L,apply:({elements:ie,rects:Ge,availableWidth:Je,availableHeight:De})=>{const{width:Ue,height:at}=Ge.reference,Ke=ie.floating.style;Ke.setProperty("--radix-popper-available-width",`${Je}px`),Ke.setProperty("--radix-popper-available-height",`${De}px`),Ke.setProperty("--radix-popper-anchor-width",`${Ue}px`),Ke.setProperty("--radix-popper-anchor-height",`${at}px`)}}),T&&Q0({element:T,padding:a}),aS({arrowWidth:E,arrowHeight:R}),h&&Z0({strategy:"referenceHidden",...L})]}),[U,X]=Wf(W),F=St(x);yt(()=>{se&&(F==null||F())},[se,F]);const q=(J=K.arrow)==null?void 0:J.x,me=(D=K.arrow)==null?void 0:D.y,ge=((ee=K.arrow)==null?void 0:ee.centerOffset)!==0,[ke,Se]=g.useState();return yt(()=>{y&&Se(window.getComputedStyle(y).zIndex)},[y]),c.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...B,transform:se?B.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ke,"--radix-popper-transform-origin":[(re=K.transformOrigin)==null?void 0:re.x,(ae=K.transformOrigin)==null?void 0:ae.y].join(" "),...((le=K.hide)==null?void 0:le.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(rS,{scope:n,placedSide:U,onArrowChange:C,arrowX:q,arrowY:me,shouldHideArrow:ge,children:c.jsx(Ie.div,{"data-side":U,"data-align":X,...v,ref:S,style:{...v.style,animation:se?void 0:"none"}})})})});Bf.displayName=Xa;var Hf="PopperArrow",sS={top:"bottom",right:"left",bottom:"top",left:"right"},Uf=g.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=oS(Hf,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"}})})});Uf.displayName=Hf;function iS(e){return e!==null}var aS=e=>({name:"transformOrigin",options:e,fn(t){var m,y,b;const{placement:n,rects:r,middlewareData:o}=t,i=((m=o.arrow)==null?void 0:m.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 x="",v="";return u==="bottom"?(x=i?f:`${h}px`,v=`${-l}px`):u==="top"?(x=i?f:`${h}px`,v=`${r.floating.height+l}px`):u==="right"?(x=`${-l}px`,v=i?f:`${p}px`):u==="left"&&(x=`${r.floating.width+l}px`,v=i?f:`${p}px`),{data:{x,y:v}}}});function Wf(e){const[t,n="center"]=e.split("-");return[t,n]}var Vf=Ff,Kf=zf,qf=Bf,Gf=Uf,Ja="rovingFocusGroup.onEntryFocus",lS={bubbles:!1,cancelable:!0},bo="RovingFocusGroup",[Za,Yf,cS]=La(bo),[uS,Xf]=wn(bo,[cS]),[dS,fS]=uS(bo),Jf=g.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})})}));Jf.displayName=bo;var hS=g.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=g.useRef(null),p=He(t,h),x=zs(s),[v,m]=pr({prop:i,defaultProp:a??null,onChange:l,caller:bo}),[y,b]=g.useState(!1),S=St(u),T=Yf(n),C=g.useRef(!1),[k,E]=g.useState(0);return g.useEffect(()=>{const R=h.current;if(R)return R.addEventListener(Ja,S),()=>R.removeEventListener(Ja,S)},[S]),c.jsx(dS,{scope:n,orientation:r,dir:x,loop:o,currentTabStopId:v,onItemFocus:g.useCallback(R=>m(R),[m]),onItemShiftTab:g.useCallback(()=>b(!0),[]),onFocusableItemAdd:g.useCallback(()=>E(R=>R+1),[]),onFocusableItemRemove:g.useCallback(()=>E(R=>R-1),[]),children:c.jsx(Ie.div,{tabIndex:y||k===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:he(e.onMouseDown,()=>{C.current=!0}),onFocus:he(e.onFocus,R=>{const P=!C.current;if(R.target===R.currentTarget&&P&&!y){const j=new CustomEvent(Ja,lS);if(R.currentTarget.dispatchEvent(j),!j.defaultPrevented){const H=T().filter(W=>W.focusable),$=H.find(W=>W.active),L=H.find(W=>W.id===v),B=[$,L,...H].filter(Boolean).map(W=>W.ref.current);eh(B,d)}}C.current=!1}),onBlur:he(e.onBlur,()=>b(!1))})})}),Zf="RovingFocusGroupItem",Qf=g.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Sn(),u=s||l,d=fS(Zf,n),f=d.currentTabStopId===u,h=Yf(n),{onFocusableItemAdd:p,onFocusableItemRemove:x,currentTabStopId:v}=d;return g.useEffect(()=>{if(r)return p(),()=>x()},[r,p,x]),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:he(e.onMouseDown,m=>{r?d.onItemFocus(u):m.preventDefault()}),onFocus:he(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:he(e.onKeyDown,m=>{if(m.key==="Tab"&&m.shiftKey){d.onItemShiftTab();return}if(m.target!==m.currentTarget)return;const y=gS(m,d.orientation,d.dir);if(y!==void 0){if(m.metaKey||m.ctrlKey||m.altKey||m.shiftKey)return;m.preventDefault();let S=h().filter(T=>T.focusable).map(T=>T.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const T=S.indexOf(m.currentTarget);S=d.loop?xS(S,T+1):S.slice(T+1)}setTimeout(()=>eh(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:v!=null}):i})})});Qf.displayName=Zf;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 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 xS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var yS=Jf,vS=Qf,Qa=["Enter"," "],bS=["ArrowDown","PageUp","Home"],th=["ArrowUp","PageDown","End"],wS=[...bS,...th],SS={ltr:[...Qa,"ArrowRight"],rtl:[...Qa,"ArrowLeft"]},CS={ltr:["ArrowLeft"],rtl:["ArrowRight"]},wo="Menu",[So,kS,TS]=La(wo),[vr,nh]=wn(wo,[TS,Js,Xf]),Zs=Js(),rh=Xf(),[ES,br]=vr(wo),[IS,Co]=vr(wo),oh=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=Zs(t),[l,u]=g.useState(null),d=g.useRef(!1),f=St(s),h=zs(o);return g.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},x=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),c.jsx(Vf,{...a,children:c.jsx(ES,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(IS,{scope:t,onClose:g.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};oh.displayName=wo;var AS="MenuAnchor",el=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Zs(n);return c.jsx(Kf,{...o,...r,ref:t})});el.displayName=AS;var tl="MenuPortal",[NS,sh]=vr(tl,{forceMount:void 0}),ih=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=br(tl,t);return c.jsx(NS,{scope:t,forceMount:n,children:c.jsx(Ut,{present:n||s.open,children:c.jsx(ws,{asChild:!0,container:o,children:r})})})};ih.displayName=tl;var Zt="MenuContent",[_S,nl]=vr(Zt),ah=g.forwardRef((e,t)=>{const n=sh(Zt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=br(Zt,e.__scopeMenu),i=Co(Zt,e.__scopeMenu);return c.jsx(So.Provider,{scope:e.__scopeMenu,children:c.jsx(Ut,{present:r||s.open,children:c.jsx(So.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(jS,{...o,ref:t}):c.jsx(RS,{...o,ref:t})})})})}),jS=g.forwardRef((e,t)=>{const n=br(Zt,e.__scopeMenu),r=g.useRef(null),o=He(t,r);return g.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)})}),RS=g.forwardRef((e,t)=>{const n=br(Zt,e.__scopeMenu);return c.jsx(rl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),PS=sr.createSlot("MenuContent.ScrollLock"),rl=g.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:x,...v}=e,m=br(Zt,n),y=Co(Zt,n),b=Zs(n),S=rh(n),T=kS(n),[C,k]=g.useState(null),E=g.useRef(null),R=He(t,E,m.onContentChange),P=g.useRef(0),j=g.useRef(""),H=g.useRef(0),$=g.useRef(null),L=g.useRef("right"),O=g.useRef(0),B=x?Is:g.Fragment,W=x?{as:PS,allowPinchZoom:!0}:void 0,se=U=>{var J,D;const X=j.current+U,F=T().filter(ee=>!ee.disabled),q=document.activeElement,me=(J=F.find(ee=>ee.ref.current===q))==null?void 0:J.textValue,ge=F.map(ee=>ee.textValue),ke=VS(ge,X,me),Se=(D=F.find(ee=>ee.textValue===ke))==null?void 0:D.ref.current;(function ee(re){j.current=re,window.clearTimeout(P.current),re!==""&&(P.current=window.setTimeout(()=>ee(""),1e3))})(X),Se&&setTimeout(()=>Se.focus())};g.useEffect(()=>()=>window.clearTimeout(P.current),[]),Ea();const K=g.useCallback(U=>{var F,q;return L.current===((F=$.current)==null?void 0:F.side)&&qS(U,(q=$.current)==null?void 0:q.area)},[]);return c.jsx(_S,{scope:n,searchRef:j,onItemEnter:g.useCallback(U=>{K(U)&&U.preventDefault()},[K]),onItemLeave:g.useCallback(U=>{var X;K(U)||((X=E.current)==null||X.focus(),k(null))},[K]),onTriggerLeave:g.useCallback(U=>{K(U)&&U.preventDefault()},[K]),pointerGraceTimerRef:H,onPointerGraceIntentChange:g.useCallback(U=>{$.current=U},[]),children:c.jsx(B,{...W,children:c.jsx(bs,{asChild:!0,trapped:o,onMountAutoFocus:he(s,U=>{var X;U.preventDefault(),(X=E.current)==null||X.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(yS,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:he(l,U=>{y.isUsingKeyboardRef.current||U.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(qf,{role:"menu","aria-orientation":"vertical","data-state":kh(m.open),"data-radix-menu-content":"",dir:y.dir,...b,...v,ref:R,style:{outline:"none",...v.style},onKeyDown:he(v.onKeyDown,U=>{const F=U.target.closest("[data-radix-menu-content]")===U.currentTarget,q=U.ctrlKey||U.altKey||U.metaKey,me=U.key.length===1;F&&(U.key==="Tab"&&U.preventDefault(),!q&&me&&se(U.key));const ge=E.current;if(U.target!==ge||!wS.includes(U.key))return;U.preventDefault();const Se=T().filter(J=>!J.disabled).map(J=>J.ref.current);th.includes(U.key)&&Se.reverse(),US(Se)}),onBlur:he(e.onBlur,U=>{U.currentTarget.contains(U.target)||(window.clearTimeout(P.current),j.current="")}),onPointerMove:he(e.onPointerMove,To(U=>{const X=U.target,F=O.current!==U.clientX;if(U.currentTarget.contains(X)&&F){const q=U.clientX>O.current?"right":"left";L.current=q,O.current=U.clientX}}))})})})})})})});ah.displayName=Zt;var OS="MenuGroup",ol=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ie.div,{role:"group",...r,ref:t})});ol.displayName=OS;var MS="MenuLabel",lh=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ie.div,{...r,ref:t})});lh.displayName=MS;var Qs="MenuItem",ch="menu.itemSelect",ei=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=g.useRef(null),i=Co(Qs,e.__scopeMenu),a=nl(Qs,e.__scopeMenu),l=He(t,s),u=g.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=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=nl(Qs,n),a=rh(n),l=g.useRef(null),u=He(t,l),[d,f]=g.useState(!1),[h,p]=g.useState("");return g.useEffect(()=>{const x=l.current;x&&p((x.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:he(e.onPointerMove,To(x=>{r?i.onItemLeave(x):(i.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:he(e.onPointerLeave,To(x=>i.onItemLeave(x))),onFocus:he(e.onFocus,()=>f(!0)),onBlur:he(e.onBlur,()=>f(!1))})})})}),DS="MenuCheckboxItem",dh=g.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=DS;var fh="MenuRadioGroup",[LS,FS]=vr(fh,{value:void 0,onValueChange:()=>{}}),hh=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=St(r);return c.jsx(LS,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(ol,{...o,ref:t})})});hh.displayName=fh;var ph="MenuRadioItem",mh=g.forwardRef((e,t)=>{const{value:n,...r}=e,o=FS(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,$S]=vr(sl,{checked:!1}),xh=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=$S(sl,n);return c.jsx(Ut,{present:r||ti(s.checked)||s.checked===!0,children:c.jsx(Ie.span,{...o,ref:t,"data-state":il(s.checked)})})});xh.displayName=sl;var zS="MenuSeparator",yh=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ie.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});yh.displayName=zS;var BS="MenuArrow",vh=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Zs(n);return c.jsx(Gf,{...o,...r,ref:t})});vh.displayName=BS;var HS="MenuSub",[TT,bh]=vr(HS),ko="MenuSubTrigger",wh=g.forwardRef((e,t)=>{const n=br(ko,e.__scopeMenu),r=Co(ko,e.__scopeMenu),o=bh(ko,e.__scopeMenu),s=nl(ko,e.__scopeMenu),i=g.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},d=g.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return g.useEffect(()=>d,[d]),g.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,x;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const v=(x=n.content)==null?void 0:x.dataset.side,m=v==="right",y=m?-5:5,b=h[m?"left":"right"],S=h[m?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+y,y:f.clientY},{x:b,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:b,y:h.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:he(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())})})})});wh.displayName=ko;var Sh="MenuSubContent",Ch=g.forwardRef((e,t)=>{const n=sh(Zt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=br(Zt,e.__scopeMenu),i=Co(Zt,e.__scopeMenu),a=bh(Sh,e.__scopeMenu),l=g.useRef(null),u=He(t,l);return c.jsx(So.Provider,{scope:e.__scopeMenu,children:c.jsx(Ut,{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=CS[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 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 To(e){return t=>t.pointerType==="mouse"?e(t):void 0}var GS=oh,YS=el,XS=ih,JS=ah,ZS=ol,QS=lh,eC=ei,tC=dh,nC=hh,rC=mh,oC=xh,sC=yh,iC=vh,aC=wh,lC=Ch,ni="DropdownMenu",[cC,ET]=wn(ni,[nh]),Ot=nh(),[uC,Th]=cC(ni),Eh=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Ot(t),u=g.useRef(null),[d,f]=pr({prop:o,defaultProp:s??!1,onChange:i,caller:ni});return c.jsx(uC,{scope:t,triggerId:Sn(),triggerRef:u,contentId:Sn(),open:d,onOpenChange:f,onOpenToggle:g.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(GS,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Eh.displayName=ni;var Ih="DropdownMenuTrigger",Ah=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Th(Ih,n),i=Ot(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: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 dC="DropdownMenuPortal",Nh=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ot(t);return c.jsx(XS,{...r,...n})};Nh.displayName=dC;var _h="DropdownMenuContent",jh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Th(_h,n),s=Ot(n),i=g.useRef(!1);return c.jsx(JS,{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 fC="DropdownMenuGroup",hC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(ZS,{...o,...r,ref:t})});hC.displayName=fC;var pC="DropdownMenuLabel",Rh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(QS,{...o,...r,ref:t})});Rh.displayName=pC;var mC="DropdownMenuItem",Ph=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(eC,{...o,...r,ref:t})});Ph.displayName=mC;var gC="DropdownMenuCheckboxItem",Oh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(tC,{...o,...r,ref:t})});Oh.displayName=gC;var xC="DropdownMenuRadioGroup",yC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(nC,{...o,...r,ref:t})});yC.displayName=xC;var vC="DropdownMenuRadioItem",Mh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(rC,{...o,...r,ref:t})});Mh.displayName=vC;var bC="DropdownMenuItemIndicator",Dh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(oC,{...o,...r,ref:t})});Dh.displayName=bC;var wC="DropdownMenuSeparator",Lh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(sC,{...o,...r,ref:t})});Lh.displayName=wC;var SC="DropdownMenuArrow",CC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(iC,{...o,...r,ref:t})});CC.displayName=SC;var kC="DropdownMenuSubTrigger",Fh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(aC,{...o,...r,ref:t})});Fh.displayName=kC;var TC="DropdownMenuSubContent",$h=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(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)"}})});$h.displayName=TC;var EC=Eh,IC=Ah,AC=Nh,zh=jh,Bh=Rh,Hh=Ph,Uh=Oh,Wh=Mh,Vh=Dh,Kh=Lh,qh=Fh,Gh=$h;const NC=EC,_C=IC,jC=g.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(qh,{ref:o,className:oe("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(pe.ChevronRight,{className:"ml-auto h-4 w-4"})]}));jC.displayName=qh.displayName;const RC=g.forwardRef(({className:e,...t},n)=>c.jsx(Gh,{ref:n,className:oe("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=Gh.displayName;const Yh=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(AC,{children:c.jsx(zh,{ref:r,sideOffset:t,className:oe("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=g.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Hh,{ref:r,className:oe("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 PC=g.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(Uh,{ref:o,className:oe("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(pe.Check,{className:"h-4 w-4"})})}),t]}));PC.displayName=Uh.displayName;const OC=g.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Wh,{ref:r,className:oe("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(pe.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));OC.displayName=Wh.displayName;const MC=g.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Bh,{ref:r,className:oe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));MC.displayName=Bh.displayName;const DC=g.forwardRef(({className:e,...t},n)=>c.jsx(Kh,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));DC.displayName=Kh.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,showToolMessages:d=!0,customStyles:f={},onMessageSent:h,onExcelUploadSuccess:p,onError:x}){const{api:v}=Ni(),{currentThreadId:m}=Yo(),{threadId:y,messages:b,hasMore:S,isHistoryLoading:T,isLoading:C,loadOlder:k,navigateToCheckpoint:E,returnToLatest:R,checkpoint:P,checkpoints:j,interrupt:H,metadata:$}=Xo(),{isStreaming:L,error:O,submit:B,stop:W}=Uc(),se=y??m??null,K=(P==null?void 0:P.id)??null,U=(P==null?void 0:P.namespace)??null,X=($==null?void 0:$.assemblingMessageId)??null,F=H,[q,me]=w.useState(!1);w.useEffect(()=>{F||me(!1)},[F]);const ge=w.useCallback(()=>{me(!0)},[]),ke=w.useCallback(()=>{me(!1)},[]),Se=!!F||q,[J,D]=w.useState(null),[ee,re]=w.useState(""),[ae,le]=w.useState(null),[ie,Ge]=w.useState([]),[Je,De]=w.useState(0),[Ue,at]=w.useState(0),[Ke,je]=w.useState(!1),[mt,gt]=w.useState(null),[Ct,rt]=w.useState(null),[te,ue]=w.useState(!1),[xe,ze]=w.useState(null),[Pe,et]=w.useState(!1),xt=w.useRef(!1),[$t,un]=w.useState(!1),Nn=w.useCallback((N,z)=>{if(!N||typeof N!="object")return null;const G=N[z];return typeof G=="number"?G:null},[]),tr=w.useCallback((N,z)=>{if(!N||typeof N!="object")return null;const G=N[z];return typeof G=="string"&&G.trim()?G:null},[]),dn=w.useMemo(()=>{const N=Array.isArray(j)?[...j]:[];return N.some(G=>Nn(G.metadata,"step")!==null)&&N.sort((G,ve)=>{const Ce=Nn(G.metadata,"step"),Ae=Nn(ve.metadata,"step");if(Ce!==null||Ae!==null)return(Ae??Number.NEGATIVE_INFINITY)-(Ce??Number.NEGATIVE_INFINITY);const Oe=Date.parse(G.createdAt??""),dt=Date.parse(ve.createdAt??"");return Number.isNaN(Oe)||Number.isNaN(dt)?0:dt-Oe}),N},[j,Nn]),fn=w.useRef(null),Mt=w.useRef(null),hn=w.useCallback(()=>{fn.current&&(fn.current.value=""),Mt.current&&(Mt.current.value=""),De(N=>N+1),at(N=>N+1)},[]),Kt=w.useRef(!1);w.useEffect(()=>{Kt.current&&!L&&(Ge([]),hn()),Kt.current=L},[L,hn]);const[kt,kr]=w.useState("desktop");w.useEffect(()=>{const N=()=>{const z=window.innerWidth;kr(z<640?"phone":z<1024?"tablet":"desktop")};return N(),window.addEventListener("resize",N),()=>window.removeEventListener("resize",N)},[]),w.useEffect(()=>{et(!1),xt.current=!1},[se]);const nr=w.useCallback(async()=>{if(!(!S||T||!Pe))try{await k()}catch(N){console.warn("loadOlder failed",N)}},[S,Pe,T,k]);w.useEffect(()=>{(async()=>{if(!v.baseUrl){ze(null);return}try{const z=await v.getAgent("default");ze(z.uiDefaultMessage||null)}catch(z){console.warn("Failed to fetch default message:",z),ze(null)}})()},[v]),w.useEffect(()=>{O&&!te&&(x==null||x(O))},[O,te,x]);const vt=N=>{if(N.length>$s)return`Message too long (${N.length}/${$s} characters)`;try{return Hw(N),null}catch(z){return(z==null?void 0:z.message)||"Invalid message"}},pn=async N=>{const z=N.trim();if(!(!z&&ie.length===0)){if(z){const G=vt(z);if(G){le(G);return}}try{await B({text:z||"",attachments:ie,payload:J?{edit:!0,originalMessageId:J}:void 0},{checkpointId:K??void 0,checkpointNs:U??void 0}),h==null||h(z),le(null),Ge([]),hn(),D(null),re("")}catch(G){const ve=(G==null?void 0:G.message)||"Failed to send message";le(ve),x==null||x(ve)}}},_n=w.useCallback((N,z)=>{u&&(D(N),re(z),le(null))},[u]),$n=w.useCallback(()=>{D(null),re(""),le(null)},[]),qt=w.useCallback((N,z)=>{_n(N,z)},[_n]),Tr=w.useCallback(N=>{const z=G=>{const ve=G.content||[],Ce=ve.filter(Ae=>Ae.type==="text").map(Ae=>Ae.text).join("");if(Ce)return Ce;try{return JSON.stringify(ve,null,2)}catch{return String(ve)}};for(let G=N-1;G>=0;G--)if(b[G].role==="user"){const ve=z(b[G]);ve&&B({text:ve},{checkpointId:K??void 0,checkpointNs:U??void 0});break}},[b,B,K,U]),jn=N=>{const z=Array.from(N.target.files||[]);Ge(G=>[...G,...z]),N.target.value=""},mn=N=>{Ge(z=>{const G=z.filter((ve,Ce)=>N!==Ce);return G.length===0&&hn(),G})},rr=async N=>{const z=(N.target.files||[])[0];if(z){gt(null),rt(null),je(!0);try{await B({attachments:[z]},{checkpointId:K??void 0,checkpointNs:U??void 0});const G=`Uploaded ${z.name} - processing through chat stream`;rt(G)}catch(G){const ve=G instanceof Error?G.message:"Failed to upload Excel file";console.error("Excel upload failed",G),gt(ve),x==null||x(ve)}finally{je(!1),N.target.value="",hn()}}},Io=N=>{if(!N)return"Unknown";const z=Date.parse(N);return Number.isNaN(z)?N:new Date(z).toLocaleString()},Ur=async N=>{if(m){un(!0);try{if(!N){await R();return}const z=dn.find(ve=>ve.checkpointId===N),G=(z==null?void 0:z.checkpointNs)??null;await E(N,G)}finally{un(!1)}}},Wr=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${f.container||""}`,or=`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 ${f.messagesArea||""}`,I=`flex-shrink-0 w-full border-t p-4 bg-transparent ${f.inputArea||""}`;return c.jsxs("div",{className:Wr,children:[!!O&&!te&&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:O}),c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>ue(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(pe.X,{size:16})})]}),m&&j.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:K??"",onChange:N=>{const z=N.target.value||null;Ur(z)},children:[c.jsx("option",{value:"",children:"Latest"}),dn.map(N=>{const z=Nn(N.metadata,"step"),G=tr(N.metadata,"source"),ve=LC(N.messages),Ce=[];z!==null&&Ce.push(`Step ${z}`),G&&Ce.push(G),ve&&Ce.push(ve.slice(0,40));const Ae=Ce.length?` — ${Ce.join(" • ")}`:"";return c.jsxs("option",{value:N.checkpointId,children:[Io(N.createdAt),Ae]},N.checkpointId)})]})]}),c.jsxs("div",{className:`relative ${or}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(Da,{className:"h-full",style:{height:"100%"},messages:b,isStreaming:L,streamingAssistantId:X,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:kt,enableMessageEditing:u,editingMessageId:J,onStartReached:()=>{Pe&&nr()},onScrollAway:N=>{if(!xt.current){xt.current=!0;return}N&&et(!0)},onEdit:qt,onRegenerate:Tr,onCancelEdit:$n,emptyMessage:xe??void 0,isNavigatingCheckpoint:$t,activeInterrupt:F,disableInterruptActions:q,onInterruptActionStart:ge,onInterruptActionEnd:ke,showToolMessages:d}),C&&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(pe.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:I,children:[J&&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(pe.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:$n,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(pe.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:fn,type:"file",multiple:!0,onChange:N=>jn(N),className:"hidden"},Je),ie.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:ie.map((N,z)=>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(pe.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:N.name}),c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>mn(z),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 ${N.name}`,children:c.jsx(pe.X,{size:12})})]},z))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:Mt,type:"file",accept:".xls,.xlsx,.xlsm",onChange:rr,className:"hidden"},Ue),Ke&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(pe.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),Ct&&!Ke&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:Ct}),mt&&!Ke&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:mt})]})]}),ae&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:ae}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(NC,{children:[c.jsx(_C,{asChild:!0,children:c.jsx(qe,{type:"button",size:"icon",variant:"outline",disabled:L||Se,title:"More input actions",className:f.moreButton||"",children:c.jsx(pe.Plus,{size:16})})}),c.jsxs(Yh,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(al,{onClick:()=>{var N;return(N=fn.current)==null?void 0:N.click()},className:"cursor-pointer",children:[c.jsx(pe.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(al,{onClick:()=>{var N;Ke||(N=Mt.current)==null||N.click()},className:`cursor-pointer ${Ke?"opacity-60 pointer-events-none":""}`,children:[c.jsx(pe.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx(Xx,{initialValue:ee,editingMessageId:J,placeholder:J?"Edit your message...":t,isStreaming:L,disabled:Se,maxLength:$s,onSend:pn,onCancelEdit:$n,onStop:W,allowEmptySend:ie.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${J?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${ae?"border-red-400":""} ${f.textarea||""}`})})]})]})]})}const oi=g.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:oe("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 g.useReducer((n,r)=>t[n][r]??n,e)}var cl="ScrollArea",[Xh,IT]=wn(cl),[$C,Qt]=Xh(cl),Jh=g.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=g.useState(null),[u,d]=g.useState(null),[f,h]=g.useState(null),[p,x]=g.useState(null),[v,m]=g.useState(null),[y,b]=g.useState(0),[S,T]=g.useState(0),[C,k]=g.useState(!1),[E,R]=g.useState(!1),P=He(t,H=>l(H)),j=zs(o);return c.jsx($C,{scope:n,type:r,dir:j,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:x,scrollbarXEnabled:C,onScrollbarXEnabledChange:k,scrollbarY:v,onScrollbarYChange:m,scrollbarYEnabled:E,onScrollbarYEnabledChange:R,onCornerWidthChange:b,onCornerHeightChange:T,children:c.jsx(Ie.div,{dir:j,...i,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Jh.displayName=cl;var Zh="ScrollAreaViewport",Qh=g.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Qt(Zh,n),a=g.useRef(null),l=He(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})})]})});Qh.displayName=Zh;var An="ScrollAreaScrollbar",ul=g.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(An,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return g.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(ep,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(dl,{...r,ref:t}):null});ul.displayName=An;var zC=g.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(An,e.__scopeScrollArea),[s,i]=g.useState(!1);return g.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(Ut,{present:n||s,children:c.jsx(ep,{"data-state":s?"visible":"hidden",...r,ref:t})})}),BC=g.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(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 g.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,l]),g.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(Ut,{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=g.forwardRef((e,t)=>{const n=Qt(An,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=g.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(Ut,{present:r||s,children:c.jsx(dl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),dl=g.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Qt(An,e.__scopeScrollArea),s=g.useRef(null),i=g.useRef(0),[a,l]=g.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 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=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(UC,{...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}),HC=g.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Qt(An,e.__scopeScrollArea),[i,a]=g.useState(),l=g.useRef(null),u=He(t,l,s.onScrollbarXChange);return g.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)}})}})}),UC=g.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Qt(An,e.__scopeScrollArea),[i,a]=g.useState(),l=g.useRef(null),u=He(t,l,s.onScrollbarYChange);return g.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)}})}})}),[WC,tp]=Xh(An),np=g.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=Qt(An,n),[x,v]=g.useState(null),m=He(t,P=>v(P)),y=g.useRef(null),b=g.useRef(""),S=p.viewport,T=r.content-r.viewport,C=St(d),k=St(l),E=li(f,10);function R(P){if(y.current){const j=P.clientX-y.current.left,H=P.clientY-y.current.top;u({x:j,y:H})}}return g.useEffect(()=>{const P=j=>{const H=j.target;(x==null?void 0:x.contains(H))&&C(j,T)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[S,x,T,C]),g.useEffect(k,[r,k]),zr(x,E),zr(p.content,E),c.jsx(WC,{scope:n,scrollbar:x,hasThumb:o,onThumbChange:St(s),onThumbPointerUp:St(i),onThumbPositionChange:k,onThumbPointerDown:St(a),children:c.jsx(Ie.div,{...h,ref:m,style:{position:"absolute",...h.style},onPointerDown:he(e.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),y.current=x.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),R(P))}),onPointerMove:he(e.onPointerMove,R),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=g.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=tp(si,e.__scopeScrollArea);return c.jsx(Ut,{present:n||o.hasThumb,children:c.jsx(VC,{ref:t,...r})})}),VC=g.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Qt(si,n),i=tp(si,n),{onThumbPositionChange:a}=i,l=He(t,f=>i.onThumbChange(f)),u=g.useRef(void 0),d=li(()=>{u.current&&(u.current(),u.current=void 0)},100);return g.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:he(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),x=f.clientX-p.left,v=f.clientY-p.top;i.onThumbPointerDown({x,y:v})}),onPointerUp:he(e.onPointerUp,i.onThumbPointerUp)})});rp.displayName=si;var fl="ScrollAreaCorner",op=g.forwardRef((e,t)=>{const n=Qt(fl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(KC,{...e,ref:t}):null});op.displayName=fl;var KC=g.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Qt(fl,n),[s,i]=g.useState(0),[a,l]=g.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 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 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 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 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=St(e),r=g.useRef(0);return g.useEffect(()=>()=>window.clearTimeout(r.current),[]),g.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function zr(e,t){const n=St(t);yt(()=>{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,YC=Qh,XC=op;const up=g.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(cp,{ref:r,className:oe("relative overflow-hidden",e),...n,children:[c.jsx(YC,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(dp,{}),c.jsx(XC,{})]}));up.displayName=cp.displayName;const dp=g.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(ul,{ref:r,orientation:t,className:oe("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:x}=Yo(),{loadThread:v}=Xo(),{createThread:m,deleteThread:y,renameThread:b}=x,[S,T]=w.useState(Array.isArray(f)?f:[]),C=w.useRef(S.length>0),[k,E]=w.useState(null),[R,P]=w.useState(""),[j,H]=w.useState(!1);w.useEffect(()=>{const F=Array.isArray(f)?f:[];if(F.length>0){C.current=!0,T(F);return}p||(C.current=!1,T(F))},[f,p]);const $=async F=>{try{await v(F),a==null||a(F),l==null||l(F)}catch(q){console.error("Failed to select thread:",q)}},L=async()=>{try{H(!0);const F=await m();u==null||u(F),a==null||a(F)}catch(F){console.error("Failed to create thread:",F)}finally{H(!1)}},O=async(F,q)=>{if(q.stopPropagation(),!!confirm("Delete this thread?"))try{await y(F),d==null||d(F)}catch(me){console.error("Failed to delete thread:",me)}},B=(F,q)=>{q.stopPropagation(),E(F.threadId),P(F.title||`Thread ${F.threadId.slice(0,8)}`)},W=async F=>{if(R.trim())try{await b(F,R.trim()),E(null),P("")}catch(q){console.error("Failed to update title:",q)}},se=()=>{E(null),P("")},K=(F,q)=>{F.key==="Enter"?W(q):F.key==="Escape"&&se()},U=F=>{if(!F)return"";try{const q=new Date(F),ge=new Date().getTime()-q.getTime(),ke=Math.floor(ge/(1e3*60*60*24));return ke===0?q.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):ke===1?"Yesterday":ke<7?`${ke} days ago`:q.toLocaleDateString()}catch{return""}},X=F=>F.title||`Thread ${F.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:L,disabled:j||p,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:j?"Creating...":"New Chat",children:c.jsx(pe.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(pe.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):S.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(pe.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"})]}):S.slice().sort((F,q)=>new Date(q.updatedAt||q.createdAt||"").getTime()-new Date(F.updatedAt||F.createdAt||"").getTime()).map(F=>c.jsxs("div",{onClick:()=>$(F.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??h)===F.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===F.threadId?c.jsxs("div",{className:"flex items-center gap-2",onClick:q=>q.stopPropagation(),children:[c.jsx(oi,{value:R,onChange:q=>P(q.target.value),onKeyDown:q=>K(q,F.threadId),className:"h-6 text-sm",autoFocus:!0}),c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>W(F.threadId),className:"h-6 w-6 p-0",children:c.jsx(pe.Check,{size:12})}),c.jsx(qe,{variant:"ghost",size:"sm",onClick:se,className:"h-6 w-6 p-0",children:c.jsx(pe.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:X(F)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(pe.Calendar,{size:10}),c.jsx("span",{children:U(F.updatedAt||F.createdAt)})]})]})}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&k!==F.threadId&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:q=>B(F,q),className:"h-6 w-6 p-0",title:"Edit title",children:c.jsx(pe.Edit3,{size:12})}),n&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:q=>O(F.threadId,q),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(pe.Trash2,{size:12})})]})]}),i===F.threadId&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},F.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 fp(){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 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,darkMode:!1,enableSound:!1,messageHistory:100}}const xp="chat-settings";function ZC(){try{const e=localStorage.getItem(xp);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(xp,JSON.stringify(t)),t.apiKey&&Hn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function ek(){const e=gp(),t=ZC(),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 tk(e){Hn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),QC(e)}var nk="Label",yp=g.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())}}));yp.displayName=nk;var vp=yp;const rk=Ro.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),en=g.forwardRef(({className:e,...t},n)=>c.jsx(vp,{ref:n,className:oe(rk(),e),...t}));en.displayName=vp.displayName;function bp(e){const t=g.useRef({value:e,previous:e});return g.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var ci="Switch",[ok,AT]=wn(ci),[sk,ik]=ok(ci),wp=g.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]=g.useState(null),x=He(t,S=>p(S)),v=g.useRef(!1),m=h?d||!!h.closest("form"):!0,[y,b]=pr({prop:o,defaultProp:s??!1,onChange:u,caller:ci});return c.jsxs(sk,{scope:n,checked:y,disabled:a,children:[c.jsx(Ie.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:x,onClick:he(e.onClick,S=>{b(T=>!T),m&&(v.current=S.isPropagationStopped(),v.current||S.stopPropagation())})}),m&&c.jsx(kp,{control:h,bubbles:!v.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});wp.displayName=ci;var Sp="SwitchThumb",Cp=g.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=ik(Sp,n);return c.jsx(Ie.span,{"data-state":Tp(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Cp.displayName=Sp;var ak="SwitchBubbleInput",kp=g.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=g.useRef(null),a=He(i,s),l=bp(n),u=Mf(t);return g.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const x=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(x)}},[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=ak;function Tp(e){return e?"checked":"unchecked"}var Ep=wp,lk=Cp;const Zn=g.forwardRef(({className:e,...t},n)=>c.jsx(Ep,{className:oe("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(lk,{className:oe("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"}),ck="VisuallyHidden",uk=g.forwardRef((e,t)=>c.jsx(Ie.span,{...e,ref:t,style:{...Ip,...e.style}}));uk.displayName=ck;var dk=[" ","Enter","ArrowUp","ArrowDown"],fk=[" ","Enter"],wr="Select",[ui,di,hk]=La(wr),[Hr,NT]=wn(wr,[hk,Js]),fi=Js(),[pk,Qn]=Hr(wr),[mk,gk]=Hr(wr),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:x}=e,v=fi(t),[m,y]=g.useState(null),[b,S]=g.useState(null),[T,C]=g.useState(!1),k=zs(u),[E,R]=pr({prop:r,defaultProp:o??!1,onChange:s,caller:wr}),[P,j]=pr({prop:i,defaultProp:a,onChange:l,caller:wr}),H=g.useRef(null),$=m?x||!!m.closest("form"):!0,[L,O]=g.useState(new Set),B=Array.from(L).map(W=>W.props.value).join(";");return c.jsx(Vf,{...v,children:c.jsxs(pk,{required:p,scope:t,trigger:m,onTriggerChange:y,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:T,onValueNodeHasChildrenChange:C,contentId:Sn(),value:P,onValueChange:j,open:E,onOpenChange:R,dir:k,triggerPointerDownPosRef:H,disabled:h,children:[c.jsx(ui.Provider,{scope:t,children:c.jsx(mk,{scope:e.__scopeSelect,onNativeOptionAdd:g.useCallback(W=>{O(se=>new Set(se).add(W))},[]),onNativeOptionRemove:g.useCallback(W=>{O(se=>{const K=new Set(se);return K.delete(W),K})},[]),children:n})}),$?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:x,children:[P===void 0?c.jsx("option",{value:""}):null,Array.from(L)]},B):null]})})};Ap.displayName=wr;var Np="SelectTrigger",_p=g.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=fi(n),i=Qn(Np,n),a=i.disabled||r,l=He(t,i.onTriggerChange),u=di(n),d=g.useRef("touch"),[f,h,p]=em(v=>{const m=u().filter(S=>!S.disabled),y=m.find(S=>S.value===i.value),b=tm(m,v,y);b!==void 0&&i.onValueChange(b.value)}),x=v=>{a||(i.onOpenChange(!0),p()),v&&(i.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return c.jsx(Kf,{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":Qp(i.value)?"":void 0,...o,ref:l,onClick:he(o.onClick,v=>{v.currentTarget.focus(),d.current!=="mouse"&&x(v)}),onPointerDown:he(o.onPointerDown,v=>{d.current=v.pointerType;const m=v.target;m.hasPointerCapture(v.pointerId)&&m.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(x(v),v.preventDefault())}),onKeyDown:he(o.onKeyDown,v=>{const m=f.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&h(v.key),!(m&&v.key===" ")&&dk.includes(v.key)&&(x(),v.preventDefault())})})})});_p.displayName=Np;var jp="SelectValue",Rp=g.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=He(t,l.onValueNodeChange);return yt(()=>{u(d)},[u,d]),c.jsx(Ie.span,{...a,ref:f,style:{pointerEvents:"none"},children:Qp(l.value)?c.jsx(c.Fragment,{children:i}):s})});Rp.displayName=jp;var xk="SelectIcon",Pp=g.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(Ie.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Pp.displayName=xk;var yk="SelectPortal",Op=e=>c.jsx(ws,{asChild:!0,...e});Op.displayName=yk;var Sr="SelectContent",Mp=g.forwardRef((e,t)=>{const n=Qn(Sr,e.__scopeSelect),[r,o]=g.useState();if(yt(()=>{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=Sr;var cn=10,[Dp,er]=Hr(Sr),vk="SelectContentImpl",bk=sr.createSlot("SelectContent.RemoveScroll"),Lp=g.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:x,hideWhenDetached:v,avoidCollisions:m,...y}=e,b=Qn(Sr,n),[S,T]=g.useState(null),[C,k]=g.useState(null),E=He(t,J=>T(J)),[R,P]=g.useState(null),[j,H]=g.useState(null),$=di(n),[L,O]=g.useState(!1),B=g.useRef(!1);g.useEffect(()=>{if(S)return Ra(S)},[S]),Ea();const W=g.useCallback(J=>{const[D,...ee]=$().map(le=>le.ref.current),[re]=ee.slice(-1),ae=document.activeElement;for(const le of J)if(le===ae||(le==null||le.scrollIntoView({block:"nearest"}),le===D&&C&&(C.scrollTop=0),le===re&&C&&(C.scrollTop=C.scrollHeight),le==null||le.focus(),document.activeElement!==ae))return},[$,C]),se=g.useCallback(()=>W([R,S]),[W,R,S]);g.useEffect(()=>{L&&se()},[L,se]);const{onOpenChange:K,triggerPointerDownPosRef:U}=b;g.useEffect(()=>{if(S){let J={x:0,y:0};const D=re=>{var ae,le;J={x:Math.abs(Math.round(re.pageX)-(((ae=U.current)==null?void 0:ae.x)??0)),y:Math.abs(Math.round(re.pageY)-(((le=U.current)==null?void 0:le.y)??0))}},ee=re=>{J.x<=10&&J.y<=10?re.preventDefault():S.contains(re.target)||K(!1),document.removeEventListener("pointermove",D),U.current=null};return U.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",ee,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",ee,{capture:!0})}}},[S,K,U]),g.useEffect(()=>{const J=()=>K(!1);return window.addEventListener("blur",J),window.addEventListener("resize",J),()=>{window.removeEventListener("blur",J),window.removeEventListener("resize",J)}},[K]);const[X,F]=em(J=>{const D=$().filter(ae=>!ae.disabled),ee=D.find(ae=>ae.ref.current===document.activeElement),re=tm(D,J,ee);re&&setTimeout(()=>re.ref.current.focus())}),q=g.useCallback((J,D,ee)=>{const re=!B.current&&!ee;(b.value!==void 0&&b.value===D||re)&&(P(J),re&&(B.current=!0))},[b.value]),me=g.useCallback(()=>S==null?void 0:S.focus(),[S]),ge=g.useCallback((J,D,ee)=>{const re=!B.current&&!ee;(b.value!==void 0&&b.value===D||re)&&H(J)},[b.value]),ke=r==="popper"?pl:Fp,Se=ke===pl?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:x,hideWhenDetached:v,avoidCollisions:m}:{};return c.jsx(Dp,{scope:n,content:S,viewport:C,onViewportChange:k,itemRefCallback:q,selectedItem:R,onItemLeave:me,itemTextRefCallback:ge,focusSelectedItem:se,selectedItemText:j,position:r,isPositioned:L,searchRef:X,children:c.jsx(Is,{as:bk,allowPinchZoom:!0,children:c.jsx(bs,{asChild:!0,trapped:b.open,onMountAutoFocus:J=>{J.preventDefault()},onUnmountAutoFocus:he(o,J=>{var D;(D=b.trigger)==null||D.focus({preventScroll:!0}),J.preventDefault()}),children:c.jsx(vs,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:J=>J.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:c.jsx(ke,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:J=>J.preventDefault(),...y,...Se,onPlaced:()=>O(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:he(y.onKeyDown,J=>{const D=J.ctrlKey||J.altKey||J.metaKey;if(J.key==="Tab"&&J.preventDefault(),!D&&J.key.length===1&&F(J.key),["ArrowUp","ArrowDown","Home","End"].includes(J.key)){let re=$().filter(ae=>!ae.disabled).map(ae=>ae.ref.current);if(["ArrowUp","End"].includes(J.key)&&(re=re.slice().reverse()),["ArrowUp","ArrowDown"].includes(J.key)){const ae=J.target,le=re.indexOf(ae);re=re.slice(le+1)}setTimeout(()=>W(re)),J.preventDefault()}})})})})})})});Lp.displayName=vk;var wk="SelectItemAlignedPosition",Fp=g.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Qn(Sr,n),i=er(Sr,n),[a,l]=g.useState(null),[u,d]=g.useState(null),f=He(t,E=>d(E)),h=di(n),p=g.useRef(!1),x=g.useRef(!0),{viewport:v,selectedItem:m,selectedItemText:y,focusSelectedItem:b}=i,S=g.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&v&&m&&y){const E=s.trigger.getBoundingClientRect(),R=u.getBoundingClientRect(),P=s.valueNode.getBoundingClientRect(),j=y.getBoundingClientRect();if(s.dir!=="rtl"){const ae=j.left-R.left,le=P.left-ae,ie=E.left-le,Ge=E.width+ie,Je=Math.max(Ge,R.width),De=window.innerWidth-cn,Ue=ll(le,[cn,Math.max(cn,De-Je)]);a.style.minWidth=Ge+"px",a.style.left=Ue+"px"}else{const ae=R.right-j.right,le=window.innerWidth-P.right-ae,ie=window.innerWidth-E.right-le,Ge=E.width+ie,Je=Math.max(Ge,R.width),De=window.innerWidth-cn,Ue=ll(le,[cn,Math.max(cn,De-Je)]);a.style.minWidth=Ge+"px",a.style.right=Ue+"px"}const H=h(),$=window.innerHeight-cn*2,L=v.scrollHeight,O=window.getComputedStyle(u),B=parseInt(O.borderTopWidth,10),W=parseInt(O.paddingTop,10),se=parseInt(O.borderBottomWidth,10),K=parseInt(O.paddingBottom,10),U=B+W+L+K+se,X=Math.min(m.offsetHeight*5,U),F=window.getComputedStyle(v),q=parseInt(F.paddingTop,10),me=parseInt(F.paddingBottom,10),ge=E.top+E.height/2-cn,ke=$-ge,Se=m.offsetHeight/2,J=m.offsetTop+Se,D=B+W+J,ee=U-D;if(D<=ge){const ae=H.length>0&&m===H[H.length-1].ref.current;a.style.bottom="0px";const le=u.clientHeight-v.offsetTop-v.offsetHeight,ie=Math.max(ke,Se+(ae?me:0)+le+se),Ge=D+ie;a.style.height=Ge+"px"}else{const ae=H.length>0&&m===H[0].ref.current;a.style.top="0px";const ie=Math.max(ge,B+v.offsetTop+(ae?q:0)+Se)+ee;a.style.height=ie+"px",v.scrollTop=D-ge+v.offsetTop}a.style.margin=`${cn}px 0`,a.style.minHeight=X+"px",a.style.maxHeight=$+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,v,m,y,s.dir,r]);yt(()=>S(),[S]);const[T,C]=g.useState();yt(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const k=g.useCallback(E=>{E&&x.current===!0&&(S(),b==null||b(),x.current=!1)},[S,b]);return c.jsx(Ck,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:k,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:T},children:c.jsx(Ie.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Fp.displayName=wk;var Sk="SelectPopperPosition",pl=g.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=cn,...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=Sk;var[Ck,ml]=Hr(Sr,{}),gl="SelectViewport",$p=g.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=er(gl,n),i=ml(gl,n),a=He(t,s.onViewportChange),l=g.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: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 x=window.innerHeight-cn*2,v=parseFloat(f.style.minHeight),m=parseFloat(f.style.height),y=Math.max(v,m);if(y<x){const b=y+p,S=Math.min(x,b),T=b-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=T>0?T:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});$p.displayName=gl;var zp="SelectGroup",[kk,Tk]=Hr(zp),Ek=g.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Sn();return c.jsx(kk,{scope:n,id:o,children:c.jsx(Ie.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Ek.displayName=zp;var Bp="SelectLabel",Hp=g.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Tk(Bp,n);return c.jsx(Ie.div,{id:o.id,...r,ref:t})});Hp.displayName=Bp;var hi="SelectItem",[Ik,Up]=Hr(hi),Wp=g.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]=g.useState(s??""),[h,p]=g.useState(!1),x=He(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),v=Sn(),m=g.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(Ik,{scope:n,value:r,disabled:o,textId:v,isSelected:u,onItemTextChange:g.useCallback(b=>{f(S=>S||((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":v,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:x,onFocus:he(i.onFocus,()=>p(!0)),onBlur:he(i.onBlur,()=>p(!1)),onClick:he(i.onClick,()=>{m.current!=="mouse"&&y()}),onPointerUp:he(i.onPointerUp,()=>{m.current==="mouse"&&y()}),onPointerDown:he(i.onPointerDown,b=>{m.current=b.pointerType}),onPointerMove:he(i.onPointerMove,b=>{var S;m.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):m.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:he(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:he(i.onKeyDown,b=>{var T;((T=l.searchRef)==null?void 0:T.current)!==""&&b.key===" "||(fk.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});Wp.displayName=hi;var Eo="SelectItemText",Vp=g.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=gk(Eo,n),[d,f]=g.useState(null),h=He(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,x=g.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:v,onNativeOptionRemove:m}=u;return yt(()=>(v(x),()=>m(x)),[v,m,x]),c.jsxs(c.Fragment,{children:[c.jsx(Ie.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=g.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Up(Kp,n).isSelected?c.jsx(Ie.span,{"aria-hidden":!0,...r,ref:t}):null});qp.displayName=Kp;var xl="SelectScrollUpButton",Gp=g.forwardRef((e,t)=>{const n=er(xl,e.__scopeSelect),r=ml(xl,e.__scopeSelect),[o,s]=g.useState(!1),i=He(t,r.onScrollButtonChange);return yt(()=>{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=g.forwardRef((e,t)=>{const n=er(yl,e.__scopeSelect),r=ml(yl,e.__scopeSelect),[o,s]=g.useState(!1),i=He(t,r.onScrollButtonChange);return yt(()=>{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=g.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=er("SelectScrollButton",n),i=g.useRef(null),a=di(n),l=g.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return g.useEffect(()=>()=>l(),[l]),yt(()=>{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: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()})})}),Ak="SelectSeparator",Jp=g.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(Ie.div,{"aria-hidden":!0,...r,ref:t})});Jp.displayName=Ak;var vl="SelectArrow",Nk=g.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});Nk.displayName=vl;var _k="SelectBubbleInput",Zp=g.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=g.useRef(null),s=He(r,o),i=bp(t);return g.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:{...Ip,...n.style},ref:s,defaultValue:t})});Zp.displayName=_k;function Qp(e){return e===""||e===void 0}function em(e){const t=St(e),n=g.useRef(""),r=g.useRef(0),o=g.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=g.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return g.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=jk(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 jk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Rk=Ap,nm=_p,Pk=Rp,Ok=Pp,Mk=Op,rm=Mp,Dk=$p,om=Hp,sm=Wp,Lk=Vp,Fk=qp,im=Gp,am=Yp,lm=Jp;const cm=Rk,um=Pk,bl=g.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(nm,{ref:r,className:oe("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(Ok,{asChild:!0,children:c.jsx(pe.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));bl.displayName=nm.displayName;const dm=g.forwardRef(({className:e,...t},n)=>c.jsx(im,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(pe.ChevronUp,{className:"h-4 w-4"})}));dm.displayName=im.displayName;const fm=g.forwardRef(({className:e,...t},n)=>c.jsx(am,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(pe.ChevronDown,{className:"h-4 w-4"})}));fm.displayName=am.displayName;const wl=g.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(Mk,{children:c.jsxs(rm,{ref:o,className:oe("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(Dk,{className:oe("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 $k=g.forwardRef(({className:e,...t},n)=>c.jsx(om,{ref:n,className:oe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));$k.displayName=om.displayName;const Cr=g.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(sm,{ref:r,className:oe("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(Fk,{children:c.jsx(pe.Check,{className:"h-4 w-4"})})}),c.jsx(Lk,{children:t})]}));Cr.displayName=sm.displayName;const zk=g.forwardRef(({className:e,...t},n)=>c.jsx(lm,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));zk.displayName=lm.displayName;var Bk="Separator",hm="horizontal",Hk=["horizontal","vertical"],pm=g.forwardRef((e,t)=>{const{decorative:n,orientation:r=hm,...o}=e,s=Uk(r)?r:hm,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})});pm.displayName=Bk;function Uk(e){return Hk.includes(e)}var mm=pm;const gm=g.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(mm,{ref:o,decorative:n,orientation:t,className:oe("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));gm.displayName=mm.displayName;const Wk=Zd,Vk=bw,Kk=Qd,xm=g.forwardRef(({className:e,...t},n)=>c.jsx(Rs,{className:oe("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 qk=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=g.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(Kk,{children:[c.jsx(xm,{}),c.jsxs(Ps,{ref:o,className:oe(qk({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(pe.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:oe("flex flex-col space-y-2 text-center sm:text-left",e),...t});vm.displayName="SheetHeader";const bm=g.forwardRef(({className:e,...t},n)=>c.jsx(xr,{ref:n,className:oe("text-lg font-semibold text-foreground",e),...t}));bm.displayName=xr.displayName;const wm=g.forwardRef(({className:e,...t},n)=>c.jsx(Os,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));wm.displayName=Os.displayName;const Gk={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 Yk({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 m=JSON.stringify(a)!==JSON.stringify(e);d(m)},[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(Gk),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},x=()=>{l(e),d(!1),o(!1)},v=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(Wk,{open:r,onOpenChange:o,children:[c.jsx(Vk,{asChild:!0,children:c.jsxs(qe,{variant:"outline",size:"sm",className:n,children:[c.jsx(pe.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(pe.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(en,{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:m=>l(y=>({...y,api:{...y.api,baseUrl:m.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(qe,{variant:"outline",onClick:v,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(en,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(Zn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:m=>l(y=>({...y,api:{...y.api,enableAuth:m}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(en,{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:m=>l(y=>({...y,api:{...y.api,authToken:m.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(qe,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(pe.EyeOff,{className:"h-4 w-4"}):c.jsx(pe.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(pe.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(en,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(cm,{value:a.ui.layout,onValueChange:m=>l(y=>({...y,ui:{...y.ui,layout:m}})),children:[c.jsx(bl,{children:c.jsx(um,{})}),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(en,{htmlFor:"theme",children:"Theme"}),c.jsxs(cm,{value:a.ui.theme,onValueChange:m=>l(y=>({...y,ui:{...y.ui,theme:m}})),children:[c.jsx(bl,{children:c.jsx(um,{})}),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(gm,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(en,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(Zn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:m=>l(y=>({...y,ui:{...y.ui,showTimestamps:m}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(en,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(Zn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:m=>l(y=>({...y,ui:{...y.ui,showAgentNames:m}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(en,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(Zn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:m=>l(y=>({...y,ui:{...y.ui,compactMessages:m}}))})]})]})]})]}),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(pe.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(en,{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:m=>l(y=>({...y,behavior:{...y.behavior,autoSave:m}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(en,{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:m=>l(y=>({...y,behavior:{...y.behavior,enableStreaming:m}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(en,{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:m=>l(y=>({...y,behavior:{...y.behavior,showTypingIndicator:m}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(qe,{variant:"outline",onClick:p,children:[c.jsx(pe.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(qe,{variant:"outline",onClick:x,children:"Cancel"}),c.jsxs(qe,{onClick:h,disabled:!u,children:[c.jsx(pe.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function Xk({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})})]})})}Ne.ChatApi=vc,Ne.ChatInterface=ri,Ne.ChatProviders=Jo,Ne.ChatSettings=Yk,Ne.MarkdownContent=ya,Ne.MessageComponent=uf,Ne.MessageList=Da,Ne.ThreadManager=hl,Ne.applySettings=tk,Ne.chatApiClient=Hn,Ne.default=Xk,Ne.del=yc,Ne.get=nn,Ne.getChatToken=pc,Ne.getCurrentSettings=ek,Ne.getDefaultApiConfig=mp,Ne.getDefaultChatSettings=gp,Ne.onChatTokenChanged=mc,Ne.post=gc,Ne.put=xc,Ne.setChatToken=Ai,Ne.useApi=Ni,Ne.useChatStream=Oc,Ne.useMessagesReducer=Ec,Ne.useStream=Uc,Ne.useThreadState=Xo,Ne.useThreads=Yo,Object.defineProperties(Ne,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
138
+ `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function Fb(e,t=Fs){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 $b(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),Fb(t),Lb(t)}function La(e){const t=e+"CollectionProvider",[n,r]=bn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=v=>{const{scope:m,children:x}=v,w=b.useRef(null),S=b.useRef(new Map).current;return u.jsx(o,{scope:m,itemMap:S,collectionRef:w,children:x})};i.displayName=t;const a=e+"CollectionSlot",l=sr.createSlot(a),c=b.forwardRef((v,m)=>{const{scope:x,children:w}=v,S=s(a,x),T=Be(m,S.collectionRef);return u.jsx(l,{ref:T,children:w})});c.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=sr.createSlot(d),p=b.forwardRef((v,m)=>{const{scope:x,children:w,...S}=v,T=b.useRef(null),C=Be(m,T),k=s(d,x);return b.useEffect(()=>(k.itemMap.set(T,{ref:T,...S}),()=>void k.itemMap.delete(T))),u.jsx(h,{[f]:"",ref:C,children:w})});p.displayName=d;function y(v){const m=s(e+"CollectionConsumer",v);return b.useCallback(()=>{const w=m.collectionRef.current;if(!w)return[];const S=Array.from(w.querySelectorAll(`[${f}]`));return Array.from(m.itemMap.values()).sort((k,E)=>S.indexOf(k.ref.current)-S.indexOf(E.ref.current))},[m.collectionRef,m.itemMap])}return[{Provider:i,Slot:c,ItemSlot:p},y,r]}var zb=g.createContext(void 0);function $s(e){const t=g.useContext(zb);return e||t||"ltr"}const Bb=["top","right","bottom","left"],Xn=Math.min,Wt=Math.max,zs=Math.round,Bs=Math.floor,kn=e=>({x:e,y:e}),Hb={left:"right",right:"left",bottom:"top",top:"bottom"},Ub={start:"end",end:"start"};function Fa(e,t,n){return Wt(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 Wb=new Set(["top","bottom"]);function Tn(e){return Wb.has(Fn(e))?"y":"x"}function Ba(e){return $a(Tn(e))}function Vb(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=Hs(i)),[i,Hs(i)]}function Kb(e){const t=Hs(e);return[Ha(e),t,Ha(t)]}function Ha(e){return e.replace(/start|end/g,t=>Ub[t])}const uf=["left","right"],df=["right","left"],qb=["top","bottom"],Gb=["bottom","top"];function Yb(e,t,n){switch(e){case"top":case"bottom":return n?t?df:uf:t?uf:df;case"left":case"right":return t?qb:Gb;default:return[]}}function Xb(e,t,n,r){const o=Dr(e);let s=Yb(Fn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ha)))),s}function Hs(e){return e.replace(/left|right|bottom|top/g,t=>Hb[t])}function Jb(e){return{top:0,right:0,bottom:0,left:0,...e}}function ff(e){return typeof e!="number"?Jb(e):{top:e,right:e,bottom:e,left:e}}function Us(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 hf(e,t,n){let{reference:r,floating:o}=e;const s=Tn(t),i=Ba(t),a=za(i),l=Fn(t),c=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&&c?-1:1);break;case"end":p[i]+=h*(n&&c?-1:1);break}return p}const Zb=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 c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=hf(c,r,l),h=r,p={},y=0;for(let v=0;v<a.length;v++){const{name:m,fn:x}=a[v],{x:w,y:S,data:T,reset:C}=await x({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:c,platform:i,elements:{reference:e,floating:t}});d=w??d,f=S??f,p={...p,[m]:{...p[m],...T}},C&&y<=50&&(y++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(c=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=hf(c,h,l)),v=-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:c="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=Ln(t,e),y=ff(p),m=a[h?f==="floating"?"reference":"floating":f],x=Us(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(m)))==null||n?m:m.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),w=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),T=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=Us(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:S,strategy:l}):w);return{top:(x.top-C.top+y.top)/T.y,bottom:(C.bottom-x.bottom+y.bottom)/T.y,left:(x.left-C.left+y.left)/T.x,right:(C.right-x.right+y.right)/T.x}}const Qb=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:c,padding:d=0}=Ln(e,t)||{};if(c==null)return{};const f=ff(d),h={x:n,y:r},p=Ba(o),y=za(p),v=await i.getDimensions(c),m=p==="y",x=m?"top":"left",w=m?"bottom":"right",S=m?"clientHeight":"clientWidth",T=s.reference[y]+s.reference[p]-h[p]-s.floating[y],C=h[p]-s.reference[p],k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=k?k[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(k)))&&(E=a.floating[S]||s.floating[y]);const R=T/2-C/2,P=E/2-v[y]/2-1,j=Xn(f[x],P),B=Xn(f[w],P),$=j,L=E-v[y]-B,O=E/2-v[y]/2+R,H=Fa($,O,L),W=!l.arrow&&Dr(o)!=null&&O!==H&&s.reference[y]/2-(O<$?j:B)-v[y]/2<0,se=W?O<$?O-$:O-L:0;return{[p]:h[p]+se,data:{[p]:H,centerOffset:O-H-se,...W&&{alignmentOffset:se}},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:c}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:v=!0,...m}=Ln(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=Fn(o),w=Tn(a),S=Fn(a)===a,T=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=h||(S||!v?[Hs(a)]:Kb(a)),k=y!=="none";!h&&k&&C.push(...Xb(a,v,y,T));const E=[a,...C],R=await xo(t,m),P=[];let j=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&P.push(R[x]),f){const O=Vb(o,i,T);P.push(R[O[0]],R[O[1]])}if(j=[...j,{placement:o,overflows:P}],!P.every(O=>O<=0)){var B,$;const O=(((B=s.flip)==null?void 0:B.index)||0)+1,H=E[O];if(H&&(!(f==="alignment"?w!==Tn(H):!1)||j.every(K=>Tn(K.placement)===w?K.overflows[0]>0:!0)))return{data:{index:O,overflows:j},reset:{placement:H}};let W=($=j.filter(se=>se.overflows[0]<=0).sort((se,K)=>se.overflows[1]-K.overflows[1])[0])==null?void 0:$.placement;if(!W)switch(p){case"bestFit":{var L;const se=(L=j.filter(K=>{if(k){const U=Tn(K.placement);return U===w||U==="y"}return!0}).map(K=>[K.placement,K.overflows.filter(U=>U>0).reduce((U,X)=>U+X,0)]).sort((K,U)=>K[1]-U[1])[0])==null?void 0:L[0];se&&(W=se);break}case"initialPlacement":W=a;break}if(o!==W)return{reset:{placement:W}}}return{}}}};function pf(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function mf(e){return Bb.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=pf(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:mf(i)}}}case"escaped":{const s=await xo(t,{...o,altBoundary:!0}),i=pf(s,n.floating);return{data:{escapedOffsets:i,escaped:mf(i)}}}default:return{}}}}},gf=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=Tn(n)==="y",c=gf.has(i)?-1:1,d=s&&l?-1:1,f=Ln(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:y}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof y=="number"&&(p=a==="end"?y*-1:y),l?{x:p*d,y:h*c}:{x:h*c,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:m=>{let{x,y:w}=m;return{x,y:w}}},...l}=Ln(e,t),c={x:n,y:r},d=await xo(t,l),f=Tn(Fn(o)),h=$a(f);let p=c[h],y=c[f];if(s){const m=h==="y"?"top":"left",x=h==="y"?"bottom":"right",w=p+d[m],S=p-d[x];p=Fa(w,p,S)}if(i){const m=f==="y"?"top":"left",x=f==="y"?"bottom":"right",w=y+d[m],S=y-d[x];y=Fa(w,y,S)}const v=a.fn({...t,[h]:p,[f]:y});return{...v,data:{x:v.x-n,y:v.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:c=!0}=Ln(e,t),d={x:n,y:r},f=Tn(o),h=$a(f);let p=d[h],y=d[f];const v=Ln(a,t),m=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(l){const S=h==="y"?"height":"width",T=s.reference[h]-s.floating[S]+m.mainAxis,C=s.reference[h]+s.reference[S]-m.mainAxis;p<T?p=T:p>C&&(p=C)}if(c){var x,w;const S=h==="y"?"width":"height",T=gf.has(Fn(o)),C=s.reference[f]-s.floating[S]+(T&&((x=i.offset)==null?void 0:x[f])||0)+(T?0:m.crossAxis),k=s.reference[f]+s.reference[S]+(T?0:((w=i.offset)==null?void 0:w[f])||0)-(T?m.crossAxis:0);y<C?y=C:y>k&&(y=k)}return{[h]:p,[f]:y}}}},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=()=>{},...c}=Ln(e,t),d=await xo(t,c),f=Fn(o),h=Dr(o),p=Tn(o)==="y",{width:y,height:v}=s.floating;let m,x;f==="top"||f==="bottom"?(m=f,x=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=f,m=h==="end"?"top":"bottom");const w=v-d.top-d.bottom,S=y-d.left-d.right,T=Xn(v-d[m],w),C=Xn(y-d[x],S),k=!t.middlewareData.shift;let E=T,R=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(R=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),k&&!h){const j=Wt(d.left,0),B=Wt(d.right,0),$=Wt(d.top,0),L=Wt(d.bottom,0);p?R=y-2*(j!==0||B!==0?j+B:Wt(d.left,d.right)):E=v-2*($!==0||L!==0?$+L:Wt(d.top,d.bottom))}await l({...t,availableWidth:R,availableHeight:E});const P=await i.getDimensions(a.floating);return y!==P.width||v!==P.height?{reset:{rects:!0}}:{}}}};function Ws(){return typeof window<"u"}function Lr(e){return xf(e)?(e.nodeName||"").toLowerCase():"#document"}function Vt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function En(e){var t;return(t=(xf(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function xf(e){return Ws()?e instanceof Node||e instanceof Vt(e).Node:!1}function an(e){return Ws()?e instanceof Element||e instanceof Vt(e).Element:!1}function In(e){return Ws()?e instanceof HTMLElement||e instanceof Vt(e).HTMLElement:!1}function yf(e){return!Ws()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Vt(e).ShadowRoot}const a0=new Set(["inline","contents"]);function yo(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=ln(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 Vs(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=an(e)?ln(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(;In(t)&&!Fr(t);){if(Ua(t))return t;if(Vs(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 ln(e){return Vt(e).getComputedStyle(e)}function Ks(e){return an(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||yf(e)&&e.host||En(e);return yf(t)?t.host:t}function vf(e){const t=Jn(e);return Fr(t)?e.ownerDocument?e.ownerDocument.body:e.body:In(t)&&yo(t)?t:vf(t)}function vo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=vf(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Vt(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 wf(e){const t=ln(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=In(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=zs(n)!==s||zs(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Ka(e){return an(e)?e:e.contextElement}function $r(e){const t=Ka(e);if(!In(t))return kn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=wf(t);let i=(s?zs(n.width):n.width)/r,a=(s?zs(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const g0=kn(0);function bf(e){const t=Vt(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!==Vt(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?an(r)&&(i=$r(r)):i=$r(e));const a=x0(s,n,r)?bf(s):kn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=Vt(s),p=r&&an(r)?Vt(r):r;let y=h,v=Va(y);for(;v&&r&&p!==y;){const m=$r(v),x=v.getBoundingClientRect(),w=ln(v),S=x.left+(v.clientLeft+parseFloat(w.paddingLeft))*m.x,T=x.top+(v.clientTop+parseFloat(w.paddingTop))*m.y;l*=m.x,c*=m.y,d*=m.x,f*=m.y,l+=S,c+=T,y=Vt(v),v=Va(y)}}return Us({width:d,height:f,x:l,y:c})}function qs(e,t){const n=Ks(e).scrollLeft;return t?t.left+n:yr(En(e)).left+n}function Sf(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-qs(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=En(r),a=t?Vs(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=kn(1);const d=kn(0),f=In(r);if((f||!f&&!s)&&((Lr(r)!=="body"||yo(i))&&(l=Ks(r)),In(r))){const p=yr(r);c=$r(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?Sf(i,l):kn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+h.x,y:n.y*c.y-l.scrollTop*c.y+d.y+h.y}}function v0(e){return Array.from(e.getClientRects())}function w0(e){const t=En(e),n=Ks(e),r=e.ownerDocument.body,o=Wt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Wt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+qs(e);const a=-n.scrollTop;return ln(r).direction==="rtl"&&(i+=Wt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Cf=25;function b0(e,t){const n=Vt(e),r=En(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 c=qs(r);if(c<=0){const d=r.ownerDocument,f=d.body,h=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,y=Math.abs(r.clientWidth-f.clientWidth-p);y<=Cf&&(s-=y)}else c<=Cf&&(s+=c);return{width:s,height:i,x:a,y:l}}const S0=new Set(["absolute","fixed"]);function C0(e,t){const n=yr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=In(e)?$r(e):kn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function kf(e,t,n){let r;if(t==="viewport")r=b0(e,n);else if(t==="document")r=w0(En(e));else if(an(t))r=C0(t,n);else{const o=bf(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Us(r)}function Tf(e,t){const n=Jn(e);return n===t||!an(n)||Fr(n)?!1:ln(n).position==="fixed"||Tf(n,t)}function k0(e,t){const n=t.get(e);if(n)return n;let r=vo(e,[],!1).filter(a=>an(a)&&Lr(a)!=="body"),o=null;const s=ln(e).position==="fixed";let i=s?Jn(e):e;for(;an(i)&&!Fr(i);){const a=ln(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&&Tf(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"?Vs(t)?[]:k0(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const f=kf(t,d,o);return c.top=Wt(f.top,c.top),c.right=Xn(f.right,c.right),c.bottom=Xn(f.bottom,c.bottom),c.left=Wt(f.left,c.left),c},kf(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}=wf(e);return{width:t,height:n}}function I0(e,t,n){const r=In(t),o=En(t),s=n==="fixed",i=yr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=kn(0);function c(){l.x=qs(o)}if(r||!r&&!s)if((Lr(t)!=="body"||yo(o))&&(a=Ks(t)),r){const p=yr(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?Sf(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 ln(e).position==="static"}function Ef(e,t){if(!In(e)||ln(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return En(e)===n&&(n=n.ownerDocument.body),n}function If(e,t){const n=Vt(e);if(Vs(e))return n;if(!In(e)){let o=Jn(e);for(;o&&!Fr(o);){if(an(o)&&!qa(o))return o;o=Jn(o)}return n}let r=Ef(e,t);for(;r&&c0(r)&&qa(r);)r=Ef(r,t);return r&&Fr(r)&&qa(r)&&!Ua(r)?n:r||p0(e)||n}const N0=async function(e){const t=this.getOffsetParent||If,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 A0(e){return ln(e).direction==="rtl"}const _0={convertOffsetParentRelativeRectToViewportRelativeRect:y0,getDocumentElement:En,getClippingRect:T0,getOffsetParent:If,getElementRects:N0,getClientRects:v0,getDimensions:E0,getScale:$r,isElement:an,isRTL:A0};function Nf(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=En(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 c=e.getBoundingClientRect(),{left:d,top:f,width:h,height:p}=c;if(a||t(),!h||!p)return;const y=Bs(f),v=Bs(o.clientWidth-(d+h)),m=Bs(o.clientHeight-(f+p)),x=Bs(d),S={rootMargin:-y+"px "+-v+"px "+-m+"px "+-x+"px",threshold:Wt(0,Xn(1,l))||1};let T=!0;function C(k){const E=k[0].intersectionRatio;if(E!==l){if(!T)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!Nf(c,e.getBoundingClientRect())&&i(),T=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}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,c=Ka(e),d=o||s?[...c?vo(c):[],...vo(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const f=c&&a?j0(c,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(x=>{let[w]=x;w&&w.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let y,v=l?yr(e):null;l&&m();function m(){const x=yr(e);v&&!Nf(v,x)&&n(),v=x,y=requestAnimationFrame(m)}return n(),()=>{var x;d.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),f==null||f(),(x=p)==null||x.disconnect(),p=null,l&&cancelAnimationFrame(y)}}const P0=r0,O0=o0,M0=e0,D0=i0,L0=t0,Af=Qb,F0=s0,$0=(e,t,n)=>{const r=new Map,o={platform:_0,...n},s={...o.platform,_c:r};return Zb(e,t,{...o,platform:s})};var z0=typeof document<"u",B0=function(){},Gs=z0?b.useLayoutEffect:B0;function Ys(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(!Ys(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)&&!Ys(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function _f(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function jf(e,t){const n=_f(e);return Math.round(t*n)/n}function Ga(e){const t=g.useRef(e);return Gs(()=>{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:c}=e,[d,f]=g.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=g.useState(r);Ys(h,r)||p(r);const[y,v]=g.useState(null),[m,x]=g.useState(null),w=g.useCallback(K=>{K!==k.current&&(k.current=K,v(K))},[]),S=g.useCallback(K=>{K!==E.current&&(E.current=K,x(K))},[]),T=s||y,C=i||m,k=g.useRef(null),E=g.useRef(null),R=g.useRef(d),P=l!=null,j=Ga(l),B=Ga(o),$=Ga(c),L=g.useCallback(()=>{if(!k.current||!E.current)return;const K={placement:t,strategy:n,middleware:h};B.current&&(K.platform=B.current),$0(k.current,E.current,K).then(U=>{const X={...U,isPositioned:$.current!==!1};O.current&&!Ys(R.current,X)&&(R.current=X,Po.flushSync(()=>{f(X)}))})},[h,t,n,B,$]);Gs(()=>{c===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,f(K=>({...K,isPositioned:!1})))},[c]);const O=g.useRef(!1);Gs(()=>(O.current=!0,()=>{O.current=!1}),[]),Gs(()=>{if(T&&(k.current=T),C&&(E.current=C),T&&C){if(j.current)return j.current(T,C,L);L()}},[T,C,L,j,P]);const H=g.useMemo(()=>({reference:k,floating:E,setReference:w,setFloating:S}),[w,S]),W=g.useMemo(()=>({reference:T,floating:C}),[T,C]),se=g.useMemo(()=>{const K={position:n,left:0,top:0};if(!W.floating)return K;const U=jf(W.floating,d.x),X=jf(W.floating,d.y);return a?{...K,transform:"translate("+U+"px, "+X+"px)",..._f(W.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:U,top:X}},[n,a,W.floating,d.x,d.y]);return g.useMemo(()=>({...d,update:L,refs:H,elements:W,floatingStyles:se}),[d,L,H,W,se])}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?Af({element:r.current,padding:o}).fn(n):{}:r?Af({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",Rf=g.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(Ie.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u.jsx("polygon",{points:"0,0 30,0 15,10"})})});Rf.displayName=J0;var Z0=Rf;function Pf(e){const[t,n]=g.useState(void 0);return yt(()=>{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,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.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",[Of,Xs]=bn(Ya),[Q0,Mf]=Of(Ya),Df=e=>{const{__scopePopper:t,children:n}=e,[r,o]=g.useState(null);return u.jsx(Q0,{scope:t,anchor:r,onAnchorChange:o,children:n})};Df.displayName=Ya;var Lf="PopperAnchor",Ff=g.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Mf(Lf,n),i=g.useRef(null),a=Be(t,i),l=g.useRef(null);return g.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(Ie.div,{...o,ref:a})});Ff.displayName=Lf;var Xa="PopperContent",[eS,tS]=Of(Xa),$f=g.forwardRef((e,t)=>{var J,D,ee,re,ce,ae;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:y,...v}=e,m=Mf(Xa,n),[x,w]=g.useState(null),S=Be(t,ie=>w(ie)),[T,C]=g.useState(null),k=Pf(T),E=(k==null?void 0:k.width)??0,R=(k==null?void 0:k.height)??0,P=r+(s!=="center"?"-"+s:""),j=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},B=Array.isArray(c)?c:[c],$=B.length>0,L={padding:j,boundary:B.filter(rS),altBoundary:$},{refs:O,floatingStyles:H,placement:W,isPositioned:se,middlewareData:K}=H0({strategy:"fixed",placement:P,whileElementsMounted:(...ie)=>R0(...ie,{animationFrame:p==="always"}),elements:{reference:m.anchor},middleware:[W0({mainAxis:o+R,alignmentAxis:i}),l&&V0({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?K0():void 0,...L}),l&&q0({...L}),G0({...L,apply:({elements:ie,rects:Ge,availableWidth:Je,availableHeight:Me})=>{const{width:He,height:at}=Ge.reference,Ke=ie.floating.style;Ke.setProperty("--radix-popper-available-width",`${Je}px`),Ke.setProperty("--radix-popper-available-height",`${Me}px`),Ke.setProperty("--radix-popper-anchor-width",`${He}px`),Ke.setProperty("--radix-popper-anchor-height",`${at}px`)}}),T&&X0({element:T,padding:a}),oS({arrowWidth:E,arrowHeight:R}),h&&Y0({strategy:"referenceHidden",...L})]}),[U,X]=Hf(W),F=St(y);yt(()=>{se&&(F==null||F())},[se,F]);const q=(J=K.arrow)==null?void 0:J.x,pe=(D=K.arrow)==null?void 0:D.y,ge=((ee=K.arrow)==null?void 0:ee.centerOffset)!==0,[ke,Se]=g.useState();return yt(()=>{x&&Se(window.getComputedStyle(x).zIndex)},[x]),u.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:se?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ke,"--radix-popper-transform-origin":[(re=K.transformOrigin)==null?void 0:re.x,(ce=K.transformOrigin)==null?void 0:ce.y].join(" "),...((ae=K.hide)==null?void 0:ae.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(eS,{scope:n,placedSide:U,onArrowChange:C,arrowX:q,arrowY:pe,shouldHideArrow:ge,children:u.jsx(Ie.div,{"data-side":U,"data-align":X,...v,ref:S,style:{...v.style,animation:se?void 0:"none"}})})})});$f.displayName=Xa;var zf="PopperArrow",nS={top:"bottom",right:"left",bottom:"top",left:"right"},Bf=g.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=tS(zf,r),i=nS[s.placedSide];return u.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:u.jsx(Z0,{...o,ref:n,style:{...o.style,display:"block"}})})});Bf.displayName=zf;function rS(e){return e!==null}var oS=e=>({name:"transformOrigin",options:e,fn(t){var m,x,w;const{placement:n,rects:r,middlewareData:o}=t,i=((m=o.arrow)==null?void 0:m.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,d]=Hf(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((x=o.arrow)==null?void 0:x.x)??0)+a/2,p=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let y="",v="";return c==="bottom"?(y=i?f:`${h}px`,v=`${-l}px`):c==="top"?(y=i?f:`${h}px`,v=`${r.floating.height+l}px`):c==="right"?(y=`${-l}px`,v=i?f:`${p}px`):c==="left"&&(y=`${r.floating.width+l}px`,v=i?f:`${p}px`),{data:{x:y,y:v}}}});function Hf(e){const[t,n="center"]=e.split("-");return[t,n]}var Uf=Df,Wf=Ff,Vf=$f,Kf=Bf,Ja="rovingFocusGroup.onEntryFocus",sS={bubbles:!1,cancelable:!0},wo="RovingFocusGroup",[Za,qf,iS]=La(wo),[aS,Gf]=bn(wo,[iS]),[lS,cS]=aS(wo),Yf=g.forwardRef((e,t)=>u.jsx(Za.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Za.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(uS,{...e,ref:t})})}));Yf.displayName=wo;var uS=g.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...f}=e,h=g.useRef(null),p=Be(t,h),y=$s(s),[v,m]=pr({prop:i,defaultProp:a??null,onChange:l,caller:wo}),[x,w]=g.useState(!1),S=St(c),T=qf(n),C=g.useRef(!1),[k,E]=g.useState(0);return g.useEffect(()=>{const R=h.current;if(R)return R.addEventListener(Ja,S),()=>R.removeEventListener(Ja,S)},[S]),u.jsx(lS,{scope:n,orientation:r,dir:y,loop:o,currentTabStopId:v,onItemFocus:g.useCallback(R=>m(R),[m]),onItemShiftTab:g.useCallback(()=>w(!0),[]),onFocusableItemAdd:g.useCallback(()=>E(R=>R+1),[]),onFocusableItemRemove:g.useCallback(()=>E(R=>R-1),[]),children:u.jsx(Ie.div,{tabIndex:x||k===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:fe(e.onMouseDown,()=>{C.current=!0}),onFocus:fe(e.onFocus,R=>{const P=!C.current;if(R.target===R.currentTarget&&P&&!x){const j=new CustomEvent(Ja,sS);if(R.currentTarget.dispatchEvent(j),!j.defaultPrevented){const B=T().filter(W=>W.focusable),$=B.find(W=>W.active),L=B.find(W=>W.id===v),H=[$,L,...B].filter(Boolean).map(W=>W.ref.current);Zf(H,d)}}C.current=!1}),onBlur:fe(e.onBlur,()=>w(!1))})})}),Xf="RovingFocusGroupItem",Jf=g.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Sn(),c=s||l,d=cS(Xf,n),f=d.currentTabStopId===c,h=qf(n),{onFocusableItemAdd:p,onFocusableItemRemove:y,currentTabStopId:v}=d;return g.useEffect(()=>{if(r)return p(),()=>y()},[r,p,y]),u.jsx(Za.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(Ie.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:fe(e.onMouseDown,m=>{r?d.onItemFocus(c):m.preventDefault()}),onFocus:fe(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:fe(e.onKeyDown,m=>{if(m.key==="Tab"&&m.shiftKey){d.onItemShiftTab();return}if(m.target!==m.currentTarget)return;const x=hS(m,d.orientation,d.dir);if(x!==void 0){if(m.metaKey||m.ctrlKey||m.altKey||m.shiftKey)return;m.preventDefault();let S=h().filter(T=>T.focusable).map(T=>T.ref.current);if(x==="last")S.reverse();else if(x==="prev"||x==="next"){x==="prev"&&S.reverse();const T=S.indexOf(m.currentTarget);S=d.loop?pS(S,T+1):S.slice(T+1)}setTimeout(()=>Zf(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:v!=null}):i})})});Jf.displayName=Xf;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 Zf(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=Yf,gS=Jf,Qa=["Enter"," "],xS=["ArrowDown","PageUp","Home"],Qf=["ArrowUp","PageDown","End"],yS=[...xS,...Qf],vS={ltr:[...Qa,"ArrowRight"],rtl:[...Qa,"ArrowLeft"]},wS={ltr:["ArrowLeft"],rtl:["ArrowRight"]},bo="Menu",[So,bS,SS]=La(bo),[vr,eh]=bn(bo,[SS,Xs,Gf]),Js=Xs(),th=Gf(),[CS,wr]=vr(bo),[kS,Co]=vr(bo),nh=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=Js(t),[l,c]=g.useState(null),d=g.useRef(!1),f=St(s),h=$s(o);return g.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",y,{capture:!0,once:!0}),document.addEventListener("pointermove",y,{capture:!0,once:!0})},y=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",y,{capture:!0}),document.removeEventListener("pointermove",y,{capture:!0})}},[]),u.jsx(Uf,{...a,children:u.jsx(CS,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c,children:u.jsx(kS,{scope:t,onClose:g.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};nh.displayName=bo;var TS="MenuAnchor",el=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Js(n);return u.jsx(Wf,{...o,...r,ref:t})});el.displayName=TS;var tl="MenuPortal",[ES,rh]=vr(tl,{forceMount:void 0}),oh=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=wr(tl,t);return u.jsx(ES,{scope:t,forceMount:n,children:u.jsx(Ut,{present:n||s.open,children:u.jsx(bs,{asChild:!0,container:o,children:r})})})};oh.displayName=tl;var Zt="MenuContent",[IS,nl]=vr(Zt),sh=g.forwardRef((e,t)=>{const n=rh(Zt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=wr(Zt,e.__scopeMenu),i=Co(Zt,e.__scopeMenu);return u.jsx(So.Provider,{scope:e.__scopeMenu,children:u.jsx(Ut,{present:r||s.open,children:u.jsx(So.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(NS,{...o,ref:t}):u.jsx(AS,{...o,ref:t})})})})}),NS=g.forwardRef((e,t)=>{const n=wr(Zt,e.__scopeMenu),r=g.useRef(null),o=Be(t,r);return g.useEffect(()=>{const s=r.current;if(s)return ja(s)},[]),u.jsx(rl,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:fe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),AS=g.forwardRef((e,t)=>{const n=wr(Zt,e.__scopeMenu);return u.jsx(rl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),_S=sr.createSlot("MenuContent.ScrollLock"),rl=g.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:y,...v}=e,m=wr(Zt,n),x=Co(Zt,n),w=Js(n),S=th(n),T=bS(n),[C,k]=g.useState(null),E=g.useRef(null),R=Be(t,E,m.onContentChange),P=g.useRef(0),j=g.useRef(""),B=g.useRef(0),$=g.useRef(null),L=g.useRef("right"),O=g.useRef(0),H=y?Is:g.Fragment,W=y?{as:_S,allowPinchZoom:!0}:void 0,se=U=>{var J,D;const X=j.current+U,F=T().filter(ee=>!ee.disabled),q=document.activeElement,pe=(J=F.find(ee=>ee.ref.current===q))==null?void 0:J.textValue,ge=F.map(ee=>ee.textValue),ke=HS(ge,X,pe),Se=(D=F.find(ee=>ee.textValue===ke))==null?void 0:D.ref.current;(function ee(re){j.current=re,window.clearTimeout(P.current),re!==""&&(P.current=window.setTimeout(()=>ee(""),1e3))})(X),Se&&setTimeout(()=>Se.focus())};g.useEffect(()=>()=>window.clearTimeout(P.current),[]),Ta();const K=g.useCallback(U=>{var F,q;return L.current===((F=$.current)==null?void 0:F.side)&&WS(U,(q=$.current)==null?void 0:q.area)},[]);return u.jsx(IS,{scope:n,searchRef:j,onItemEnter:g.useCallback(U=>{K(U)&&U.preventDefault()},[K]),onItemLeave:g.useCallback(U=>{var X;K(U)||((X=E.current)==null||X.focus(),k(null))},[K]),onTriggerLeave:g.useCallback(U=>{K(U)&&U.preventDefault()},[K]),pointerGraceTimerRef:B,onPointerGraceIntentChange:g.useCallback(U=>{$.current=U},[]),children:u.jsx(H,{...W,children:u.jsx(ws,{asChild:!0,trapped:o,onMountAutoFocus:fe(s,U=>{var X;U.preventDefault(),(X=E.current)==null||X.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(vs,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:u.jsx(mS,{asChild:!0,...S,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:fe(l,U=>{x.isUsingKeyboardRef.current||U.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(Vf,{role:"menu","aria-orientation":"vertical","data-state":Sh(m.open),"data-radix-menu-content":"",dir:x.dir,...w,...v,ref:R,style:{outline:"none",...v.style},onKeyDown:fe(v.onKeyDown,U=>{const F=U.target.closest("[data-radix-menu-content]")===U.currentTarget,q=U.ctrlKey||U.altKey||U.metaKey,pe=U.key.length===1;F&&(U.key==="Tab"&&U.preventDefault(),!q&&pe&&se(U.key));const ge=E.current;if(U.target!==ge||!yS.includes(U.key))return;U.preventDefault();const Se=T().filter(J=>!J.disabled).map(J=>J.ref.current);Qf.includes(U.key)&&Se.reverse(),zS(Se)}),onBlur:fe(e.onBlur,U=>{U.currentTarget.contains(U.target)||(window.clearTimeout(P.current),j.current="")}),onPointerMove:fe(e.onPointerMove,To(U=>{const X=U.target,F=O.current!==U.clientX;if(U.currentTarget.contains(X)&&F){const q=U.clientX>O.current?"right":"left";L.current=q,O.current=U.clientX}}))})})})})})})});sh.displayName=Zt;var jS="MenuGroup",ol=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Ie.div,{role:"group",...r,ref:t})});ol.displayName=jS;var RS="MenuLabel",ih=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Ie.div,{...r,ref:t})});ih.displayName=RS;var Zs="MenuItem",ah="menu.itemSelect",Qs=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=g.useRef(null),i=Co(Zs,e.__scopeMenu),a=nl(Zs,e.__scopeMenu),l=Be(t,s),c=g.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(ah,{bubbles:!0,cancelable:!0});f.addEventListener(ah,p=>r==null?void 0:r(p),{once:!0}),Vu(f,h),h.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(lh,{...o,ref:l,disabled:n,onClick:fe(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),c.current=!0},onPointerUp:fe(e.onPointerUp,f=>{var h;c.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:fe(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||Qa.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Qs.displayName=Zs;var lh=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=nl(Zs,n),a=th(n),l=g.useRef(null),c=Be(t,l),[d,f]=g.useState(!1),[h,p]=g.useState("");return g.useEffect(()=>{const y=l.current;y&&p((y.textContent??"").trim())},[s.children]),u.jsx(So.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:u.jsx(gS,{asChild:!0,...a,focusable:!r,children:u.jsx(Ie.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:fe(e.onPointerMove,To(y=>{r?i.onItemLeave(y):(i.onItemEnter(y),y.defaultPrevented||y.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:fe(e.onPointerLeave,To(y=>i.onItemLeave(y))),onFocus:fe(e.onFocus,()=>f(!0)),onBlur:fe(e.onBlur,()=>f(!1))})})})}),PS="MenuCheckboxItem",ch=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(ph,{scope:e.__scopeMenu,checked:n,children:u.jsx(Qs,{role:"menuitemcheckbox","aria-checked":ei(n)?"mixed":n,...o,ref:t,"data-state":il(n),onSelect:fe(o.onSelect,()=>r==null?void 0:r(ei(n)?!0:!n),{checkForDefaultPrevented:!1})})})});ch.displayName=PS;var uh="MenuRadioGroup",[OS,MS]=vr(uh,{value:void 0,onValueChange:()=>{}}),dh=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=St(r);return u.jsx(OS,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(ol,{...o,ref:t})})});dh.displayName=uh;var fh="MenuRadioItem",hh=g.forwardRef((e,t)=>{const{value:n,...r}=e,o=MS(fh,e.__scopeMenu),s=n===o.value;return u.jsx(ph,{scope:e.__scopeMenu,checked:s,children:u.jsx(Qs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":il(s),onSelect:fe(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});hh.displayName=fh;var sl="MenuItemIndicator",[ph,DS]=vr(sl,{checked:!1}),mh=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=DS(sl,n);return u.jsx(Ut,{present:r||ei(s.checked)||s.checked===!0,children:u.jsx(Ie.span,{...o,ref:t,"data-state":il(s.checked)})})});mh.displayName=sl;var LS="MenuSeparator",gh=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Ie.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});gh.displayName=LS;var FS="MenuArrow",xh=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Js(n);return u.jsx(Kf,{...o,...r,ref:t})});xh.displayName=FS;var $S="MenuSub",[ST,yh]=vr($S),ko="MenuSubTrigger",vh=g.forwardRef((e,t)=>{const n=wr(ko,e.__scopeMenu),r=Co(ko,e.__scopeMenu),o=yh(ko,e.__scopeMenu),s=nl(ko,e.__scopeMenu),i=g.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=g.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return g.useEffect(()=>d,[d]),g.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),u.jsx(el,{asChild:!0,...c,children:u.jsx(lh,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Sh(n.open),...e,ref:da(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:fe(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:fe(e.onPointerLeave,To(f=>{var p,y;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const v=(y=n.content)==null?void 0:y.dataset.side,m=v==="right",x=m?-5:5,w=h[m?"left":"right"],S=h[m?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+x,y:f.clientY},{x:w,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:w,y:h.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:fe(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())})})})});vh.displayName=ko;var wh="MenuSubContent",bh=g.forwardRef((e,t)=>{const n=rh(Zt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=wr(Zt,e.__scopeMenu),i=Co(Zt,e.__scopeMenu),a=yh(wh,e.__scopeMenu),l=g.useRef(null),c=Be(t,l);return u.jsx(So.Provider,{scope:e.__scopeMenu,children:u.jsx(Ut,{present:r||s.open,children:u.jsx(So.Slot,{scope:e.__scopeMenu,children:u.jsx(rl,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,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:fe(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:fe(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:fe(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=wS[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});bh.displayName=wh;function Sh(e){return e?"open":"closed"}function ei(e){return e==="indeterminate"}function il(e){return ei(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(c=>c===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(c=>c!==n));const l=i.find(c=>c.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],c=a.x,d=a.y,f=l.x,h=l.y;d>r!=h>r&&n<(f-c)*(r-d)/(h-d)+c&&(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=nh,KS=el,qS=oh,GS=sh,YS=ol,XS=ih,JS=Qs,ZS=ch,QS=dh,eC=hh,tC=mh,nC=gh,rC=xh,oC=vh,sC=bh,ti="DropdownMenu",[iC,CT]=bn(ti,[eh]),Ot=eh(),[aC,Ch]=iC(ti),kh=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Ot(t),c=g.useRef(null),[d,f]=pr({prop:o,defaultProp:s??!1,onChange:i,caller:ti});return u.jsx(aC,{scope:t,triggerId:Sn(),triggerRef:c,contentId:Sn(),open:d,onOpenChange:f,onOpenToggle:g.useCallback(()=>f(h=>!h),[f]),modal:a,children:u.jsx(VS,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};kh.displayName=ti;var Th="DropdownMenuTrigger",Eh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Ch(Th,n),i=Ot(n);return u.jsx(KS,{asChild:!0,...i,children:u.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:da(t,s.triggerRef),onPointerDown:fe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:fe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Eh.displayName=Th;var lC="DropdownMenuPortal",Ih=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ot(t);return u.jsx(qS,{...r,...n})};Ih.displayName=lC;var Nh="DropdownMenuContent",Ah=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ch(Nh,n),s=Ot(n),i=g.useRef(!1);return u.jsx(GS,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:fe(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:fe(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!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)"}})});Ah.displayName=Nh;var cC="DropdownMenuGroup",uC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(YS,{...o,...r,ref:t})});uC.displayName=cC;var dC="DropdownMenuLabel",_h=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(XS,{...o,...r,ref:t})});_h.displayName=dC;var fC="DropdownMenuItem",jh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(JS,{...o,...r,ref:t})});jh.displayName=fC;var hC="DropdownMenuCheckboxItem",Rh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(ZS,{...o,...r,ref:t})});Rh.displayName=hC;var pC="DropdownMenuRadioGroup",mC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(QS,{...o,...r,ref:t})});mC.displayName=pC;var gC="DropdownMenuRadioItem",Ph=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(eC,{...o,...r,ref:t})});Ph.displayName=gC;var xC="DropdownMenuItemIndicator",Oh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(tC,{...o,...r,ref:t})});Oh.displayName=xC;var yC="DropdownMenuSeparator",Mh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(nC,{...o,...r,ref:t})});Mh.displayName=yC;var vC="DropdownMenuArrow",wC=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(rC,{...o,...r,ref:t})});wC.displayName=vC;var bC="DropdownMenuSubTrigger",Dh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(oC,{...o,...r,ref:t})});Dh.displayName=bC;var SC="DropdownMenuSubContent",Lh=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.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)"}})});Lh.displayName=SC;var CC=kh,kC=Eh,TC=Ih,Fh=Ah,$h=_h,zh=jh,Bh=Rh,Hh=Ph,Uh=Oh,Wh=Mh,Vh=Dh,Kh=Lh;const EC=CC,IC=kC,NC=g.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Vh,{ref:o,className:oe("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,u.jsx(he.ChevronRight,{className:"ml-auto h-4 w-4"})]}));NC.displayName=Vh.displayName;const AC=g.forwardRef(({className:e,...t},n)=>u.jsx(Kh,{ref:n,className:oe("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}));AC.displayName=Kh.displayName;const qh=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(TC,{children:u.jsx(Fh,{ref:r,sideOffset:t,className:oe("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=Fh.displayName;const al=g.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(zh,{ref:r,className:oe("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=zh.displayName;const _C=g.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Bh,{ref:o,className:oe("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:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Uh,{children:u.jsx(he.Check,{className:"h-4 w-4"})})}),t]}));_C.displayName=Bh.displayName;const jC=g.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Hh,{ref:r,className:oe("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:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Uh,{children:u.jsx(he.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));jC.displayName=Hh.displayName;const RC=g.forwardRef(({className:e,inset:t,...n},r)=>u.jsx($h,{ref:r,className:oe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));RC.displayName=$h.displayName;const PC=g.forwardRef(({className:e,...t},n)=>u.jsx(Wh,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));PC.displayName=Wh.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 ni({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:c=!0,showToolMessages:d=!0,customStyles:f={},onMessageSent:h,onExcelUploadSuccess:p,onError:y}){const{api:v}=Ni(),{currentThreadId:m}=Yo(),{threadId:x,messages:w,hasMore:S,isHistoryLoading:T,isLoading:C,loadOlder:k,navigateToCheckpoint:E,returnToLatest:R,checkpoint:P,checkpoints:j,interrupt:B,metadata:$}=Xo(),{isStreaming:L,error:O,submit:H,stop:W}=Uc(),se=x??m??null,K=(P==null?void 0:P.id)??null,U=(P==null?void 0:P.namespace)??null,X=($==null?void 0:$.assemblingMessageId)??null,F=B,[q,pe]=b.useState(!1);b.useEffect(()=>{F||pe(!1)},[F]);const ge=b.useCallback(()=>{pe(!0)},[]),ke=b.useCallback(()=>{pe(!1)},[]),Se=!!F||q,[J,D]=b.useState(null),[ee,re]=b.useState(""),[ce,ae]=b.useState(null),[ie,Ge]=b.useState([]),[Je,Me]=b.useState(0),[He,at]=b.useState(0),[Ke,je]=b.useState(!1),[mt,gt]=b.useState(null),[Ct,rt]=b.useState(null),[te,me]=b.useState(!1),[ve,We]=b.useState(null),[De,et]=b.useState(!1),xt=b.useRef(!1),[$t,un]=b.useState(!1),An=b.useCallback((A,z)=>{if(!A||typeof A!="object")return null;const G=A[z];return typeof G=="number"?G:null},[]),tr=b.useCallback((A,z)=>{if(!A||typeof A!="object")return null;const G=A[z];return typeof G=="string"&&G.trim()?G:null},[]),dn=b.useMemo(()=>{const A=Array.isArray(j)?[...j]:[];return A.some(G=>An(G.metadata,"step")!==null)&&A.sort((G,ye)=>{const Ce=An(G.metadata,"step"),Ne=An(ye.metadata,"step");if(Ce!==null||Ne!==null)return(Ne??Number.NEGATIVE_INFINITY)-(Ce??Number.NEGATIVE_INFINITY);const Pe=Date.parse(G.createdAt??""),dt=Date.parse(ye.createdAt??"");return Number.isNaN(Pe)||Number.isNaN(dt)?0:dt-Pe}),A},[j,An]),fn=b.useRef(null),Mt=b.useRef(null),hn=b.useCallback(()=>{fn.current&&(fn.current.value=""),Mt.current&&(Mt.current.value=""),Me(A=>A+1),at(A=>A+1)},[]),Kt=b.useRef(!1);b.useEffect(()=>{Kt.current&&!L&&(Ge([]),hn()),Kt.current=L},[L,hn]);const[kt,kr]=b.useState("desktop");b.useEffect(()=>{const A=()=>{const z=window.innerWidth;kr(z<640?"phone":z<1024?"tablet":"desktop")};return A(),window.addEventListener("resize",A),()=>window.removeEventListener("resize",A)},[]),b.useEffect(()=>{et(!1),xt.current=!1},[se]);const nr=b.useCallback(async()=>{if(!(!S||T||!De))try{await k()}catch(A){console.warn("loadOlder failed",A)}},[S,De,T,k]);b.useEffect(()=>{(async()=>{if(!v.baseUrl){We(null);return}try{const z=await v.getAgent("default");We(z.uiDefaultMessage||null)}catch(z){console.warn("Failed to fetch default message:",z),We(null)}})()},[v]),b.useEffect(()=>{O&&!te&&(y==null||y(O))},[O,te,y]);const vt=A=>{if(A.length>Fs)return`Message too long (${A.length}/${Fs} characters)`;try{return $b(A),null}catch(z){return(z==null?void 0:z.message)||"Invalid message"}},pn=async A=>{const z=A.trim();if(!(!z&&ie.length===0)){if(z){const G=vt(z);if(G){ae(G);return}}try{await H({text:z||"",attachments:ie,payload:J?{edit:!0,originalMessageId:J}:void 0},{checkpointId:K??void 0,checkpointNs:U??void 0}),h==null||h(z),ae(null),Ge([]),hn(),D(null),re("")}catch(G){const ye=(G==null?void 0:G.message)||"Failed to send message";ae(ye),y==null||y(ye)}}},_n=b.useCallback((A,z)=>{c&&(D(A),re(z),ae(null))},[c]),$n=b.useCallback(()=>{D(null),re(""),ae(null)},[]),qt=b.useCallback((A,z)=>{_n(A,z)},[_n]),Tr=b.useCallback(A=>{const z=G=>{const ye=G.content||[],Ce=ye.filter(Ne=>Ne.type==="text").map(Ne=>Ne.text).join("");if(Ce)return Ce;try{return JSON.stringify(ye,null,2)}catch{return String(ye)}};for(let G=A-1;G>=0;G--)if(w[G].role==="user"){const ye=z(w[G]);ye&&H({text:ye},{checkpointId:K??void 0,checkpointNs:U??void 0});break}},[w,H,K,U]),jn=A=>{const z=Array.from(A.target.files||[]);Ge(G=>[...G,...z]),A.target.value=""},mn=A=>{Ge(z=>{const G=z.filter((ye,Ce)=>A!==Ce);return G.length===0&&hn(),G})},rr=async A=>{const z=(A.target.files||[])[0];if(z){gt(null),rt(null),je(!0);try{await H({attachments:[z]},{checkpointId:K??void 0,checkpointNs:U??void 0});const G=`Uploaded ${z.name} - processing through chat stream`;rt(G)}catch(G){const ye=G instanceof Error?G.message:"Failed to upload Excel file";console.error("Excel upload failed",G),gt(ye),y==null||y(ye)}finally{je(!1),A.target.value="",hn()}}},Io=A=>{if(!A)return"Unknown";const z=Date.parse(A);return Number.isNaN(z)?A:new Date(z).toLocaleString()},Ur=async A=>{if(m){un(!0);try{if(!A){await R();return}const z=dn.find(ye=>ye.checkpointId===A),G=(z==null?void 0:z.checkpointNs)??null;await E(A,G)}finally{un(!1)}}},Wr=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${f.container||""}`,or=`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 ${f.messagesArea||""}`,I=`flex-shrink-0 w-full border-t p-4 bg-transparent ${f.inputArea||""}`;return u.jsxs("div",{className:Wr,children:[!!O&&!te&&u.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:[u.jsx("span",{children:O}),u.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>me(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(he.X,{size:16})})]}),m&&j.length>0&&u.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:[u.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),u.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:K??"",onChange:A=>{const z=A.target.value||null;Ur(z)},children:[u.jsx("option",{value:"",children:"Latest"}),dn.map(A=>{const z=An(A.metadata,"step"),G=tr(A.metadata,"source"),ye=OC(A.messages),Ce=[];z!==null&&Ce.push(`Step ${z}`),G&&Ce.push(G),ye&&Ce.push(ye.slice(0,40));const Ne=Ce.length?` — ${Ce.join(" • ")}`:"";return u.jsxs("option",{value:A.checkpointId,children:[Io(A.createdAt),Ne]},A.checkpointId)})]})]}),u.jsxs("div",{className:`relative ${or}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(Da,{className:"h-full",style:{height:"100%"},messages:w,isStreaming:L,streamingAssistantId:X,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:kt,enableMessageEditing:c,editingMessageId:J,onStartReached:()=>{De&&nr()},onScrollAway:A=>{if(!xt.current){xt.current=!0;return}A&&et(!0)},onEdit:qt,onRegenerate:Tr,onCancelEdit:$n,emptyMessage:ve??void 0,isNavigatingCheckpoint:$t,activeInterrupt:F,disableInterruptActions:q,onInterruptActionStart:ge,onInterruptActionEnd:ke,showToolMessages:d}),C&&u.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:[u.jsx(he.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]})]}),u.jsxs("div",{className:I,children:[J&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(he.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(qe,{variant:"ghost",size:"sm",onClick:$n,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(he.X,{size:16})})]})}),(a||l)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[a&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:fn,type:"file",multiple:!0,onChange:A=>jn(A),className:"hidden"},Je),ie.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:ie.map((A,z)=>u.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:[u.jsx(he.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:A.name}),u.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>mn(z),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 ${A.name}`,children:u.jsx(he.X,{size:12})})]},z))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:Mt,type:"file",accept:".xls,.xlsx,.xlsm",onChange:rr,className:"hidden"},He),Ke&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(he.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),Ct&&!Ke&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:Ct}),mt&&!Ke&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:mt})]})]}),ce&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:ce}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(EC,{children:[u.jsx(IC,{asChild:!0,children:u.jsx(qe,{type:"button",size:"icon",variant:"outline",disabled:L||Se,title:"More input actions",className:f.moreButton||"",children:u.jsx(he.Plus,{size:16})})}),u.jsxs(qh,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(al,{onClick:()=>{var A;return(A=fn.current)==null?void 0:A.click()},className:"cursor-pointer",children:[u.jsx(he.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(al,{onClick:()=>{var A;Ke||(A=Mt.current)==null||A.click()},className:`cursor-pointer ${Ke?"opacity-60 pointer-events-none":""}`,children:[u.jsx(he.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(Gx,{initialValue:ee,editingMessageId:J,placeholder:J?"Edit your message...":t,isStreaming:L,disabled:Se,maxLength:Fs,onSend:pn,onCancelEdit:$n,onStop:W,allowEmptySend:ie.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${J?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${ce?"border-red-400":""} ${f.textarea||""}`})})]})]})]})}const ri=g.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:oe("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}));ri.displayName="Input";function ll(e,[t,n]){return Math.min(n,Math.max(t,e))}function MC(e,t){return g.useReducer((n,r)=>t[n][r]??n,e)}var cl="ScrollArea",[Gh,kT]=bn(cl),[DC,Qt]=Gh(cl),Yh=g.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=g.useState(null),[c,d]=g.useState(null),[f,h]=g.useState(null),[p,y]=g.useState(null),[v,m]=g.useState(null),[x,w]=g.useState(0),[S,T]=g.useState(0),[C,k]=g.useState(!1),[E,R]=g.useState(!1),P=Be(t,B=>l(B)),j=$s(o);return u.jsx(DC,{scope:n,type:r,dir:j,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:y,scrollbarXEnabled:C,onScrollbarXEnabledChange:k,scrollbarY:v,onScrollbarYChange:m,scrollbarYEnabled:E,onScrollbarYEnabledChange:R,onCornerWidthChange:w,onCornerHeightChange:T,children:u.jsx(Ie.div,{dir:j,...i,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Yh.displayName=cl;var Xh="ScrollAreaViewport",Jh=g.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Qt(Xh,n),a=g.useRef(null),l=Be(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.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}),u.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:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Jh.displayName=Xh;var Nn="ScrollAreaScrollbar",ul=g.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(Nn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return g.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(LC,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(FC,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(Zh,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(dl,{...r,ref:t}):null});ul.displayName=Nn;var LC=g.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(Nn,e.__scopeScrollArea),[s,i]=g.useState(!1);return g.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Ut,{present:n||s,children:u.jsx(Zh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),FC=g.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(Nn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ai(()=>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 g.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),g.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let f=c[d];const h=()=>{const p=c[d];f!==p&&(l("SCROLL"),i()),f=p};return c.addEventListener("scroll",h),()=>c.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),u.jsx(Ut,{present:n||a!=="hidden",children:u.jsx(dl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:fe(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:fe(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Zh=g.forwardRef((e,t)=>{const n=Qt(Nn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=g.useState(!1),a=e.orientation==="horizontal",l=ai(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return zr(n.viewport,l),zr(n.content,l),u.jsx(Ut,{present:r||s,children:u.jsx(dl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),dl=g.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Qt(Nn,e.__scopeScrollArea),s=g.useRef(null),i=g.useRef(0),[a,l]=g.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=rp(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<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"?u.jsx($C,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=op(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"?u.jsx(zC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=op(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=g.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Qt(Nn,e.__scopeScrollArea),[i,a]=g.useState(),l=g.useRef(null),c=Be(t,l,s.onScrollbarXChange);return g.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(ep,{"data-orientation":"horizontal",...o,ref:c,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":ii(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),ip(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:si(i.paddingLeft),paddingEnd:si(i.paddingRight)}})}})}),zC=g.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Qt(Nn,e.__scopeScrollArea),[i,a]=g.useState(),l=g.useRef(null),c=Be(t,l,s.onScrollbarYChange);return g.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(ep,{"data-orientation":"vertical",...o,ref:c,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":ii(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),ip(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:si(i.paddingTop),paddingEnd:si(i.paddingBottom)}})}})}),[BC,Qh]=Gh(Nn),ep=g.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:f,...h}=e,p=Qt(Nn,n),[y,v]=g.useState(null),m=Be(t,P=>v(P)),x=g.useRef(null),w=g.useRef(""),S=p.viewport,T=r.content-r.viewport,C=St(d),k=St(l),E=ai(f,10);function R(P){if(x.current){const j=P.clientX-x.current.left,B=P.clientY-x.current.top;c({x:j,y:B})}}return g.useEffect(()=>{const P=j=>{const B=j.target;(y==null?void 0:y.contains(B))&&C(j,T)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[S,y,T,C]),g.useEffect(k,[r,k]),zr(y,E),zr(p.content,E),u.jsx(BC,{scope:n,scrollbar:y,hasThumb:o,onThumbChange:St(s),onThumbPointerUp:St(i),onThumbPositionChange:k,onThumbPointerDown:St(a),children:u.jsx(Ie.div,{...h,ref:m,style:{position:"absolute",...h.style},onPointerDown:fe(e.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),x.current=y.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),R(P))}),onPointerMove:fe(e.onPointerMove,R),onPointerUp:fe(e.onPointerUp,P=>{const j=P.target;j.hasPointerCapture(P.pointerId)&&j.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=w.current,p.viewport&&(p.viewport.style.scrollBehavior=""),x.current=null})})})}),oi="ScrollAreaThumb",tp=g.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qh(oi,e.__scopeScrollArea);return u.jsx(Ut,{present:n||o.hasThumb,children:u.jsx(HC,{ref:t,...r})})}),HC=g.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Qt(oi,n),i=Qh(oi,n),{onThumbPositionChange:a}=i,l=Be(t,f=>i.onThumbChange(f)),c=g.useRef(void 0),d=ai(()=>{c.current&&(c.current(),c.current=void 0)},100);return g.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!c.current){const p=VC(f,a);c.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),u.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:fe(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),y=f.clientX-p.left,v=f.clientY-p.top;i.onThumbPointerDown({x:y,y:v})}),onPointerUp:fe(e.onPointerUp,i.onThumbPointerUp)})});tp.displayName=oi;var fl="ScrollAreaCorner",np=g.forwardRef((e,t)=>{const n=Qt(fl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(UC,{...e,ref:t}):null});np.displayName=fl;var UC=g.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Qt(fl,n),[s,i]=g.useState(0),[a,l]=g.useState(0),c=!!(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)}),c?u.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 si(e){return e?parseInt(e,10):0}function rp(e,t){const n=e/t;return isNaN(n)?0:n}function ii(e){const t=rp(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=ii(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return sp([l,c],f)(e)}function op(e,t,n="ltr"){const r=ii(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],c=ll(e,l);return sp([0,i],[0,a])(c)}function sp(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 ip(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 ai(e,t){const n=St(e),r=g.useRef(0);return g.useEffect(()=>()=>window.clearTimeout(r.current),[]),g.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function zr(e,t){const n=St(t);yt(()=>{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 ap=Yh,KC=Jh,qC=np;const lp=g.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(ap,{ref:r,className:oe("relative overflow-hidden",e),...n,children:[u.jsx(KC,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(cp,{}),u.jsx(qC,{})]}));lp.displayName=ap.displayName;const cp=g.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(ul,{ref:r,orientation:t,className:oe("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:u.jsx(tp,{className:"relative flex-1 rounded-full bg-border"})}));cp.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:c,onThreadDelete:d}){const{threads:f,currentThreadId:h,isLoading:p,actions:y}=Yo(),{loadThread:v}=Xo(),{createThread:m,deleteThread:x,renameThread:w}=y,[S,T]=b.useState(Array.isArray(f)?f:[]),C=b.useRef(S.length>0),[k,E]=b.useState(null),[R,P]=b.useState(""),[j,B]=b.useState(!1);b.useEffect(()=>{const F=Array.isArray(f)?f:[];if(F.length>0){C.current=!0,T(F);return}p||(C.current=!1,T(F))},[f,p]);const $=async F=>{try{await v(F),a==null||a(F),l==null||l(F)}catch(q){console.error("Failed to select thread:",q)}},L=async()=>{try{B(!0);const F=await m();c==null||c(F),a==null||a(F)}catch(F){console.error("Failed to create thread:",F)}finally{B(!1)}},O=async(F,q)=>{if(q.stopPropagation(),!!confirm("Delete this thread?"))try{await x(F),d==null||d(F)}catch(pe){console.error("Failed to delete thread:",pe)}},H=(F,q)=>{q.stopPropagation(),E(F.threadId),P(F.title||`Thread ${F.threadId.slice(0,8)}`)},W=async F=>{if(R.trim())try{await w(F,R.trim()),E(null),P("")}catch(q){console.error("Failed to update title:",q)}},se=()=>{E(null),P("")},K=(F,q)=>{F.key==="Enter"?W(q):F.key==="Escape"&&se()},U=F=>{if(!F)return"";try{const q=new Date(F),ge=new Date().getTime()-q.getTime(),ke=Math.floor(ge/(1e3*60*60*24));return ke===0?q.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):ke===1?"Yesterday":ke<7?`${ke} days ago`:q.toLocaleDateString()}catch{return""}},X=F=>F.title||`Thread ${F.threadId.slice(0,8)}`;return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&u.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:u.jsx(qe,{onClick:L,disabled:j||p,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:j?"Creating...":"New Chat",children:u.jsx(he.MessageSquarePlus,{size:20})})}),u.jsx(lp,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children:p?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(he.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):S.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(he.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):S.slice().sort((F,q)=>new Date(q.updatedAt||q.createdAt||"").getTime()-new Date(F.updatedAt||F.createdAt||"").getTime()).map(F=>u.jsxs("div",{onClick:()=>$(F.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??h)===F.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:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:k===F.threadId?u.jsxs("div",{className:"flex items-center gap-2",onClick:q=>q.stopPropagation(),children:[u.jsx(ri,{value:R,onChange:q=>P(q.target.value),onKeyDown:q=>K(q,F.threadId),className:"h-6 text-sm",autoFocus:!0}),u.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>W(F.threadId),className:"h-6 w-6 p-0",children:u.jsx(he.Check,{size:12})}),u.jsx(qe,{variant:"ghost",size:"sm",onClick:se,className:"h-6 w-6 p-0",children:u.jsx(he.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:X(F)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(he.Calendar,{size:10}),u.jsx("span",{children:U(F.updatedAt||F.createdAt)})]})]})}),u.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&k!==F.threadId&&u.jsx(qe,{variant:"ghost",size:"sm",onClick:q=>H(F,q),className:"h-6 w-6 p-0",title:"Edit title",children:u.jsx(he.Edit3,{size:12})}),n&&u.jsx(qe,{variant:"ghost",size:"sm",onClick:q=>O(F.threadId,q),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:u.jsx(he.Trash2,{size:12})})]})]}),i===F.threadId&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},F.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 up(){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 dp(){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 fp(...e){for(const t of e)if(typeof t=="string"&&t.trim())return Mn(t);return Mn()}function hp(){const e={},t=up(),n=dp();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function pp(){const e=hp(),t=Hn.getAuthToken(),n=up();return{apiBaseUrl:fp(e.baseUrl,Hn.baseUrl,n),apiKey:t||e.apiKey||dp()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const mp="chat-settings";function YC(){try{const e=localStorage.getItem(mp);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(mp,JSON.stringify(t)),t.apiKey&&Hn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function JC(){const e=pp(),t=YC(),n=Hn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:fp(Hn.baseUrl,r,e.apiBaseUrl)}}function ZC(e){Hn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),XC(e)}var QC="Label",gp=g.forwardRef((e,t)=>u.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())}}));gp.displayName=QC;var xp=gp;const ek=Ro.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),en=g.forwardRef(({className:e,...t},n)=>u.jsx(xp,{ref:n,className:oe(ek(),e),...t}));en.displayName=xp.displayName;function yp(e){const t=g.useRef({value:e,previous:e});return g.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var li="Switch",[tk,TT]=bn(li),[nk,rk]=tk(li),vp=g.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...f}=e,[h,p]=g.useState(null),y=Be(t,S=>p(S)),v=g.useRef(!1),m=h?d||!!h.closest("form"):!0,[x,w]=pr({prop:o,defaultProp:s??!1,onChange:c,caller:li});return u.jsxs(nk,{scope:n,checked:x,disabled:a,children:[u.jsx(Ie.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":Cp(x),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:y,onClick:fe(e.onClick,S=>{w(T=>!T),m&&(v.current=S.isPropagationStopped(),v.current||S.stopPropagation())})}),m&&u.jsx(Sp,{control:h,bubbles:!v.current,name:r,value:l,checked:x,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});vp.displayName=li;var wp="SwitchThumb",bp=g.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=rk(wp,n);return u.jsx(Ie.span,{"data-state":Cp(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});bp.displayName=wp;var ok="SwitchBubbleInput",Sp=g.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=g.useRef(null),a=Be(i,s),l=yp(n),c=Pf(t);return g.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const y=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(y)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Sp.displayName=ok;function Cp(e){return e?"checked":"unchecked"}var kp=vp,sk=bp;const Zn=g.forwardRef(({className:e,...t},n)=>u.jsx(kp,{className:oe("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:u.jsx(sk,{className:oe("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=kp.displayName;var Tp=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=g.forwardRef((e,t)=>u.jsx(Ie.span,{...e,ref:t,style:{...Tp,...e.style}}));ak.displayName=ik;var lk=[" ","Enter","ArrowUp","ArrowDown"],ck=[" ","Enter"],br="Select",[ci,ui,uk]=La(br),[Hr,ET]=bn(br,[uk,Xs]),di=Xs(),[dk,Qn]=Hr(br),[fk,hk]=Hr(br),Ep=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:f,disabled:h,required:p,form:y}=e,v=di(t),[m,x]=g.useState(null),[w,S]=g.useState(null),[T,C]=g.useState(!1),k=$s(c),[E,R]=pr({prop:r,defaultProp:o??!1,onChange:s,caller:br}),[P,j]=pr({prop:i,defaultProp:a,onChange:l,caller:br}),B=g.useRef(null),$=m?y||!!m.closest("form"):!0,[L,O]=g.useState(new Set),H=Array.from(L).map(W=>W.props.value).join(";");return u.jsx(Uf,{...v,children:u.jsxs(dk,{required:p,scope:t,trigger:m,onTriggerChange:x,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:T,onValueNodeHasChildrenChange:C,contentId:Sn(),value:P,onValueChange:j,open:E,onOpenChange:R,dir:k,triggerPointerDownPosRef:B,disabled:h,children:[u.jsx(ci.Provider,{scope:t,children:u.jsx(fk,{scope:e.__scopeSelect,onNativeOptionAdd:g.useCallback(W=>{O(se=>new Set(se).add(W))},[]),onNativeOptionRemove:g.useCallback(W=>{O(se=>{const K=new Set(se);return K.delete(W),K})},[]),children:n})}),$?u.jsxs(Xp,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:P,onChange:W=>j(W.target.value),disabled:h,form:y,children:[P===void 0?u.jsx("option",{value:""}):null,Array.from(L)]},H):null]})})};Ep.displayName=br;var Ip="SelectTrigger",Np=g.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=di(n),i=Qn(Ip,n),a=i.disabled||r,l=Be(t,i.onTriggerChange),c=ui(n),d=g.useRef("touch"),[f,h,p]=Zp(v=>{const m=c().filter(S=>!S.disabled),x=m.find(S=>S.value===i.value),w=Qp(m,v,x);w!==void 0&&i.onValueChange(w.value)}),y=v=>{a||(i.onOpenChange(!0),p()),v&&(i.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return u.jsx(Wf,{asChild:!0,...s,children:u.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":Jp(i.value)?"":void 0,...o,ref:l,onClick:fe(o.onClick,v=>{v.currentTarget.focus(),d.current!=="mouse"&&y(v)}),onPointerDown:fe(o.onPointerDown,v=>{d.current=v.pointerType;const m=v.target;m.hasPointerCapture(v.pointerId)&&m.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(y(v),v.preventDefault())}),onKeyDown:fe(o.onKeyDown,v=>{const m=f.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&h(v.key),!(m&&v.key===" ")&&lk.includes(v.key)&&(y(),v.preventDefault())})})})});Np.displayName=Ip;var Ap="SelectValue",_p=g.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Qn(Ap,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,f=Be(t,l.onValueNodeChange);return yt(()=>{c(d)},[c,d]),u.jsx(Ie.span,{...a,ref:f,style:{pointerEvents:"none"},children:Jp(l.value)?u.jsx(u.Fragment,{children:i}):s})});_p.displayName=Ap;var pk="SelectIcon",jp=g.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(Ie.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});jp.displayName=pk;var mk="SelectPortal",Rp=e=>u.jsx(bs,{asChild:!0,...e});Rp.displayName=mk;var Sr="SelectContent",Pp=g.forwardRef((e,t)=>{const n=Qn(Sr,e.__scopeSelect),[r,o]=g.useState();if(yt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Po.createPortal(u.jsx(Op,{scope:e.__scopeSelect,children:u.jsx(ci.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Mp,{...e,ref:t})});Pp.displayName=Sr;var cn=10,[Op,er]=Hr(Sr),gk="SelectContentImpl",xk=sr.createSlot("SelectContent.RemoveScroll"),Mp=g.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:y,hideWhenDetached:v,avoidCollisions:m,...x}=e,w=Qn(Sr,n),[S,T]=g.useState(null),[C,k]=g.useState(null),E=Be(t,J=>T(J)),[R,P]=g.useState(null),[j,B]=g.useState(null),$=ui(n),[L,O]=g.useState(!1),H=g.useRef(!1);g.useEffect(()=>{if(S)return ja(S)},[S]),Ta();const W=g.useCallback(J=>{const[D,...ee]=$().map(ae=>ae.ref.current),[re]=ee.slice(-1),ce=document.activeElement;for(const ae of J)if(ae===ce||(ae==null||ae.scrollIntoView({block:"nearest"}),ae===D&&C&&(C.scrollTop=0),ae===re&&C&&(C.scrollTop=C.scrollHeight),ae==null||ae.focus(),document.activeElement!==ce))return},[$,C]),se=g.useCallback(()=>W([R,S]),[W,R,S]);g.useEffect(()=>{L&&se()},[L,se]);const{onOpenChange:K,triggerPointerDownPosRef:U}=w;g.useEffect(()=>{if(S){let J={x:0,y:0};const D=re=>{var ce,ae;J={x:Math.abs(Math.round(re.pageX)-(((ce=U.current)==null?void 0:ce.x)??0)),y:Math.abs(Math.round(re.pageY)-(((ae=U.current)==null?void 0:ae.y)??0))}},ee=re=>{J.x<=10&&J.y<=10?re.preventDefault():S.contains(re.target)||K(!1),document.removeEventListener("pointermove",D),U.current=null};return U.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",ee,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",ee,{capture:!0})}}},[S,K,U]),g.useEffect(()=>{const J=()=>K(!1);return window.addEventListener("blur",J),window.addEventListener("resize",J),()=>{window.removeEventListener("blur",J),window.removeEventListener("resize",J)}},[K]);const[X,F]=Zp(J=>{const D=$().filter(ce=>!ce.disabled),ee=D.find(ce=>ce.ref.current===document.activeElement),re=Qp(D,J,ee);re&&setTimeout(()=>re.ref.current.focus())}),q=g.useCallback((J,D,ee)=>{const re=!H.current&&!ee;(w.value!==void 0&&w.value===D||re)&&(P(J),re&&(H.current=!0))},[w.value]),pe=g.useCallback(()=>S==null?void 0:S.focus(),[S]),ge=g.useCallback((J,D,ee)=>{const re=!H.current&&!ee;(w.value!==void 0&&w.value===D||re)&&B(J)},[w.value]),ke=r==="popper"?pl:Dp,Se=ke===pl?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:y,hideWhenDetached:v,avoidCollisions:m}:{};return u.jsx(Op,{scope:n,content:S,viewport:C,onViewportChange:k,itemRefCallback:q,selectedItem:R,onItemLeave:pe,itemTextRefCallback:ge,focusSelectedItem:se,selectedItemText:j,position:r,isPositioned:L,searchRef:X,children:u.jsx(Is,{as:xk,allowPinchZoom:!0,children:u.jsx(ws,{asChild:!0,trapped:w.open,onMountAutoFocus:J=>{J.preventDefault()},onUnmountAutoFocus:fe(o,J=>{var D;(D=w.trigger)==null||D.focus({preventScroll:!0}),J.preventDefault()}),children:u.jsx(vs,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:J=>J.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(ke,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:J=>J.preventDefault(),...x,...Se,onPlaced:()=>O(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:fe(x.onKeyDown,J=>{const D=J.ctrlKey||J.altKey||J.metaKey;if(J.key==="Tab"&&J.preventDefault(),!D&&J.key.length===1&&F(J.key),["ArrowUp","ArrowDown","Home","End"].includes(J.key)){let re=$().filter(ce=>!ce.disabled).map(ce=>ce.ref.current);if(["ArrowUp","End"].includes(J.key)&&(re=re.slice().reverse()),["ArrowUp","ArrowDown"].includes(J.key)){const ce=J.target,ae=re.indexOf(ce);re=re.slice(ae+1)}setTimeout(()=>W(re)),J.preventDefault()}})})})})})})});Mp.displayName=gk;var yk="SelectItemAlignedPosition",Dp=g.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Qn(Sr,n),i=er(Sr,n),[a,l]=g.useState(null),[c,d]=g.useState(null),f=Be(t,E=>d(E)),h=ui(n),p=g.useRef(!1),y=g.useRef(!0),{viewport:v,selectedItem:m,selectedItemText:x,focusSelectedItem:w}=i,S=g.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&v&&m&&x){const E=s.trigger.getBoundingClientRect(),R=c.getBoundingClientRect(),P=s.valueNode.getBoundingClientRect(),j=x.getBoundingClientRect();if(s.dir!=="rtl"){const ce=j.left-R.left,ae=P.left-ce,ie=E.left-ae,Ge=E.width+ie,Je=Math.max(Ge,R.width),Me=window.innerWidth-cn,He=ll(ae,[cn,Math.max(cn,Me-Je)]);a.style.minWidth=Ge+"px",a.style.left=He+"px"}else{const ce=R.right-j.right,ae=window.innerWidth-P.right-ce,ie=window.innerWidth-E.right-ae,Ge=E.width+ie,Je=Math.max(Ge,R.width),Me=window.innerWidth-cn,He=ll(ae,[cn,Math.max(cn,Me-Je)]);a.style.minWidth=Ge+"px",a.style.right=He+"px"}const B=h(),$=window.innerHeight-cn*2,L=v.scrollHeight,O=window.getComputedStyle(c),H=parseInt(O.borderTopWidth,10),W=parseInt(O.paddingTop,10),se=parseInt(O.borderBottomWidth,10),K=parseInt(O.paddingBottom,10),U=H+W+L+K+se,X=Math.min(m.offsetHeight*5,U),F=window.getComputedStyle(v),q=parseInt(F.paddingTop,10),pe=parseInt(F.paddingBottom,10),ge=E.top+E.height/2-cn,ke=$-ge,Se=m.offsetHeight/2,J=m.offsetTop+Se,D=H+W+J,ee=U-D;if(D<=ge){const ce=B.length>0&&m===B[B.length-1].ref.current;a.style.bottom="0px";const ae=c.clientHeight-v.offsetTop-v.offsetHeight,ie=Math.max(ke,Se+(ce?pe:0)+ae+se),Ge=D+ie;a.style.height=Ge+"px"}else{const ce=B.length>0&&m===B[0].ref.current;a.style.top="0px";const ie=Math.max(ge,H+v.offsetTop+(ce?q:0)+Se)+ee;a.style.height=ie+"px",v.scrollTop=D-ge+v.offsetTop}a.style.margin=`${cn}px 0`,a.style.minHeight=X+"px",a.style.maxHeight=$+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,c,v,m,x,s.dir,r]);yt(()=>S(),[S]);const[T,C]=g.useState();yt(()=>{c&&C(window.getComputedStyle(c).zIndex)},[c]);const k=g.useCallback(E=>{E&&y.current===!0&&(S(),w==null||w(),y.current=!1)},[S,w]);return u.jsx(wk,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:k,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:T},children:u.jsx(Ie.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Dp.displayName=yk;var vk="SelectPopperPosition",pl=g.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=cn,...s}=e,i=di(n);return u.jsx(Vf,{...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[wk,ml]=Hr(Sr,{}),gl="SelectViewport",Lp=g.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=er(gl,n),i=ml(gl,n),a=Be(t,s.onViewportChange),l=g.useRef(0);return u.jsxs(u.Fragment,{children:[u.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}),u.jsx(ci.Slot,{scope:n,children:u.jsx(Ie.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:fe(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const y=window.innerHeight-cn*2,v=parseFloat(f.style.minHeight),m=parseFloat(f.style.height),x=Math.max(v,m);if(x<y){const w=x+p,S=Math.min(y,w),T=w-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=T>0?T:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Lp.displayName=gl;var Fp="SelectGroup",[bk,Sk]=Hr(Fp),Ck=g.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Sn();return u.jsx(bk,{scope:n,id:o,children:u.jsx(Ie.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Ck.displayName=Fp;var $p="SelectLabel",zp=g.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Sk($p,n);return u.jsx(Ie.div,{id:o.id,...r,ref:t})});zp.displayName=$p;var fi="SelectItem",[kk,Bp]=Hr(fi),Hp=g.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Qn(fi,n),l=er(fi,n),c=a.value===r,[d,f]=g.useState(s??""),[h,p]=g.useState(!1),y=Be(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),v=Sn(),m=g.useRef("touch"),x=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(kk,{scope:n,value:r,disabled:o,textId:v,isSelected:c,onItemTextChange:g.useCallback(w=>{f(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(ci.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(Ie.div,{role:"option","aria-labelledby":v,"data-highlighted":h?"":void 0,"aria-selected":c&&h,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:y,onFocus:fe(i.onFocus,()=>p(!0)),onBlur:fe(i.onBlur,()=>p(!1)),onClick:fe(i.onClick,()=>{m.current!=="mouse"&&x()}),onPointerUp:fe(i.onPointerUp,()=>{m.current==="mouse"&&x()}),onPointerDown:fe(i.onPointerDown,w=>{m.current=w.pointerType}),onPointerMove:fe(i.onPointerMove,w=>{var S;m.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):m.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:fe(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:fe(i.onKeyDown,w=>{var T;((T=l.searchRef)==null?void 0:T.current)!==""&&w.key===" "||(ck.includes(w.key)&&x(),w.key===" "&&w.preventDefault())})})})})});Hp.displayName=fi;var Eo="SelectItemText",Up=g.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Qn(Eo,n),a=er(Eo,n),l=Bp(Eo,n),c=hk(Eo,n),[d,f]=g.useState(null),h=Be(t,x=>f(x),l.onItemTextChange,x=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,x,l.value,l.disabled)}),p=d==null?void 0:d.textContent,y=g.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:v,onNativeOptionRemove:m}=c;return yt(()=>(v(y),()=>m(y)),[v,m,y]),u.jsxs(u.Fragment,{children:[u.jsx(Ie.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Po.createPortal(s.children,i.valueNode):null]})});Up.displayName=Eo;var Wp="SelectItemIndicator",Vp=g.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Bp(Wp,n).isSelected?u.jsx(Ie.span,{"aria-hidden":!0,...r,ref:t}):null});Vp.displayName=Wp;var xl="SelectScrollUpButton",Kp=g.forwardRef((e,t)=>{const n=er(xl,e.__scopeSelect),r=ml(xl,e.__scopeSelect),[o,s]=g.useState(!1),i=Be(t,r.onScrollButtonChange);return yt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Gp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Kp.displayName=xl;var yl="SelectScrollDownButton",qp=g.forwardRef((e,t)=>{const n=er(yl,e.__scopeSelect),r=ml(yl,e.__scopeSelect),[o,s]=g.useState(!1),i=Be(t,r.onScrollButtonChange);return yt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Gp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});qp.displayName=yl;var Gp=g.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=er("SelectScrollButton",n),i=g.useRef(null),a=ui(n),l=g.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return g.useEffect(()=>()=>l(),[l]),yt(()=>{var d;const c=a().find(f=>f.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(Ie.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:fe(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:fe(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:fe(o.onPointerLeave,()=>{l()})})}),Tk="SelectSeparator",Yp=g.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(Ie.div,{"aria-hidden":!0,...r,ref:t})});Yp.displayName=Tk;var vl="SelectArrow",Ek=g.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=di(n),s=Qn(vl,n),i=er(vl,n);return s.open&&i.position==="popper"?u.jsx(Kf,{...o,...r,ref:t}):null});Ek.displayName=vl;var Ik="SelectBubbleInput",Xp=g.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=g.useRef(null),s=Be(r,o),i=yp(t);return g.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]),u.jsx(Ie.select,{...n,style:{...Tp,...n.style},ref:s,defaultValue:t})});Xp.displayName=Ik;function Jp(e){return e===""||e===void 0}function Zp(e){const t=St(e),n=g.useRef(""),r=g.useRef(0),o=g.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=g.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return g.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Qp(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=Nk(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function Nk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ak=Ep,em=Np,_k=_p,jk=jp,Rk=Rp,tm=Pp,Pk=Lp,nm=zp,rm=Hp,Ok=Up,Mk=Vp,om=Kp,sm=qp,im=Yp;const am=Ak,lm=_k,wl=g.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(em,{ref:r,className:oe("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,u.jsx(jk,{asChild:!0,children:u.jsx(he.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));wl.displayName=em.displayName;const cm=g.forwardRef(({className:e,...t},n)=>u.jsx(om,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(he.ChevronUp,{className:"h-4 w-4"})}));cm.displayName=om.displayName;const um=g.forwardRef(({className:e,...t},n)=>u.jsx(sm,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(he.ChevronDown,{className:"h-4 w-4"})}));um.displayName=sm.displayName;const bl=g.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(Rk,{children:u.jsxs(tm,{ref:o,className:oe("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:[u.jsx(cm,{}),u.jsx(Pk,{className:oe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(um,{})]})}));bl.displayName=tm.displayName;const Dk=g.forwardRef(({className:e,...t},n)=>u.jsx(nm,{ref:n,className:oe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Dk.displayName=nm.displayName;const Cr=g.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(rm,{ref:r,className:oe("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:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Mk,{children:u.jsx(he.Check,{className:"h-4 w-4"})})}),u.jsx(Ok,{children:t})]}));Cr.displayName=rm.displayName;const Lk=g.forwardRef(({className:e,...t},n)=>u.jsx(im,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));Lk.displayName=im.displayName;var Fk="Separator",dm="horizontal",$k=["horizontal","vertical"],fm=g.forwardRef((e,t)=>{const{decorative:n,orientation:r=dm,...o}=e,s=zk(r)?r:dm,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(Ie.div,{"data-orientation":s,...a,...o,ref:t})});fm.displayName=Fk;function zk(e){return $k.includes(e)}var hm=fm;const pm=g.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(hm,{ref:o,decorative:n,orientation:t,className:oe("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));pm.displayName=hm.displayName;const Bk=Zd,Hk=yb,Uk=Qd,mm=g.forwardRef(({className:e,...t},n)=>u.jsx(Rs,{className:oe("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}));mm.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"}}),gm=g.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(Uk,{children:[u.jsx(mm,{}),u.jsxs(Ps,{ref:o,className:oe(Wk({side:e}),t),...r,children:[n,u.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:[u.jsx(he.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));gm.displayName=Ps.displayName;const xm=({className:e,...t})=>u.jsx("div",{className:oe("flex flex-col space-y-2 text-center sm:text-left",e),...t});xm.displayName="SheetHeader";const ym=g.forwardRef(({className:e,...t},n)=>u.jsx(xr,{ref:n,className:oe("text-lg font-semibold text-foreground",e),...t}));ym.displayName=xr.displayName;const vm=g.forwardRef(({className:e,...t},n)=>u.jsx(Os,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));vm.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]=b.useState(!1),[s,i]=b.useState(!1),[a,l]=b.useState(e),[c,d]=b.useState(!1),{toast:f}=wa();b.useEffect(()=>{const m=JSON.stringify(a)!==JSON.stringify(e);d(m)},[a,e]),b.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."})},y=()=>{l(e),d(!1),o(!1)},v=async()=>{try{const x=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${x.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return u.jsxs(Bk,{open:r,onOpenChange:o,children:[u.jsx(Hk,{asChild:!0,children:u.jsxs(qe,{variant:"outline",size:"sm",className:n,children:[u.jsx(he.Settings,{className:"h-4 w-4 mr-2"}),"Settings",c&&u.jsx(Uu,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),u.jsxs(gm,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[u.jsxs(xm,{children:[u.jsx(ym,{children:"Chat Settings"}),u.jsx(vm,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),u.jsxs("div",{className:"space-y-6 py-6",children:[u.jsxs(uo,{children:[u.jsx(fo,{className:"pb-3",children:u.jsxs(ho,{className:"text-lg flex items-center gap-2",children:[u.jsx(he.Server,{className:"h-5 w-5"}),"API Configuration"]})}),u.jsxs(po,{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(en,{htmlFor:"api-url",children:"API Base URL"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(ri,{id:"api-url",value:a.api.baseUrl,onChange:m=>l(x=>({...x,api:{...x.api,baseUrl:m.target.value}})),placeholder:"http://localhost:8000/api"}),u.jsx(qe,{variant:"outline",onClick:v,children:"Test"})]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(en,{htmlFor:"enable-auth",children:"Enable Authentication"}),u.jsx(Zn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:m=>l(x=>({...x,api:{...x.api,enableAuth:m}}))})]}),a.api.enableAuth&&u.jsxs("div",{className:"space-y-2",children:[u.jsx(en,{htmlFor:"auth-token",children:"Authentication Token"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(ri,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:m=>l(x=>({...x,api:{...x.api,authToken:m.target.value}})),placeholder:"Enter your Bearer token"}),u.jsx(qe,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?u.jsx(he.EyeOff,{className:"h-4 w-4"}):u.jsx(he.Eye,{className:"h-4 w-4"})})]})]})]})]}),u.jsxs(uo,{children:[u.jsx(fo,{className:"pb-3",children:u.jsxs(ho,{className:"text-lg flex items-center gap-2",children:[u.jsx(he.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),u.jsxs(po,{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(en,{htmlFor:"layout",children:"Layout Style"}),u.jsxs(am,{value:a.ui.layout,onValueChange:m=>l(x=>({...x,ui:{...x.ui,layout:m}})),children:[u.jsx(wl,{children:u.jsx(lm,{})}),u.jsxs(bl,{children:[u.jsx(Cr,{value:"sidebar",children:"Sidebar Layout"}),u.jsx(Cr,{value:"fullscreen",children:"Fullscreen"}),u.jsx(Cr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(en,{htmlFor:"theme",children:"Theme"}),u.jsxs(am,{value:a.ui.theme,onValueChange:m=>l(x=>({...x,ui:{...x.ui,theme:m}})),children:[u.jsx(wl,{children:u.jsx(lm,{})}),u.jsxs(bl,{children:[u.jsx(Cr,{value:"light",children:"Light"}),u.jsx(Cr,{value:"dark",children:"Dark"}),u.jsx(Cr,{value:"system",children:"System"})]})]})]}),u.jsx(pm,{}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(en,{htmlFor:"show-timestamps",children:"Show Timestamps"}),u.jsx(Zn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:m=>l(x=>({...x,ui:{...x.ui,showTimestamps:m}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(en,{htmlFor:"show-agent-names",children:"Show Agent Names"}),u.jsx(Zn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:m=>l(x=>({...x,ui:{...x.ui,showAgentNames:m}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(en,{htmlFor:"compact-messages",children:"Compact Messages"}),u.jsx(Zn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:m=>l(x=>({...x,ui:{...x.ui,compactMessages:m}}))})]})]})]})]}),u.jsxs(uo,{children:[u.jsx(fo,{className:"pb-3",children:u.jsxs(ho,{className:"text-lg flex items-center gap-2",children:[u.jsx(he.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),u.jsxs(po,{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(en,{htmlFor:"auto-save",children:"Auto-save Conversations"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),u.jsx(Zn,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:m=>l(x=>({...x,behavior:{...x.behavior,autoSave:m}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(en,{htmlFor:"enable-streaming",children:"Enable Streaming"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),u.jsx(Zn,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:m=>l(x=>({...x,behavior:{...x.behavior,enableStreaming:m}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(en,{htmlFor:"typing-indicator",children:"Typing Indicator"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),u.jsx(Zn,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:m=>l(x=>({...x,behavior:{...x.behavior,showTypingIndicator:m}}))})]})]})]})]}),u.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[u.jsxs(qe,{variant:"outline",onClick:p,children:[u.jsx(he.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(qe,{variant:"outline",onClick:y,children:"Cancel"}),u.jsxs(qe,{onClick:h,disabled:!c,children:[u.jsx(he.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=c=>{const d="h-full";switch(c){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=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=b.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(Jo,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(ni,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(Jo,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(hl,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(ni,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(Jo,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(hl,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(ni,{onError:s.onError,enableFileUpload:!0})})]})})}Ae.ChatApi=vc,Ae.ChatInterface=ni,Ae.ChatProviders=Jo,Ae.ChatSettings=Kk,Ae.MarkdownContent=xa,Ae.MessageComponent=lf,Ae.MessageList=Da,Ae.ThreadManager=hl,Ae.applySettings=ZC,Ae.chatApiClient=Hn,Ae.default=qk,Ae.del=yc,Ae.get=nn,Ae.getChatToken=pc,Ae.getCurrentSettings=JC,Ae.getDefaultApiConfig=hp,Ae.getDefaultChatSettings=pp,Ae.onChatTokenChanged=mc,Ae.post=gc,Ae.put=xc,Ae.setChatToken=Ii,Ae.useApi=Ni,Ae.useChatStream=Oc,Ae.useMessagesReducer=Ec,Ae.useStream=Uc,Ae.useThreadState=Xo,Ae.useThreads=Yo,Object.defineProperties(Ae,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});