teodor-new-chat-ui 4.1.19 → 4.1.21

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(Ie,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom"],y):(Ie=typeof globalThis<"u"?globalThis:Ie||self,y(Ie.NewChatUI={},Ie.React,Ie.LucideReact,Ie.reactSlot,Ie.classVarianceAuthority,Ie.clsx,Ie.tailwindMerge,Ie.ReactDOM))})(this,function(Ie,y,se,Rn,to,Tp,kp,Rs){"use strict";var mC=Object.defineProperty;var gC=(Ie,y,se)=>y in Ie?mC(Ie,y,{enumerable:!0,configurable:!0,writable:!0,value:se}):Ie[y]=se;var Sp=(Ie,y,se)=>gC(Ie,typeof y!="symbol"?y+"":y,se);function Ma(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const m=Ma(y),no=Ma(Rs);var Ps={exports:{}},Cr={};/**
1
+ (function(Ne,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom"],y):(Ne=typeof globalThis<"u"?globalThis:Ne||self,y(Ne.NewChatUI={},Ne.React,Ne.LucideReact,Ne.reactSlot,Ne.classVarianceAuthority,Ne.clsx,Ne.tailwindMerge,Ne.ReactDOM))})(this,function(Ne,y,re,Rn,no,Np,Ap,Rs){"use strict";var CC=Object.defineProperty;var TC=(Ne,y,re)=>y in Ne?CC(Ne,y,{enumerable:!0,configurable:!0,writable:!0,value:re}):Ne[y]=re;var Ep=(Ne,y,re)=>TC(Ne,typeof y!="symbol"?y+"":y,re);function $a(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const m=$a(y),ro=$a(Rs);var Ps={exports:{}},Sr={};/**
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 Da;function Ep(){if(Da)return Cr;Da=1;var e=y,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,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 Cr.Fragment=n,Cr.jsx=i,Cr.jsxs=i,Cr}var Tr={};/**
9
+ */var Fa;function _p(){if(Fa)return Sr;Fa=1;var e=y,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,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 Sr.Fragment=n,Sr.jsx=i,Sr.jsxs=i,Sr}var Cr={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,36 +14,36 @@
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 La;function Ip(){return La||(La=1,process.env.NODE_ENV!=="production"&&function(){var e=y,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),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"),w=Symbol.iterator,v="@@iterator";function g(k){if(k===null||typeof k!="object")return null;var K=w&&k[w]||k[v];return typeof K=="function"?K:null}var x=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(k){{for(var K=arguments.length,oe=new Array(K>1?K-1:0),Ee=1;Ee<K;Ee++)oe[Ee-1]=arguments[Ee];S("error",k,oe)}}function S(k,K,oe){{var Ee=x.ReactDebugCurrentFrame,Ge=Ee.getStackAddendum();Ge!==""&&(K+="%s",oe=oe.concat([Ge]));var tt=oe.map(function(Be){return String(Be)});tt.unshift("Warning: "+K),Function.prototype.apply.call(console[k],console,tt)}}var E=!1,C=!1,T=!1,I=!1,A=!1,P;P=Symbol.for("react.module.reference");function j(k){return!!(typeof k=="string"||typeof k=="function"||k===r||k===s||A||k===o||k===u||k===d||I||k===p||E||C||T||typeof k=="object"&&k!==null&&(k.$$typeof===h||k.$$typeof===f||k.$$typeof===i||k.$$typeof===a||k.$$typeof===l||k.$$typeof===P||k.getModuleId!==void 0))}function M(k,K,oe){var Ee=k.displayName;if(Ee)return Ee;var Ge=K.displayName||K.name||"";return Ge!==""?oe+"("+Ge+")":oe}function L(k){return k.displayName||"Context"}function W(k){if(k==null)return null;if(typeof k.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof k=="function")return k.displayName||k.name||null;if(typeof k=="string")return k;switch(k){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 k=="object")switch(k.$$typeof){case a:var K=k;return L(K)+".Consumer";case i:var oe=k;return L(oe._context)+".Provider";case l:return M(k,k.render,"ForwardRef");case f:var Ee=k.displayName||null;return Ee!==null?Ee:W(k.type)||"Memo";case h:{var Ge=k,tt=Ge._payload,Be=Ge._init;try{return W(Be(tt))}catch{return null}}}return null}var O=Object.assign,Y=0,q,J,$,_,G,B,he;function de(){}de.__reactDisabledLog=!0;function xe(){{if(Y===0){q=console.log,J=console.info,$=console.warn,_=console.error,G=console.group,B=console.groupCollapsed,he=console.groupEnd;var k={configurable:!0,enumerable:!0,value:de,writable:!0};Object.defineProperties(console,{info:k,log:k,warn:k,error:k,group:k,groupCollapsed:k,groupEnd:k})}Y++}}function _e(){{if(Y--,Y===0){var k={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:O({},k,{value:q}),info:O({},k,{value:J}),warn:O({},k,{value:$}),error:O({},k,{value:_}),group:O({},k,{value:G}),groupCollapsed:O({},k,{value:B}),groupEnd:O({},k,{value:he})})}Y<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Ce=x.ReactCurrentDispatcher,F;function D(k,K,oe){{if(F===void 0)try{throw Error()}catch(Ge){var Ee=Ge.stack.trim().match(/\n( *(at )?)/);F=Ee&&Ee[1]||""}return`
18
- `+F+k}}var Z=!1,ee;{var ce=typeof WeakMap=="function"?WeakMap:Map;ee=new ce}function ne(k,K){if(!k||Z)return"";{var oe=ee.get(k);if(oe!==void 0)return oe}var Ee;Z=!0;var Ge=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var tt;tt=Ce.current,Ce.current=null,xe();try{if(K){var Be=function(){throw Error()};if(Object.defineProperty(Be.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Be,[])}catch(gn){Ee=gn}Reflect.construct(k,[],Be)}else{try{Be.call()}catch(gn){Ee=gn}k.call(Be.prototype)}}else{try{throw Error()}catch(gn){Ee=gn}k()}}catch(gn){if(gn&&Ee&&typeof gn.stack=="string"){for(var Fe=gn.stack.split(`
19
- `),kt=Ee.stack.split(`
20
- `),dt=Fe.length-1,ht=kt.length-1;dt>=1&&ht>=0&&Fe[dt]!==kt[ht];)ht--;for(;dt>=1&&ht>=0;dt--,ht--)if(Fe[dt]!==kt[ht]){if(dt!==1||ht!==1)do if(dt--,ht--,ht<0||Fe[dt]!==kt[ht]){var Ht=`
21
- `+Fe[dt].replace(" at new "," at ");return k.displayName&&Ht.includes("<anonymous>")&&(Ht=Ht.replace("<anonymous>",k.displayName)),typeof k=="function"&&ee.set(k,Ht),Ht}while(dt>=1&&ht>=0);break}}}finally{Z=!1,Ce.current=tt,_e(),Error.prepareStackTrace=Ge}var Sr=k?k.displayName||k.name:"",yp=Sr?D(Sr):"";return typeof k=="function"&&ee.set(k,yp),yp}function Oe(k,K,oe){return ne(k,!1)}function Ye(k){var K=k.prototype;return!!(K&&K.isReactComponent)}function Ue(k,K,oe){if(k==null)return"";if(typeof k=="function")return ne(k,Ye(k));if(typeof k=="string")return D(k);switch(k){case u:return D("Suspense");case d:return D("SuspenseList")}if(typeof k=="object")switch(k.$$typeof){case l:return Oe(k.render);case f:return Ue(k.type,K,oe);case h:{var Ee=k,Ge=Ee._payload,tt=Ee._init;try{return Ue(tt(Ge),K,oe)}catch{}}}return""}var je=Object.prototype.hasOwnProperty,Me={},Je=x.ReactDebugCurrentFrame;function ze(k){if(k){var K=k._owner,oe=Ue(k.type,k._source,K?K.type:null);Je.setExtraStackFrame(oe)}else Je.setExtraStackFrame(null)}function nt(k,K,oe,Ee,Ge){{var tt=Function.call.bind(je);for(var Be in k)if(tt(k,Be)){var Fe=void 0;try{if(typeof k[Be]!="function"){var kt=Error((Ee||"React class")+": "+oe+" type `"+Be+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof k[Be]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw kt.name="Invariant Violation",kt}Fe=k[Be](K,Be,Ee,oe,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(dt){Fe=dt}Fe&&!(Fe instanceof Error)&&(ze(Ge),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).",Ee||"React class",oe,Be,typeof Fe),ze(null)),Fe instanceof Error&&!(Fe.message in Me)&&(Me[Fe.message]=!0,ze(Ge),b("Failed %s type: %s",oe,Fe.message),ze(null))}}}var st=Array.isArray;function re(k){return st(k)}function ue(k){{var K=typeof Symbol=="function"&&Symbol.toStringTag,oe=K&&k[Symbol.toStringTag]||k.constructor.name||"Object";return oe}}function ge(k){try{return ke(k),!1}catch{return!0}}function ke(k){return""+k}function ve(k){if(ge(k))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ue(k)),ke(k)}var Re=x.ReactCurrentOwner,Ze={key:!0,ref:!0,__self:!0,__source:!0},Ke,at;function Ct(k){if(je.call(k,"ref")){var K=Object.getOwnPropertyDescriptor(k,"ref").get;if(K&&K.isReactWarning)return!1}return k.ref!==void 0}function Tt(k){if(je.call(k,"key")){var K=Object.getOwnPropertyDescriptor(k,"key").get;if(K&&K.isReactWarning)return!1}return k.key!==void 0}function wr(k,K){typeof k.ref=="string"&&Re.current}function br(k,K){{var oe=function(){Ke||(Ke=!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)",K))};oe.isReactWarning=!0,Object.defineProperty(k,"key",{get:oe,configurable:!0})}}function Jn(k,K){{var oe=function(){at||(at=!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)",K))};oe.isReactWarning=!0,Object.defineProperty(k,"ref",{get:oe,configurable:!0})}}var _n=function(k,K,oe,Ee,Ge,tt,Be){var Fe={$$typeof:t,type:k,key:K,ref:oe,props:Be,_owner:tt};return Fe._store={},Object.defineProperty(Fe._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Fe,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Ee}),Object.defineProperty(Fe,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Ge}),Object.freeze&&(Object.freeze(Fe.props),Object.freeze(Fe)),Fe};function yr(k,K,oe,Ee,Ge){{var tt,Be={},Fe=null,kt=null;oe!==void 0&&(ve(oe),Fe=""+oe),Tt(K)&&(ve(K.key),Fe=""+K.key),Ct(K)&&(kt=K.ref,wr(K,Ge));for(tt in K)je.call(K,tt)&&!Ze.hasOwnProperty(tt)&&(Be[tt]=K[tt]);if(k&&k.defaultProps){var dt=k.defaultProps;for(tt in dt)Be[tt]===void 0&&(Be[tt]=dt[tt])}if(Fe||kt){var ht=typeof k=="function"?k.displayName||k.name||"Unknown":k;Fe&&br(Be,ht),kt&&Jn(Be,ht)}return _n(k,Fe,kt,Ge,Ee,Re.current,Be)}}var jn=x.ReactCurrentOwner,Zn=x.ReactDebugCurrentFrame;function un(k){if(k){var K=k._owner,oe=Ue(k.type,k._source,K?K.type:null);Zn.setExtraStackFrame(oe)}else Zn.setExtraStackFrame(null)}var Qn;Qn=!1;function er(k){return typeof k=="object"&&k!==null&&k.$$typeof===t}function N(){{if(jn.current){var k=W(jn.current.type);if(k)return`
17
+ */var Ba;function jp(){return Ba||(Ba=1,process.env.NODE_ENV!=="production"&&function(){var e=y,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),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"),w=Symbol.iterator,v="@@iterator";function g(T){if(T===null||typeof T!="object")return null;var F=w&&T[w]||T[v];return typeof F=="function"?F:null}var x=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(T){{for(var F=arguments.length,te=new Array(F>1?F-1:0),ye=1;ye<F;ye++)te[ye-1]=arguments[ye];S("error",T,te)}}function S(T,F,te){{var ye=x.ReactDebugCurrentFrame,We=ye.getStackAddendum();We!==""&&(F+="%s",te=te.concat([We]));var Ve=te.map(function(ze){return String(ze)});Ve.unshift("Warning: "+F),Function.prototype.apply.call(console[T],console,Ve)}}var N=!1,C=!1,k=!1,I=!1,A=!1,R;R=Symbol.for("react.module.reference");function P(T){return!!(typeof T=="string"||typeof T=="function"||T===r||T===s||A||T===o||T===u||T===d||I||T===p||N||C||k||typeof T=="object"&&T!==null&&(T.$$typeof===h||T.$$typeof===f||T.$$typeof===i||T.$$typeof===a||T.$$typeof===l||T.$$typeof===R||T.getModuleId!==void 0))}function L(T,F,te){var ye=T.displayName;if(ye)return ye;var We=F.displayName||F.name||"";return We!==""?te+"("+We+")":te}function $(T){return T.displayName||"Context"}function H(T){if(T==null)return null;if(typeof T.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof T=="function")return T.displayName||T.name||null;if(typeof T=="string")return T;switch(T){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 T=="object")switch(T.$$typeof){case a:var F=T;return $(F)+".Consumer";case i:var te=T;return $(te._context)+".Provider";case l:return L(T,T.render,"ForwardRef");case f:var ye=T.displayName||null;return ye!==null?ye:H(T.type)||"Memo";case h:{var We=T,Ve=We._payload,ze=We._init;try{return H(ze(Ve))}catch{return null}}}return null}var M=Object.assign,q=0,V,Y,B,j,G,Z,ge;function de(){}de.__reactDisabledLog=!0;function ee(){{if(q===0){V=console.log,Y=console.info,B=console.warn,j=console.error,G=console.group,Z=console.groupCollapsed,ge=console.groupEnd;var T={configurable:!0,enumerable:!0,value:de,writable:!0};Object.defineProperties(console,{info:T,log:T,warn:T,error:T,group:T,groupCollapsed:T,groupEnd:T})}q++}}function Ae(){{if(q--,q===0){var T={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:M({},T,{value:V}),info:M({},T,{value:Y}),warn:M({},T,{value:B}),error:M({},T,{value:j}),group:M({},T,{value:G}),groupCollapsed:M({},T,{value:Z}),groupEnd:M({},T,{value:ge})})}q<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Te=x.ReactCurrentDispatcher,K;function D(T,F,te){{if(K===void 0)try{throw Error()}catch(We){var ye=We.stack.trim().match(/\n( *(at )?)/);K=ye&&ye[1]||""}return`
18
+ `+K+T}}var J=!1,U;{var fe=typeof WeakMap=="function"?WeakMap:Map;U=new fe}function ue(T,F){if(!T||J)return"";{var te=U.get(T);if(te!==void 0)return te}var ye;J=!0;var We=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Ve;Ve=Te.current,Te.current=null,ee();try{if(F){var ze=function(){throw Error()};if(Object.defineProperty(ze.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ze,[])}catch(pn){ye=pn}Reflect.construct(T,[],ze)}else{try{ze.call()}catch(pn){ye=pn}T.call(ze.prototype)}}else{try{throw Error()}catch(pn){ye=pn}T()}}catch(pn){if(pn&&ye&&typeof pn.stack=="string"){for(var De=pn.stack.split(`
19
+ `),Ct=ye.stack.split(`
20
+ `),ct=De.length-1,dt=Ct.length-1;ct>=1&&dt>=0&&De[ct]!==Ct[dt];)dt--;for(;ct>=1&&dt>=0;ct--,dt--)if(De[ct]!==Ct[dt]){if(ct!==1||dt!==1)do if(ct--,dt--,dt<0||De[ct]!==Ct[dt]){var zt=`
21
+ `+De[ct].replace(" at new "," at ");return T.displayName&&zt.includes("<anonymous>")&&(zt=zt.replace("<anonymous>",T.displayName)),typeof T=="function"&&U.set(T,zt),zt}while(ct>=1&&dt>=0);break}}}finally{J=!1,Te.current=Ve,Ae(),Error.prepareStackTrace=We}var yr=T?T.displayName||T.name:"",kp=yr?D(yr):"";return typeof T=="function"&&U.set(T,kp),kp}function $e(T,F,te){return ue(T,!1)}function Ge(T){var F=T.prototype;return!!(F&&F.isReactComponent)}function qe(T,F,te){if(T==null)return"";if(typeof T=="function")return ue(T,Ge(T));if(typeof T=="string")return D(T);switch(T){case u:return D("Suspense");case d:return D("SuspenseList")}if(typeof T=="object")switch(T.$$typeof){case l:return $e(T.render);case f:return qe(T.type,F,te);case h:{var ye=T,We=ye._payload,Ve=ye._init;try{return qe(Ve(We),F,te)}catch{}}}return""}var ke=Object.prototype.hasOwnProperty,Oe={},Be=x.ReactDebugCurrentFrame;function Ue(T){if(T){var F=T._owner,te=qe(T.type,T._source,F?F.type:null);Be.setExtraStackFrame(te)}else Be.setExtraStackFrame(null)}function st(T,F,te,ye,We){{var Ve=Function.call.bind(ke);for(var ze in T)if(Ve(T,ze)){var De=void 0;try{if(typeof T[ze]!="function"){var Ct=Error((ye||"React class")+": "+te+" type `"+ze+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof T[ze]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ct.name="Invariant Violation",Ct}De=T[ze](F,ze,ye,te,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ct){De=ct}De&&!(De instanceof Error)&&(Ue(We),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).",ye||"React class",te,ze,typeof De),Ue(null)),De instanceof Error&&!(De.message in Oe)&&(Oe[De.message]=!0,Ue(We),b("Failed %s type: %s",te,De.message),Ue(null))}}}var ot=Array.isArray;function ne(T){return ot(T)}function le(T){{var F=typeof Symbol=="function"&&Symbol.toStringTag,te=F&&T[Symbol.toStringTag]||T.constructor.name||"Object";return te}}function xe(T){try{return Se(T),!1}catch{return!0}}function Se(T){return""+T}function be(T){if(xe(T))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",le(T)),Se(T)}var je=x.ReactCurrentOwner,Qe={key:!0,ref:!0,__self:!0,__source:!0},Ye,it;function gt(T){if(ke.call(T,"ref")){var F=Object.getOwnPropertyDescriptor(T,"ref").get;if(F&&F.isReactWarning)return!1}return T.ref!==void 0}function hn(T){if(ke.call(T,"key")){var F=Object.getOwnPropertyDescriptor(T,"key").get;if(F&&F.isReactWarning)return!1}return T.key!==void 0}function Jn(T,F){typeof T.ref=="string"&&je.current}function vr(T,F){{var te=function(){Ye||(Ye=!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)",F))};te.isReactWarning=!0,Object.defineProperty(T,"key",{get:te,configurable:!0})}}function Zn(T,F){{var te=function(){it||(it=!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)",F))};te.isReactWarning=!0,Object.defineProperty(T,"ref",{get:te,configurable:!0})}}var Nn=function(T,F,te,ye,We,Ve,ze){var De={$$typeof:t,type:T,key:F,ref:te,props:ze,_owner:Ve};return De._store={},Object.defineProperty(De._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(De,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ye}),Object.defineProperty(De,"_source",{configurable:!1,enumerable:!1,writable:!1,value:We}),Object.freeze&&(Object.freeze(De.props),Object.freeze(De)),De};function Bt(T,F,te,ye,We){{var Ve,ze={},De=null,Ct=null;te!==void 0&&(be(te),De=""+te),hn(F)&&(be(F.key),De=""+F.key),gt(F)&&(Ct=F.ref,Jn(F,We));for(Ve in F)ke.call(F,Ve)&&!Qe.hasOwnProperty(Ve)&&(ze[Ve]=F[Ve]);if(T&&T.defaultProps){var ct=T.defaultProps;for(Ve in ct)ze[Ve]===void 0&&(ze[Ve]=ct[Ve])}if(De||Ct){var dt=typeof T=="function"?T.displayName||T.name||"Unknown":T;De&&vr(ze,dt),Ct&&Zn(ze,dt)}return Nn(T,De,Ct,We,ye,je.current,ze)}}var An=x.ReactCurrentOwner,Qn=x.ReactDebugCurrentFrame;function Yt(T){if(T){var F=T._owner,te=qe(T.type,T._source,F?F.type:null);Qn.setExtraStackFrame(te)}else Qn.setExtraStackFrame(null)}var _n;_n=!1;function jn(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function er(){{if(An.current){var T=H(An.current.type);if(T)return`
22
22
 
23
- Check the render method of \``+k+"`."}return""}}function z(k){return""}var te={};function we(k){{var K=N();if(!K){var oe=typeof k=="string"?k:k.displayName||k.name;oe&&(K=`
23
+ Check the render method of \``+T+"`."}return""}}function wr(T){return""}var br={};function to(T){{var F=er();if(!F){var te=typeof T=="string"?T:T.displayName||T.name;te&&(F=`
24
24
 
25
- Check the top-level render call using <`+oe+">.")}return K}}function H(k,K){{if(!k._store||k._store.validated||k.key!=null)return;k._store.validated=!0;var oe=we(K);if(te[oe])return;te[oe]=!0;var Ee="";k&&k._owner&&k._owner!==jn.current&&(Ee=" It was passed a child from "+W(k._owner.type)+"."),un(k),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',oe,Ee),un(null)}}function U(k,K){{if(typeof k!="object")return;if(re(k))for(var oe=0;oe<k.length;oe++){var Ee=k[oe];er(Ee)&&H(Ee,K)}else if(er(k))k._store&&(k._store.validated=!0);else if(k){var Ge=g(k);if(typeof Ge=="function"&&Ge!==k.entries)for(var tt=Ge.call(k),Be;!(Be=tt.next()).done;)er(Be.value)&&H(Be.value,K)}}}function be(k){{var K=k.type;if(K==null||typeof K=="string")return;var oe;if(typeof K=="function")oe=K.propTypes;else if(typeof K=="object"&&(K.$$typeof===l||K.$$typeof===f))oe=K.propTypes;else return;if(oe){var Ee=W(K);nt(oe,k.props,"prop",Ee,k)}else if(K.PropTypes!==void 0&&!Qn){Qn=!0;var Ge=W(K);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ge||"Unknown")}typeof K.getDefaultProps=="function"&&!K.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function We(k){{for(var K=Object.keys(k.props),oe=0;oe<K.length;oe++){var Ee=K[oe];if(Ee!=="children"&&Ee!=="key"){un(k),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ee),un(null);break}}k.ref!==null&&(un(k),b("Invalid attribute `ref` supplied to `React.Fragment`."),un(null))}}function Xe(k,K,oe,Ee,Ge,tt){{var Be=j(k);if(!Be){var Fe="";(k===void 0||typeof k=="object"&&k!==null&&Object.keys(k).length===0)&&(Fe+=" 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 kt=z();kt?Fe+=kt:Fe+=N();var dt;k===null?dt="null":re(k)?dt="array":k!==void 0&&k.$$typeof===t?(dt="<"+(W(k.type)||"Unknown")+" />",Fe=" Did you accidentally export a JSX literal instead of a component?"):dt=typeof k,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",dt,Fe)}var ht=yr(k,K,oe,Ge,tt);if(ht==null)return ht;if(Be){var Ht=K.children;if(Ht!==void 0)if(Ee)if(re(Ht)){for(var Sr=0;Sr<Ht.length;Sr++)U(Ht[Sr],k);Object.freeze&&Object.freeze(Ht)}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 U(Ht,k)}return k===r?We(ht):be(ht),ht}}function lt(k,K,oe){return Xe(k,K,oe,!0)}function Xt(k,K,oe){return Xe(k,K,oe,!1)}var dn=Xt,tr=lt;Tr.Fragment=r,Tr.jsx=dn,Tr.jsxs=tr}()),Tr}process.env.NODE_ENV==="production"?Ps.exports=Ep():Ps.exports=Ip();var c=Ps.exports;function Fa(e,t){return function(){return e.apply(t,arguments)}}const{toString:Np}=Object.prototype,{getPrototypeOf:Os}=Object,{iterator:ro,toStringTag:$a}=Symbol,oo=(e=>t=>{const n=Np.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ut=e=>(e=e.toLowerCase(),t=>oo(t)===e),so=e=>t=>typeof t===e,{isArray:nr}=Array,rr=so("undefined");function kr(e){return e!==null&&!rr(e)&&e.constructor!==null&&!rr(e.constructor)&&Et(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const za=Ut("ArrayBuffer");function Ap(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&za(e.buffer),t}const _p=so("string"),Et=so("function"),Ba=so("number"),Er=e=>e!==null&&typeof e=="object",jp=e=>e===!0||e===!1,io=e=>{if(oo(e)!=="object")return!1;const t=Os(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!($a in e)&&!(ro in e)},Rp=e=>{if(!Er(e)||kr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Pp=Ut("Date"),Op=Ut("File"),Mp=Ut("Blob"),Dp=Ut("FileList"),Lp=e=>Er(e)&&Et(e.pipe),Fp=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Et(e.append)&&((t=oo(e))==="formdata"||t==="object"&&Et(e.toString)&&e.toString()==="[object FormData]"))},$p=Ut("URLSearchParams"),[zp,Bp,Hp,Up]=["ReadableStream","Request","Response","Headers"].map(Ut),Wp=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Ir(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),nr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(kr(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 Ha(e,t){if(kr(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 Pn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ua=e=>!rr(e)&&e!==Pn;function Ms(){const{caseless:e,skipUndefined:t}=Ua(this)&&this||{},n={},r=(o,s)=>{const i=e&&Ha(n,s)||s;io(n[i])&&io(o)?n[i]=Ms(n[i],o):io(o)?n[i]=Ms({},o):nr(o)?n[i]=o.slice():(!t||!rr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Ir(arguments[o],r);return n}const Vp=(e,t,n,{allOwnKeys:r}={})=>(Ir(t,(o,s)=>{n&&Et(o)?e[s]=Fa(o,n):e[s]=o},{allOwnKeys:r}),e),Kp=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),qp=(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)},Gp=(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&&Os(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Yp=(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},Xp=e=>{if(!e)return null;if(nr(e))return e;let t=e.length;if(!Ba(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Jp=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Os(Uint8Array)),Zp=(e,t)=>{const r=(e&&e[ro]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Qp=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},em=Ut("HTMLFormElement"),tm=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Wa=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),nm=Ut("RegExp"),Va=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Ir(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},rm=e=>{Va(e,(t,n)=>{if(Et(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Et(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+"'")})}})},om=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return nr(e)?r(e):r(String(e).split(t)),n},sm=()=>{},im=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function am(e){return!!(e&&Et(e.append)&&e[$a]==="FormData"&&e[ro])}const lm=e=>{const t=new Array(10),n=(r,o)=>{if(Er(r)){if(t.indexOf(r)>=0)return;if(kr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=nr(r)?[]:{};return Ir(r,(i,a)=>{const l=n(i,o+1);!rr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},cm=Ut("AsyncFunction"),um=e=>e&&(Er(e)||Et(e))&&Et(e.then)&&Et(e.catch),Ka=((e,t)=>e?setImmediate:t?((n,r)=>(Pn.addEventListener("message",({source:o,data:s})=>{o===Pn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Pn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Et(Pn.postMessage)),dm=typeof queueMicrotask<"u"?queueMicrotask.bind(Pn):typeof process<"u"&&process.nextTick||Ka,R={isArray:nr,isArrayBuffer:za,isBuffer:kr,isFormData:Fp,isArrayBufferView:Ap,isString:_p,isNumber:Ba,isBoolean:jp,isObject:Er,isPlainObject:io,isEmptyObject:Rp,isReadableStream:zp,isRequest:Bp,isResponse:Hp,isHeaders:Up,isUndefined:rr,isDate:Pp,isFile:Op,isBlob:Mp,isRegExp:nm,isFunction:Et,isStream:Lp,isURLSearchParams:$p,isTypedArray:Jp,isFileList:Dp,forEach:Ir,merge:Ms,extend:Vp,trim:Wp,stripBOM:Kp,inherits:qp,toFlatObject:Gp,kindOf:oo,kindOfTest:Ut,endsWith:Yp,toArray:Xp,forEachEntry:Zp,matchAll:Qp,isHTMLForm:em,hasOwnProperty:Wa,hasOwnProp:Wa,reduceDescriptors:Va,freezeMethods:rm,toObjectSet:om,toCamelCase:tm,noop:sm,toFiniteNumber:im,findKey:Ha,global:Pn,isContextDefined:Ua,isSpecCompliantForm:am,toJSONObject:lm,isAsyncFn:cm,isThenable:um,setImmediate:Ka,asap:dm,isIterable:e=>e!=null&&Et(e[ro])};function Ae(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)}R.inherits(Ae,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:R.toJSONObject(this.config),code:this.code,status:this.status}}});const qa=Ae.prototype,Ga={};["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=>{Ga[e]={value:e}}),Object.defineProperties(Ae,Ga),Object.defineProperty(qa,"isAxiosError",{value:!0}),Ae.from=(e,t,n,r,o,s)=>{const i=Object.create(qa);R.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 Ae.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 fm=null;function Ds(e){return R.isPlainObject(e)||R.isArray(e)}function Ya(e){return R.endsWith(e,"[]")?e.slice(0,-2):e}function Xa(e,t,n){return e?e.concat(t).map(function(o,s){return o=Ya(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function hm(e){return R.isArray(e)&&!e.some(Ds)}const pm=R.toFlatObject(R,{},null,function(t){return/^is[A-Z]/.test(t)});function ao(e,t,n){if(!R.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=R.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,g){return!R.isUndefined(g[v])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&R.isSpecCompliantForm(t);if(!R.isFunction(o))throw new TypeError("visitor must be a function");function u(w){if(w===null)return"";if(R.isDate(w))return w.toISOString();if(R.isBoolean(w))return w.toString();if(!l&&R.isBlob(w))throw new Ae("Blob is not supported. Use a Buffer instead.");return R.isArrayBuffer(w)||R.isTypedArray(w)?l&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function d(w,v,g){let x=w;if(w&&!g&&typeof w=="object"){if(R.endsWith(v,"{}"))v=r?v:v.slice(0,-2),w=JSON.stringify(w);else if(R.isArray(w)&&hm(w)||(R.isFileList(w)||R.endsWith(v,"[]"))&&(x=R.toArray(w)))return v=Ya(v),x.forEach(function(S,E){!(R.isUndefined(S)||S===null)&&t.append(i===!0?Xa([v],E,s):i===null?v:v+"[]",u(S))}),!1}return Ds(w)?!0:(t.append(Xa(g,v,s),u(w)),!1)}const f=[],h=Object.assign(pm,{defaultVisitor:d,convertValue:u,isVisitable:Ds});function p(w,v){if(!R.isUndefined(w)){if(f.indexOf(w)!==-1)throw Error("Circular reference detected in "+v.join("."));f.push(w),R.forEach(w,function(x,b){(!(R.isUndefined(x)||x===null)&&o.call(t,x,R.isString(b)?b.trim():b,v,h))===!0&&p(x,v?v.concat(b):[b])}),f.pop()}}if(!R.isObject(e))throw new TypeError("data must be an object");return p(e),t}function Ja(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ls(e,t){this._pairs=[],e&&ao(e,this,t)}const Za=Ls.prototype;Za.append=function(t,n){this._pairs.push([t,n])},Za.toString=function(t){const n=t?function(r){return t.call(this,r,Ja)}:Ja;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function mm(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Qa(e,t,n){if(!t)return e;const r=n&&n.encode||mm;R.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=R.isURLSearchParams(t)?t.toString():new Ls(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class el{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){R.forEach(this.handlers,function(r){r!==null&&t(r)})}}const tl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},gm={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ls,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Fs=typeof window<"u"&&typeof document<"u",$s=typeof navigator=="object"&&navigator||void 0,xm=Fs&&(!$s||["ReactNative","NativeScript","NS"].indexOf($s.product)<0),vm=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",wm=Fs&&window.location.href||"http://localhost",xt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Fs,hasStandardBrowserEnv:xm,hasStandardBrowserWebWorkerEnv:vm,navigator:$s,origin:wm},Symbol.toStringTag,{value:"Module"})),...gm};function bm(e,t){return ao(e,new xt.classes.URLSearchParams,{visitor:function(n,r,o,s){return xt.isNode&&R.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function ym(e){return R.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Sm(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 nl(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&&R.isArray(o)?o.length:i,l?(R.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!R.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&R.isArray(o[i])&&(o[i]=Sm(o[i])),!a)}if(R.isFormData(e)&&R.isFunction(e.entries)){const n={};return R.forEachEntry(e,(r,o)=>{t(ym(r),o,n,0)}),n}return null}function Cm(e,t,n){if(R.isString(e))try{return(t||JSON.parse)(e),R.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Nr={transitional:tl,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=R.isObject(t);if(s&&R.isHTMLForm(t)&&(t=new FormData(t)),R.isFormData(t))return o?JSON.stringify(nl(t)):t;if(R.isArrayBuffer(t)||R.isBuffer(t)||R.isStream(t)||R.isFile(t)||R.isBlob(t)||R.isReadableStream(t))return t;if(R.isArrayBufferView(t))return t.buffer;if(R.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 bm(t,this.formSerializer).toString();if((a=R.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return ao(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Cm(t)):t}],transformResponse:[function(t){const n=this.transitional||Nr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(R.isResponse(t)||R.isReadableStream(t))return t;if(t&&R.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"?Ae.from(a,Ae.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:xt.classes.FormData,Blob:xt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};R.forEach(["delete","get","head","post","put","patch"],e=>{Nr.headers[e]={}});const Tm=R.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"]),km=e=>{const t={};let n,r,o;return e&&e.split(`
26
- `).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&Tm[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},rl=Symbol("internals");function Ar(e){return e&&String(e).trim().toLowerCase()}function lo(e){return e===!1||e==null?e:R.isArray(e)?e.map(lo):String(e)}function Em(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 Im=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function zs(e,t,n,r,o){if(R.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!R.isString(t)){if(R.isString(r))return t.indexOf(r)!==-1;if(R.isRegExp(r))return r.test(t)}}function Nm(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Am(e,t){const n=R.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 It=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,u){const d=Ar(l);if(!d)throw new Error("header name must be a non-empty string");const f=R.findKey(o,d);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||l]=lo(a))}const i=(a,l)=>R.forEach(a,(u,d)=>s(u,d,l));if(R.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(R.isString(t)&&(t=t.trim())&&!Im(t))i(km(t),n);else if(R.isObject(t)&&R.isIterable(t)){let a={},l,u;for(const d of t){if(!R.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(l=a[u])?R.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=Ar(t),t){const r=R.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Em(o);if(R.isFunction(n))return n.call(this,o,r);if(R.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Ar(t),t){const r=R.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||zs(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Ar(i),i){const a=R.findKey(r,i);a&&(!n||zs(r,r[a],a,n))&&(delete r[a],o=!0)}}return R.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||zs(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return R.forEach(this,(o,s)=>{const i=R.findKey(r,s);if(i){n[i]=lo(o),delete n[s];return}const a=t?Nm(s):String(s).trim();a!==s&&delete n[s],n[a]=lo(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return R.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&R.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(`
27
- `)}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[rl]=this[rl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Ar(i);r[a]||(Am(o,i),r[a]=!0)}return R.isArray(t)?t.forEach(s):s(t),this}};It.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),R.reduceDescriptors(It.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),R.freezeMethods(It);function Bs(e,t){const n=this||Nr,r=t||n,o=It.from(r.headers);let s=r.data;return R.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function ol(e){return!!(e&&e.__CANCEL__)}function or(e,t,n){Ae.call(this,e??"canceled",Ae.ERR_CANCELED,t,n),this.name="CanceledError"}R.inherits(or,Ae,{__CANCEL__:!0});function sl(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Ae("Request failed with status code "+n.status,[Ae.ERR_BAD_REQUEST,Ae.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function _m(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function jm(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 Rm(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 co=(e,t,n=3)=>{let r=0;const o=jm(50,250);return Rm(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)},il=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},al=e=>(...t)=>R.asap(()=>e(...t)),Pm=xt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,xt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(xt.origin),xt.navigator&&/(msie|trident)/i.test(xt.navigator.userAgent)):()=>!0,Om=xt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];R.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),R.isString(r)&&i.push("path="+r),R.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 Mm(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Dm(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function ll(e,t,n){let r=!Mm(t);return e&&(r||n==!1)?Dm(e,t):t}const cl=e=>e instanceof It?{...e}:e;function On(e,t){t=t||{};const n={};function r(u,d,f,h){return R.isPlainObject(u)&&R.isPlainObject(d)?R.merge.call({caseless:h},u,d):R.isPlainObject(d)?R.merge({},d):R.isArray(d)?d.slice():d}function o(u,d,f,h){if(R.isUndefined(d)){if(!R.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!R.isUndefined(d))return r(void 0,d)}function i(u,d){if(R.isUndefined(d)){if(!R.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(cl(u),cl(d),f,!0)};return R.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,h=f(e[d],t[d],d);R.isUndefined(h)&&f!==a||(n[d]=h)}),n}const ul=e=>{const t=On({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=It.from(i),t.url=Qa(ll(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),R.isFormData(n)){if(xt.hasStandardBrowserEnv||xt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(R.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(xt.hasStandardBrowserEnv&&(r&&R.isFunction(r)&&(r=r(t)),r||r!==!1&&Pm(t.url))){const l=o&&s&&Om.read(s);l&&i.set(o,l)}return t},Lm=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=ul(e);let s=o.data;const i=It.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=o,d,f,h,p,w;function v(){p&&p(),w&&w(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function x(){if(!g)return;const S=It.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:S,config:e,request:g};sl(function(I){n(I),v()},function(I){r(I),v()},C),g=null}"onloadend"in g?g.onloadend=x:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(x)},g.onabort=function(){g&&(r(new Ae("Request aborted",Ae.ECONNABORTED,e,g)),g=null)},g.onerror=function(E){const C=E&&E.message?E.message:"Network Error",T=new Ae(C,Ae.ERR_NETWORK,e,g);T.event=E||null,r(T),g=null},g.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||tl;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),r(new Ae(E,C.clarifyTimeoutError?Ae.ETIMEDOUT:Ae.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&R.forEach(i.toJSON(),function(E,C){g.setRequestHeader(C,E)}),R.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,w]=co(u,!0),g.addEventListener("progress",h)),l&&g.upload&&([f,p]=co(l),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=S=>{g&&(r(!S||S.type?new or(null,e,g):S),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=_m(o.url);if(b&&xt.protocols.indexOf(b)===-1){r(new Ae("Unsupported protocol "+b+":",Ae.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Fm=(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 Ae?d:new or(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Ae(`timeout ${t} of ms exceeded`,Ae.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=()=>R.asap(a),l}},$m=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},zm=async function*(e,t){for await(const n of Bm(e))yield*$m(n,t)},Bm=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()}},dl=(e,t,n,r)=>{const o=zm(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})},fl=64*1024,{isFunction:uo}=R,Hm=(({Request:e,Response:t})=>({Request:e,Response:t}))(R.global),{ReadableStream:hl,TextEncoder:pl}=R.global,ml=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Um=e=>{e=R.merge.call({skipUndefined:!0},Hm,e);const{fetch:t,Request:n,Response:r}=e,o=t?uo(t):typeof fetch=="function",s=uo(n),i=uo(r);if(!o)return!1;const a=o&&uo(hl),l=o&&(typeof pl=="function"?(w=>v=>w.encode(v))(new pl):async w=>new Uint8Array(await new n(w).arrayBuffer())),u=s&&a&&ml(()=>{let w=!1;const v=new n(xt.origin,{body:new hl,method:"POST",get duplex(){return w=!0,"half"}}).headers.has("Content-Type");return w&&!v}),d=i&&a&&ml(()=>R.isReadableStream(new r("").body)),f={stream:d&&(w=>w.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(w=>{!f[w]&&(f[w]=(v,g)=>{let x=v&&v[w];if(x)return x.call(v);throw new Ae(`Response type '${w}' is not supported`,Ae.ERR_NOT_SUPPORT,g)})});const h=async w=>{if(w==null)return 0;if(R.isBlob(w))return w.size;if(R.isSpecCompliantForm(w))return(await new n(xt.origin,{method:"POST",body:w}).arrayBuffer()).byteLength;if(R.isArrayBufferView(w)||R.isArrayBuffer(w))return w.byteLength;if(R.isURLSearchParams(w)&&(w=w+""),R.isString(w))return(await l(w)).byteLength},p=async(w,v)=>{const g=R.toFiniteNumber(w.getContentLength());return g??h(v)};return async w=>{let{url:v,method:g,data:x,signal:b,cancelToken:S,timeout:E,onDownloadProgress:C,onUploadProgress:T,responseType:I,headers:A,withCredentials:P="same-origin",fetchOptions:j}=ul(w),M=t||fetch;I=I?(I+"").toLowerCase():"text";let L=Fm([b,S&&S.toAbortSignal()],E),W=null;const O=L&&L.unsubscribe&&(()=>{L.unsubscribe()});let Y;try{if(T&&u&&g!=="get"&&g!=="head"&&(Y=await p(A,x))!==0){let B=new n(v,{method:"POST",body:x,duplex:"half"}),he;if(R.isFormData(x)&&(he=B.headers.get("content-type"))&&A.setContentType(he),B.body){const[de,xe]=il(Y,co(al(T)));x=dl(B.body,fl,de,xe)}}R.isString(P)||(P=P?"include":"omit");const q=s&&"credentials"in n.prototype,J={...j,signal:L,method:g.toUpperCase(),headers:A.normalize().toJSON(),body:x,duplex:"half",credentials:q?P:void 0};W=s&&new n(v,J);let $=await(s?M(W,j):M(v,J));const _=d&&(I==="stream"||I==="response");if(d&&(C||_&&O)){const B={};["status","statusText","headers"].forEach(_e=>{B[_e]=$[_e]});const he=R.toFiniteNumber($.headers.get("content-length")),[de,xe]=C&&il(he,co(al(C),!0))||[];$=new r(dl($.body,fl,de,()=>{xe&&xe(),O&&O()}),B)}I=I||"text";let G=await f[R.findKey(f,I)||"text"]($,w);return!_&&O&&O(),await new Promise((B,he)=>{sl(B,he,{data:G,headers:It.from($.headers),status:$.status,statusText:$.statusText,config:w,request:W})})}catch(q){throw O&&O(),q&&q.name==="TypeError"&&/Load failed|fetch/i.test(q.message)?Object.assign(new Ae("Network Error",Ae.ERR_NETWORK,w,W),{cause:q.cause||q}):Ae.from(q,q&&q.code,w,W)}}},Wm=new Map,gl=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=Wm;for(;a--;)l=s[a],u=d.get(l),u===void 0&&d.set(l,u=a?new Map:Um(t)),d=u;return u};gl();const Hs={http:fm,xhr:Lm,fetch:{get:gl}};R.forEach(Hs,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const xl=e=>`- ${e}`,Vm=e=>R.isFunction(e)||e===null||e===!1,vl={getAdapter:(e,t)=>{e=R.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,!Vm(r)&&(o=Hs[(a=String(r)).toLowerCase()],o===void 0))throw new Ae(`Unknown adapter '${a}'`);if(o&&(R.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 :
28
- `+i.map(xl).join(`
29
- `):" "+xl(i[0]):"as no adapter specified";throw new Ae("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:Hs};function Us(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new or(null,e)}function wl(e){return Us(e),e.headers=It.from(e.headers),e.data=Bs.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),vl.getAdapter(e.adapter||Nr.adapter,e)(e).then(function(r){return Us(e),r.data=Bs.call(e,e.transformResponse,r),r.headers=It.from(r.headers),r},function(r){return ol(r)||(Us(e),r&&r.response&&(r.response.data=Bs.call(e,e.transformResponse,r.response),r.response.headers=It.from(r.response.headers))),Promise.reject(r)})}const bl="1.12.2",fo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{fo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const yl={};fo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+bl+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Ae(o(i," has been removed"+(n?" in "+n:"")),Ae.ERR_DEPRECATED);return n&&!yl[i]&&(yl[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}},fo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Km(e,t,n){if(typeof e!="object")throw new Ae("options must be an object",Ae.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 Ae("option "+s+" must be "+l,Ae.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Ae("Unknown option "+s,Ae.ERR_BAD_OPTION)}}const ho={assertOptions:Km,validators:fo},Jt=ho.validators;let Mn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new el,response:new el}}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+=`
30
- `+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=On(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&ho.assertOptions(r,{silentJSONParsing:Jt.transitional(Jt.boolean),forcedJSONParsing:Jt.transitional(Jt.boolean),clarifyTimeoutError:Jt.transitional(Jt.boolean)},!1),o!=null&&(R.isFunction(o)?n.paramsSerializer={serialize:o}:ho.assertOptions(o,{encode:Jt.function,serialize:Jt.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ho.assertOptions(n,{baseUrl:Jt.spelling("baseURL"),withXsrfToken:Jt.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&R.merge(s.common,s[n.method]);s&&R.forEach(["delete","get","head","post","put","patch","common"],w=>{delete s[w]}),n.headers=It.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 w=[wl.bind(this),void 0];for(w.unshift(...a),w.push(...u),h=w.length,d=Promise.resolve(n);f<h;)d=d.then(w[f++],w[f++]);return d}h=a.length;let p=n;for(;f<h;){const w=a[f++],v=a[f++];try{p=w(p)}catch(g){v.call(this,g);break}}try{d=wl.call(this,p)}catch(w){return Promise.reject(w)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=On(this.defaults,t);const n=ll(t.baseURL,t.url,t.allowAbsoluteUrls);return Qa(n,t.params,t.paramsSerializer)}};R.forEach(["delete","get","head","options"],function(t){Mn.prototype[t]=function(n,r){return this.request(On(r||{},{method:t,url:n,data:(r||{}).data}))}}),R.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(On(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Mn.prototype[t]=n(),Mn.prototype[t+"Form"]=n(!0)});let qm=class Cp{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 or(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 Cp(function(o){t=o}),cancel:t}}};function Gm(e){return function(n){return e.apply(null,n)}}function Ym(e){return R.isObject(e)&&e.isAxiosError===!0}const Ws={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(Ws).forEach(([e,t])=>{Ws[t]=e});function Sl(e){const t=new Mn(e),n=Fa(Mn.prototype.request,t);return R.extend(n,Mn.prototype,t,{allOwnKeys:!0}),R.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Sl(On(e,o))},n}const ct=Sl(Nr);ct.Axios=Mn,ct.CanceledError=or,ct.CancelToken=qm,ct.isCancel=ol,ct.VERSION=bl,ct.toFormData=ao,ct.AxiosError=Ae,ct.Cancel=ct.CanceledError,ct.all=function(t){return Promise.all(t)},ct.spread=Gm,ct.isAxiosError=Ym,ct.mergeConfig=On,ct.AxiosHeaders=It,ct.formToJSON=e=>nl(R.isHTMLForm(e)?new FormData(e):e),ct.getAdapter=vl.getAdapter,ct.HttpStatusCode=Ws,ct.default=ct;const{Axios:CC,AxiosError:TC,CanceledError:kC,isCancel:EC,CancelToken:IC,VERSION:NC,all:AC,Cancel:_C,isAxiosError:jC,spread:RC,toFormData:PC,AxiosHeaders:OC,HttpStatusCode:MC,formToJSON:DC,getAdapter:LC,mergeConfig:FC}=ct,Cl=typeof window<"u"?window.__API_BASE_URL__:void 0,Tl=Cl?fn(Cl):void 0;function fn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let po=null;const Vs=new Set;function kl(){return po}function Ks(e){po=e,Vs.forEach(t=>t(e))}function El(e){return Vs.add(e),()=>Vs.delete(e)}const Dt=ct.create({...Tl?{baseURL:Tl}:{},timeout:3e4,withCredentials:!0});Dt.interceptors.request.use(e=>(po&&(e.headers.Authorization=`Bearer ${po}`),e)),Dt.interceptors.response.use(e=>e,e=>Promise.reject(e));async function At(e,t){return Dt.defaults.baseURL?(await Dt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function qs(e,t,n){return Dt.defaults.baseURL?(await Dt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Il(e,t,n){return Dt.defaults.baseURL?(await Dt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Nl(e,t){return Dt.defaults.baseURL?(await Dt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function _t(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Al{get baseUrl(){const t=Dt.defaults.baseURL;return t?fn(String(t)):""}updateConfig(t){t.baseUrl&&(Dt.defaults.baseURL=fn(String(t.baseUrl))),t.authToken!==void 0&&Ks(t.authToken)}getAuthToken(){return kl()}setAuthToken(t){Ks(t)}onTokenChange(t){return El(t)}async listThreads(){const t=await At("/threads"),n=_t(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await qs("/threads",t?{title:t}:void 0);return _t(r)}async updateThread(t,n){const r=await Il(`/threads/${t}`,{title:n});return _t(r)}async deleteThread(t){const n=await Nl(`/threads/${t}`);return _t(n)}async threadInfo(t){const n=await At(`/threads/${t}/info`);return _t(n)}async listAgents(){const t=await At("/agents"),n=_t(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await At(`/agents/${t}`);return _t(n)}async getAgentSchema(t){const n=await At(`/agents/${t}/schema`);return _t(n)}async getMessages(t){const n=await At(`/threads/${t.threadId}/messages`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs,limit:t.limit,before_id:t.beforeId??void 0}});return _t(n)}async getState(t){const n=await At(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return _t(n)}async getStateHistory(t){const n=await At(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return _t(n)}async listCheckpoints(t){const n=await At(`/threads/${t}/checkpoints`,{params:{thread_id:t}});return _t(n)}async resume(t){const n=await qs("/runs/resume",{thread_id:t.threadId,value:t.value});return _t(n)}}const xn=new Al,_l=y.createContext(null);function Xm({children:e,apiConfig:t}){const n=xn;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(_l.Provider,{value:r,children:e})}function Gs(){const e=y.useContext(_l);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function Jm(e,t){const n=e==null?void 0:e.checkpoints,r=Array.isArray(n)?n.slice():n?Object.values(n):[],o=i=>i&&typeof i=="object"&&i!==null&&"checkpointId"in i&&"createdAt"in i&&typeof i.checkpointId=="string"&&typeof i.createdAt=="string",s=r.filter(o).map(i=>{const a=i;return{checkpointId:a.checkpointId,checkpointNs:a.checkpointNs??"",createdAt:a.createdAt,messagesLen:a.messagesLen??0,preview:a.preview??"",role:a.role??null,parentId:a.parentId??null,editedMessageId:a.editedMessageId??null,branchLabel:a.branchLabel??null,lastMessageId:a.lastMessageId??null,hasMessages:typeof a.hasMessages=="boolean"?a.hasMessages:void 0}});return{threadId:(e==null?void 0:e.threadId)??t??null,checkpoints:s}}async function Zm(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let 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 Qm(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const u=await Zm(l);a.push({filename:l.name,data:u,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}function eg(e){return e.type!=="thread_info"&&e.type!=="token"}const tg={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};function ng(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:Ys(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};return console.log("[MessageReducer] 📊 After reset - messages count:",r.messages.length),r}case"seed":{const r=Ys(t.payload.messages),o={...e,messages:r,assemblingId:null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),console.log("[MessageReducer] seed action (REPLACE mode):",{incomingCount:t.payload.messages.length,sanitizedCount:r.length,previousCount:e.messages.length,checkpointId:o.lastCheckpointId}),o}case"prepend":{const r=Ys(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 Rl(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Rl(o,s),e):e}case"interrupt_response":{const{interruptId:r}=t.payload,o=e.messages.map(s=>({...s,content:s.content.filter(i=>i.type!=="interrupt")}));return{...e,messages:o,pendingInterrupt:null}}default:return e}}function jl(e=[]){const[t,n]=y.useReducer(ng,{...tg,messages:e}),r=y.useRef([]),o=y.useRef(null),s=y.useRef(null),i=y.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=y.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=y.useCallback(d=>{r.current.push(d),a()},[a]);y.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const u=y.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:d=>n({type:"user_message",payload:{message:d}}),onEvent:l}),[l]);return{state:t,dispatch:n,...u}}function Rl(e,t){var n,r;if(t.type==="message_start"&&t.role==="assistant"){const o=t.id,s=lg(t.model);if(e.messages.some(l=>l.id===o))return{...e,assemblingId:o};const a={id:o,role:"assistant",name:s||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:o,messages:[...e.messages,a]}}if(t.type==="message_delta"){const o=e.assemblingId??Xs(e.messages);return o?{...e,messages:Js(e.messages,o,t.delta)}:e}if(t.type==="message_end"){const o=e.assemblingId??Xs(e.messages);if(!o)return{...e,assemblingId:null};const s=e.messages,i=s.findIndex(a=>a.id===o&&a.role==="assistant");if(i>=0&&!((n=s[i].content)==null?void 0:n.some(u=>{var d;return(u==null?void 0:u.type)==="text"&&((d=u.text)==null?void 0:d.trim())}))){const u=[...s.slice(0,i),...s.slice(i+1)];return{...e,assemblingId:null,messages:u}}return e}if(t.type==="tool_start"){const o=t.id??t.call_id,s=t.name??t.tool??"tool";if(!o)return e;const i=`tool-${o}`,a={type:"tool_call",id:o,name:s,args:t.args};if(e.messages.find(d=>d.id===i))return{...e,toolIndex:{...e.toolIndex,[o]:i}};const u={id:i,role:"tool",name:s,createdAt:new Date().toISOString(),content:[a]};return{...e,messages:[...e.messages,u],toolIndex:{...e.toolIndex,[o]:i}}}if(t.type==="tool_end"){const o=t.id??t.call_id;if(!o)return e;const s=e.toolIndex[o]??`tool-${o}`,i={type:"tool_end",toolCallId:o,output:t.output,error:t.error},a=e.messages.find(d=>d.id===s),l={id:s,role:"tool",name:t.name??((r=e.messages.find(d=>d.id===s))==null?void 0:r.name),content:[i],createdAt:new Date().toISOString()},u=a?Js(e.messages,s,[i]):[...e.messages,l];return{...e,messages:u,toolIndex:{...e.toolIndex,[o]:s}}}if(t.type==="checkpoint"){const o=t.checkpointNs??e.lastCheckpointNs??null,s=ag(e.messages,t.checkpointId,o);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:o,messages:s}}if(t.type==="branch"){const o=t.checkpointId??e.lastCheckpointId,s=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:o??null,lastCheckpointNs:s??null}}if(t.type==="error"){const o={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,o]}}if(t.type==="interrupt"){const o=e.assemblingId??Xs(e.messages),s={type:"interrupt",value:t.value};if(o)return{...e,assemblingId:null,messages:Js(e.messages,o,[s]),pendingInterrupt:{id:t.id,value:t.value}};const i={id:`interrupt-${t.id}`,role:"system",createdAt:new Date().toISOString(),content:[s]};return{...e,messages:[...e.messages,i],pendingInterrupt:{id:t.id,value:t.value}}}return e}function Ys(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 rg(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Xs(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function og(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 Js(e,t,n){return og(e,t,r=>({...r,content:sg(r.content,n)}))}function sg(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"){const i=o,a=i.text??"";if(!a){i.text=s;continue}if(s.startsWith(a)){i.text=s;continue}if(a.includes(s))continue;const l=ig(a,s);l?i.text=a+l:i.text=a+s}else n.push({type:"text",text:s})}else n.push(r);return n}function ig(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let r=n;r>0;r--)if(e.slice(-r)===t.slice(0,r))return t.slice(r);return t}function ag(e,t,n){for(let r=e.length-1;r>=0;r--)if(e[r].role==="assistant"){const s={...e[r],checkpointId:t,checkpointNs:n??void 0};return rg(e,r,s)}return e}function lg(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Pl(e={}){const t=y.useMemo(()=>fn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=y.useState(e.token??null),s=y.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=y.useState(!1),[u,d]=y.useState(null),[f,h]=y.useState(""),[p,w]=y.useState(null),[v,g]=y.useState(0),[x,b]=y.useState(!1),S=y.useRef(null),E=y.useRef(!0),C=y.useRef(0),T=y.useCallback(j=>{o(j)},[]),I=y.useCallback(()=>{var j;(j=S.current)==null||j.abort(),S.current=null,l(!1),b(!1),C.current=0,g(0)},[]),A=y.useCallback(()=>{h(""),w(null),d(null)},[]),P=y.useCallback((j,M,L)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h("");const W=new AbortController;return S.current=W,(async()=>{var Y,q,J,$,_,G,B,he;const O=de=>{var xe;try{const _e=JSON.parse(JSON.stringify(de));return(xe=_e==null?void 0:_e.payload)!=null&&xe.files_info&&Array.isArray(_e.payload.files_info)&&(_e.payload.files_info=_e.payload.files_info.map(Ce=>({...Ce,data:Ce!=null&&Ce.data?`<base64 ${String(Ce.data).length} chars>`:Ce==null?void 0:Ce.data}))),_e}catch{return de}};try{let de={};try{if(r)de={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Me=window.__AUTH_TOKEN__,Je=((Y=window.localStorage)==null?void 0:Y.getItem("authToken"))||null;let ze=null;try{const st=(q=window.localStorage)==null?void 0:q.getItem("chat-settings");st&&(ze=((J=JSON.parse(st))==null?void 0:J.apiKey)||null)}catch{}const nt=Me||Je||ze||null;nt&&(de={Authorization:`Bearer ${nt}`})}}catch{}console.debug("[use-chat] POST",t+n,O(j));const xe=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...de,...s.current},body:JSON.stringify(j),signal:W.signal,credentials:i});if(!xe.ok||!xe.body){const je=await xe.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",xe.status,je==null?void 0:je.slice(0,500)),new Error(`stream ${xe.status}${je?": "+je:""}`)}b(!0);const _e=xe.body.getReader(),Ce=new TextDecoder;let F="",D=[];C.current=0,g(0);let Z=0,ee=null;const ce=()=>{if(D.length){const je=D.join("");D=[],E.current&&h(Me=>Me+je)}ee=null},ne=()=>{typeof window<"u"&&ee==null&&(ee=requestAnimationFrame(ce))};let Oe=Date.now();const Ye=setInterval(()=>{var je;if(Date.now()-Oe>6e4){const Me="Stream idle timeout";d(Me),W.abort(),(je=L==null?void 0:L.onError)==null||je.call(L,Me)}},5e3),Ue=1024*1024;try{const je=xe.headers.get("X-Thread-Id")||xe.headers.get("x-thread-id"),Me=xe.headers.get("X-Thread-Created")||xe.headers.get("x-thread-created"),Je=je??null,ze=String(Me??"").toLowerCase()==="true";for(($=L==null?void 0:L.onOpen)==null||$.call(L,{threadId:Je,created:ze});;){const{value:nt,done:st}=await _e.read();if(st)break;F+=Ce.decode(nt,{stream:!0}),F.length>Ue&&(F="",console.warn("Stream buffer reset: exceeded 1MB"));let re;for(;(re=F.indexOf(`
25
+ Check the top-level render call using <`+te+">.")}return F}}function se(T,F){{if(!T._store||T._store.validated||T.key!=null)return;T._store.validated=!0;var te=to(F);if(br[te])return;br[te]=!0;var ye="";T&&T._owner&&T._owner!==An.current&&(ye=" It was passed a child from "+H(T._owner.type)+"."),Yt(T),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',te,ye),Yt(null)}}function E(T,F){{if(typeof T!="object")return;if(ne(T))for(var te=0;te<T.length;te++){var ye=T[te];jn(ye)&&se(ye,F)}else if(jn(T))T._store&&(T._store.validated=!0);else if(T){var We=g(T);if(typeof We=="function"&&We!==T.entries)for(var Ve=We.call(T),ze;!(ze=Ve.next()).done;)jn(ze.value)&&se(ze.value,F)}}}function _(T){{var F=T.type;if(F==null||typeof F=="string")return;var te;if(typeof F=="function")te=F.propTypes;else if(typeof F=="object"&&(F.$$typeof===l||F.$$typeof===f))te=F.propTypes;else return;if(te){var ye=H(F);st(te,T.props,"prop",ye,T)}else if(F.PropTypes!==void 0&&!_n){_n=!0;var We=H(F);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",We||"Unknown")}typeof F.getDefaultProps=="function"&&!F.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function W(T){{for(var F=Object.keys(T.props),te=0;te<F.length;te++){var ye=F[te];if(ye!=="children"&&ye!=="key"){Yt(T),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ye),Yt(null);break}}T.ref!==null&&(Yt(T),b("Invalid attribute `ref` supplied to `React.Fragment`."),Yt(null))}}function ie(T,F,te,ye,We,Ve){{var ze=P(T);if(!ze){var De="";(T===void 0||typeof T=="object"&&T!==null&&Object.keys(T).length===0)&&(De+=" 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 Ct=wr();Ct?De+=Ct:De+=er();var ct;T===null?ct="null":ne(T)?ct="array":T!==void 0&&T.$$typeof===t?(ct="<"+(H(T.type)||"Unknown")+" />",De=" Did you accidentally export a JSX literal instead of a component?"):ct=typeof T,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ct,De)}var dt=Bt(T,F,te,We,Ve);if(dt==null)return dt;if(ze){var zt=F.children;if(zt!==void 0)if(ye)if(ne(zt)){for(var yr=0;yr<zt.length;yr++)E(zt[yr],T);Object.freeze&&Object.freeze(zt)}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 E(zt,T)}return T===r?W(dt):_(dt),dt}}function pe(T,F,te){return ie(T,F,te,!0)}function he(T,F,te){return ie(T,F,te,!1)}var et=he,ht=pe;Cr.Fragment=r,Cr.jsx=et,Cr.jsxs=ht}()),Cr}process.env.NODE_ENV==="production"?Ps.exports=_p():Ps.exports=jp();var c=Ps.exports;function za(e,t){return function(){return e.apply(t,arguments)}}const{toString:Rp}=Object.prototype,{getPrototypeOf:Os}=Object,{iterator:oo,toStringTag:Ha}=Symbol,so=(e=>t=>{const n=Rp.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ht=e=>(e=e.toLowerCase(),t=>so(t)===e),io=e=>t=>typeof t===e,{isArray:tr}=Array,nr=io("undefined");function Tr(e){return e!==null&&!nr(e)&&e.constructor!==null&&!nr(e.constructor)&&Tt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ua=Ht("ArrayBuffer");function Pp(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ua(e.buffer),t}const Op=io("string"),Tt=io("function"),Wa=io("number"),kr=e=>e!==null&&typeof e=="object",Mp=e=>e===!0||e===!1,ao=e=>{if(so(e)!=="object")return!1;const t=Os(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Ha in e)&&!(oo in e)},Dp=e=>{if(!kr(e)||Tr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Lp=Ht("Date"),$p=Ht("File"),Fp=Ht("Blob"),Bp=Ht("FileList"),zp=e=>kr(e)&&Tt(e.pipe),Hp=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Tt(e.append)&&((t=so(e))==="formdata"||t==="object"&&Tt(e.toString)&&e.toString()==="[object FormData]"))},Up=Ht("URLSearchParams"),[Wp,Vp,Kp,qp]=["ReadableStream","Request","Response","Headers"].map(Ht),Gp=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Er(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),tr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Tr(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 Va(e,t){if(Tr(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 Pn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ka=e=>!nr(e)&&e!==Pn;function Ms(){const{caseless:e,skipUndefined:t}=Ka(this)&&this||{},n={},r=(o,s)=>{const i=e&&Va(n,s)||s;ao(n[i])&&ao(o)?n[i]=Ms(n[i],o):ao(o)?n[i]=Ms({},o):tr(o)?n[i]=o.slice():(!t||!nr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Er(arguments[o],r);return n}const Yp=(e,t,n,{allOwnKeys:r}={})=>(Er(t,(o,s)=>{n&&Tt(o)?e[s]=za(o,n):e[s]=o},{allOwnKeys:r}),e),Xp=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Jp=(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)},Zp=(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&&Os(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Qp=(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},em=e=>{if(!e)return null;if(tr(e))return e;let t=e.length;if(!Wa(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},tm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Os(Uint8Array)),nm=(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])}},rm=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},om=Ht("HTMLFormElement"),sm=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),qa=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),im=Ht("RegExp"),Ga=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Er(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},am=e=>{Ga(e,(t,n)=>{if(Tt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Tt(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+"'")})}})},lm=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return tr(e)?r(e):r(String(e).split(t)),n},cm=()=>{},um=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function dm(e){return!!(e&&Tt(e.append)&&e[Ha]==="FormData"&&e[oo])}const fm=e=>{const t=new Array(10),n=(r,o)=>{if(kr(r)){if(t.indexOf(r)>=0)return;if(Tr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=tr(r)?[]:{};return Er(r,(i,a)=>{const l=n(i,o+1);!nr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},hm=Ht("AsyncFunction"),pm=e=>e&&(kr(e)||Tt(e))&&Tt(e.then)&&Tt(e.catch),Ya=((e,t)=>e?setImmediate:t?((n,r)=>(Pn.addEventListener("message",({source:o,data:s})=>{o===Pn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Pn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Tt(Pn.postMessage)),mm=typeof queueMicrotask<"u"?queueMicrotask.bind(Pn):typeof process<"u"&&process.nextTick||Ya,O={isArray:tr,isArrayBuffer:Ua,isBuffer:Tr,isFormData:Hp,isArrayBufferView:Pp,isString:Op,isNumber:Wa,isBoolean:Mp,isObject:kr,isPlainObject:ao,isEmptyObject:Dp,isReadableStream:Wp,isRequest:Vp,isResponse:Kp,isHeaders:qp,isUndefined:nr,isDate:Lp,isFile:$p,isBlob:Fp,isRegExp:im,isFunction:Tt,isStream:zp,isURLSearchParams:Up,isTypedArray:tm,isFileList:Bp,forEach:Er,merge:Ms,extend:Yp,trim:Gp,stripBOM:Xp,inherits:Jp,toFlatObject:Zp,kindOf:so,kindOfTest:Ht,endsWith:Qp,toArray:em,forEachEntry:nm,matchAll:rm,isHTMLForm:om,hasOwnProperty:qa,hasOwnProp:qa,reduceDescriptors:Ga,freezeMethods:am,toObjectSet:lm,toCamelCase:sm,noop:cm,toFiniteNumber:um,findKey:Va,global:Pn,isContextDefined:Ka,isSpecCompliantForm:dm,toJSONObject:fm,isAsyncFn:hm,isThenable:pm,setImmediate:Ya,asap:mm,isIterable:e=>e!=null&&Tt(e[oo])};function Re(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}O.inherits(Re,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:O.toJSONObject(this.config),code:this.code,status:this.status}}});const Xa=Re.prototype,Ja={};["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=>{Ja[e]={value:e}}),Object.defineProperties(Re,Ja),Object.defineProperty(Xa,"isAxiosError",{value:!0}),Re.from=(e,t,n,r,o,s)=>{const i=Object.create(Xa);O.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Re.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const gm=null;function Ds(e){return O.isPlainObject(e)||O.isArray(e)}function Za(e){return O.endsWith(e,"[]")?e.slice(0,-2):e}function Qa(e,t,n){return e?e.concat(t).map(function(o,s){return o=Za(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function xm(e){return O.isArray(e)&&!e.some(Ds)}const vm=O.toFlatObject(O,{},null,function(t){return/^is[A-Z]/.test(t)});function lo(e,t,n){if(!O.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=O.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,g){return!O.isUndefined(g[v])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&O.isSpecCompliantForm(t);if(!O.isFunction(o))throw new TypeError("visitor must be a function");function u(w){if(w===null)return"";if(O.isDate(w))return w.toISOString();if(O.isBoolean(w))return w.toString();if(!l&&O.isBlob(w))throw new Re("Blob is not supported. Use a Buffer instead.");return O.isArrayBuffer(w)||O.isTypedArray(w)?l&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function d(w,v,g){let x=w;if(w&&!g&&typeof w=="object"){if(O.endsWith(v,"{}"))v=r?v:v.slice(0,-2),w=JSON.stringify(w);else if(O.isArray(w)&&xm(w)||(O.isFileList(w)||O.endsWith(v,"[]"))&&(x=O.toArray(w)))return v=Za(v),x.forEach(function(S,N){!(O.isUndefined(S)||S===null)&&t.append(i===!0?Qa([v],N,s):i===null?v:v+"[]",u(S))}),!1}return Ds(w)?!0:(t.append(Qa(g,v,s),u(w)),!1)}const f=[],h=Object.assign(vm,{defaultVisitor:d,convertValue:u,isVisitable:Ds});function p(w,v){if(!O.isUndefined(w)){if(f.indexOf(w)!==-1)throw Error("Circular reference detected in "+v.join("."));f.push(w),O.forEach(w,function(x,b){(!(O.isUndefined(x)||x===null)&&o.call(t,x,O.isString(b)?b.trim():b,v,h))===!0&&p(x,v?v.concat(b):[b])}),f.pop()}}if(!O.isObject(e))throw new TypeError("data must be an object");return p(e),t}function el(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ls(e,t){this._pairs=[],e&&lo(e,this,t)}const tl=Ls.prototype;tl.append=function(t,n){this._pairs.push([t,n])},tl.toString=function(t){const n=t?function(r){return t.call(this,r,el)}:el;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function wm(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function nl(e,t,n){if(!t)return e;const r=n&&n.encode||wm;O.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=O.isURLSearchParams(t)?t.toString():new Ls(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class rl{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){O.forEach(this.handlers,function(r){r!==null&&t(r)})}}const ol={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},bm={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ls,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},$s=typeof window<"u"&&typeof document<"u",Fs=typeof navigator=="object"&&navigator||void 0,ym=$s&&(!Fs||["ReactNative","NativeScript","NS"].indexOf(Fs.product)<0),Sm=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Cm=$s&&window.location.href||"http://localhost",xt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:$s,hasStandardBrowserEnv:ym,hasStandardBrowserWebWorkerEnv:Sm,navigator:Fs,origin:Cm},Symbol.toStringTag,{value:"Module"})),...bm};function Tm(e,t){return lo(e,new xt.classes.URLSearchParams,{visitor:function(n,r,o,s){return xt.isNode&&O.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function km(e){return O.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Em(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 sl(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&O.isArray(o)?o.length:i,l?(O.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!O.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&O.isArray(o[i])&&(o[i]=Em(o[i])),!a)}if(O.isFormData(e)&&O.isFunction(e.entries)){const n={};return O.forEachEntry(e,(r,o)=>{t(km(r),o,n,0)}),n}return null}function Im(e,t,n){if(O.isString(e))try{return(t||JSON.parse)(e),O.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Ir={transitional:ol,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=O.isObject(t);if(s&&O.isHTMLForm(t)&&(t=new FormData(t)),O.isFormData(t))return o?JSON.stringify(sl(t)):t;if(O.isArrayBuffer(t)||O.isBuffer(t)||O.isStream(t)||O.isFile(t)||O.isBlob(t)||O.isReadableStream(t))return t;if(O.isArrayBufferView(t))return t.buffer;if(O.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Tm(t,this.formSerializer).toString();if((a=O.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return lo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Im(t)):t}],transformResponse:[function(t){const n=this.transitional||Ir.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(O.isResponse(t)||O.isReadableStream(t))return t;if(t&&O.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Re.from(a,Re.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:xt.classes.FormData,Blob:xt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};O.forEach(["delete","get","head","post","put","patch"],e=>{Ir.headers[e]={}});const Nm=O.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Am=e=>{const t={};let n,r,o;return e&&e.split(`
26
+ `).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&Nm[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},il=Symbol("internals");function Nr(e){return e&&String(e).trim().toLowerCase()}function co(e){return e===!1||e==null?e:O.isArray(e)?e.map(co):String(e)}function _m(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 jm=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Bs(e,t,n,r,o){if(O.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!O.isString(t)){if(O.isString(r))return t.indexOf(r)!==-1;if(O.isRegExp(r))return r.test(t)}}function Rm(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Pm(e,t){const n=O.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,i){return this[r].call(this,t,o,s,i)},configurable:!0})})}let kt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,u){const d=Nr(l);if(!d)throw new Error("header name must be a non-empty string");const f=O.findKey(o,d);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||l]=co(a))}const i=(a,l)=>O.forEach(a,(u,d)=>s(u,d,l));if(O.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(O.isString(t)&&(t=t.trim())&&!jm(t))i(Am(t),n);else if(O.isObject(t)&&O.isIterable(t)){let a={},l,u;for(const d of t){if(!O.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(l=a[u])?O.isArray(l)?[...l,d[1]]:[l,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=Nr(t),t){const r=O.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return _m(o);if(O.isFunction(n))return n.call(this,o,r);if(O.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Nr(t),t){const r=O.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Bs(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Nr(i),i){const a=O.findKey(r,i);a&&(!n||Bs(r,r[a],a,n))&&(delete r[a],o=!0)}}return O.isArray(t)?t.forEach(s):s(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const s=n[r];(!t||Bs(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return O.forEach(this,(o,s)=>{const i=O.findKey(r,s);if(i){n[i]=co(o),delete n[s];return}const a=t?Rm(s):String(s).trim();a!==s&&delete n[s],n[a]=co(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return O.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&O.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
27
+ `)}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[il]=this[il]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Nr(i);r[a]||(Pm(o,i),r[a]=!0)}return O.isArray(t)?t.forEach(s):s(t),this}};kt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),O.reduceDescriptors(kt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),O.freezeMethods(kt);function zs(e,t){const n=this||Ir,r=t||n,o=kt.from(r.headers);let s=r.data;return O.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function al(e){return!!(e&&e.__CANCEL__)}function rr(e,t,n){Re.call(this,e??"canceled",Re.ERR_CANCELED,t,n),this.name="CanceledError"}O.inherits(rr,Re,{__CANCEL__:!0});function ll(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 Om(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Mm(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 Dm(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 uo=(e,t,n=3)=>{let r=0;const o=Mm(50,250);return Dm(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)},cl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},ul=e=>(...t)=>O.asap(()=>e(...t)),Lm=xt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,xt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(xt.origin),xt.navigator&&/(msie|trident)/i.test(xt.navigator.userAgent)):()=>!0,$m=xt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];O.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),O.isString(r)&&i.push("path="+r),O.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Fm(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Bm(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function dl(e,t,n){let r=!Fm(t);return e&&(r||n==!1)?Bm(e,t):t}const fl=e=>e instanceof kt?{...e}:e;function On(e,t){t=t||{};const n={};function r(u,d,f,h){return O.isPlainObject(u)&&O.isPlainObject(d)?O.merge.call({caseless:h},u,d):O.isPlainObject(d)?O.merge({},d):O.isArray(d)?d.slice():d}function o(u,d,f,h){if(O.isUndefined(d)){if(!O.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!O.isUndefined(d))return r(void 0,d)}function i(u,d){if(O.isUndefined(d)){if(!O.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function a(u,d,f){if(f in t)return r(u,d);if(f in e)return r(void 0,u)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(u,d,f)=>o(fl(u),fl(d),f,!0)};return O.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,h=f(e[d],t[d],d);O.isUndefined(h)&&f!==a||(n[d]=h)}),n}const hl=e=>{const t=On({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=kt.from(i),t.url=nl(dl(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),O.isFormData(n)){if(xt.hasStandardBrowserEnv||xt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(O.isFunction(n.getHeaders)){const l=n.getHeaders(),u=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{u.includes(d.toLowerCase())&&i.set(d,f)})}}if(xt.hasStandardBrowserEnv&&(r&&O.isFunction(r)&&(r=r(t)),r||r!==!1&&Lm(t.url))){const l=o&&s&&$m.read(s);l&&i.set(o,l)}return t},zm=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=hl(e);let s=o.data;const i=kt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=o,d,f,h,p,w;function v(){p&&p(),w&&w(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function x(){if(!g)return;const S=kt.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:S,config:e,request:g};ll(function(I){n(I),v()},function(I){r(I),v()},C),g=null}"onloadend"in g?g.onloadend=x:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(x)},g.onabort=function(){g&&(r(new Re("Request aborted",Re.ECONNABORTED,e,g)),g=null)},g.onerror=function(N){const C=N&&N.message?N.message:"Network Error",k=new Re(C,Re.ERR_NETWORK,e,g);k.event=N||null,r(k),g=null},g.ontimeout=function(){let N=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||ol;o.timeoutErrorMessage&&(N=o.timeoutErrorMessage),r(new Re(N,C.clarifyTimeoutError?Re.ETIMEDOUT:Re.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&O.forEach(i.toJSON(),function(N,C){g.setRequestHeader(C,N)}),O.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,w]=uo(u,!0),g.addEventListener("progress",h)),l&&g.upload&&([f,p]=uo(l),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=S=>{g&&(r(!S||S.type?new rr(null,e,g):S),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=Om(o.url);if(b&&xt.protocols.indexOf(b)===-1){r(new Re("Unsupported protocol "+b+":",Re.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Hm=(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 rr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Re(`timeout ${t} of ms exceeded`,Re.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>O.asap(a),l}},Um=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},Wm=async function*(e,t){for await(const n of Vm(e))yield*Um(n,t)},Vm=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()}},pl=(e,t,n,r)=>{const o=Wm(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})},ml=64*1024,{isFunction:fo}=O,Km=(({Request:e,Response:t})=>({Request:e,Response:t}))(O.global),{ReadableStream:gl,TextEncoder:xl}=O.global,vl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},qm=e=>{e=O.merge.call({skipUndefined:!0},Km,e);const{fetch:t,Request:n,Response:r}=e,o=t?fo(t):typeof fetch=="function",s=fo(n),i=fo(r);if(!o)return!1;const a=o&&fo(gl),l=o&&(typeof xl=="function"?(w=>v=>w.encode(v))(new xl):async w=>new Uint8Array(await new n(w).arrayBuffer())),u=s&&a&&vl(()=>{let w=!1;const v=new n(xt.origin,{body:new gl,method:"POST",get duplex(){return w=!0,"half"}}).headers.has("Content-Type");return w&&!v}),d=i&&a&&vl(()=>O.isReadableStream(new r("").body)),f={stream:d&&(w=>w.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(w=>{!f[w]&&(f[w]=(v,g)=>{let x=v&&v[w];if(x)return x.call(v);throw new Re(`Response type '${w}' is not supported`,Re.ERR_NOT_SUPPORT,g)})});const h=async w=>{if(w==null)return 0;if(O.isBlob(w))return w.size;if(O.isSpecCompliantForm(w))return(await new n(xt.origin,{method:"POST",body:w}).arrayBuffer()).byteLength;if(O.isArrayBufferView(w)||O.isArrayBuffer(w))return w.byteLength;if(O.isURLSearchParams(w)&&(w=w+""),O.isString(w))return(await l(w)).byteLength},p=async(w,v)=>{const g=O.toFiniteNumber(w.getContentLength());return g??h(v)};return async w=>{let{url:v,method:g,data:x,signal:b,cancelToken:S,timeout:N,onDownloadProgress:C,onUploadProgress:k,responseType:I,headers:A,withCredentials:R="same-origin",fetchOptions:P}=hl(w),L=t||fetch;I=I?(I+"").toLowerCase():"text";let $=Hm([b,S&&S.toAbortSignal()],N),H=null;const M=$&&$.unsubscribe&&(()=>{$.unsubscribe()});let q;try{if(k&&u&&g!=="get"&&g!=="head"&&(q=await p(A,x))!==0){let Z=new n(v,{method:"POST",body:x,duplex:"half"}),ge;if(O.isFormData(x)&&(ge=Z.headers.get("content-type"))&&A.setContentType(ge),Z.body){const[de,ee]=cl(q,uo(ul(k)));x=pl(Z.body,ml,de,ee)}}O.isString(R)||(R=R?"include":"omit");const V=s&&"credentials"in n.prototype,Y={...P,signal:$,method:g.toUpperCase(),headers:A.normalize().toJSON(),body:x,duplex:"half",credentials:V?R:void 0};H=s&&new n(v,Y);let B=await(s?L(H,P):L(v,Y));const j=d&&(I==="stream"||I==="response");if(d&&(C||j&&M)){const Z={};["status","statusText","headers"].forEach(Ae=>{Z[Ae]=B[Ae]});const ge=O.toFiniteNumber(B.headers.get("content-length")),[de,ee]=C&&cl(ge,uo(ul(C),!0))||[];B=new r(pl(B.body,ml,de,()=>{ee&&ee(),M&&M()}),Z)}I=I||"text";let G=await f[O.findKey(f,I)||"text"](B,w);return!j&&M&&M(),await new Promise((Z,ge)=>{ll(Z,ge,{data:G,headers:kt.from(B.headers),status:B.status,statusText:B.statusText,config:w,request:H})})}catch(V){throw M&&M(),V&&V.name==="TypeError"&&/Load failed|fetch/i.test(V.message)?Object.assign(new Re("Network Error",Re.ERR_NETWORK,w,H),{cause:V.cause||V}):Re.from(V,V&&V.code,w,H)}}},Gm=new Map,wl=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=Gm;for(;a--;)l=s[a],u=d.get(l),u===void 0&&d.set(l,u=a?new Map:qm(t)),d=u;return u};wl();const Hs={http:gm,xhr:zm,fetch:{get:wl}};O.forEach(Hs,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const bl=e=>`- ${e}`,Ym=e=>O.isFunction(e)||e===null||e===!1,yl={getAdapter:(e,t)=>{e=O.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){r=e[i];let a;if(o=r,!Ym(r)&&(o=Hs[(a=String(r)).toLowerCase()],o===void 0))throw new Re(`Unknown adapter '${a}'`);if(o&&(O.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,u])=>`adapter ${l} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
28
+ `+i.map(bl).join(`
29
+ `):" "+bl(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:Hs};function Us(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new rr(null,e)}function Sl(e){return Us(e),e.headers=kt.from(e.headers),e.data=zs.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),yl.getAdapter(e.adapter||Ir.adapter,e)(e).then(function(r){return Us(e),r.data=zs.call(e,e.transformResponse,r),r.headers=kt.from(r.headers),r},function(r){return al(r)||(Us(e),r&&r.response&&(r.response.data=zs.call(e,e.transformResponse,r.response),r.response.headers=kt.from(r.response.headers))),Promise.reject(r)})}const Cl="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 Tl={};ho.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Cl+"] 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&&!Tl[i]&&(Tl[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 Xm(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 po={assertOptions:Xm,validators:ho},Xt=po.validators;let Mn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new rl,response:new rl}}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+=`
30
+ `+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=On(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&po.assertOptions(r,{silentJSONParsing:Xt.transitional(Xt.boolean),forcedJSONParsing:Xt.transitional(Xt.boolean),clarifyTimeoutError:Xt.transitional(Xt.boolean)},!1),o!=null&&(O.isFunction(o)?n.paramsSerializer={serialize:o}:po.assertOptions(o,{encode:Xt.function,serialize:Xt.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),po.assertOptions(n,{baseUrl:Xt.spelling("baseURL"),withXsrfToken:Xt.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&O.merge(s.common,s[n.method]);s&&O.forEach(["delete","get","head","post","put","patch","common"],w=>{delete s[w]}),n.headers=kt.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 w=[Sl.bind(this),void 0];for(w.unshift(...a),w.push(...u),h=w.length,d=Promise.resolve(n);f<h;)d=d.then(w[f++],w[f++]);return d}h=a.length;let p=n;for(;f<h;){const w=a[f++],v=a[f++];try{p=w(p)}catch(g){v.call(this,g);break}}try{d=Sl.call(this,p)}catch(w){return Promise.reject(w)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=On(this.defaults,t);const n=dl(t.baseURL,t.url,t.allowAbsoluteUrls);return nl(n,t.params,t.paramsSerializer)}};O.forEach(["delete","get","head","options"],function(t){Mn.prototype[t]=function(n,r){return this.request(On(r||{},{method:t,url:n,data:(r||{}).data}))}}),O.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(On(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Mn.prototype[t]=n(),Mn.prototype[t+"Form"]=n(!0)});let Jm=class Ip{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 rr(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 Ip(function(o){t=o}),cancel:t}}};function Zm(e){return function(n){return e.apply(null,n)}}function Qm(e){return O.isObject(e)&&e.isAxiosError===!0}const Ws={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(Ws).forEach(([e,t])=>{Ws[t]=e});function kl(e){const t=new Mn(e),n=za(Mn.prototype.request,t);return O.extend(n,Mn.prototype,t,{allOwnKeys:!0}),O.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return kl(On(e,o))},n}const at=kl(Ir);at.Axios=Mn,at.CanceledError=rr,at.CancelToken=Jm,at.isCancel=al,at.VERSION=Cl,at.toFormData=lo,at.AxiosError=Re,at.Cancel=at.CanceledError,at.all=function(t){return Promise.all(t)},at.spread=Zm,at.isAxiosError=Qm,at.mergeConfig=On,at.AxiosHeaders=kt,at.formToJSON=e=>sl(O.isHTMLForm(e)?new FormData(e):e),at.getAdapter=yl.getAdapter,at.HttpStatusCode=Ws,at.default=at;const{Axios:jC,AxiosError:RC,CanceledError:PC,isCancel:OC,CancelToken:MC,VERSION:DC,all:LC,Cancel:$C,isAxiosError:FC,spread:BC,toFormData:zC,AxiosHeaders:HC,HttpStatusCode:UC,formToJSON:WC,getAdapter:VC,mergeConfig:KC}=at,El=typeof window<"u"?window.__API_BASE_URL__:void 0,Il=El?cn(El):void 0;function cn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let mo=null;const Vs=new Set;function Nl(){return mo}function Ks(e){mo=e,Vs.forEach(t=>t(e))}function Al(e){return Vs.add(e),()=>Vs.delete(e)}const Ot=at.create({...Il?{baseURL:Il}:{},timeout:3e4,withCredentials:!0});Ot.interceptors.request.use(e=>(mo&&(e.headers.Authorization=`Bearer ${mo}`),e)),Ot.interceptors.response.use(e=>e,e=>Promise.reject(e));async function It(e,t){return Ot.defaults.baseURL?(await Ot.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function qs(e,t,n){return Ot.defaults.baseURL?(await Ot.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function _l(e,t,n){return Ot.defaults.baseURL?(await Ot.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function jl(e,t){return Ot.defaults.baseURL?(await Ot.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Nt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Rl{get baseUrl(){const t=Ot.defaults.baseURL;return t?cn(String(t)):""}updateConfig(t){t.baseUrl&&(Ot.defaults.baseURL=cn(String(t.baseUrl))),t.authToken!==void 0&&Ks(t.authToken)}getAuthToken(){return Nl()}setAuthToken(t){Ks(t)}onTokenChange(t){return Al(t)}async listThreads(){const t=await It("/threads"),n=Nt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await qs("/threads",t?{title:t}:void 0);return Nt(r)}async updateThread(t,n){const r=await _l(`/threads/${t}`,{title:n});return Nt(r)}async deleteThread(t){const n=await jl(`/threads/${t}`);return Nt(n)}async threadInfo(t){const n=await It(`/threads/${t}/info`);return Nt(n)}async listAgents(){const t=await It("/agents"),n=Nt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await It(`/agents/${t}`);return Nt(n)}async getAgentSchema(t){const n=await It(`/agents/${t}/schema`);return Nt(n)}async getMessages(t){const n=await It(`/threads/${t.threadId}/messages`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs,limit:t.limit,before_id:t.beforeId??void 0}});return Nt(n)}async getState(t){const n=await It(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Nt(n)}async getStateHistory(t){const n=await It(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Nt(n)}async listCheckpoints(t){const n=await It(`/threads/${t}/checkpoints`,{params:{thread_id:t}});return Nt(n)}async resume(t){const n=await qs("/runs/resume",{thread_id:t.threadId,value:t.value});return Nt(n)}}const mn=new Rl,Pl=y.createContext(null);function eg({children:e,apiConfig:t}){const n=mn;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(Pl.Provider,{value:r,children:e})}function Gs(){const e=y.useContext(Pl);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function tg(e,t){const n=e==null?void 0:e.checkpoints,r=Array.isArray(n)?n.slice():n?Object.values(n):[],o=i=>i&&typeof i=="object"&&i!==null&&"checkpointId"in i&&"createdAt"in i&&typeof i.checkpointId=="string"&&typeof i.createdAt=="string",s=r.filter(o).map(i=>{const a=i;return{checkpointId:a.checkpointId,checkpointNs:a.checkpointNs??"",createdAt:a.createdAt,messagesLen:a.messagesLen??0,preview:a.preview??"",role:a.role??null,parentId:a.parentId??null,editedMessageId:a.editedMessageId??null,branchLabel:a.branchLabel??null,lastMessageId:a.lastMessageId??null,hasMessages:typeof a.hasMessages=="boolean"?a.hasMessages:void 0}});return{threadId:(e==null?void 0:e.threadId)??t??null,checkpoints:s}}async function ng(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 rg(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const u=await ng(l);a.push({filename:l.name,data:u,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}function og(e){return e.type!=="thread_info"&&e.type!=="token"}const sg={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};function ig(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:Ys(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};return console.log("[MessageReducer] 📊 After reset - messages count:",r.messages.length),r}case"seed":{const r=Ys(t.payload.messages),o={...e,messages:r,assemblingId:null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),console.log("[MessageReducer] seed action (REPLACE mode):",{incomingCount:t.payload.messages.length,sanitizedCount:r.length,previousCount:e.messages.length,checkpointId:o.lastCheckpointId}),o}case"prepend":{const r=Ys(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 Ml(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Ml(o,s),e):e}case"interrupt_response":{const{interruptId:r}=t.payload,o=e.messages.map(s=>({...s,content:s.content.filter(i=>i.type!=="interrupt")}));return{...e,messages:o,pendingInterrupt:null}}default:return e}}function Ol(e=[]){const[t,n]=y.useReducer(ig,{...sg,messages:e}),r=y.useRef([]),o=y.useRef(null),s=y.useRef(null),i=y.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=y.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=y.useCallback(d=>{r.current.push(d),a()},[a]);y.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const u=y.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:d=>n({type:"user_message",payload:{message:d}}),onEvent:l}),[l]);return{state:t,dispatch:n,...u}}function Ml(e,t){var n,r;if(t.type==="message_start"&&t.role==="assistant"){const o=t.id,s=fg(t.model);if(e.messages.some(l=>l.id===o))return{...e,assemblingId:o};const a={id:o,role:"assistant",name:s||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:o,messages:[...e.messages,a]}}if(t.type==="message_delta"){const o=e.assemblingId??Xs(e.messages);return o?{...e,messages:Js(e.messages,o,t.delta)}:e}if(t.type==="message_end"){const o=e.assemblingId??Xs(e.messages);if(!o)return{...e,assemblingId:null};const s=e.messages,i=s.findIndex(a=>a.id===o&&a.role==="assistant");if(i>=0&&!((n=s[i].content)==null?void 0:n.some(u=>{var d;return(u==null?void 0:u.type)==="text"&&((d=u.text)==null?void 0:d.trim())}))){const u=[...s.slice(0,i),...s.slice(i+1)];return{...e,assemblingId:null,messages:u}}return e}if(t.type==="tool_start"){const o=t.id??t.call_id,s=t.name??t.tool??"tool";if(!o)return e;const i=`tool-${o}`,a={type:"tool_call",id:o,name:s,args:t.args};if(e.messages.find(d=>d.id===i))return{...e,toolIndex:{...e.toolIndex,[o]:i}};const u={id:i,role:"tool",name:s,createdAt:new Date().toISOString(),content:[a]};return{...e,messages:[...e.messages,u],toolIndex:{...e.toolIndex,[o]:i}}}if(t.type==="tool_end"){const o=t.id??t.call_id;if(!o)return e;const s=e.toolIndex[o]??`tool-${o}`,i={type:"tool_end",toolCallId:o,output:t.output,error:t.error},a=e.messages.find(d=>d.id===s),l={id:s,role:"tool",name:t.name??((r=e.messages.find(d=>d.id===s))==null?void 0:r.name),content:[i],createdAt:new Date().toISOString()},u=a?Js(e.messages,s,[i]):[...e.messages,l];return{...e,messages:u,toolIndex:{...e.toolIndex,[o]:s}}}if(t.type==="checkpoint"){const o=t.checkpointNs??e.lastCheckpointNs??null,s=dg(e.messages,t.checkpointId,o);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:o,messages:s}}if(t.type==="branch"){const o=t.checkpointId??e.lastCheckpointId,s=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:o??null,lastCheckpointNs:s??null}}if(t.type==="error"){const o={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,o]}}if(t.type==="interrupt"){const o=e.assemblingId??Xs(e.messages),s={type:"interrupt",value:t.value};if(o)return{...e,assemblingId:null,messages:Js(e.messages,o,[s]),pendingInterrupt:{id:t.id,value:t.value}};const i={id:`interrupt-${t.id}`,role:"system",createdAt:new Date().toISOString(),content:[s]};return{...e,messages:[...e.messages,i],pendingInterrupt:{id:t.id,value:t.value}}}return e}function Ys(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 ag(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Xs(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function lg(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 Js(e,t,n){return lg(e,t,r=>({...r,content:cg(r.content,n)}))}function cg(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"){const i=o,a=i.text??"";if(!a){i.text=s;continue}if(s.startsWith(a)){i.text=s;continue}if(a.includes(s))continue;const l=ug(a,s);l?i.text=a+l:i.text=a+s}else n.push({type:"text",text:s})}else n.push(r);return n}function ug(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let r=n;r>0;r--)if(e.slice(-r)===t.slice(0,r))return t.slice(r);return t}function dg(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 ag(e,r,s)}return e}function fg(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Dl(e={}){const t=y.useMemo(()=>cn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=y.useState(e.token??null),s=y.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=y.useState(!1),[u,d]=y.useState(null),[f,h]=y.useState(""),[p,w]=y.useState(null),[v,g]=y.useState(0),[x,b]=y.useState(!1),S=y.useRef(null),N=y.useRef(!0),C=y.useRef(0),k=y.useCallback(P=>{o(P)},[]),I=y.useCallback(()=>{var P;(P=S.current)==null||P.abort(),S.current=null,l(!1),b(!1),C.current=0,g(0)},[]),A=y.useCallback(()=>{h(""),w(null),d(null)},[]),R=y.useCallback((P,L,$)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h("");const H=new AbortController;return S.current=H,(async()=>{var q,V,Y,B,j,G,Z,ge;const M=de=>{var ee;try{const Ae=JSON.parse(JSON.stringify(de));return(ee=Ae==null?void 0:Ae.payload)!=null&&ee.files_info&&Array.isArray(Ae.payload.files_info)&&(Ae.payload.files_info=Ae.payload.files_info.map(Te=>({...Te,data:Te!=null&&Te.data?`<base64 ${String(Te.data).length} chars>`:Te==null?void 0:Te.data}))),Ae}catch{return de}};try{let de={};try{if(r)de={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Oe=window.__AUTH_TOKEN__,Be=((q=window.localStorage)==null?void 0:q.getItem("authToken"))||null;let Ue=null;try{const ot=(V=window.localStorage)==null?void 0:V.getItem("chat-settings");ot&&(Ue=((Y=JSON.parse(ot))==null?void 0:Y.apiKey)||null)}catch{}const st=Oe||Be||Ue||null;st&&(de={Authorization:`Bearer ${st}`})}}catch{}console.debug("[use-chat] POST",t+n,M(P));const ee=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...de,...s.current},body:JSON.stringify(P),signal:H.signal,credentials:i});if(!ee.ok||!ee.body){const ke=await ee.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",ee.status,ke==null?void 0:ke.slice(0,500)),new Error(`stream ${ee.status}${ke?": "+ke:""}`)}b(!0);const Ae=ee.body.getReader(),Te=new TextDecoder;let K="",D=[];C.current=0,g(0);let J=0,U=null;const fe=()=>{if(D.length){const ke=D.join("");D=[],N.current&&h(Oe=>Oe+ke)}U=null},ue=()=>{typeof window<"u"&&U==null&&(U=requestAnimationFrame(fe))};let $e=Date.now();const Ge=setInterval(()=>{var ke;if(Date.now()-$e>6e4){const Oe="Stream idle timeout";d(Oe),H.abort(),(ke=$==null?void 0:$.onError)==null||ke.call($,Oe)}},5e3),qe=1024*1024;try{const ke=ee.headers.get("X-Thread-Id")||ee.headers.get("x-thread-id"),Oe=ee.headers.get("X-Thread-Created")||ee.headers.get("x-thread-created"),Be=ke??null,Ue=String(Oe??"").toLowerCase()==="true";for((B=$==null?void 0:$.onOpen)==null||B.call($,{threadId:Be,created:Ue});;){const{value:st,done:ot}=await Ae.read();if(ot)break;K+=Te.decode(st,{stream:!0}),K.length>qe&&(K="",console.warn("Stream buffer reset: exceeded 1MB"));let ne;for(;(ne=K.indexOf(`
31
31
 
32
- `))>=0;){const ue=F.slice(0,re);F=F.slice(re+2);const ge=ug(ue);if(!ge)continue;let ke;try{ke=JSON.parse(ge)}catch{console.debug("[use-chat] malformed SSE:",ge.slice(0,200));continue}const ve=cg(ke)?ke.data:ke;Oe=Date.now();const Re=ve.seq;if(Re!==void 0){if(Re<=Z){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:Re,lastProcessedSeq:Z,type:ve.type});continue}Z>0&&Re>Z+1&&((_=L==null?void 0:L.onGap)==null||_.call(L,{from:Z,to:Re})),Z=Re,C.current=Re,g(Re)}if(M==null||M(ve),ve.type==="token"&&e.autoAppendAssistant!==!1)D.push(ve.content),ne();else if(ve.type==="message_delta"){const Ze=ve.delta.filter(Ke=>Ke.type==="text").map(Ke=>Ke.text).join("");Ze&&e.autoAppendAssistant!==!1&&(D.push(Ze),ne())}else ve.type==="heartbeat"?console.debug("[use-chat] heartbeat received"):(ee!==null&&cancelAnimationFrame(ee),ce(),ve.type==="checkpoint"?w(ve.checkpointId):ve.type==="error"&&d(ve.message))}}ce()}catch(je){if(je.name!=="AbortError"){const Me=je.message||String(je);d(Me),(G=L==null?void 0:L.onError)==null||G.call(L,Me)}}finally{try{await _e.cancel()}catch{}finally{(B=_e.releaseLock)==null||B.call(_e)}ee!==null&&typeof window<"u"&&window.cancelAnimationFrame(ee),clearInterval(Ye),l(!1),b(!1),S.current=null,C.current=0,g(0)}}catch(de){if(de.name!=="AbortError"){const xe=de.message||String(de);d(xe),(he=L==null?void 0:L.onError)==null||he.call(L,xe)}}finally{l(!1),b(!1),S.current=null,C.current=0,g(0)}})(),{close:()=>W.abort()}},[t,n,r,e.autoAppendAssistant]);return y.useEffect(()=>()=>{var j;E.current=!1,(j=S.current)==null||j.abort()},[]),{isStreaming:a,error:u,assistantText:f,lastCheckpointId:p,lastSeq:v,connected:x,stream:P,stop:I,clear:A,setToken:T}}function cg(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function ug(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(`
33
- `)}function dg({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onUnhandledEvent:r,onSequenceGap:o}){const s=y.useRef(null),i=y.useCallback(p=>{const w=p.seq??null;if(w!==null){const v=s.current;if(v!==null){if(w<=v)return;w>v+1&&(o==null||o({from:v,to:w}))}s.current=w}if(p.type==="thread_info"){console.log("[useChatStreamingService] 🎯 Received thread_info event:",p),t(p);return}if(eg(p)){n(p);return}r==null||r(p)},[n,o,t,r]),{stream:a,stop:l,isStreaming:u,error:d,setToken:f}=Pl({baseUrl:e,token:null}),h=y.useCallback((p,w)=>{s.current=null,a(p,i,{onOpen:w==null?void 0:w.onOpen,onError:v=>{var g;(g=w==null?void 0:w.onError)==null||g.call(w,v)},onGap:(w==null?void 0:w.onGap)??o})},[i,o,a]);return y.useMemo(()=>({startStream:h,stop:l,isStreaming:u,error:d,setAuthToken:f}),[h,l,u,d,f])}const Ol=y.createContext(null),Ml=y.createContext(null),Dl=y.createContext(null),fg=y.createContext(!1),hg=20,Zs="cachedThreads",pg="v1",mg=300;function mo(){return typeof window<"u"&&typeof window.localStorage<"u"}function Ll(e){if(!mo())return null;try{return window.localStorage.getItem(e)}catch{return null}}function Fl(e,t){if(mo())try{window.localStorage.setItem(e,t)}catch{}}function $l(e){if(mo())try{window.localStorage.removeItem(e)}catch{}}function gg(){const e=Ll(Zs);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 zl(e){try{Fl(Zs,JSON.stringify(e))}catch{}}function xg({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}=Gs(),d=y.useMemo(()=>fn(u),[u]),f=y.useMemo(()=>{try{return new URL(u).host}catch{return"unknown"}},[u]),h=y.useMemo(()=>`threadPayload:${pg}:${f}:`,[f]),p=y.useCallback(N=>`${h}${N}`,[h]),w=y.useCallback(N=>{if(!N||typeof N!="object")return null;const z=N;return typeof z.threadId!="string"||!Array.isArray(z.messages)?null:{threadId:z.threadId,messages:z.messages,hasMore:!!z.hasMore,nextCursor:z.nextCursor??null,checkpointId:z.checkpointId??null,checkpointNs:z.checkpointNs??null}},[]),v=y.useCallback(N=>{const z=Ll(p(N));if(!z)return null;try{const te=JSON.parse(z);return w(te)}catch{return null}},[p,w]),g=y.useCallback((N,z=100)=>{const te={...N,messages:Array.isArray(N.messages)?N.messages.slice(-z):[]};try{Fl(p(N.threadId),JSON.stringify(te))}catch{}},[p]),x=y.useCallback(N=>{$l(p(N))},[p]),b=y.useCallback(()=>{if(mo())try{const N=h;for(let z=0;z<window.localStorage.length;z++){const te=window.localStorage.key(z);te&&te.startsWith(N)&&window.localStorage.removeItem(te)}}catch{}},[h]),[S,E]=y.useState(()=>gg()),[C,T]=y.useState(t),[I,A]=y.useState(!1),[P,j]=y.useState(!1),[M,L]=y.useState(!1),[W,O]=y.useState(!1),[Y,q]=y.useState(null),[J,$]=y.useState(void 0),[_,G]=y.useState(void 0),{state:B,seed:he,prepend:de,pushUser:xe,onEvent:_e,reset:Ce}=jl(),F=y.useRef(C);y.useEffect(()=>{F.current=C},[C]);const D=y.useRef(!1),Z=y.useRef([]),ee=y.useRef(null),ce=y.useRef(null),ne=y.useRef(new Map),Oe=y.useRef(C),Ye=y.useCallback((N,z)=>new Promise((te,we)=>{const H=async()=>{D.current=!0;try{await N(),te()}catch(U){we(U)}finally{D.current=!1;const U=Z.current.shift();U&&U().catch(()=>{})}};D.current?Z.current.push(H):H().catch(U=>{we(U)})}),[]),Ue=y.useCallback(async()=>{A(!0);try{const N=await l.listThreads();E(z=>N.length===0&&z.length>0?z:N)}catch(N){i==null||i(String(N)),console.error("[ChatSessionProvider] Failed to refresh threads:",N)}finally{A(!1)}},[l,i]),je=y.useRef(!1),Me=y.useRef(null),Je=y.useCallback((N,z,te)=>{const we=Array.isArray(N==null?void 0:N.messages)?N.messages:[],H=te??(N==null?void 0:N.threadId)??F.current;if(z==="replace"){if(H){const U={threadId:H,messages:we.slice(),hasMore:!!(N!=null&&N.hasMore),nextCursor:(N==null?void 0:N.nextCursor)??null,checkpointId:(N==null?void 0:N.checkpointId)??null,checkpointNs:(N==null?void 0:N.checkpointNs)??null};ne.current.set(H,U),Oe.current=H}he(we,{checkpointId:(N==null?void 0:N.checkpointId)??null,checkpointNs:(N==null?void 0:N.checkpointNs)??null})}else if(z==="prepend"&&we.length&&H){const U=ne.current.get(H),be=(U==null?void 0:U.messages)??[],We=new Set,Xe=[...we,...be].filter(Xt=>{const dn=Xt==null?void 0:Xt.id;return dn?We.has(dn)?!1:(We.add(dn),!0):!0}),lt={threadId:H,messages:Xe,hasMore:(N==null?void 0:N.hasMore)??(U==null?void 0:U.hasMore)??!1,nextCursor:(N==null?void 0:N.nextCursor)??(U==null?void 0:U.nextCursor)??null,checkpointId:(U==null?void 0:U.checkpointId)??(N==null?void 0:N.checkpointId)??null,checkpointNs:(U==null?void 0:U.checkpointNs)??(N==null?void 0:N.checkpointNs)??null};ne.current.set(H,lt),de(we)}else z==="prepend"&&we.length&&de(we);z==="replace"?(q((N==null?void 0:N.nextCursor)??null),L(!!(N!=null&&N.hasMore)),$((N==null?void 0:N.checkpointId)??void 0),G((N==null?void 0:N.checkpointNs)??void 0)):(q(U=>(N==null?void 0:N.nextCursor)??U??null),L(U=>(N==null?void 0:N.hasMore)!==void 0?!!(N!=null&&N.hasMore):U),$(U=>(N==null?void 0:N.checkpointId)??U??void 0),G(U=>(N==null?void 0:N.checkpointNs)??U??void 0))},[de,he]),ze=y.useCallback(N=>{he(N.messages,{checkpointId:N.checkpointId,checkpointNs:N.checkpointNs}),q(N.nextCursor),L(N.hasMore),$(N.checkpointId??void 0),G(N.checkpointNs??void 0),Oe.current=N.threadId},[he]),nt=y.useCallback(N=>{N&&(ne.current.delete(N),x(N),Oe.current===N&&(Oe.current=null))},[x]),st=y.useCallback(()=>{const N=F.current;N&&nt(N),Ce([]),L(!1),O(!1),q(null),$(void 0),G(void 0)},[nt,Ce]),re=y.useCallback(({from:N,to:z})=>{const te=F.current;te&&console.warn(`[ChatSessionProvider] Stream sequence gap detected (${N} -> ${z}) for thread ${te}`)},[]),ue=y.useCallback(N=>{const z=N.threadId;console.log("[ChatSessionProvider] 📥 Handling thread_info event:",{threadId:z,title:N.title,created:N.created,currentThreads:S.length});const te={threadId:z,title:N.title||`Thread ${z.slice(0,8)}`,createdAt:N.createdAt||new Date().toISOString(),updatedAt:N.updatedAt||new Date().toISOString(),messageCount:N.messageCount||0};F.current!==z&&(!F.current&&B.messages.length<=1&&(ce.current=z),T(z)),E(we=>{const H=we.findIndex(U=>U.threadId===z);if(H>=0){const U=[...we];return U[H]=te,console.log("[ChatSessionProvider] ✏️ Updated existing thread at index:",H),U}else return console.log("[ChatSessionProvider] ➕ Added new thread to list"),[te,...we]})},[B.messages.length]),{startStream:ge,stop:ke,isStreaming:ve,error:Re,setAuthToken:Ze}=dg({baseUrl:d,onThreadInfo:ue,onMessageEvent:_e,onUnhandledEvent:N=>{console.warn(`[ChatSessionProvider] Unhandled stream event: ${N.type}`,N)},onSequenceGap:re});y.useEffect(()=>{je.current=ve},[ve]),y.useEffect(()=>{S.length>0&&zl(S)},[S]),y.useEffect(()=>{var te;const N=l.getAuthToken();Ze(N);const z=(te=l.onTokenChange)==null?void 0:te.call(l,we=>{Ze(we),b()});return()=>{z==null||z()}},[l,Ze,b]);const Ke=y.useCallback(async N=>{const z=`temp-${Date.now()}`,te={threadId:z,title:N||"New Chat",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messageCount:0};E(we=>[te,...we]),T(z);try{const we=await l.createThread(N),H=typeof we=="string"?we:we.threadId;return E(U=>U.map(be=>be.threadId===z?{...be,threadId:H}:be)),T(H),setTimeout(()=>Ue(),10),H}catch(we){throw E(H=>H.filter(U=>U.threadId!==z)),T(null),we}},[l,Ue]),at=y.useCallback(async N=>{await l.deleteThread(N),E(z=>{const te=z.filter(we=>we.threadId!==N);try{te.length===0?$l(Zs):zl(te)}catch{}return te}),nt(N),F.current===N&&(ce.current=N,T(null),F.current=null,Oe.current=null,st()),await Ue()},[l,st,nt,Ue]),Ct=y.useCallback(async(N,z)=>{try{await l.updateThread(N,z),E(te=>te.map(we=>we.threadId===N?{...we,title:z}:we))}catch(te){throw await Ue(),te}},[l,Ue]),Tt=y.useCallback(async(N,z,te,we=!1)=>{await Ye(async()=>{if(ce.current===N&&!we){ce.current=null;return}if(ee.current===N&&!we)return;T(Xe=>Xe===N?Xe:N),F.current=N;const H=!we&&!z&&!te;let U=!1;if(H){const Xe=ne.current.get(N);if(Xe)ze(Xe),U=!0;else{const lt=v(N);lt&&(ne.current.set(N,lt),ze(lt),U=!0)}}const be=we||!U||!!z||!!te,We=async Xe=>{Xe&&j(!0),ee.current=N;try{const lt=await l.getMessages({threadId:N,checkpointId:z,checkpointNs:te});Je(lt,"replace",N)}catch(lt){throw(!U||we||Xe)&&(i==null||i(String(lt))),lt}finally{ee.current=null,Xe&&j(!1)}};be?await We(!0):H&&U&&We(!1).catch(Xe=>{console.warn("[ChatSessionProvider] Background refresh failed:",Xe)})},`loadThread-${N}`)},[l,ze,Je,Ye,i]),wr=y.useCallback(async()=>{await Ye(async()=>{const N=F.current;N&&nt(N),ce.current=null,T(null),F.current=null,Oe.current=null,st(),$(void 0),G(void 0);try{localStorage.removeItem("lastThreadId")}catch(z){console.warn("[ChatSessionProvider] Failed to clear lastThreadId:",z)}},"clearCurrentThread")},[st,nt,Ye]),br=y.useCallback(async N=>{const z=await l.listCheckpoints(N);return Jm(z,N)},[l]),Jn=y.useCallback(async(N,z)=>{if(!F.current)throw new Error("No active thread");await Tt(F.current,N,z??void 0,!0)},[Tt]),_n=y.useCallback(async()=>{if(!F.current)throw new Error("No active thread");await Tt(F.current,void 0,void 0,!0)},[Tt]),yr=y.useCallback(async N=>{if(!F.current)throw new Error("No active thread");if(W||!M)return;const z=Y;if(z){O(!0);try{const te=F.current,we=await l.getMessages({threadId:te,checkpointId:J,checkpointNs:_,limit:(N==null?void 0:N.limit)??hg,beforeId:z});Je(we,"prepend",te??void 0)}finally{O(!1)}}},[l,Je,M,J,_,Y,W]),jn=y.useCallback(async(N,z)=>{var tr;const te=F.current;!te&&!(z!=null&&z.payloadExtras)&&console.warn("[ChatSessionProvider] No thread ID - message will create new thread");const we=(z==null?void 0:z.attachments)||[],{contentParts:H,filesInfo:U}=await Qm(l,we),be=[...H];N&&N.trim()&&be.push({type:"text",text:N.trim()});const We={id:((tr=crypto.randomUUID)==null?void 0:tr.call(crypto))||`user-${Date.now()}`,role:"user",content:be,createdAt:new Date().toISOString(),checkpointId:(z==null?void 0:z.checkpointId)??B.lastCheckpointId??void 0,checkpointNs:(z==null?void 0:z.checkpointNs)??B.lastCheckpointNs??void 0};xe(We);const Xe={...We,content:be},lt={...(z==null?void 0:z.payloadExtras)??{}},Xt=we.length>0,dn={...te?{threadId:te}:{},payload:{messages:[Xe],files_info:U,...o&&Xt&&s?{active_agent:s}:{},...lt},checkpointId:(z==null?void 0:z.checkpointId)??B.lastCheckpointId??void 0,checkpointNs:(z==null?void 0:z.checkpointNs)??B.lastCheckpointNs??void 0,nodeFilter:z==null?void 0:z.nodeFilter,config:z==null?void 0:z.config};ge(dn,{onError:k=>{console.warn("[ChatSessionProvider] Stream error:",k)},onOpen:({threadId:k,created:K})=>{!F.current&&k&&(B.messages.length<=1&&(ce.current=k),T(k))},onGap:re})},[l,o,s,re,B.lastCheckpointId,B.lastCheckpointNs,B.messages.length,xe,ge]),Zn=y.useCallback(async(N,z,te)=>{const we=F.current;if(!we)throw new Error("No active thread to handle interrupt");try{const H=z?te??!0:!1;await l.resume({threadId:we,value:H})}catch(H){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${N}:`,H),H}},[l]);y.useEffect(()=>{if(a==null||a(C),C)try{localStorage.setItem("lastThreadId",C)}catch(N){console.warn("[ChatSessionProvider] Failed to persist lastThreadId:",N)}},[C,a]),y.useEffect(()=>{let N=!0;return(async()=>{try{if(await Ue(),!N)return;if(!r&&!t)try{const te=localStorage.getItem("lastThreadId");te&&(T(te),n&&await Tt(te))}catch(te){console.warn("[ChatSessionProvider] Failed to restore last thread:",te)}else t&&n&&await Tt(t)}catch(te){console.error("[ChatSessionProvider] Initialization failed:",te),i==null||i(String(te))}})(),()=>{N=!1}},[]),y.useEffect(()=>{const N=F.current;if(!N||Oe.current!==N)return;const z={threadId:N,messages:B.messages.slice(),hasMore:M,nextCursor:Y,checkpointId:B.lastCheckpointId??null,checkpointNs:B.lastCheckpointNs??null},te=ne.current.get(N);(!te||te.messages.length!==z.messages.length||te.messages.some((H,U)=>{var be;return(H==null?void 0:H.id)!==((be=z.messages[U])==null?void 0:be.id)})||(te==null?void 0:te.hasMore)!==z.hasMore||(te==null?void 0:te.nextCursor)!==z.nextCursor||(te==null?void 0:te.checkpointId)!==z.checkpointId||(te==null?void 0:te.checkpointNs)!==z.checkpointNs)&&(ne.current.set(N,z),Me.current&&window.clearTimeout(Me.current),Me.current=window.setTimeout(()=>{try{g(z,100)}catch(H){console.warn("[ChatSessionProvider] Failed to persist thread payload:",H)}},mg))},[M,Y,B.lastCheckpointId,B.lastCheckpointNs,B.messages]);const un=y.useMemo(()=>({threads:S,currentThreadId:C,isLoadingThreads:I,isLoadingThread:P,setCurrentThreadId:T,createThread:Ke,deleteThread:at,renameThread:Ct,refreshThreads:Ue,loadThread:Tt,clearCurrentThread:wr,listCheckpoints:br,navigateToCheckpoint:Jn,returnToLatest:_n}),[wr,Ke,C,at,P,I,br,Tt,Jn,Ue,Ct,_n,S]),Qn=y.useMemo(()=>({messages:B.messages,assemblingId:B.assemblingId,lastUserMessage:null,hasMoreHistory:M,isLoadingHistory:W,send:jn,stop:ke,loadOlderMessages:yr,clearMessages:st,handleInterrupt:Zn}),[st,Zn,M,W,yr,B.assemblingId,B.messages,jn,ke]),er=y.useMemo(()=>({isStreaming:ve,error:Re,streamingAssistantId:B.assemblingId,lastCheckpointId:B.lastCheckpointId??null,lastCheckpointNs:B.lastCheckpointNs??null}),[ve,B.assemblingId,B.lastCheckpointId,B.lastCheckpointNs,Re]);return c.jsx(fg.Provider,{value:!0,children:c.jsx(Dl.Provider,{value:er,children:c.jsx(Ol.Provider,{value:un,children:c.jsx(Ml.Provider,{value:Qn,children:e})})})})}function go(){const e=y.useContext(Ol);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Qs(){const e=y.useContext(Ml);if(!e)throw new Error("useMessages must be used within ChatSessionProvider");return e}function Bl(){const e=y.useContext(Dl);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function xo({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(Xm,{apiConfig:t,children:c.jsx(xg,{initialThreadId:n,autoLoadInitial:r,disableAutoRestore:o,enableFileAgentRouting:s,fileAgentId:i,onError:a,onThreadChange:l,children:e})})}function Q(...e){return kp.twMerge(Tp.clsx(e))}const vg=to.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"}}),He=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Rn.Slot:"button";return c.jsx(i,{className:Q(vg({variant:t,size:n,className:e})),ref:s,...o})});He.displayName="Button";const Hl=m.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:Q("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}));Hl.displayName="Textarea";function wg({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,onSend:i,onCancelEdit:a,onStop:l,className:u="",textareaClassName:d="",allowEmptySend:f=!1}){const[h,p]=y.useState(e),[w,v]=y.useTransition(),g=y.useRef(null);y.useEffect(()=>{p(e??""),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const x=y.useCallback(()=>{const A=g.current;A&&(A.style.height="auto",A.style.height=`${A.scrollHeight}px`)},[]);y.useEffect(()=>{x()},[x]);const b=y.useCallback(async A=>{A&&A.preventDefault();const P=(h??"").trim();!P&&!f||v(()=>{try{const j=i(P);j&&typeof j.then=="function"?j.then(()=>{p(""),g.current&&(g.current.style.height="auto")}).catch(()=>{}):(p(""),g.current&&(g.current.style.height="auto"))}catch{}})},[h,i,f]),S=y.useCallback(A=>{p(A.target.value),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),E=y.useCallback(A=>{A.key==="Enter"&&!A.shiftKey?(A.preventDefault(),b()):A.key==="Escape"&&t&&(A.preventDefault(),a==null||a())},[b,t,a]),I=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${d}`;return c.jsx("form",{onSubmit:A=>void b(A),className:`w-full ${u}`,children:c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsx("div",{className:"flex-1",children:c.jsx(Hl,{ref:g,value:h,onChange:S,onKeyDown:E,placeholder:t?"Edit your message...":n,className:I,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),c.jsx("div",{children:r?c.jsx(He,{type:"button",onClick:()=>{l==null||l()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!l,children:c.jsx(se.Square,{size:16})}):c.jsx(He,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||w,children:c.jsx(se.Send,{size:16})})})]})})}const bg=y.memo(wg),vo=0,vn=1,sr=2,Ul=4;function Wl(e){return()=>e}function yg(e){e()}function Vl(e,t){return n=>e(t(n))}function Kl(e,t){return()=>e(t)}function Sg(e,t){return n=>e(t,n)}function ei(e){return e!==void 0}function Cg(...e){return()=>{e.map(yg)}}function ir(){}function wo(e,t){return t(e),e}function Tg(e,t){return t(e)}function rt(...e){return e}function qe(e,t){return e(vn,t)}function Pe(e,t){e(vo,t)}function ti(e){e(sr)}function ut(e){return e(Ul)}function fe(e,t){return qe(e,Sg(t,vo))}function Wt(e,t){const n=e(vn,r=>{n(),t(r)});return n}function ql(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Gl(e,t){return e===t}function ot(e=Gl){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Se(e){return t=>n=>{e(n)&&t(n)}}function ie(e){return t=>Vl(t,e)}function Zt(e){return t=>()=>{t(e)}}function V(e,...t){const n=kg(...t);return(r,o)=>{switch(r){case sr:ti(e);return;case vn:return qe(e,n(o))}}}function Qt(e,t){return n=>r=>{n(t=e(t,r))}}function Dn(e){return t=>n=>{e>0?e--:t(n)}}function hn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function De(...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);qe(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 kg(...e){return t=>e.reduceRight(Tg,t)}function Eg(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case vn:return s?n===s?void 0:(r(),n=s,t=qe(e,s),t):(r(),ir);case sr:r(),n=null;return}}}function X(e){let t=e;const n=$e();return(r,o)=>{switch(r){case vo:t=o;break;case vn:{o(t);break}case Ul:return t}return n(r,o)}}function vt(e,t){return wo(X(t),n=>fe(e,n))}function $e(){const e=[];return(t,n)=>{switch(t){case vo:e.slice().forEach(r=>{r(n)});return;case sr:e.splice(0,e.length);return;case vn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function jt(e){return wo($e(),t=>fe(e,t))}function Ve(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Ig(),singleton:n}}const Ig=()=>Symbol();function Ng(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function ft(...e){const t=$e(),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);qe(s,l=>{n[i]=l,r=r|a,r===o&&Pe(t,n)})}),function(s,i){switch(s){case sr:{ti(t);return}case vn:return r===o&&i(n),qe(t,i)}}}function ye(e,t=Gl){return V(e,ot(t))}function ni(...e){return function(t,n){switch(t){case sr:return;case vn:return Cg(...e.map(r=>qe(r,n)))}}}var Nt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Nt||{});const Ag={0:"debug",3:"error",1:"log",2:"warn"},_g=()=>typeof globalThis>"u"?window:globalThis,wn=Ve(()=>{const e=X(3);return{log:X((t,n,r=1)=>{var o;const s=(o=_g().VIRTUOSO_LOG_LEVEL)!=null?o:ut(e);r>=s&&console[Ag[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Ln(e,t,n){return ri(e,t,n).callbackRef}function ri(e,t,n){const r=y.useRef(null);let o=i=>{};const s=y.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 jg(e,t,n,r,o,s,i,a,l){const u=y.useCallback(d=>{const f=Rg(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const p=h.lastElementChild.dataset.viewportType==="window";let w;p&&(w=h.ownerDocument.defaultView);const v=i?a?i.scrollLeft:i.scrollTop:p?a?w.scrollX||w.document.documentElement.scrollLeft:w.scrollY||w.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:p?a?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,x=i?a?i.offsetWidth:i.offsetHeight:p?a?w.innerWidth:w.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(v,0),viewportHeight:x}),s==null||s(a?Yl("column-gap",getComputedStyle(d).columnGap,o):Yl("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return ri(u,n,l)}function Rg(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const 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},Nt.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 Yl(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Nt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Xl(e,t,n){const r=y.useRef(null),o=y.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const u=l.getBoundingClientRect(),d=u.width;let f,h;if(t){const p=t.getBoundingClientRect(),w=u.top-p.top;h=p.height-Math.max(0,w),f=w+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}=ri(o,!0,n),a=y.useCallback(()=>{o(i.current)},[o,i]);return y.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 yt=Ve(()=>{const e=$e(),t=$e(),n=X(0),r=$e(),o=X(0),s=$e(),i=$e(),a=X(0),l=X(0),u=X(0),d=X(0),f=$e(),h=$e(),p=X(!1),w=X(!1),v=X(!1);return fe(V(e,ie(({scrollTop:g})=>g)),t),fe(V(e,ie(({scrollHeight:g})=>g)),i),fe(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:w,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:v,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),_r={lvl:0};function Jl(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 Qe(e){return e===_r}function jr(e,t){if(!Qe(e))return t===e.k?e.v:t<e.k?jr(e.l,t):jr(e.r,t)}function Vt(e,t,n="k"){if(Qe(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=Vt(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return Vt(e.l,t,n)}function Rt(e,t,n){return Qe(e)?ec(t,n,1):t===e.k?pt(e,{k:t,v:n}):t<e.k?tc(pt(e,{l:Rt(e.l,t,n)})):tc(pt(e,{r:Rt(e.r,t,n)}))}function ar(){return _r}function bo(e,t,n){if(Qe(e))return[];const r=Vt(e,t)[0];return Pg(si(e,r,n))}function oi(e,t){if(Qe(e))return _r;const{k:n,l:r,r:o}=e;if(t===n){if(Qe(r))return o;if(Qe(o))return r;{const[s,i]=Ql(r);return yo(pt(e,{k:s,l:Zl(r),v:i}))}}else return t<n?yo(pt(e,{l:oi(r,t)})):yo(pt(e,{r:oi(o,t)}))}function Fn(e){return Qe(e)?[]:[...Fn(e.l),{k:e.k,v:e.v},...Fn(e.r)]}function si(e,t,n){if(Qe(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(si(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(si(s,t,n))),a}function yo(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(ii(t))return nc(pt(e,{lvl:n-1}));if(!Qe(t)&&!Qe(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(ii(e))return ai(pt(e,{lvl:n-1}));if(!Qe(r)&&!Qe(r.l)){const o=r.l,s=ii(o)?r.lvl-1:r.lvl;return pt(o,{l:pt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:ai(pt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function pt(e,t){return ec(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 Zl(e){return Qe(e.r)?e.l:yo(pt(e,{r:Zl(e.r)}))}function ii(e){return Qe(e)||e.lvl>e.r.lvl}function Ql(e){return Qe(e.r)?[e.k,e.v]:Ql(e.r)}function ec(e,t,n,r=_r,o=_r){return{k:e,l:r,lvl:n,r:o,v:t}}function tc(e){return ai(nc(e))}function nc(e){const{l:t}=e;return!Qe(t)&&t.lvl===e.lvl?pt(t,{r:pt(e,{l:t.r})}):e}function ai(e){const{lvl:t,r:n}=e;return!Qe(n)&&!Qe(n.r)&&n.lvl===t&&n.r.lvl===t?pt(n,{l:pt(e,{r:n.l}),lvl:t+1}):e}function Pg(e){return Jl(e,({k:t,v:n})=>({index:t,value:n}))}function rc(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Rr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const li=Ve(()=>({recalcInProgress:X(!1)}),[],{singleton:!0});function oc(e,t,n){return e[So(e,t,n)]}function So(e,t,n,r=0){let o=e.length-1;for(;r<=o;){const s=Math.floor((r+o)/2),i=e[s],a=n(i,t);if(a===0)return s;if(a===-1){if(o-r<2)return s-1;o=s-1}else{if(o===r)return s;r=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function Og(e,t,n,r){const o=So(e,t,r),s=So(e,n,r,o);return e.slice(o,s+1)}function bn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Co(e){return!Qe(e.groupOffsetTree)}function ci({index:e},t){return t===e?0:t<e?-1:1}function Mg(){return{groupIndices:[],groupOffsetTree:ar(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:ar()}}function Dg(e,t){let n=Qe(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Qe(e)){e=Rt(e,0,s);continue}const a=bo(e,i-1,o+1);if(a.some(Ug(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=oi(e,f)):(u=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=Rt(e,o+1,h));u&&(e=Rt(e,i,s))}return[e,n]}function Lg(e){return typeof e.groupIndex<"u"}function Fg({offset:e},t){return t===e?0:t<e?-1:1}function Pr(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=oc(t,e,ci),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function sc(e,t){if(!Co(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function ic(e,t,n){if(Lg(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=sc(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function $g(e,t,n,r=0){return r>0&&(t=Math.max(t,oc(e,r,ci).offset)),Jl(Og(e,t,n,Fg),Hg)}function zg(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Nt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&Qe(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((w,v)=>Rt(Rt(w,v,h),v+1,p),i)}else[i,a]=Dg(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=ui(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>Rt(h,p,Pr(p,f,o)),ar()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function Bg(e){return Fn(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 ac(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 ui(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=So(o,t-1,ci),a=o[l].offset;const u=Vt(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===Vt(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:u,value:d}of bo(n,t,1/0)){const f=u-s,h=f*i+a+f*r;o.push({index:u,offset:h,size:d}),s=u,a=h,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function Hg(e){return{index:e.index,value:e}}function Ug(e){const{endIndex:t,size:n,startIndex:r}=e;return o=>o.start===r&&(o.end===t||o.end===1/0)&&o.value===n}const Wg={offsetHeight:"height",offsetWidth:"width"},en=Ve(([{log:e},{recalcInProgress:t}])=>{const n=$e(),r=$e(),o=vt(r,0),s=$e(),i=$e(),a=X(0),l=X([]),u=X(void 0),d=X(void 0),f=X((C,T)=>bn(C,Wg[T])),h=X(void 0),p=X(0),w=Mg(),v=vt(V(n,De(l,e,p),Qt(zg,w),ot()),w),g=vt(V(l,ot(),Qt((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),ie(({prev:C})=>C)),[]);fe(V(l,Se(C=>C.length>0),De(v,p),ie(([C,T,I])=>{const A=C.reduce((P,j,M)=>Rt(P,j,Pr(j,T.offsetTree,I)||M),ar());return{...T,groupIndices:C,groupOffsetTree:A}})),v),fe(V(r,De(v),Se(([C,{lastIndex:T}])=>C<T),ie(([C,{lastIndex:T,lastSize:I}])=>[{endIndex:T,size:I,startIndex:C}])),n),fe(u,d);const x=vt(V(u,ie(C=>C===void 0)),!0);fe(V(d,Se(C=>C!==void 0&&Qe(ut(v).sizeTree)),ie(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=jt(V(n,De(v),Qt(({sizes:C},[T,I])=>({changed:I!==C,sizes:I}),{changed:!1,sizes:w}),ie(C=>C.changed)));qe(V(a,Qt((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),ie(C=>C.diff)),C=>{const{groupIndices:T}=ut(v);if(C>0)Pe(t,!0),Pe(s,C+ac(C,T));else if(C<0){const I=ut(g);I.length>0&&(C-=ac(-C,I)),Pe(i,C)}}),qe(V(a,De(e)),([C,T])=>{C<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Nt.ERROR)});const S=jt(s);fe(V(s,De(v),ie(([C,T])=>{const I=T.groupIndices.length>0,A=[],P=T.lastSize;if(I){const j=jr(T.sizeTree,0);let M=0,L=0;for(;M<C;){const O=T.groupIndices[L],Y=T.groupIndices.length===L+1?1/0:T.groupIndices[L+1]-O-1;A.push({endIndex:O,size:j,startIndex:O}),A.push({endIndex:O+1+Y-1,size:P,startIndex:O+1}),L++,M+=Y+1}const W=Fn(T.sizeTree);return M!==C&&W.shift(),W.reduce((O,{k:Y,v:q})=>{let J=O.ranges;return O.prevSize!==0&&(J=[...O.ranges,{endIndex:Y+C-1,size:O.prevSize,startIndex:O.prevIndex}]),{prevIndex:Y+C,prevSize:q,ranges:J}},{prevIndex:C,prevSize:0,ranges:A}).ranges}return Fn(T.sizeTree).reduce((j,{k:M,v:L})=>({prevIndex:M+C,prevSize:L,ranges:[...j.ranges,{endIndex:M+C-1,size:j.prevSize,startIndex:j.prevIndex}]}),{prevIndex:0,prevSize:P,ranges:[]}).ranges})),n);const E=jt(V(i,De(v,p),ie(([C,{offsetTree:T},I])=>{const A=-C;return Pr(A,T,I)})));return fe(V(i,De(v,p),ie(([C,T,I])=>{if(T.groupIndices.length>0){if(Qe(T.sizeTree))return T;let A=ar();const P=ut(g);let j=0,M=0,L=0;for(;j<-C;){L=P[M];const W=P[M+1]-L-1;M++,j+=W+1}if(A=Fn(T.sizeTree).reduce((W,{k:O,v:Y})=>Rt(W,Math.max(0,O+C),Y),A),j!==-C){const W=jr(T.sizeTree,L);A=Rt(A,0,W);const O=Vt(T.sizeTree,-C+1)[1];A=Rt(A,1,O)}return{...T,sizeTree:A,...ui(T.offsetTree,0,A,I)}}else{const A=Fn(T.sizeTree).reduce((P,{k:j,v:M})=>Rt(P,Math.max(0,j+C),M),ar());return{...T,sizeTree:A,...ui(T.offsetTree,0,A,I)}}})),v),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:v,statefulTotalCount:o,totalCount:r,trackItemSizes:x,unshiftWith:s}},rt(wn,li),{singleton:!0});function Vg(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const lc=Ve(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=$e(),i=$e(),a=jt(V(s,ie(Vg)));return fe(V(a,ie(l=>l.totalCount)),n),fe(V(a,ie(l=>l.groupIndices)),e),fe(V(ft(o,t,r),Se(([l,u])=>Co(u)),ie(([l,u,d])=>Vt(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),ot(),ie(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},rt(en,yt)),yn=Ve(([{log:e}])=>{const t=X(!1),n=jt(V(t,Se(r=>r),ot()));return qe(t,r=>{r&&ut(e)("props updated",{},Nt.DEBUG)}),{didMount:n,propsReady:t}},rt(wn),{singleton:!0}),Kg=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function cc(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Kg)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Or=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=$e(),w=$e(),v=X(0);let g=null,x=null,b=null;function S(){g&&(g(),g=null),b&&(b(),b=null),x&&(clearTimeout(x),x=null),Pe(l,!1)}return fe(V(p,De(n,f,r,v,a,i,h),De(e,s,o),ie(([[E,C,T,I,A,P,j,M],L,W,O])=>{const Y=cc(E),{align:q,behavior:J,offset:$}=Y,_=I-1,G=ic(Y,C,_);let B=Pr(G,C.offsetTree,L)+P;q==="end"?(B+=W+Vt(C.sizeTree,G)[1]-T+O,G===_&&(B+=j)):q==="center"?B+=(W+Vt(C.sizeTree,G)[1]-T+O)/2:B-=A,$&&(B+=$);const he=de=>{S(),de?(M("retrying to scroll to",{location:E},Nt.DEBUG),Pe(p,E)):(Pe(w,!0),M("list did not change, scroll successful",{},Nt.DEBUG))};if(S(),J==="smooth"){let de=!1;b=qe(t,xe=>{de=de||xe}),g=Wt(d,()=>{he(de)})}else g=Wt(V(t,qg(150)),he);return x=setTimeout(()=>{S()},1200),Pe(l,!0),M("scrolling from index to",{behavior:J,index:G,top:B},Nt.DEBUG),{behavior:J,top:B}})),u),{scrollTargetReached:w,scrollToIndex:p,topListHeight:v}},rt(en,yt,wn),{singleton:!0});function qg(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function di(e,t){e==0?t():requestAnimationFrame(()=>{di(e-1,t)})}function fi(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Mr=Ve(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=X(!0),l=X(0),u=X(!0);return fe(V(i,De(l),Se(([d,f])=>!!f),Zt(!1)),a),fe(V(i,De(l),Se(([d,f])=>!!f),Zt(!1)),u),qe(V(ft(t,i),De(a,n,e,u),Se(([[,d],f,{sizeTree:h},p,w])=>d&&(!Qe(h)||ei(p))&&!f&&!w),De(l)),([,d])=>{Wt(o,()=>{Pe(u,!0)}),di(4,()=>{Wt(r,()=>{Pe(a,!0)}),Pe(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},rt(en,yt,Or,yn),{singleton:!0});function uc(e,t){return Math.abs(e-t)<1.01}const Dr="up",Lr="down",Gg="none",Yg={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Xg=0,Fr=Ve(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=X(!1),a=X(!0),l=$e(),u=$e(),d=X(4),f=X(Xg),h=vt(V(ni(V(ye(o),Dn(1),Zt(!0)),V(ye(o),Dn(1),Zt(!1),ql(100))),ot()),!1),p=vt(V(ni(V(n,Zt(!0)),V(n,Zt(!1),ql(200))),ot()),!1);fe(V(ft(ye(o),ye(f)),ie(([b,S])=>b<=S),ot()),a),fe(V(a,hn(50)),u);const w=jt(V(ft(r,ye(s),ye(t),ye(e),ye(d)),Qt((b,[{scrollHeight:S,scrollTop:E},C,T,I,A])=>{const P=E+C-S>-A,j={scrollHeight:S,scrollTop:E,viewportHeight:C};if(P){let L,W;return E>b.state.scrollTop?(L="SCROLLED_DOWN",W=b.state.scrollTop-E):(L="SIZE_DECREASED",W=b.state.scrollTop-E||b.scrollTopDelta),{atBottom:!0,atBottomBecause:L,scrollTopDelta:W,state:j}}let M;return j.scrollHeight>b.state.scrollHeight?M="SIZE_INCREASED":C<b.state.viewportHeight?M="VIEWPORT_HEIGHT_DECREASING":E<b.state.scrollTop?M="SCROLLING_UPWARDS":M="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:M,state:j}},Yg),ot((b,S)=>b&&b.atBottom===S.atBottom))),v=vt(V(r,Qt((b,{scrollHeight:S,scrollTop:E,viewportHeight:C})=>{if(uc(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:E};{const T=S-(E+C)<1;return b.scrollTop!==E&&T?{changed:!0,jump:b.scrollTop-E,scrollHeight:S,scrollTop:E}:{changed:!0,jump:0,scrollHeight:S,scrollTop:E}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Se(b=>b.changed),ie(b=>b.jump)),0);fe(V(w,ie(b=>b.atBottom)),i),fe(V(i,hn(50)),l);const g=X(Lr);fe(V(r,ie(({scrollTop:b})=>b),ot(),Qt((b,S)=>ut(p)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?Dr:Lr,prevScrollTop:S},{direction:Lr,prevScrollTop:0}),ie(b=>b.direction)),g),fe(V(r,hn(50),Zt(Gg)),g);const x=X(0);return fe(V(h,Se(b=>!b),Zt(0)),x),fe(V(o,hn(100),De(h),Se(([b,S])=>!!S),Qt(([b,S],[E])=>[S,E],[0,0]),ie(([b,S])=>S-b)),x),{atBottomState:w,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:v,scrollDirection:g,scrollVelocity:x}},rt(yt)),To="top",ko="bottom",dc="none";function fc(e,t,n){return typeof e=="number"?n===Dr&&t===To||n===Lr&&t===ko?e:0:n===Dr?t===To?e.main:e.reverse:t===ko?e.main:e.reverse}function hc(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const hi=Ve(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=$e(),i=X(0),a=X(0),l=X(0),u=vt(V(ft(ye(r),ye(o),ye(n),ye(s,Rr),ye(l),ye(i),ye(t),ye(e),ye(a)),ie(([d,f,h,[p,w],v,g,x,b,S])=>{const E=d-b,C=g+x,T=Math.max(h-E,0);let I=dc;const A=hc(S,To),P=hc(S,ko);return p-=b,p+=h+x,w+=h+x,w-=b,p>d+C-A&&(I=Dr),w<d-T+f+P&&(I=Lr),I!==dc?[Math.max(E-h-fc(v,To,I)-A,0),E-T-x+f+fc(v,ko,I)+P]:null}),Se(d=>d!=null),ot(Rr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},rt(yt),{singleton:!0});function Jg(e,t,n){if(Co(t)){const r=sc(e,t);return[{index:Vt(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 pi={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Eo(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,w=h-d;return{bottom:d,firstItemIndex:s,items:mc(e,o,s),offsetBottom:w,offsetTop:u,top:p,topItems:mc(t,o,s),topListHeight:t.reduce((v,g)=>g.size+v,0),totalCount:n}}function pc(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=fi(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return Eo(u,[],a,o,n,r)}function mc(e,t,n){if(e.length===0)return[];if(!Co(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=bo(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 $n=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:w}])=>{const v=X([]),g=X(0),x=$e();fe(s.topItemsIndexes,v);const b=vt(V(ft(p,w,ye(l,Rr),ye(o),ye(r),ye(u),d,ye(v),ye(t),ye(n),e),Se(([T,I,,A,,,,,,,P])=>{const j=P&&P.length!==A;return T&&!I&&!j}),ie(([,,[T,I],A,P,j,M,L,W,O,Y])=>{const q=P,{offsetTree:J,sizeTree:$}=q,_=ut(g);if(A===0)return{...pi,totalCount:A};if(T===0&&I===0)return _===0?{...pi,totalCount:A}:pc(_,j,P,W,O,Y||[]);if(Qe($))return _>0?null:Eo(Jg(fi(j,A),q,Y),[],A,O,q,W);const G=[];if(L.length>0){const _e=L[0],Ce=L[L.length-1];let F=0;for(const D of bo($,_e,Ce)){const Z=D.value,ee=Math.max(D.start,_e),ce=Math.min(D.end,Ce);for(let ne=ee;ne<=ce;ne++)G.push({data:Y==null?void 0:Y[ne],index:ne,offset:F,size:Z}),F+=Z}}if(!M)return Eo([],G,A,O,q,W);const B=L.length>0?L[L.length-1]+1:0,he=$g(J,T,I,B);if(he.length===0)return null;const de=A-1,xe=wo([],_e=>{for(const Ce of he){const F=Ce.value;let D=F.offset,Z=Ce.start;const ee=F.size;if(F.offset<T){Z+=Math.floor((T-F.offset+O)/(ee+O));const ne=Z-Ce.start;D+=ne*ee+ne*O}Z<B&&(D+=(B-Z)*ee,Z=B);const ce=Math.min(Ce.end,de);for(let ne=Z;ne<=ce&&!(D>=I);ne++)_e.push({data:Y==null?void 0:Y[ne],index:ne,offset:D,size:ee}),D+=ee+O}});return Eo(xe,G,A,O,q,W)}),Se(T=>T!==null),ot()),pi);fe(V(e,Se(ei),ie(T=>T==null?void 0:T.length)),o),fe(V(b,ie(T=>T.topListHeight)),f),fe(f,a),fe(V(b,ie(T=>[T.top,T.bottom])),i),fe(V(b,ie(T=>T.items)),x);const S=jt(V(b,Se(({items:T})=>T.length>0),De(o,e),Se(([{items:T},I])=>T[T.length-1].originalIndex===I-1),ie(([,T,I])=>[T-1,I]),ot(Rr),ie(([T])=>T))),E=jt(V(b,hn(200),Se(({items:T,topItems:I})=>T.length>0&&T[0].originalIndex===I.length),ie(({items:T})=>T[0].index),ot())),C=jt(V(b,Se(({items:T})=>T.length>0),ie(({items:T})=>{let I=0,A=T.length-1;for(;T[I].type==="group"&&I<A;)I++;for(;T[A].type==="group"&&A>I;)A--;return{endIndex:T[A].index,startIndex:T[I].index}}),ot(rc)));return{endReached:S,initialItemCount:g,itemsRendered:x,listState:b,rangeChanged:C,startReached:E,topItemsIndexes:v,...h}},rt(en,lc,hi,Mr,Or,Fr,yn,li),{singleton:!0}),gc=Ve(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=$e(),i=vt(V(ft(n,e,r,t,o),ie(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return fe(ye(i),s),{totalListHeight:i,totalListHeightChanged:s}},rt(yt,$n),{singleton:!0}),Zg=Ve(([{viewportHeight:e},{totalListHeight:t}])=>{const n=X(!1),r=vt(V(ft(n,e,t),Se(([o])=>o),ie(([,o,s])=>Math.max(0,o-s)),hn(0),ot()),0);return{alignToBottom:n,paddingTopAddition:r}},rt(yt,gc),{singleton:!0}),xc=Ve(()=>({context:X(null)})),Qg=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...o},viewportBottom:s,viewportTop:i})=>t<i?{...o,align:n??"start",behavior:r}:e>s?{...o,align:n??"end",behavior:r}:null,vc=Ve(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:u}])=>{const d=$e();return fe(V(d,De(t,l,n,s,o,r,a),De(e),ie(([[f,h,p,w,v,g,x,b],S])=>{const{align:E,behavior:C,calculateViewLocation:T=Qg,done:I,...A}=f,P=ic(f,h,w-1),j=Pr(P,h.offsetTree,S)+v+g,M=j+Vt(h.sizeTree,P)[1],L=b+g,W=b+p-x,O=T({itemBottom:M,itemTop:j,locationParams:{align:E,behavior:C,...A},viewportBottom:W,viewportTop:L});return O?I&&Wt(V(i,Se(Y=>!Y),Dn(ut(i)?1:2)),I):I&&I(),O}),Se(f=>f!==null)),u),{scrollIntoView:d}},rt(en,yt,Or,$n,wn),{singleton:!0});function wc(e){return e?e==="smooth"?"smooth":"auto":!1}const ex=(e,t)=>typeof e=="function"?wc(e(t)):t&&wc(e),tx=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 w=X(!1),v=$e();let g=null;function x(C){Pe(i,{align:"end",behavior:C,index:"LAST"})}qe(V(ft(V(ye(t),Dn(1)),l),De(ye(w),s,a,f),ie(([[C,T],I,A,P,j])=>{let M=T&&P,L="auto";return M&&(L=ex(I,A||j),M=M&&!!L),{followOutputBehavior:L,shouldFollow:M,totalCount:C}}),Se(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{g&&(g(),g=null),ut(n)?requestAnimationFrame(()=>{ut(d)("following output to ",{totalCount:T},Nt.DEBUG),x(C)}):g=Wt(e,()=>{ut(d)("following output to ",{totalCount:T},Nt.DEBUG),x(C),g=null})});function b(C){const T=Wt(o,I=>{C&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(ut(d)("scrolling to bottom due to increased size",{},Nt.DEBUG),x("auto"))});setTimeout(T,100)}qe(V(ft(ye(w),t,u),Se(([C,,T])=>C&&T),Qt(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),Se(({refreshed:C})=>C),De(w,t)),([,C])=>{ut(a)&&b(C!==!1)}),qe(v,()=>{b(ut(w)!==!1)}),qe(ft(ye(w),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&x("auto")});const S=X(null),E=$e();return fe(ni(V(ye(r),ie(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),V(ye(t))),E),qe(V(ft(V(E,Dn(1)),l),De(ye(S),a,f,h),ie(([[C,T],I,A,P,j])=>T&&A&&(I==null?void 0:I({context:j,totalCount:C,scrollingInProgress:P}))),Se(C=>!!C),hn(0)),C=>{g&&(g(),g=null),ut(n)?requestAnimationFrame(()=>{ut(d)("scrolling into view",{}),Pe(p,C)}):g=Wt(e,()=>{ut(d)("scrolling into view",{}),Pe(p,C),g=null})}),{autoscrollToBottom:v,followOutput:w,scrollIntoViewOnChange:S}},rt(en,Fr,Or,Mr,yn,wn,yt,xc,vc)),nx=Ve(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(fe(V(a,De(s),Se(([,l])=>l!==0),De(o,r,t,n,e),ie(([[,l],u,d,f,h,p=[]])=>pc(l,u,d,f,h,p))),i),{}),rt(en,Mr,$n,yn),{singleton:!0}),rx=Ve(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=X(0);return qe(V(e,De(r),Se(([,o])=>o!==0),ie(([,o])=>({top:o}))),o=>{Wt(V(n,Dn(1),Se(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Pe(t,o)})})}),{initialScrollTop:r}},rt(yn,yt,$n),{singleton:!0}),bc=Ve(([{scrollVelocity:e}])=>{const t=X(!1),n=$e(),r=X(!1);return fe(V(e,De(r,t,n),Se(([o,s])=>!!s),ie(([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}),ot()),t),qe(V(ft(t,e,n),De(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},rt(Fr),{singleton:!0}),mi=Ve(([{scrollContainerState:e,scrollTo:t}])=>{const n=$e(),r=$e(),o=$e(),s=X(!1),i=X(void 0);return fe(V(ft(n,r),ie(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),fe(V(t,De(r),ie(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},rt(yt)),ox=Ve(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=$e(),d=X(void 0),f=X(null),h=X(null);return fe(a,f),fe(l,h),qe(V(u,De(t,r,i,f,h,n)),([p,w,v,g,x,b,S])=>{const E=Bg(w.sizeTree);g&&x!==null&&b!==null&&(v=x.scrollTop-b.offsetTop),v-=S,p({ranges:E,scrollTop:v})}),fe(V(d,Se(ei),ie(sx)),o),fe(V(s,De(d),Se(([,p])=>p!==void 0),ot(),ie(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},rt(en,yt,Mr,yn,mi));function sx(e){return{align:"start",index:0,offset:e.scrollTop}}const ix=Ve(([{topItemsIndexes:e}])=>{const t=X(0);return fe(V(t,Se(n=>n>=0),ie(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},rt($n));function yc(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const ax=yc(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),lx=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:w}])=>{const v=jt(V(l,De(i),Qt(([,x,b,S],[{bottom:E,items:C,offsetBottom:T,totalCount:I},A])=>{const P=E+T;let j=0;return b===I&&x.length>0&&C.length>0&&(C[0].originalIndex===0&&x[0].originalIndex===0||(j=P-S,j!==0&&(j+=A))),[j,C,I,P]},[0,[],0,0]),Se(([x])=>x!==0),De(r,a,n,o,p,w),Se(([,x,b,S,,,E])=>!E&&!S&&x!==0&&b===Dr),ie(([[x],,,,,b])=>(b("Upward scrolling compensation",{amount:x},Nt.DEBUG),x))));function g(x){x>0?(Pe(t,{behavior:"auto",top:-x}),Pe(e,0)):(Pe(e,0),Pe(t,{behavior:"auto",top:-x}))}return qe(V(v,De(e,s)),([x,b,S])=>{S&&ax()?Pe(e,b-x):g(-x)}),qe(V(ft(vt(s,!1),e,w),Se(([x,b,S])=>!x&&!S&&b!==0),ie(([x,b])=>b),hn(1)),g),fe(V(f,ie(x=>({top:-x}))),t),qe(V(u,De(h,d),ie(([x,{groupIndices:b,lastSize:S,sizeTree:E},C])=>{function T(I){return I*(S+C)}if(b.length===0)return T(x);{let I=0;const A=jr(E,0);let P=0,j=0;for(;P<x;){P++,I+=A;let M=b.length===j+1?1/0:b[j+1]-b[j]-1;P+M>x&&(I-=A,M=x-P+1),P+=M,I+=T(M),j++}return I}})),x=>{Pe(e,x),requestAnimationFrame(()=>{Pe(t,{top:x}),requestAnimationFrame(()=>{Pe(e,0),Pe(w,!1)})})}),{deviation:e}},rt(yt,Fr,$n,en,wn,li)),cx=Ve(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),rt(hi,nx,yn,bc,gc,rx,Zg,mi,vc,wn,xc)),Sc=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:w},v,g,x,{listState:b,topItemsIndexes:S,...E},{scrollToIndex:C},T,{topItemCount:I},{groupCounts:A},P])=>(fe(E.rangeChanged,P.scrollSeekRangeChanged),fe(V(P.windowViewportRect,ie(j=>j.visibleHeight)),v.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:w,sizeRanges:a,topItemCount:I,topItemsIndexes:S,totalCount:d,...x,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...E,...P,...v,sizes:l,...g}),rt(en,Mr,yt,ox,tx,$n,Or,lx,ix,lc,cx));function ux(e,t){const n={},r={};let o=0;const s=e.length;for(;o<s;)r[e[o]]=1,o+=1;for(const i in t)Object.hasOwn(r,i)||(n[i]=t[i]);return n}const Io=typeof document<"u"?y.useLayoutEffect:y.useEffect;function Cc(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=y.createContext({});function l(g,x){g.propsReady&&Pe(g.propsReady,!1);for(const b of r){const S=g[t.required[b]];Pe(S,x[b])}for(const b of o)if(b in x){const S=g[t.optional[b]];Pe(S,x[b])}g.propsReady&&Pe(g.propsReady,!0)}function u(g){return s.reduce((x,b)=>(x[b]=S=>{const E=g[t.methods[b]];Pe(E,S)},x),{})}function d(g){return i.reduce((x,b)=>(x[b]=Eg(g[t.events[b]]),x),{})}const f=y.forwardRef((g,x)=>{const{children:b,...S}=g,[E]=y.useState(()=>wo(Ng(e),I=>{l(I,S)})),[C]=y.useState(Kl(d,E));Io(()=>{for(const I of i)I in S&&qe(C[I],S[I]);return()=>{Object.values(C).map(ti)}},[S,C,E]),Io(()=>{l(E,S)}),y.useImperativeHandle(x,Wl(u(E)));const T=n;return c.jsx(a.Provider,{value:E,children:n?c.jsx(T,{...ux([...r,...o,...i],S),children:b}):b})}),h=g=>{const x=y.useContext(a);return y.useCallback(b=>{Pe(x[g],b)},[x,g])},p=g=>{const x=y.useContext(a)[g],b=y.useCallback(S=>qe(x,S),[x]);return y.useSyncExternalStore(b,()=>ut(x),()=>ut(x))},w=g=>{const x=y.useContext(a)[g],[b,S]=y.useState(Kl(ut,x));return Io(()=>qe(x,E=>{E!==b&&S(Wl(E))}),[x,b]),b},v=y.version.startsWith("18")?p:w;return{Component:f,useEmitter:(g,x)=>{const b=y.useContext(a)[g];Io(()=>qe(b,x),[x,b])},useEmitterValue:v,usePublisher:h}}const Tc=y.createContext(void 0),kc=y.createContext(void 0),Ec=typeof document<"u"?y.useLayoutEffect:y.useEffect;function gi(e){return"self"in e}function dx(e){return"body"in e}function Ic(e,t,n,r=ir,o,s){const i=y.useRef(null),a=y.useRef(null),l=y.useRef(null),u=y.useCallback(h=>{let p,w,v;const g=h.target;if(dx(g)||gi(g)){const b=gi(g)?g:g.defaultView;v=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,w=s?b.innerWidth:b.innerHeight}else v=s?g.scrollLeft:g.scrollTop,p=s?g.scrollWidth:g.scrollHeight,w=s?g.offsetWidth:g.offsetHeight;const x=()=>{e({scrollHeight:p,scrollTop:Math.max(v,0),viewportHeight:w})};h.suppressFlushSync?x():Rs.flushSync(x),a.current!==null&&(v===a.current||v<=0||v===p-w)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);y.useEffect(()=>{const h=o||i.current;return r(o||i.current),u({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",u,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",u)}},[i,u,n,r,o]);function d(h){const p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const w=h.behavior==="smooth";let v,g,x;gi(p)?(g=Math.max(bn(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):(g=p[s?"scrollWidth":"scrollHeight"],v=bn(p,s?"width":"height"),x=p[s?"scrollLeft":"scrollTop"]);const b=g-v;if(h.top=Math.ceil(Math.max(Math.min(b,h.top),0)),uc(v,g)||h.top===x){e({scrollHeight:g,scrollTop:x,viewportHeight:v}),w&&t(!0);return}w?(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 xi="-webkit-sticky",Nc="sticky",vi=yc(()=>{if(typeof document>"u")return Nc;const e=document.createElement("div");return e.style.position=xi,e.style.position===xi?xi:Nc});function wi(e){return e}const fx=Ve(()=>{const e=X(a=>`Item ${a}`),t=X(a=>`Group ${a}`),n=X({}),r=X(wi),o=X("div"),s=X(ir),i=(a,l=null)=>vt(V(n,ie(u=>u[a]),ot()),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")}}),hx=Ve(([e,t])=>({...e,...t}),rt(Sc,fx)),px=({height:e})=>c.jsx("div",{style:{height:e}}),mx={overflowAnchor:"none",position:vi(),zIndex:1},Ac={overflowAnchor:"none"},gx={...Ac,display:"inline-block",height:"100%"},_c=y.memo(function({showTopList:e=!1}){const t=Ne("listState"),n=Lt("sizeRanges"),r=Ne("useWindowScroll"),o=Ne("customScrollParent"),s=Lt("windowScrollContainerState"),i=Lt("scrollContainerState"),a=o||r?s:i,l=Ne("itemContent"),u=Ne("context"),d=Ne("groupContent"),f=Ne("trackItemSizes"),h=Ne("itemSize"),p=Ne("log"),w=Lt("gap"),v=Ne("horizontalDirection"),{callbackRef:g}=jg(n,h,f,e?ir:a,p,w,o,v,Ne("skipAnimationFrameInResizeObserver")),[x,b]=y.useState(0);bi("deviation",O=>{x!==O&&b(O)});const S=Ne("EmptyPlaceholder"),E=Ne("ScrollSeekPlaceholder")||px,C=Ne("ListComponent"),T=Ne("ItemComponent"),I=Ne("GroupComponent"),A=Ne("computeItemKey"),P=Ne("isSeeking"),j=Ne("groupIndices").length>0,M=Ne("alignToBottom"),L=Ne("initialItemFinalLocationReached"),W=e?{}:{boxSizing:"border-box",...v?{display:"inline-block",height:"100%",marginLeft:x!==0?x:M?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:x!==0?x:M?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...L?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?c.jsx(S,{...wt(S,u)}):c.jsx(C,{...wt(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:W,children:(e?t.topItems:t.items).map(O=>{const Y=O.originalIndex,q=A(Y+t.firstItemIndex,O.data,u);return P?y.createElement(E,{...wt(E,u),height:O.size,index:O.index,key:q,type:O.type||"item",...O.type==="group"?{}:{groupIndex:O.groupIndex}}):O.type==="group"?y.createElement(I,{...wt(I,u),"data-index":Y,"data-item-index":O.index,"data-known-size":O.size,key:q,style:mx},d(O.index,u)):y.createElement(T,{...wt(T,u),...bx(T,O.data),"data-index":Y,"data-item-group-index":O.groupIndex,"data-item-index":O.index,"data-known-size":O.size,key:q,style:v?gx:Ac},j?l(O.index,O.groupIndex,O.data,u):l(O.index,O.data,u))})})}),xx={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},vx={outline:"none",overflowX:"auto",position:"relative"},No=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),wx={position:vi(),top:0,width:"100%",zIndex:1};function wt(e,t){if(typeof e!="string")return{context:t}}function bx(e,t){return{item:typeof e=="string"?void 0:t}}const yx=y.memo(function(){const e=Ne("HeaderComponent"),t=Lt("headerHeight"),n=Ne("HeaderFooterTag"),r=Ln(y.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,Ne("skipAnimationFrameInResizeObserver")),o=Ne("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...wt(e,o)})}):null}),Sx=y.memo(function(){const e=Ne("FooterComponent"),t=Lt("footerHeight"),n=Ne("HeaderFooterTag"),r=Ln(y.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,Ne("skipAnimationFrameInResizeObserver")),o=Ne("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...wt(e,o)})}):null});function jc({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.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:w}=Ic(a,u,l,d,void 0,f);return e("scrollTo",w),e("scrollBy",h),c.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?vx:xx,...o},tabIndex:0,...i,...wt(l,s),children:r})})}function Rc({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.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=y.useRef(null),w=t("scrollerRef"),{scrollByCallback:v,scrollerRef:g,scrollToCallback:x}=Ic(a,u,l,w,h);return Ec(()=>{var b;return g.current=h||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",x),e("scrollBy",v),c.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...wt(l,s),children:r})})}const Cx=({children:e})=>{const t=y.useContext(Tc),n=Lt("viewportHeight"),r=Lt("fixedItemHeight"),o=Ne("alignToBottom"),s=Ne("horizontalDirection"),i=y.useMemo(()=>Vl(n,l=>bn(l,s?"width":"height")),[n,s]),a=Ln(i,!0,Ne("skipAnimationFrameInResizeObserver"));return y.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),c.jsx("div",{"data-viewport-type":"element",ref:a,style:No(o),children:e})},Tx=({children:e})=>{const t=y.useContext(Tc),n=Lt("windowViewportRect"),r=Lt("fixedItemHeight"),o=Ne("customScrollParent"),s=Xl(n,o,Ne("skipAnimationFrameInResizeObserver")),i=Ne("alignToBottom");return y.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:No(i),children:e})},kx=({children:e})=>{const t=Ne("TopItemListComponent")||"div",n=Ne("headerHeight"),r={...wx,marginTop:`${n}px`},o=Ne("context");return c.jsx(t,{style:r,...wt(t,o),children:e})},Ex=y.memo(function(e){const t=Ne("useWindowScroll"),n=Ne("topItemsIndexes").length>0,r=Ne("customScrollParent"),o=Ne("context");return c.jsxs(r||t?Ax:Nx,{...e,context:o,children:[n&&c.jsx(kx,{children:c.jsx(_c,{showTopList:!0})}),c.jsxs(r||t?Tx:Cx,{children:[c.jsx(yx,{}),c.jsx(_c,{}),c.jsx(Sx,{})]})]})}),{Component:Ix,useEmitter:bi,useEmitterValue:Ne,usePublisher:Lt}=Cc(hx,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},Ex),Nx=jc({useEmitter:bi,useEmitterValue:Ne,usePublisher:Lt}),Ax=Rc({useEmitter:bi,useEmitterValue:Ne,usePublisher:Lt}),_x=Ix;rt(Sc,Ve(()=>{const e=X(u=>c.jsxs("td",{children:["Item $",u]})),t=X(null),n=X(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=X(null),o=X(null),s=X({}),i=X(wi),a=X(ir),l=(u,d=null)=>vt(V(s,ie(f=>f[u]),ot()),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")}})),vi();const Pc={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},jx={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Oc,floor:Ao,max:$r,min:yi,round:Mc}=Math;function Dc(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function Rx(e){return{...jx,items:e}}function _o(e,t){return e&&e.width===t.width&&e.height===t.height}function Px(e,t){return e&&e.column===t.column&&e.row===t.row}const Ox=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:w,propsReady:v},{customScrollParent:g,useWindowScroll:x,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:E},C])=>{const T=X(0),I=X(0),A=X(Pc),P=X({height:0,width:0}),j=X({height:0,width:0}),M=$e(),L=$e(),W=X(0),O=X(null),Y=X({column:0,row:0}),q=$e(),J=$e(),$=X(!1),_=X(0),G=X(!0),B=X(!1),he=X(!1);qe(V(w,De(_),Se(([D,Z])=>!!Z)),()=>{Pe(G,!1)}),qe(V(ft(w,G,j,P,_,B),Se(([D,Z,ee,ce,,ne])=>D&&!Z&&ee.height!==0&&ce.height!==0&&!ne)),([,,,,D])=>{Pe(B,!0),di(1,()=>{Pe(M,D)}),Wt(V(u),()=>{Pe(t,[0,0]),Pe(G,!0)})}),fe(V(J,Se(D=>D!=null&&D.scrollTop>0),Zt(0)),I),qe(V(w,De(J),Se(([,D])=>D!=null)),([,D])=>{D&&(Pe(P,D.viewport),Pe(j,D.item),Pe(Y,D.gap),D.scrollTop>0&&(Pe($,!0),Wt(V(u,Dn(1)),Z=>{Pe($,!1)}),Pe(l,{top:D.scrollTop})))}),fe(V(P,ie(({height:D})=>D)),f),fe(V(ft(ye(P,_o),ye(j,_o),ye(Y,(D,Z)=>D&&D.column===Z.column&&D.row===Z.row),ye(u)),ie(([D,Z,ee,ce])=>({gap:ee,item:Z,scrollTop:ce,viewport:D}))),q),fe(V(ft(ye(T),r,ye(Y,Px),ye(j,_o),ye(P,_o),ye(O),ye(I),ye($),ye(G),ye(_)),Se(([,,,,,,,D])=>!D),ie(([D,[Z,ee],ce,ne,Oe,Ye,Ue,,je,Me])=>{const{column:Je,row:ze}=ce,{height:nt,width:st}=ne,{width:re}=Oe;if(Ue===0&&(D===0||re===0))return Pc;if(st===0){const Ct=fi(Me,D),Tt=Ct+Math.max(Ue-1,0);return Rx(Dc(Ct,Tt,Ye))}const ue=Lc(re,st,Je);let ge,ke;je?Z===0&&ee===0&&Ue>0?(ge=0,ke=Ue-1):(ge=ue*Ao((Z+ze)/(nt+ze)),ke=ue*Oc((ee+ze)/(nt+ze))-1,ke=yi(D-1,$r(ke,ue-1)),ge=yi(ke,$r(0,ge))):(ge=0,ke=-1);const ve=Dc(ge,ke,Ye),{bottom:Re,top:Ze}=Fc(Oe,ce,ne,ve),Ke=Oc(D/ue),at=Ke*nt+(Ke-1)*ze-Re;return{bottom:Re,itemHeight:nt,items:ve,itemWidth:st,offsetBottom:at,offsetTop:Ze,top:Ze}})),A),fe(V(O,Se(D=>D!==null),ie(D=>D.length)),T),fe(V(ft(P,j,A,Y),Se(([D,Z,{items:ee}])=>ee.length>0&&Z.height!==0&&D.height!==0),ie(([D,Z,{items:ee},ce])=>{const{bottom:ne,top:Oe}=Fc(D,ce,Z,ee);return[Oe,ne]}),ot(Rr)),t);const de=X(!1);fe(V(u,De(de),ie(([D,Z])=>Z||D!==0)),de);const xe=jt(V(ft(A,T),Se(([{items:D}])=>D.length>0),De(de),Se(([[D,Z],ee])=>{const ce=D.items[D.items.length-1].index===Z-1;return(ee||D.bottom>0&&D.itemHeight>0&&D.offsetBottom===0&&D.items.length===Z)&&ce}),ie(([[,D]])=>D-1),ot())),_e=jt(V(ye(A),Se(({items:D})=>D.length>0&&D[0].index===0),Zt(0),ot())),Ce=jt(V(ye(A),De($),Se(([{items:D},Z])=>D.length>0&&!Z),ie(([{items:D}])=>({endIndex:D[D.length-1].index,startIndex:D[0].index})),ot(rc),hn(0)));fe(Ce,p.scrollSeekRangeChanged),fe(V(M,De(P,j,T,Y),ie(([D,Z,ee,ce,ne])=>{const Oe=cc(D),{align:Ye,behavior:Ue,offset:je}=Oe;let Me=Oe.index;Me==="LAST"&&(Me=ce-1),Me=$r(0,Me,yi(ce-1,Me));let Je=Si(Z,ne,ee,Me);return Ye==="end"?Je=Mc(Je-Z.height+ee.height):Ye==="center"&&(Je=Mc(Je-Z.height/2+ee.height/2)),je&&(Je+=je),{behavior:Ue,top:Je}})),l);const F=vt(V(A,ie(D=>D.offsetBottom+D.bottom)),0);return fe(V(E,ie(D=>({height:D.visibleHeight,width:D.visibleWidth}))),P),{customScrollParent:g,data:O,deviation:W,footerHeight:o,gap:Y,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:j,overscan:n,restoreStateFrom:J,scrollBy:i,scrollContainerState:a,scrollHeight:L,scrollTo:l,scrollToIndex:M,scrollTop:u,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:x,viewportDimensions:P,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:E,...p,gridState:A,horizontalDirection:he,initialTopMostItemIndex:_,totalListHeight:F,...h,endReached:xe,propsReady:v,rangeChanged:Ce,startReached:_e,stateChanged:q,stateRestoreInProgress:$,...C}},rt(hi,yt,Fr,bc,yn,mi,wn));function Lc(e,t,n){return $r(1,Ao((e+n)/(Ao(t)+n)))}function Fc(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Si(e,t,n,r[0].index);return{bottom:Si(e,t,n,r[r.length-1].index)+o,top:s}}function Si(e,t,n,r){const o=Lc(e.width,n.width,t.column),s=Ao(r/o),i=s*n.height+$r(0,s-1)*t.row;return i>0?i+t.row:i}const Mx=Ve(()=>{const e=X(f=>`Item ${f}`),t=X({}),n=X(null),r=X("virtuoso-grid-item"),o=X("virtuoso-grid-list"),s=X(wi),i=X("div"),a=X(ir),l=(f,h=null)=>vt(V(t,ie(p=>p[f]),ot()),h),u=X(!1),d=X(!1);return fe(ye(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")}}),Dx=Ve(([e,t])=>({...e,...t}),rt(Ox,Mx)),Lx=y.memo(function(){const e=it("gridState"),t=it("listClassName"),n=it("itemClassName"),r=it("itemContent"),o=it("computeItemKey"),s=it("isSeeking"),i=Ft("scrollHeight"),a=it("ItemComponent"),l=it("ListComponent"),u=it("ScrollSeekPlaceholder"),d=it("context"),f=Ft("itemDimensions"),h=Ft("gap"),p=it("log"),w=it("stateRestoreInProgress"),v=Ft("reportReadyState"),g=Ln(y.useMemo(()=>x=>{const b=x.parentElement.parentElement.scrollHeight;i(b);const S=x.firstChild;if(S){const{height:E,width:C}=S.getBoundingClientRect();f({height:E,width:C})}h({column:zc("column-gap",getComputedStyle(x).columnGap,p),row:zc("row-gap",getComputedStyle(x).rowGap,p)})},[i,f,h,p]),!0,!1);return Ec(()=>{e.itemHeight>0&&e.itemWidth>0&&v(!0)},[e]),w?null:c.jsx(l,{className:t,ref:g,...wt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(x=>{const b=o(x.index,x.data,d);return s?c.jsx(u,{...wt(u,d),height:e.itemHeight,index:x.index,width:e.itemWidth},b):y.createElement(a,{...wt(a,d),className:n,"data-index":x.index,key:b},r(x.index,x.data,d))})})}),Fx=y.memo(function(){const e=it("HeaderComponent"),t=Ft("headerHeight"),n=it("headerFooterTag"),r=Ln(y.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,!1),o=it("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...wt(e,o)})}):null}),$x=y.memo(function(){const e=it("FooterComponent"),t=Ft("footerHeight"),n=it("headerFooterTag"),r=Ln(y.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,!1),o=it("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...wt(e,o)})}):null}),zx=({children:e})=>{const t=y.useContext(kc),n=Ft("itemDimensions"),r=Ft("viewportDimensions"),o=Ln(y.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return y.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),c.jsx("div",{ref:o,style:No(!1),children:e})},Bx=({children:e})=>{const t=y.useContext(kc),n=Ft("windowViewportRect"),r=Ft("itemDimensions"),o=it("customScrollParent"),s=Xl(n,o,!1);return y.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),c.jsx("div",{ref:s,style:No(!1),children:e})},Hx=y.memo(function({...e}){const t=it("useWindowScroll"),n=it("customScrollParent"),r=n||t?Wx:Ux,o=n||t?Bx:zx,s=it("context");return c.jsx(r,{...e,...wt(r,s),children:c.jsxs(o,{children:[c.jsx(Fx,{}),c.jsx(Lx,{}),c.jsx($x,{})]})})}),{useEmitter:$c,useEmitterValue:it,usePublisher:Ft}=Cc(Dx,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},Hx),Ux=jc({useEmitter:$c,useEmitterValue:it,usePublisher:Ft}),Wx=Rc({useEmitter:$c,useEmitterValue:it,usePublisher:Ft});function zc(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Nt.WARN),t==="normal"?0:parseInt(t??"0",10)}const Vx=to.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 Ci({className:e,variant:t,...n}){return c.jsx("div",{className:Q(Vx({variant:t}),e),...n})}function le(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Kx(e,t){const n=m.createContext(t),r=s=>{const{children:i,...a}=s,l=m.useMemo(()=>a,Object.values(a));return c.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=m.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function tn(e,t=[]){let n=[];function r(s,i){const a=m.createContext(i),l=n.length;n=[...n,i];const u=f=>{var x;const{scope:h,children:p,...w}=f,v=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,g=m.useMemo(()=>w,Object.values(w));return c.jsx(v.Provider,{value:g,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,w=m.useContext(p);if(w)return w;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>m.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,qx(o,...t)]}function qx(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:u})=>{const f=l(s)[`__scope${u}`];return{...a,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var mt=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},Gx=m[" useInsertionEffect ".trim().toString()]||mt;function zn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Yx({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=m.useRef(e!==void 0);m.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const u=m.useCallback(d=>{var f;if(a){const h=Xx(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 Yx({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return Gx(()=>{s.current=t},[t]),m.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Xx(e){return typeof e=="function"}function Bc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ti(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Bc(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():Bc(e[o],null)}}}}function Le(...e){return m.useCallback(Ti(...e),e)}var Jx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Te=Jx.reduce((e,t)=>{const n=Rn.createSlot(`Primitive.${t}`),r=m.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Hc(e,t){e&&no.flushSync(()=>e.dispatchEvent(t))}function Zx(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Pt=e=>{const{present:t,children:n}=e,r=Qx(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=Le(r.ref,ev(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};Pt.displayName="Presence";function Qx(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Zx(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=jo(r.current);s.current=a==="mounted"?u:"none"},[a]),mt(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,p=jo(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]),mt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const v=jo(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&v&&(l("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},h=p=>{p.target===t&&(s.current=jo(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function jo(e){return(e==null?void 0:e.animationName)||"none"}function ev(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var tv=m[" useId ".trim().toString()]||(()=>{}),nv=0;function nn(e){const[t,n]=m.useState(tv());return mt(()=>{n(r=>r??String(nv++))},[e]),e||(t?`radix-${t}`:"")}var Ro="Collapsible",[rv,zC]=tn(Ro),[ov,ki]=rv(Ro),Uc=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,u]=zn({prop:r,defaultProp:o??!1,onChange:i,caller:Ro});return c.jsx(ov,{scope:n,disabled:s,contentId:nn(),open:l,onOpenToggle:m.useCallback(()=>u(d=>!d),[u]),children:c.jsx(Te.div,{"data-state":Ii(l),"data-disabled":s?"":void 0,...a,ref:t})})});Uc.displayName=Ro;var Wc="CollapsibleTrigger",Vc=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=ki(Wc,n);return c.jsx(Te.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Ii(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:le(e.onClick,o.onOpenToggle)})});Vc.displayName=Wc;var Ei="CollapsibleContent",sv=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=ki(Ei,e.__scopeCollapsible);return c.jsx(Pt,{present:n||o.open,children:({present:s})=>c.jsx(iv,{...r,ref:t,present:s})})});sv.displayName=Ei;var iv=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=ki(Ei,n),[a,l]=m.useState(r),u=m.useRef(null),d=Le(t,u),f=m.useRef(0),h=f.current,p=m.useRef(0),w=p.current,v=i.open||a,g=m.useRef(v),x=m.useRef(void 0);return m.useEffect(()=>{const b=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(b)},[]),mt(()=>{const b=u.current;if(b){x.current=x.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const S=b.getBoundingClientRect();f.current=S.height,p.current=S.width,g.current||(b.style.transitionDuration=x.current.transitionDuration,b.style.animationName=x.current.animationName),l(r)}},[i.open,r]),c.jsx(Te.div,{"data-state":Ii(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!v,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":w?`${w}px`:void 0,...e.style},children:v&&o})});function Ii(e){return e?"open":"closed"}var av=Uc;const Kc=av,qc=Vc,zr=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Q("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));zr.displayName="Card";const Br=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Q("flex flex-col space-y-1.5 p-6",e),...t}));Br.displayName="CardHeader";const Hr=m.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:Q("text-2xl font-semibold leading-none tracking-tight",e),...t}));Hr.displayName="CardTitle";const Gc=m.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:Q("text-sm text-muted-foreground",e),...t}));Gc.displayName="CardDescription";const Po=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Q("p-6 pt-0",e),...t}));Po.displayName="CardContent";const Yc=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Q("flex items-center p-6 pt-0",e),...t}));Yc.displayName="CardFooter";function Xc(){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 Bn=Xc();function lv(e){Bn=e}const Jc=/[&<>"']/,cv=new RegExp(Jc.source,"g"),Zc=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,uv=new RegExp(Zc.source,"g"),dv={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Qc=e=>dv[e];function bt(e,t){if(t){if(Jc.test(e))return e.replace(cv,Qc)}else if(Zc.test(e))return e.replace(uv,Qc);return e}const fv=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function eu(e){return e.replace(fv,(t,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const hv=/(^|[^\[])\^/g;function et(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(hv,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const pv=/[^\w:]/g,mv=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function tu(e,t,n){if(e){let r;try{r=decodeURIComponent(eu(n)).replace(pv,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!mv.test(n)&&(n=wv(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Oo={},gv=/^[^:]+:\/*[^/]*$/,xv=/^([^:]+:)[\s\S]*$/,vv=/^([^:]+:\/*[^/]*)[\s\S]*$/;function wv(e,t){Oo[" "+e]||(gv.test(e)?Oo[" "+e]=e+"/":Oo[" "+e]=Do(e,"/",!0)),e=Oo[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(xv,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(vv,"$1")+t:e+t}const Mo={exec:function(){}};function nu(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 Do(e,t,n){const r=e.length;if(r===0)return"";let o=0;for(;o<r;){const s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function bv(e,t){if(e.indexOf(t[1])===-1)return-1;const n=e.length;let r=0,o=0;for(;o<n;o++)if(e[o]==="\\")o++;else if(e[o]===t[0])r++;else if(e[o]===t[1]&&(r--,r<0))return o;return-1}function yv(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function ru(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function ou(e,t,n,r){const o=t.href,s=t.title?bt(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:bt(i)}}function Sv(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
32
+ `))>=0;){const le=K.slice(0,ne);K=K.slice(ne+2);const xe=pg(le);if(!xe)continue;let Se;try{Se=JSON.parse(xe)}catch{console.debug("[use-chat] malformed SSE:",xe.slice(0,200));continue}const be=hg(Se)?Se.data:Se;$e=Date.now();const je=be.seq;if(je!==void 0){if(je<=J){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:je,lastProcessedSeq:J,type:be.type});continue}J>0&&je>J+1&&((j=$==null?void 0:$.onGap)==null||j.call($,{from:J,to:je})),J=je,C.current=je,g(je)}if(L==null||L(be),be.type==="token"&&e.autoAppendAssistant!==!1)D.push(be.content),ue();else if(be.type==="message_delta"){const Qe=be.delta.filter(Ye=>Ye.type==="text").map(Ye=>Ye.text).join("");Qe&&e.autoAppendAssistant!==!1&&(D.push(Qe),ue())}else be.type==="heartbeat"?console.debug("[use-chat] heartbeat received"):(U!==null&&cancelAnimationFrame(U),fe(),be.type==="checkpoint"?w(be.checkpointId):be.type==="error"&&d(be.message))}}fe()}catch(ke){if(ke.name!=="AbortError"){const Oe=ke.message||String(ke);d(Oe),(G=$==null?void 0:$.onError)==null||G.call($,Oe)}}finally{try{await Ae.cancel()}catch{}finally{(Z=Ae.releaseLock)==null||Z.call(Ae)}U!==null&&typeof window<"u"&&window.cancelAnimationFrame(U),clearInterval(Ge),l(!1),b(!1),S.current=null,C.current=0,g(0)}}catch(de){if(de.name!=="AbortError"){const ee=de.message||String(de);d(ee),(ge=$==null?void 0:$.onError)==null||ge.call($,ee)}}finally{l(!1),b(!1),S.current=null,C.current=0,g(0)}})(),{close:()=>H.abort()}},[t,n,r,e.autoAppendAssistant]);return y.useEffect(()=>()=>{var P;N.current=!1,(P=S.current)==null||P.abort()},[]),{isStreaming:a,error:u,assistantText:f,lastCheckpointId:p,lastSeq:v,connected:x,stream:R,stop:I,clear:A,setToken:k}}function hg(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function pg(e){const t=e.split(/\r?\n/),n=[];for(const r of t)if(r&&!r.startsWith(":")&&r.startsWith("data:")){const o=r.slice(5);n.push(o.startsWith(" ")?o.slice(1):o)}return n.length===0?null:n.join(`
33
+ `)}function mg({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onUnhandledEvent:r,onSequenceGap:o}){const s=y.useRef(null),i=y.useCallback(p=>{const w=p.seq??null;if(w!==null){const v=s.current;if(v!==null){if(w<=v)return;w>v+1&&(o==null||o({from:v,to:w}))}s.current=w}if(p.type==="thread_info"){console.log("[useChatStreamingService] 🎯 Received thread_info event:",p),t(p);return}if(og(p)){n(p);return}r==null||r(p)},[n,o,t,r]),{stream:a,stop:l,isStreaming:u,error:d,setToken:f}=Dl({baseUrl:e,token:null}),h=y.useCallback((p,w)=>{s.current=null,a(p,i,{onOpen:w==null?void 0:w.onOpen,onError:v=>{var g;(g=w==null?void 0:w.onError)==null||g.call(w,v)},onGap:(w==null?void 0:w.onGap)??o})},[i,o,a]);return y.useMemo(()=>({startStream:h,stop:l,isStreaming:u,error:d,setAuthToken:f}),[h,l,u,d,f])}const Ll=y.createContext(null),$l=y.createContext(null),Fl=y.createContext(null),gg=y.createContext(!1),xg=20,vg="cachedThreads",wg="v1",Zs=300,Bl=200;function bg(e){if(typeof window<"u"&&"requestIdleCallback"in window)try{window.requestIdleCallback(e,{timeout:1e3});return}catch{}window.setTimeout(e,Zs)}function Ar(){return typeof window<"u"&&typeof window.localStorage<"u"}function Qs(e){if(!Ar())return null;try{return window.localStorage.getItem(e)}catch{return null}}function zl(e,t){if(Ar())try{window.localStorage.setItem(e,t)}catch{}}function Hl(e){if(Ar())try{window.localStorage.removeItem(e)}catch{}}function yg(){const e=Qs(vg);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 Sg(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 ei(e,t){return`cachedThreads:v1:${e}:${Sg(t||"anon")}`}function Cg(e){const t=Qs(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 Ul(e,t){try{zl(e,JSON.stringify(t))}catch{}}function Wl(e){const t=Cg(e);if(t.length>0)return t;const n=yg();if(n.length>0)try{Ul(e,n.slice(0,Bl))}catch{}return n}function ti(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 Tg(e){return e.order.map(t=>e.byId[t]).filter(Boolean)}function kg({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}=Gs(),d=y.useMemo(()=>cn(u),[u]),f=y.useMemo(()=>{try{return new URL(u).host}catch{return"unknown"}},[u]),h=y.useMemo(()=>`threadPayload:${wg}:${f}:`,[f]),p=y.useCallback(E=>`${h}${E}`,[h]),w=y.useCallback(E=>{if(!E||typeof E!="object")return null;const _=E;return typeof _.threadId!="string"||!Array.isArray(_.messages)?null:{threadId:_.threadId,messages:_.messages,hasMore:!!_.hasMore,nextCursor:_.nextCursor??null,checkpointId:_.checkpointId??null,checkpointNs:_.checkpointNs??null}},[]),v=y.useCallback(E=>{const _=Qs(p(E));if(!_)return null;try{const W=JSON.parse(_);return w(W)}catch{return null}},[p,w]),g=y.useCallback((E,_=100)=>{const W={...E,messages:Array.isArray(E.messages)?E.messages.slice(-_):[]};try{zl(p(E.threadId),JSON.stringify(W))}catch{}},[p]),x=y.useCallback(E=>{Hl(p(E))},[p]),b=y.useCallback(()=>{if(Ar())try{const E=h;for(let _=0;_<window.localStorage.length;_++){const W=window.localStorage.key(_);W&&W.startsWith(E)&&window.localStorage.removeItem(W)}}catch{}},[h]),[S,N]=y.useState(()=>{var E;return ei(f,(E=l.getAuthToken)==null?void 0:E.call(l))}),[C,k]=y.useState(()=>{var _;const E=Wl(ei(f,(_=l.getAuthToken)==null?void 0:_.call(l)));return ti(E)}),I=y.useMemo(()=>Tg(C),[C]),[A,R]=y.useState(t),[P,L]=y.useState(!1),[$,H]=y.useState(!1),[M,q]=y.useState(!1),[V,Y]=y.useState(!1),[B,j]=y.useState(null),[G,Z]=y.useState(void 0),[ge,de]=y.useState(void 0),{state:ee,seed:Ae,prepend:Te,pushUser:K,onEvent:D,reset:J}=Ol(),U=y.useRef(A);y.useEffect(()=>{U.current=A},[A]);const fe=y.useRef(!1),ue=y.useRef([]),$e=y.useRef(null),Ge=y.useRef(null),qe=y.useRef(new Map),ke=y.useRef(A),Oe=y.useCallback((E,_)=>new Promise((W,ie)=>{const pe=async()=>{fe.current=!0;try{await E(),W()}catch(he){ie(he)}finally{fe.current=!1;const he=ue.current.shift();he&&he().catch(()=>{})}};fe.current?ue.current.push(pe):pe().catch(he=>{ie(he)})}),[]),Be=y.useCallback(async()=>{const E=I.length>0;E||L(!0);try{const _=await l.listThreads();y.startTransition(()=>{k(W=>{if(_.length===0&&I.length>0)return W;const ie=he=>he.map(et=>`${et.threadId}:${et.updatedAt??""}:${et.messageCount??""}`).join("|");return ie(I)===ie(_)?W:ti(_)})})}catch(_){i==null||i(String(_)),console.error("[ChatSessionProvider] Failed to refresh threads:",_)}finally{E||L(!1)}},[l,i,I.length]),Ue=y.useRef(!1),st=y.useRef(null),ot=y.useRef(null),ne=y.useRef(""),le=y.useCallback((E,_,W)=>{const ie=Array.isArray(E==null?void 0:E.messages)?E.messages:[],pe=W??(E==null?void 0:E.threadId)??U.current;if(_==="replace"){if(pe){const he={threadId:pe,messages:ie.slice(),hasMore:!!(E!=null&&E.hasMore),nextCursor:(E==null?void 0:E.nextCursor)??null,checkpointId:(E==null?void 0:E.checkpointId)??null,checkpointNs:(E==null?void 0:E.checkpointNs)??null};qe.current.set(pe,he),ke.current=pe}Ae(ie,{checkpointId:(E==null?void 0:E.checkpointId)??null,checkpointNs:(E==null?void 0:E.checkpointNs)??null})}else if(_==="prepend"&&ie.length&&pe){const he=qe.current.get(pe),et=(he==null?void 0:he.messages)??[],ht=new Set,T=[...ie,...et].filter(te=>{const ye=te==null?void 0:te.id;return ye?ht.has(ye)?!1:(ht.add(ye),!0):!0}),F={threadId:pe,messages:T,hasMore:(E==null?void 0:E.hasMore)??(he==null?void 0:he.hasMore)??!1,nextCursor:(E==null?void 0:E.nextCursor)??(he==null?void 0:he.nextCursor)??null,checkpointId:(he==null?void 0:he.checkpointId)??(E==null?void 0:E.checkpointId)??null,checkpointNs:(he==null?void 0:he.checkpointNs)??(E==null?void 0:E.checkpointNs)??null};qe.current.set(pe,F),Te(ie)}else _==="prepend"&&ie.length&&Te(ie);_==="replace"?(j((E==null?void 0:E.nextCursor)??null),q(!!(E!=null&&E.hasMore)),Z((E==null?void 0:E.checkpointId)??void 0),de((E==null?void 0:E.checkpointNs)??void 0)):(j(he=>(E==null?void 0:E.nextCursor)??he??null),q(he=>(E==null?void 0:E.hasMore)!==void 0?!!(E!=null&&E.hasMore):he),Z(he=>(E==null?void 0:E.checkpointId)??he??void 0),de(he=>(E==null?void 0:E.checkpointNs)??he??void 0))},[Te,Ae]),xe=y.useCallback(E=>{Ae(E.messages,{checkpointId:E.checkpointId,checkpointNs:E.checkpointNs}),j(E.nextCursor),q(E.hasMore),Z(E.checkpointId??void 0),de(E.checkpointNs??void 0),ke.current=E.threadId},[Ae]),Se=y.useCallback(E=>{E&&(qe.current.delete(E),x(E),ke.current===E&&(ke.current=null))},[x]),be=y.useCallback(()=>{const E=U.current;E&&Se(E),J([]),q(!1),Y(!1),j(null),Z(void 0),de(void 0)},[Se,J]),je=y.useCallback(({from:E,to:_})=>{const W=U.current;W&&console.warn(`[ChatSessionProvider] Stream sequence gap detected (${E} -> ${_}) for thread ${W}`)},[]),Qe=y.useCallback(E=>{const _=E.threadId;console.log("[ChatSessionProvider] 📥 Handling thread_info event:",{threadId:_,title:E.title,created:E.created,currentThreads:I.length});const W={threadId:_,title:E.title||`Thread ${_.slice(0,8)}`,createdAt:E.createdAt||new Date().toISOString(),updatedAt:E.updatedAt||new Date().toISOString(),messageCount:E.messageCount||0};U.current!==_&&(!U.current&&ee.messages.length<=1&&(Ge.current=_),R(_)),y.startTransition(()=>{k(ie=>{const pe=ie.byId[_];return pe?pe.title===W.title&&pe.updatedAt===W.updatedAt&&pe.messageCount===W.messageCount?ie:{byId:{...ie.byId,[_]:W},order:ie.order}:{byId:{...ie.byId,[_]:W},order:[_,...ie.order]}})})},[ee.messages.length]),{startStream:Ye,stop:it,isStreaming:gt,error:hn,setAuthToken:Jn}=mg({baseUrl:d,onThreadInfo:Qe,onMessageEvent:D,onUnhandledEvent:E=>{console.warn(`[ChatSessionProvider] Unhandled stream event: ${E.type}`,E)},onSequenceGap:je});y.useEffect(()=>{Ue.current=gt},[gt]),y.useEffect(()=>{if(!Ar())return;ot.current&&window.clearTimeout(ot.current);const E=I.map(_=>`${_.threadId}:${_.updatedAt??""}:${_.messageCount??""}`).join("|");if(I.length===0){try{Hl(S)}catch{}ne.current="";return}if(E!==ne.current)return ne.current=E,ot.current=window.setTimeout(()=>{bg(()=>{try{const W=I.slice(0,Bl);Ul(S,W)}catch{}})},Zs),()=>{ot.current&&window.clearTimeout(ot.current)}},[I,S]),y.useEffect(()=>{var ie;const E=l.getAuthToken();Jn(E);const _=pe=>{const he=ei(f,pe);N(he);const et=Wl(he);y.startTransition(()=>{k(ti(et))}),Be().catch(()=>{})};_(E);const W=(ie=l.onTokenChange)==null?void 0:ie.call(l,pe=>{Jn(pe),b(),_(pe)});return()=>{W==null||W()}},[l,f,Jn,b,Be]);const vr=y.useCallback(async E=>{const _=`temp-${Date.now()}`,W={threadId:_,title:E||"New Chat",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messageCount:0};k(ie=>({byId:{...ie.byId,[_]:W},order:[_,...ie.order]})),R(_);try{const ie=await l.createThread(E),pe=typeof ie=="string"?ie:ie.threadId;return k(he=>{const et=he.byId[_];if(!et)return he;const ht={...he.byId};delete ht[_],ht[pe]={...et,threadId:pe};const T=he.order.map(F=>F===_?pe:F);return{byId:ht,order:T}}),R(pe),setTimeout(()=>Be(),10),pe}catch(ie){throw k(pe=>{if(!pe.byId[_])return pe;const he={...pe.byId};delete he[_];const et=pe.order.filter(ht=>ht!==_);return{byId:he,order:et}}),R(null),ie}},[l,Be]),Zn=y.useCallback(async E=>{await l.deleteThread(E),k(_=>{if(!_.byId[E])return _;const W={..._.byId};delete W[E];const ie=_.order.filter(pe=>pe!==E);return{byId:W,order:ie}}),Se(E),U.current===E&&(Ge.current=E,R(null),U.current=null,ke.current=null,be()),await Be()},[l,be,Se,Be]),Nn=y.useCallback(async(E,_)=>{try{await l.updateThread(E,_),k(W=>{const ie=W.byId[E];return ie?{byId:{...W.byId,[E]:{...ie,title:_}},order:W.order}:W})}catch(W){throw await Be(),W}},[l,Be]),Bt=y.useCallback(async(E,_,W,ie=!1)=>{await Oe(async()=>{if(Ge.current===E&&!ie){Ge.current=null;return}if($e.current===E&&!ie)return;R(T=>T===E?T:E),U.current=E;const pe=!ie&&!_&&!W;let he=!1;if(pe){const T=qe.current.get(E);if(T)xe(T),he=!0;else{const F=v(E);F&&(qe.current.set(E,F),xe(F),he=!0)}}const et=ie||!he||!!_||!!W,ht=async T=>{T&&H(!0),$e.current=E;try{const F=await l.getMessages({threadId:E,checkpointId:_,checkpointNs:W});le(F,"replace",E)}catch(F){throw(!he||ie||T)&&(i==null||i(String(F))),F}finally{$e.current=null,T&&H(!1)}};et?await ht(!0):pe&&he&&ht(!1).catch(T=>{console.warn("[ChatSessionProvider] Background refresh failed:",T)})},`loadThread-${E}`)},[l,xe,le,Oe,i]),An=y.useCallback(async()=>{await Oe(async()=>{const E=U.current;E&&Se(E),Ge.current=null,R(null),U.current=null,ke.current=null,be(),Z(void 0),de(void 0);try{localStorage.removeItem("lastThreadId")}catch(_){console.warn("[ChatSessionProvider] Failed to clear lastThreadId:",_)}},"clearCurrentThread")},[be,Se,Oe]),Qn=y.useCallback(async E=>{const _=await l.listCheckpoints(E);return tg(_,E)},[l]),Yt=y.useCallback(async(E,_)=>{if(!U.current)throw new Error("No active thread");await Bt(U.current,E,_??void 0,!0)},[Bt]),_n=y.useCallback(async()=>{if(!U.current)throw new Error("No active thread");await Bt(U.current,void 0,void 0,!0)},[Bt]),jn=y.useCallback(async E=>{if(!U.current)throw new Error("No active thread");if(V||!M)return;const _=B;if(_){Y(!0);try{const W=U.current,ie=await l.getMessages({threadId:W,checkpointId:G,checkpointNs:ge,limit:(E==null?void 0:E.limit)??xg,beforeId:_});le(ie,"prepend",W??void 0)}finally{Y(!1)}}},[l,le,M,G,ge,B,V]),er=y.useCallback(async(E,_)=>{var We;const W=U.current;!W&&!(_!=null&&_.payloadExtras)&&console.warn("[ChatSessionProvider] No thread ID - message will create new thread");const ie=(_==null?void 0:_.attachments)||[],{contentParts:pe,filesInfo:he}=await rg(l,ie),et=[...pe];E&&E.trim()&&et.push({type:"text",text:E.trim()});const ht={id:((We=crypto.randomUUID)==null?void 0:We.call(crypto))||`user-${Date.now()}`,role:"user",content:et,createdAt:new Date().toISOString(),checkpointId:(_==null?void 0:_.checkpointId)??ee.lastCheckpointId??void 0,checkpointNs:(_==null?void 0:_.checkpointNs)??ee.lastCheckpointNs??void 0};K(ht);const T={...ht,content:et},F={...(_==null?void 0:_.payloadExtras)??{}},te=ie.length>0,ye={...W?{threadId:W}:{},payload:{messages:[T],files_info:he,...o&&te&&s?{active_agent:s}:{},...F},checkpointId:(_==null?void 0:_.checkpointId)??ee.lastCheckpointId??void 0,checkpointNs:(_==null?void 0:_.checkpointNs)??ee.lastCheckpointNs??void 0,nodeFilter:_==null?void 0:_.nodeFilter,config:_==null?void 0:_.config};Ye(ye,{onError:Ve=>{console.warn("[ChatSessionProvider] Stream error:",Ve)},onOpen:({threadId:Ve,created:ze})=>{!U.current&&Ve&&(ee.messages.length<=1&&(Ge.current=Ve),R(Ve))},onGap:je})},[l,o,s,je,ee.lastCheckpointId,ee.lastCheckpointNs,ee.messages.length,K,Ye]),wr=y.useCallback(async(E,_,W)=>{const ie=U.current;if(!ie)throw new Error("No active thread to handle interrupt");try{const pe=_?W??!0:!1;await l.resume({threadId:ie,value:pe})}catch(pe){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${E}:`,pe),pe}},[l]);y.useEffect(()=>{if(a==null||a(A),A)try{localStorage.setItem("lastThreadId",A)}catch(E){console.warn("[ChatSessionProvider] Failed to persist lastThreadId:",E)}},[A,a]),y.useEffect(()=>((async()=>{try{if(Be().catch(_=>{console.error("[ChatSessionProvider] Failed to refresh threads (background):",_),i==null||i(String(_))}),!r&&!t)try{const _=localStorage.getItem("lastThreadId");_&&(R(_),n&&await Bt(_))}catch(_){console.warn("[ChatSessionProvider] Failed to restore last thread:",_)}else t&&n&&await Bt(t)}catch(_){console.error("[ChatSessionProvider] Initialization failed:",_),i==null||i(String(_))}})(),()=>{}),[]),y.useEffect(()=>{const E=U.current;if(!E||ke.current!==E)return;const _={threadId:E,messages:ee.messages.slice(),hasMore:M,nextCursor:B,checkpointId:ee.lastCheckpointId??null,checkpointNs:ee.lastCheckpointNs??null},W=qe.current.get(E);(!W||W.messages.length!==_.messages.length||W.messages.some((pe,he)=>{var et;return(pe==null?void 0:pe.id)!==((et=_.messages[he])==null?void 0:et.id)})||(W==null?void 0:W.hasMore)!==_.hasMore||(W==null?void 0:W.nextCursor)!==_.nextCursor||(W==null?void 0:W.checkpointId)!==_.checkpointId||(W==null?void 0:W.checkpointNs)!==_.checkpointNs)&&(qe.current.set(E,_),st.current&&window.clearTimeout(st.current),st.current=window.setTimeout(()=>{try{g(_,100)}catch(pe){console.warn("[ChatSessionProvider] Failed to persist thread payload:",pe)}},Zs))},[M,B,ee.lastCheckpointId,ee.lastCheckpointNs,ee.messages]);const br=y.useMemo(()=>({threads:I,currentThreadId:A,isLoadingThreads:P,isLoadingThread:$,setCurrentThreadId:R,createThread:vr,deleteThread:Zn,renameThread:Nn,refreshThreads:Be,loadThread:Bt,clearCurrentThread:An,listCheckpoints:Qn,navigateToCheckpoint:Yt,returnToLatest:_n}),[An,vr,A,Zn,$,P,Qn,Bt,Yt,Be,Nn,_n,I]),to=y.useMemo(()=>({messages:ee.messages,assemblingId:ee.assemblingId,lastUserMessage:null,hasMoreHistory:M,isLoadingHistory:V,send:er,stop:it,loadOlderMessages:jn,clearMessages:be,handleInterrupt:wr}),[be,wr,M,V,jn,ee.assemblingId,ee.messages,er,it]),se=y.useMemo(()=>({isStreaming:gt,error:hn,streamingAssistantId:ee.assemblingId,lastCheckpointId:ee.lastCheckpointId??null,lastCheckpointNs:ee.lastCheckpointNs??null}),[gt,ee.assemblingId,ee.lastCheckpointId,ee.lastCheckpointNs,hn]);return c.jsx(gg.Provider,{value:!0,children:c.jsx(Fl.Provider,{value:se,children:c.jsx(Ll.Provider,{value:br,children:c.jsx($l.Provider,{value:to,children:e})})})})}function go(){const e=y.useContext(Ll);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function ni(){const e=y.useContext($l);if(!e)throw new Error("useMessages must be used within ChatSessionProvider");return e}function Vl(){const e=y.useContext(Fl);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function xo({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(eg,{apiConfig:t,children:c.jsx(kg,{initialThreadId:n,autoLoadInitial:r,disableAutoRestore:o,enableFileAgentRouting:s,fileAgentId:i,onError:a,onThreadChange:l,children:e})})}function Q(...e){return Ap.twMerge(Np.clsx(e))}const Eg=no.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"}}),He=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Rn.Slot:"button";return c.jsx(i,{className:Q(Eg({variant:t,size:n,className:e})),ref:s,...o})});He.displayName="Button";const Kl=m.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:Q("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}));Kl.displayName="Textarea";function Ig({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]=y.useState(e),[w,v]=y.useTransition(),g=y.useRef(null);y.useEffect(()=>{p(e??""),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const x=y.useCallback(()=>{const A=g.current;A&&(A.style.height="auto",A.style.height=`${A.scrollHeight}px`)},[]);y.useEffect(()=>{x()},[x]);const b=y.useCallback(async A=>{A&&A.preventDefault();const R=(h??"").trim();!R&&!f||v(()=>{try{const P=i(R);P&&typeof P.then=="function"?P.then(()=>{p(""),g.current&&(g.current.style.height="auto")}).catch(()=>{}):(p(""),g.current&&(g.current.style.height="auto"))}catch{}})},[h,i,f]),S=y.useCallback(A=>{p(A.target.value),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),N=y.useCallback(A=>{A.key==="Enter"&&!A.shiftKey?(A.preventDefault(),b()):A.key==="Escape"&&t&&(A.preventDefault(),a==null||a())},[b,t,a]),I=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${d}`;return c.jsx("form",{onSubmit:A=>void b(A),className:`w-full ${u}`,children:c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsx("div",{className:"flex-1",children:c.jsx(Kl,{ref:g,value:h,onChange:S,onKeyDown:N,placeholder:t?"Edit your message...":n,className:I,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),c.jsx("div",{children:r?c.jsx(He,{type:"button",onClick:()=>{l==null||l()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!l,children:c.jsx(re.Square,{size:16})}):c.jsx(He,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||w,children:c.jsx(re.Send,{size:16})})})]})})}const Ng=y.memo(Ig),vo=0,gn=1,or=2,ql=4;function Gl(e){return()=>e}function Ag(e){e()}function Yl(e,t){return n=>e(t(n))}function Xl(e,t){return()=>e(t)}function _g(e,t){return n=>e(t,n)}function ri(e){return e!==void 0}function jg(...e){return()=>{e.map(Ag)}}function sr(){}function wo(e,t){return t(e),e}function Rg(e,t){return t(e)}function tt(...e){return e}function Xe(e,t){return e(gn,t)}function Pe(e,t){e(vo,t)}function oi(e){e(or)}function lt(e){return e(ql)}function me(e,t){return Xe(e,_g(t,vo))}function Ut(e,t){const n=e(gn,r=>{n(),t(r)});return n}function Jl(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Zl(e,t){return e===t}function nt(e=Zl){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ee(e){return t=>n=>{e(n)&&t(n)}}function oe(e){return t=>Yl(t,e)}function Jt(e){return t=>()=>{t(e)}}function z(e,...t){const n=Pg(...t);return(r,o)=>{switch(r){case or:oi(e);return;case gn:return Xe(e,n(o))}}}function Zt(e,t){return n=>r=>{n(t=e(t,r))}}function Dn(e){return t=>n=>{e>0?e--:t(n)}}function un(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Me(...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);Xe(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 Pg(...e){return t=>e.reduceRight(Rg,t)}function Og(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case gn:return s?n===s?void 0:(r(),n=s,t=Xe(e,s),t):(r(),sr);case or:r(),n=null;return}}}function X(e){let t=e;const n=Fe();return(r,o)=>{switch(r){case vo:t=o;break;case gn:{o(t);break}case ql:return t}return n(r,o)}}function vt(e,t){return wo(X(t),n=>me(e,n))}function Fe(){const e=[];return(t,n)=>{switch(t){case vo:e.slice().forEach(r=>{r(n)});return;case or:e.splice(0,e.length);return;case gn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function At(e){return wo(Fe(),t=>me(e,t))}function Ke(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Mg(),singleton:n}}const Mg=()=>Symbol();function Dg(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 ut(...e){const t=Fe(),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);Xe(s,l=>{n[i]=l,r=r|a,r===o&&Pe(t,n)})}),function(s,i){switch(s){case or:{oi(t);return}case gn:return r===o&&i(n),Xe(t,i)}}}function Ce(e,t=Zl){return z(e,nt(t))}function si(...e){return function(t,n){switch(t){case or:return;case gn:return jg(...e.map(r=>Xe(r,n)))}}}var Et=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Et||{});const Lg={0:"debug",3:"error",1:"log",2:"warn"},$g=()=>typeof globalThis>"u"?window:globalThis,xn=Ke(()=>{const e=X(3);return{log:X((t,n,r=1)=>{var o;const s=(o=$g().VIRTUOSO_LOG_LEVEL)!=null?o:lt(e);r>=s&&console[Lg[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Ln(e,t,n){return ii(e,t,n).callbackRef}function ii(e,t,n){const r=y.useRef(null);let o=i=>{};const s=y.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 Fg(e,t,n,r,o,s,i,a,l){const u=y.useCallback(d=>{const f=Bg(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 w;p&&(w=h.ownerDocument.defaultView);const v=i?a?i.scrollLeft:i.scrollTop:p?a?w.scrollX||w.document.documentElement.scrollLeft:w.scrollY||w.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:p?a?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,x=i?a?i.offsetWidth:i.offsetHeight:p?a?w.innerWidth:w.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(v,0),viewportHeight:x}),s==null||s(a?Ql("column-gap",getComputedStyle(d).columnGap,o):Ql("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return ii(u,n,l)}function Bg(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},Et.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 Ql(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Et.WARN),t==="normal"?0:parseInt(t??"0",10)}function ec(e,t,n){const r=y.useRef(null),o=y.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const u=l.getBoundingClientRect(),d=u.width;let f,h;if(t){const p=t.getBoundingClientRect(),w=u.top-p.top;h=p.height-Math.max(0,w),f=w+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}=ii(o,!0,n),a=y.useCallback(()=>{o(i.current)},[o,i]);return y.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 yt=Ke(()=>{const e=Fe(),t=Fe(),n=X(0),r=Fe(),o=X(0),s=Fe(),i=Fe(),a=X(0),l=X(0),u=X(0),d=X(0),f=Fe(),h=Fe(),p=X(!1),w=X(!1),v=X(!1);return me(z(e,oe(({scrollTop:g})=>g)),t),me(z(e,oe(({scrollHeight:g})=>g)),i),me(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:w,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:v,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),_r={lvl:0};function tc(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 Je(e){return e===_r}function jr(e,t){if(!Je(e))return t===e.k?e.v:t<e.k?jr(e.l,t):jr(e.r,t)}function Wt(e,t,n="k"){if(Je(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=Wt(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return Wt(e.l,t,n)}function _t(e,t,n){return Je(e)?oc(t,n,1):t===e.k?ft(e,{k:t,v:n}):t<e.k?sc(ft(e,{l:_t(e.l,t,n)})):sc(ft(e,{r:_t(e.r,t,n)}))}function ir(){return _r}function bo(e,t,n){if(Je(e))return[];const r=Wt(e,t)[0];return zg(li(e,r,n))}function ai(e,t){if(Je(e))return _r;const{k:n,l:r,r:o}=e;if(t===n){if(Je(r))return o;if(Je(o))return r;{const[s,i]=rc(r);return yo(ft(e,{k:s,l:nc(r),v:i}))}}else return t<n?yo(ft(e,{l:ai(r,t)})):yo(ft(e,{r:ai(o,t)}))}function $n(e){return Je(e)?[]:[...$n(e.l),{k:e.k,v:e.v},...$n(e.r)]}function li(e,t,n){if(Je(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(li(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(li(s,t,n))),a}function yo(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(ci(t))return ic(ft(e,{lvl:n-1}));if(!Je(t)&&!Je(t.r))return ft(t.r,{l:ft(t,{r:t.r.l}),lvl:n,r:ft(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(ci(e))return ui(ft(e,{lvl:n-1}));if(!Je(r)&&!Je(r.l)){const o=r.l,s=ci(o)?r.lvl-1:r.lvl;return ft(o,{l:ft(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:ui(ft(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function ft(e,t){return oc(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 nc(e){return Je(e.r)?e.l:yo(ft(e,{r:nc(e.r)}))}function ci(e){return Je(e)||e.lvl>e.r.lvl}function rc(e){return Je(e.r)?[e.k,e.v]:rc(e.r)}function oc(e,t,n,r=_r,o=_r){return{k:e,l:r,lvl:n,r:o,v:t}}function sc(e){return ui(ic(e))}function ic(e){const{l:t}=e;return!Je(t)&&t.lvl===e.lvl?ft(t,{r:ft(e,{l:t.r})}):e}function ui(e){const{lvl:t,r:n}=e;return!Je(n)&&!Je(n.r)&&n.lvl===t&&n.r.lvl===t?ft(n,{l:ft(e,{r:n.l}),lvl:t+1}):e}function zg(e){return tc(e,({k:t,v:n})=>({index:t,value:n}))}function ac(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Rr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const di=Ke(()=>({recalcInProgress:X(!1)}),[],{singleton:!0});function lc(e,t,n){return e[So(e,t,n)]}function So(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 Hg(e,t,n,r){const o=So(e,t,r),s=So(e,n,r,o);return e.slice(o,s+1)}function vn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Co(e){return!Je(e.groupOffsetTree)}function fi({index:e},t){return t===e?0:t<e?-1:1}function Ug(){return{groupIndices:[],groupOffsetTree:ir(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:ir()}}function Wg(e,t){let n=Je(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Je(e)){e=_t(e,0,s);continue}const a=bo(e,i-1,o+1);if(a.some(Jg(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=ai(e,f)):(u=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=_t(e,o+1,h));u&&(e=_t(e,i,s))}return[e,n]}function Vg(e){return typeof e.groupIndex<"u"}function Kg({offset:e},t){return t===e?0:t<e?-1:1}function Pr(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=lc(t,e,fi),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function cc(e,t){if(!Co(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function uc(e,t,n){if(Vg(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=cc(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function qg(e,t,n,r=0){return r>0&&(t=Math.max(t,lc(e,r,fi).offset)),tc(Hg(e,t,n,Kg),Xg)}function Gg(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Et.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&Je(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((w,v)=>_t(_t(w,v,h),v+1,p),i)}else[i,a]=Wg(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=hi(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>_t(h,p,Pr(p,f,o)),ir()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function Yg(e){return $n(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 dc(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 hi(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=So(o,t-1,fi),a=o[l].offset;const u=Wt(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===Wt(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:u,value:d}of bo(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 Xg(e){return{index:e.index,value:e}}function Jg(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 Zg={offsetHeight:"height",offsetWidth:"width"},Qt=Ke(([{log:e},{recalcInProgress:t}])=>{const n=Fe(),r=Fe(),o=vt(r,0),s=Fe(),i=Fe(),a=X(0),l=X([]),u=X(void 0),d=X(void 0),f=X((C,k)=>vn(C,Zg[k])),h=X(void 0),p=X(0),w=Ug(),v=vt(z(n,Me(l,e,p),Zt(Gg,w),nt()),w),g=vt(z(l,nt(),Zt((C,k)=>({current:k,prev:C.current}),{current:[],prev:[]}),oe(({prev:C})=>C)),[]);me(z(l,Ee(C=>C.length>0),Me(v,p),oe(([C,k,I])=>{const A=C.reduce((R,P,L)=>_t(R,P,Pr(P,k.offsetTree,I)||L),ir());return{...k,groupIndices:C,groupOffsetTree:A}})),v),me(z(r,Me(v),Ee(([C,{lastIndex:k}])=>C<k),oe(([C,{lastIndex:k,lastSize:I}])=>[{endIndex:k,size:I,startIndex:C}])),n),me(u,d);const x=vt(z(u,oe(C=>C===void 0)),!0);me(z(d,Ee(C=>C!==void 0&&Je(lt(v).sizeTree)),oe(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=At(z(n,Me(v),Zt(({sizes:C},[k,I])=>({changed:I!==C,sizes:I}),{changed:!1,sizes:w}),oe(C=>C.changed)));Xe(z(a,Zt((C,k)=>({diff:C.prev-k,prev:k}),{diff:0,prev:0}),oe(C=>C.diff)),C=>{const{groupIndices:k}=lt(v);if(C>0)Pe(t,!0),Pe(s,C+dc(C,k));else if(C<0){const I=lt(g);I.length>0&&(C-=dc(-C,I)),Pe(i,C)}}),Xe(z(a,Me(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},Et.ERROR)});const S=At(s);me(z(s,Me(v),oe(([C,k])=>{const I=k.groupIndices.length>0,A=[],R=k.lastSize;if(I){const P=jr(k.sizeTree,0);let L=0,$=0;for(;L<C;){const M=k.groupIndices[$],q=k.groupIndices.length===$+1?1/0:k.groupIndices[$+1]-M-1;A.push({endIndex:M,size:P,startIndex:M}),A.push({endIndex:M+1+q-1,size:R,startIndex:M+1}),$++,L+=q+1}const H=$n(k.sizeTree);return L!==C&&H.shift(),H.reduce((M,{k:q,v:V})=>{let Y=M.ranges;return M.prevSize!==0&&(Y=[...M.ranges,{endIndex:q+C-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:q+C,prevSize:V,ranges:Y}},{prevIndex:C,prevSize:0,ranges:A}).ranges}return $n(k.sizeTree).reduce((P,{k:L,v:$})=>({prevIndex:L+C,prevSize:$,ranges:[...P.ranges,{endIndex:L+C-1,size:P.prevSize,startIndex:P.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),n);const N=At(z(i,Me(v,p),oe(([C,{offsetTree:k},I])=>{const A=-C;return Pr(A,k,I)})));return me(z(i,Me(v,p),oe(([C,k,I])=>{if(k.groupIndices.length>0){if(Je(k.sizeTree))return k;let A=ir();const R=lt(g);let P=0,L=0,$=0;for(;P<-C;){$=R[L];const H=R[L+1]-$-1;L++,P+=H+1}if(A=$n(k.sizeTree).reduce((H,{k:M,v:q})=>_t(H,Math.max(0,M+C),q),A),P!==-C){const H=jr(k.sizeTree,$);A=_t(A,0,H);const M=Wt(k.sizeTree,-C+1)[1];A=_t(A,1,M)}return{...k,sizeTree:A,...hi(k.offsetTree,0,A,I)}}else{const A=$n(k.sizeTree).reduce((R,{k:P,v:L})=>_t(R,Math.max(0,P+C),L),ir());return{...k,sizeTree:A,...hi(k.offsetTree,0,A,I)}}})),v),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:N,sizeRanges:n,sizes:v,statefulTotalCount:o,totalCount:r,trackItemSizes:x,unshiftWith:s}},tt(xn,di),{singleton:!0});function Qg(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const fc=Ke(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Fe(),i=Fe(),a=At(z(s,oe(Qg)));return me(z(a,oe(l=>l.totalCount)),n),me(z(a,oe(l=>l.groupIndices)),e),me(z(ut(o,t,r),Ee(([l,u])=>Co(u)),oe(([l,u,d])=>Wt(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),nt(),oe(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},tt(Qt,yt)),wn=Ke(([{log:e}])=>{const t=X(!1),n=At(z(t,Ee(r=>r),nt()));return Xe(t,r=>{r&&lt(e)("props updated",{},Et.DEBUG)}),{didMount:n,propsReady:t}},tt(xn),{singleton:!0}),ex=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function hc(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!ex)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Or=Ke(([{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=Fe(),w=Fe(),v=X(0);let g=null,x=null,b=null;function S(){g&&(g(),g=null),b&&(b(),b=null),x&&(clearTimeout(x),x=null),Pe(l,!1)}return me(z(p,Me(n,f,r,v,a,i,h),Me(e,s,o),oe(([[N,C,k,I,A,R,P,L],$,H,M])=>{const q=hc(N),{align:V,behavior:Y,offset:B}=q,j=I-1,G=uc(q,C,j);let Z=Pr(G,C.offsetTree,$)+R;V==="end"?(Z+=H+Wt(C.sizeTree,G)[1]-k+M,G===j&&(Z+=P)):V==="center"?Z+=(H+Wt(C.sizeTree,G)[1]-k+M)/2:Z-=A,B&&(Z+=B);const ge=de=>{S(),de?(L("retrying to scroll to",{location:N},Et.DEBUG),Pe(p,N)):(Pe(w,!0),L("list did not change, scroll successful",{},Et.DEBUG))};if(S(),Y==="smooth"){let de=!1;b=Xe(t,ee=>{de=de||ee}),g=Ut(d,()=>{ge(de)})}else g=Ut(z(t,tx(150)),ge);return x=setTimeout(()=>{S()},1200),Pe(l,!0),L("scrolling from index to",{behavior:Y,index:G,top:Z},Et.DEBUG),{behavior:Y,top:Z}})),u),{scrollTargetReached:w,scrollToIndex:p,topListHeight:v}},tt(Qt,yt,xn),{singleton:!0});function tx(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function pi(e,t){e==0?t():requestAnimationFrame(()=>{pi(e-1,t)})}function mi(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Mr=Ke(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=X(!0),l=X(0),u=X(!0);return me(z(i,Me(l),Ee(([d,f])=>!!f),Jt(!1)),a),me(z(i,Me(l),Ee(([d,f])=>!!f),Jt(!1)),u),Xe(z(ut(t,i),Me(a,n,e,u),Ee(([[,d],f,{sizeTree:h},p,w])=>d&&(!Je(h)||ri(p))&&!f&&!w),Me(l)),([,d])=>{Ut(o,()=>{Pe(u,!0)}),pi(4,()=>{Ut(r,()=>{Pe(a,!0)}),Pe(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},tt(Qt,yt,Or,wn),{singleton:!0});function pc(e,t){return Math.abs(e-t)<1.01}const Dr="up",Lr="down",nx="none",rx={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},ox=0,$r=Ke(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=X(!1),a=X(!0),l=Fe(),u=Fe(),d=X(4),f=X(ox),h=vt(z(si(z(Ce(o),Dn(1),Jt(!0)),z(Ce(o),Dn(1),Jt(!1),Jl(100))),nt()),!1),p=vt(z(si(z(n,Jt(!0)),z(n,Jt(!1),Jl(200))),nt()),!1);me(z(ut(Ce(o),Ce(f)),oe(([b,S])=>b<=S),nt()),a),me(z(a,un(50)),u);const w=At(z(ut(r,Ce(s),Ce(t),Ce(e),Ce(d)),Zt((b,[{scrollHeight:S,scrollTop:N},C,k,I,A])=>{const R=N+C-S>-A,P={scrollHeight:S,scrollTop:N,viewportHeight:C};if(R){let $,H;return N>b.state.scrollTop?($="SCROLLED_DOWN",H=b.state.scrollTop-N):($="SIZE_DECREASED",H=b.state.scrollTop-N||b.scrollTopDelta),{atBottom:!0,atBottomBecause:$,scrollTopDelta:H,state:P}}let L;return P.scrollHeight>b.state.scrollHeight?L="SIZE_INCREASED":C<b.state.viewportHeight?L="VIEWPORT_HEIGHT_DECREASING":N<b.state.scrollTop?L="SCROLLING_UPWARDS":L="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:L,state:P}},rx),nt((b,S)=>b&&b.atBottom===S.atBottom))),v=vt(z(r,Zt((b,{scrollHeight:S,scrollTop:N,viewportHeight:C})=>{if(pc(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:N};{const k=S-(N+C)<1;return b.scrollTop!==N&&k?{changed:!0,jump:b.scrollTop-N,scrollHeight:S,scrollTop:N}:{changed:!0,jump:0,scrollHeight:S,scrollTop:N}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ee(b=>b.changed),oe(b=>b.jump)),0);me(z(w,oe(b=>b.atBottom)),i),me(z(i,un(50)),l);const g=X(Lr);me(z(r,oe(({scrollTop:b})=>b),nt(),Zt((b,S)=>lt(p)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?Dr:Lr,prevScrollTop:S},{direction:Lr,prevScrollTop:0}),oe(b=>b.direction)),g),me(z(r,un(50),Jt(nx)),g);const x=X(0);return me(z(h,Ee(b=>!b),Jt(0)),x),me(z(o,un(100),Me(h),Ee(([b,S])=>!!S),Zt(([b,S],[N])=>[S,N],[0,0]),oe(([b,S])=>S-b)),x),{atBottomState:w,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:v,scrollDirection:g,scrollVelocity:x}},tt(yt)),To="top",ko="bottom",mc="none";function gc(e,t,n){return typeof e=="number"?n===Dr&&t===To||n===Lr&&t===ko?e:0:n===Dr?t===To?e.main:e.reverse:t===ko?e.main:e.reverse}function xc(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const gi=Ke(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Fe(),i=X(0),a=X(0),l=X(0),u=vt(z(ut(Ce(r),Ce(o),Ce(n),Ce(s,Rr),Ce(l),Ce(i),Ce(t),Ce(e),Ce(a)),oe(([d,f,h,[p,w],v,g,x,b,S])=>{const N=d-b,C=g+x,k=Math.max(h-N,0);let I=mc;const A=xc(S,To),R=xc(S,ko);return p-=b,p+=h+x,w+=h+x,w-=b,p>d+C-A&&(I=Dr),w<d-k+f+R&&(I=Lr),I!==mc?[Math.max(N-h-gc(v,To,I)-A,0),N-k-x+f+gc(v,ko,I)+R]:null}),Ee(d=>d!=null),nt(Rr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},tt(yt),{singleton:!0});function sx(e,t,n){if(Co(t)){const r=cc(e,t);return[{index:Wt(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 xi={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Eo(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,w=h-d;return{bottom:d,firstItemIndex:s,items:wc(e,o,s),offsetBottom:w,offsetTop:u,top:p,topItems:wc(t,o,s),topListHeight:t.reduce((v,g)=>g.size+v,0),totalCount:n}}function vc(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=mi(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return Eo(u,[],a,o,n,r)}function wc(e,t,n){if(e.length===0)return[];if(!Co(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=bo(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 Fn=Ke(([{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:w}])=>{const v=X([]),g=X(0),x=Fe();me(s.topItemsIndexes,v);const b=vt(z(ut(p,w,Ce(l,Rr),Ce(o),Ce(r),Ce(u),d,Ce(v),Ce(t),Ce(n),e),Ee(([k,I,,A,,,,,,,R])=>{const P=R&&R.length!==A;return k&&!I&&!P}),oe(([,,[k,I],A,R,P,L,$,H,M,q])=>{const V=R,{offsetTree:Y,sizeTree:B}=V,j=lt(g);if(A===0)return{...xi,totalCount:A};if(k===0&&I===0)return j===0?{...xi,totalCount:A}:vc(j,P,R,H,M,q||[]);if(Je(B))return j>0?null:Eo(sx(mi(P,A),V,q),[],A,M,V,H);const G=[];if($.length>0){const Ae=$[0],Te=$[$.length-1];let K=0;for(const D of bo(B,Ae,Te)){const J=D.value,U=Math.max(D.start,Ae),fe=Math.min(D.end,Te);for(let ue=U;ue<=fe;ue++)G.push({data:q==null?void 0:q[ue],index:ue,offset:K,size:J}),K+=J}}if(!L)return Eo([],G,A,M,V,H);const Z=$.length>0?$[$.length-1]+1:0,ge=qg(Y,k,I,Z);if(ge.length===0)return null;const de=A-1,ee=wo([],Ae=>{for(const Te of ge){const K=Te.value;let D=K.offset,J=Te.start;const U=K.size;if(K.offset<k){J+=Math.floor((k-K.offset+M)/(U+M));const ue=J-Te.start;D+=ue*U+ue*M}J<Z&&(D+=(Z-J)*U,J=Z);const fe=Math.min(Te.end,de);for(let ue=J;ue<=fe&&!(D>=I);ue++)Ae.push({data:q==null?void 0:q[ue],index:ue,offset:D,size:U}),D+=U+M}});return Eo(ee,G,A,M,V,H)}),Ee(k=>k!==null),nt()),xi);me(z(e,Ee(ri),oe(k=>k==null?void 0:k.length)),o),me(z(b,oe(k=>k.topListHeight)),f),me(f,a),me(z(b,oe(k=>[k.top,k.bottom])),i),me(z(b,oe(k=>k.items)),x);const S=At(z(b,Ee(({items:k})=>k.length>0),Me(o,e),Ee(([{items:k},I])=>k[k.length-1].originalIndex===I-1),oe(([,k,I])=>[k-1,I]),nt(Rr),oe(([k])=>k))),N=At(z(b,un(200),Ee(({items:k,topItems:I})=>k.length>0&&k[0].originalIndex===I.length),oe(({items:k})=>k[0].index),nt())),C=At(z(b,Ee(({items:k})=>k.length>0),oe(({items:k})=>{let I=0,A=k.length-1;for(;k[I].type==="group"&&I<A;)I++;for(;k[A].type==="group"&&A>I;)A--;return{endIndex:k[A].index,startIndex:k[I].index}}),nt(ac)));return{endReached:S,initialItemCount:g,itemsRendered:x,listState:b,rangeChanged:C,startReached:N,topItemsIndexes:v,...h}},tt(Qt,fc,gi,Mr,Or,$r,wn,di),{singleton:!0}),bc=Ke(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Fe(),i=vt(z(ut(n,e,r,t,o),oe(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return me(Ce(i),s),{totalListHeight:i,totalListHeightChanged:s}},tt(yt,Fn),{singleton:!0}),ix=Ke(([{viewportHeight:e},{totalListHeight:t}])=>{const n=X(!1),r=vt(z(ut(n,e,t),Ee(([o])=>o),oe(([,o,s])=>Math.max(0,o-s)),un(0),nt()),0);return{alignToBottom:n,paddingTopAddition:r}},tt(yt,bc),{singleton:!0}),yc=Ke(()=>({context:X(null)})),ax=({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,Sc=Ke(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:u}])=>{const d=Fe();return me(z(d,Me(t,l,n,s,o,r,a),Me(e),oe(([[f,h,p,w,v,g,x,b],S])=>{const{align:N,behavior:C,calculateViewLocation:k=ax,done:I,...A}=f,R=uc(f,h,w-1),P=Pr(R,h.offsetTree,S)+v+g,L=P+Wt(h.sizeTree,R)[1],$=b+g,H=b+p-x,M=k({itemBottom:L,itemTop:P,locationParams:{align:N,behavior:C,...A},viewportBottom:H,viewportTop:$});return M?I&&Ut(z(i,Ee(q=>!q),Dn(lt(i)?1:2)),I):I&&I(),M}),Ee(f=>f!==null)),u),{scrollIntoView:d}},tt(Qt,yt,Or,Fn,xn),{singleton:!0});function Cc(e){return e?e==="smooth"?"smooth":"auto":!1}const lx=(e,t)=>typeof e=="function"?Cc(e(t)):t&&Cc(e),cx=Ke(([{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 w=X(!1),v=Fe();let g=null;function x(C){Pe(i,{align:"end",behavior:C,index:"LAST"})}Xe(z(ut(z(Ce(t),Dn(1)),l),Me(Ce(w),s,a,f),oe(([[C,k],I,A,R,P])=>{let L=k&&R,$="auto";return L&&($=lx(I,A||P),L=L&&!!$),{followOutputBehavior:$,shouldFollow:L,totalCount:C}}),Ee(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:k})=>{g&&(g(),g=null),lt(n)?requestAnimationFrame(()=>{lt(d)("following output to ",{totalCount:k},Et.DEBUG),x(C)}):g=Ut(e,()=>{lt(d)("following output to ",{totalCount:k},Et.DEBUG),x(C),g=null})});function b(C){const k=Ut(o,I=>{C&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(lt(d)("scrolling to bottom due to increased size",{},Et.DEBUG),x("auto"))});setTimeout(k,100)}Xe(z(ut(Ce(w),t,u),Ee(([C,,k])=>C&&k),Zt(({value:C},[,k])=>({refreshed:C===k,value:k}),{refreshed:!1,value:0}),Ee(({refreshed:C})=>C),Me(w,t)),([,C])=>{lt(a)&&b(C!==!1)}),Xe(v,()=>{b(lt(w)!==!1)}),Xe(ut(Ce(w),o),([C,k])=>{C&&!k.atBottom&&k.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&x("auto")});const S=X(null),N=Fe();return me(si(z(Ce(r),oe(C=>{var k;return(k=C==null?void 0:C.length)!=null?k:0})),z(Ce(t))),N),Xe(z(ut(z(N,Dn(1)),l),Me(Ce(S),a,f,h),oe(([[C,k],I,A,R,P])=>k&&A&&(I==null?void 0:I({context:P,totalCount:C,scrollingInProgress:R}))),Ee(C=>!!C),un(0)),C=>{g&&(g(),g=null),lt(n)?requestAnimationFrame(()=>{lt(d)("scrolling into view",{}),Pe(p,C)}):g=Ut(e,()=>{lt(d)("scrolling into view",{}),Pe(p,C),g=null})}),{autoscrollToBottom:v,followOutput:w,scrollIntoViewOnChange:S}},tt(Qt,$r,Or,Mr,wn,xn,yt,yc,Sc)),ux=Ke(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(me(z(a,Me(s),Ee(([,l])=>l!==0),Me(o,r,t,n,e),oe(([[,l],u,d,f,h,p=[]])=>vc(l,u,d,f,h,p))),i),{}),tt(Qt,Mr,Fn,wn),{singleton:!0}),dx=Ke(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=X(0);return Xe(z(e,Me(r),Ee(([,o])=>o!==0),oe(([,o])=>({top:o}))),o=>{Ut(z(n,Dn(1),Ee(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Pe(t,o)})})}),{initialScrollTop:r}},tt(wn,yt,Fn),{singleton:!0}),Tc=Ke(([{scrollVelocity:e}])=>{const t=X(!1),n=Fe(),r=X(!1);return me(z(e,Me(r,t,n),Ee(([o,s])=>!!s),oe(([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),Xe(z(ut(t,e,n),Me(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},tt($r),{singleton:!0}),vi=Ke(([{scrollContainerState:e,scrollTo:t}])=>{const n=Fe(),r=Fe(),o=Fe(),s=X(!1),i=X(void 0);return me(z(ut(n,r),oe(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),me(z(t,Me(r),oe(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},tt(yt)),fx=Ke(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=Fe(),d=X(void 0),f=X(null),h=X(null);return me(a,f),me(l,h),Xe(z(u,Me(t,r,i,f,h,n)),([p,w,v,g,x,b,S])=>{const N=Yg(w.sizeTree);g&&x!==null&&b!==null&&(v=x.scrollTop-b.offsetTop),v-=S,p({ranges:N,scrollTop:v})}),me(z(d,Ee(ri),oe(hx)),o),me(z(s,Me(d),Ee(([,p])=>p!==void 0),nt(),oe(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},tt(Qt,yt,Mr,wn,vi));function hx(e){return{align:"start",index:0,offset:e.scrollTop}}const px=Ke(([{topItemsIndexes:e}])=>{const t=X(0);return me(z(t,Ee(n=>n>=0),oe(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},tt(Fn));function kc(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const mx=kc(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),gx=Ke(([{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:w}])=>{const v=At(z(l,Me(i),Zt(([,x,b,S],[{bottom:N,items:C,offsetBottom:k,totalCount:I},A])=>{const R=N+k;let P=0;return b===I&&x.length>0&&C.length>0&&(C[0].originalIndex===0&&x[0].originalIndex===0||(P=R-S,P!==0&&(P+=A))),[P,C,I,R]},[0,[],0,0]),Ee(([x])=>x!==0),Me(r,a,n,o,p,w),Ee(([,x,b,S,,,N])=>!N&&!S&&x!==0&&b===Dr),oe(([[x],,,,,b])=>(b("Upward scrolling compensation",{amount:x},Et.DEBUG),x))));function g(x){x>0?(Pe(t,{behavior:"auto",top:-x}),Pe(e,0)):(Pe(e,0),Pe(t,{behavior:"auto",top:-x}))}return Xe(z(v,Me(e,s)),([x,b,S])=>{S&&mx()?Pe(e,b-x):g(-x)}),Xe(z(ut(vt(s,!1),e,w),Ee(([x,b,S])=>!x&&!S&&b!==0),oe(([x,b])=>b),un(1)),g),me(z(f,oe(x=>({top:-x}))),t),Xe(z(u,Me(h,d),oe(([x,{groupIndices:b,lastSize:S,sizeTree:N},C])=>{function k(I){return I*(S+C)}if(b.length===0)return k(x);{let I=0;const A=jr(N,0);let R=0,P=0;for(;R<x;){R++,I+=A;let L=b.length===P+1?1/0:b[P+1]-b[P]-1;R+L>x&&(I-=A,L=x-R+1),R+=L,I+=k(L),P++}return I}})),x=>{Pe(e,x),requestAnimationFrame(()=>{Pe(t,{top:x}),requestAnimationFrame(()=>{Pe(e,0),Pe(w,!1)})})}),{deviation:e}},tt(yt,$r,Fn,Qt,xn,di)),xx=Ke(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),tt(gi,ux,wn,Tc,bc,dx,ix,vi,Sc,xn,yc)),Ec=Ke(([{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:w},v,g,x,{listState:b,topItemsIndexes:S,...N},{scrollToIndex:C},k,{topItemCount:I},{groupCounts:A},R])=>(me(N.rangeChanged,R.scrollSeekRangeChanged),me(z(R.windowViewportRect,oe(P=>P.visibleHeight)),v.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:w,sizeRanges:a,topItemCount:I,topItemsIndexes:S,totalCount:d,...x,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...N,...R,...v,sizes:l,...g}),tt(Qt,Mr,yt,fx,cx,Fn,Or,gx,px,fc,xx));function vx(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 Io=typeof document<"u"?y.useLayoutEffect:y.useEffect;function Ic(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=y.createContext({});function l(g,x){g.propsReady&&Pe(g.propsReady,!1);for(const b of r){const S=g[t.required[b]];Pe(S,x[b])}for(const b of o)if(b in x){const S=g[t.optional[b]];Pe(S,x[b])}g.propsReady&&Pe(g.propsReady,!0)}function u(g){return s.reduce((x,b)=>(x[b]=S=>{const N=g[t.methods[b]];Pe(N,S)},x),{})}function d(g){return i.reduce((x,b)=>(x[b]=Og(g[t.events[b]]),x),{})}const f=y.forwardRef((g,x)=>{const{children:b,...S}=g,[N]=y.useState(()=>wo(Dg(e),I=>{l(I,S)})),[C]=y.useState(Xl(d,N));Io(()=>{for(const I of i)I in S&&Xe(C[I],S[I]);return()=>{Object.values(C).map(oi)}},[S,C,N]),Io(()=>{l(N,S)}),y.useImperativeHandle(x,Gl(u(N)));const k=n;return c.jsx(a.Provider,{value:N,children:n?c.jsx(k,{...vx([...r,...o,...i],S),children:b}):b})}),h=g=>{const x=y.useContext(a);return y.useCallback(b=>{Pe(x[g],b)},[x,g])},p=g=>{const x=y.useContext(a)[g],b=y.useCallback(S=>Xe(x,S),[x]);return y.useSyncExternalStore(b,()=>lt(x),()=>lt(x))},w=g=>{const x=y.useContext(a)[g],[b,S]=y.useState(Xl(lt,x));return Io(()=>Xe(x,N=>{N!==b&&S(Gl(N))}),[x,b]),b},v=y.version.startsWith("18")?p:w;return{Component:f,useEmitter:(g,x)=>{const b=y.useContext(a)[g];Io(()=>Xe(b,x),[x,b])},useEmitterValue:v,usePublisher:h}}const Nc=y.createContext(void 0),Ac=y.createContext(void 0),_c=typeof document<"u"?y.useLayoutEffect:y.useEffect;function wi(e){return"self"in e}function wx(e){return"body"in e}function jc(e,t,n,r=sr,o,s){const i=y.useRef(null),a=y.useRef(null),l=y.useRef(null),u=y.useCallback(h=>{let p,w,v;const g=h.target;if(wx(g)||wi(g)){const b=wi(g)?g:g.defaultView;v=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,w=s?b.innerWidth:b.innerHeight}else v=s?g.scrollLeft:g.scrollTop,p=s?g.scrollWidth:g.scrollHeight,w=s?g.offsetWidth:g.offsetHeight;const x=()=>{e({scrollHeight:p,scrollTop:Math.max(v,0),viewportHeight:w})};h.suppressFlushSync?x():Rs.flushSync(x),a.current!==null&&(v===a.current||v<=0||v===p-w)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);y.useEffect(()=>{const h=o||i.current;return r(o||i.current),u({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",u,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",u)}},[i,u,n,r,o]);function d(h){const p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const w=h.behavior==="smooth";let v,g,x;wi(p)?(g=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):(g=p[s?"scrollWidth":"scrollHeight"],v=vn(p,s?"width":"height"),x=p[s?"scrollLeft":"scrollTop"]);const b=g-v;if(h.top=Math.ceil(Math.max(Math.min(b,h.top),0)),pc(v,g)||h.top===x){e({scrollHeight:g,scrollTop:x,viewportHeight:v}),w&&t(!0);return}w?(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 bi="-webkit-sticky",Rc="sticky",yi=kc(()=>{if(typeof document>"u")return Rc;const e=document.createElement("div");return e.style.position=bi,e.style.position===bi?bi:Rc});function Si(e){return e}const bx=Ke(()=>{const e=X(a=>`Item ${a}`),t=X(a=>`Group ${a}`),n=X({}),r=X(Si),o=X("div"),s=X(sr),i=(a,l=null)=>vt(z(n,oe(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")}}),yx=Ke(([e,t])=>({...e,...t}),tt(Ec,bx)),Sx=({height:e})=>c.jsx("div",{style:{height:e}}),Cx={overflowAnchor:"none",position:yi(),zIndex:1},Pc={overflowAnchor:"none"},Tx={...Pc,display:"inline-block",height:"100%"},Oc=y.memo(function({showTopList:e=!1}){const t=_e("listState"),n=Mt("sizeRanges"),r=_e("useWindowScroll"),o=_e("customScrollParent"),s=Mt("windowScrollContainerState"),i=Mt("scrollContainerState"),a=o||r?s:i,l=_e("itemContent"),u=_e("context"),d=_e("groupContent"),f=_e("trackItemSizes"),h=_e("itemSize"),p=_e("log"),w=Mt("gap"),v=_e("horizontalDirection"),{callbackRef:g}=Fg(n,h,f,e?sr:a,p,w,o,v,_e("skipAnimationFrameInResizeObserver")),[x,b]=y.useState(0);Ci("deviation",M=>{x!==M&&b(M)});const S=_e("EmptyPlaceholder"),N=_e("ScrollSeekPlaceholder")||Sx,C=_e("ListComponent"),k=_e("ItemComponent"),I=_e("GroupComponent"),A=_e("computeItemKey"),R=_e("isSeeking"),P=_e("groupIndices").length>0,L=_e("alignToBottom"),$=_e("initialItemFinalLocationReached"),H=e?{}:{boxSizing:"border-box",...v?{display:"inline-block",height:"100%",marginLeft:x!==0?x:L?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:x!==0?x:L?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...$?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?c.jsx(S,{...wt(S,u)}):c.jsx(C,{...wt(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:H,children:(e?t.topItems:t.items).map(M=>{const q=M.originalIndex,V=A(q+t.firstItemIndex,M.data,u);return R?y.createElement(N,{...wt(N,u),height:M.size,index:M.index,key:V,type:M.type||"item",...M.type==="group"?{}:{groupIndex:M.groupIndex}}):M.type==="group"?y.createElement(I,{...wt(I,u),"data-index":q,"data-item-index":M.index,"data-known-size":M.size,key:V,style:Cx},d(M.index,u)):y.createElement(k,{...wt(k,u),...Nx(k,M.data),"data-index":q,"data-item-group-index":M.groupIndex,"data-item-index":M.index,"data-known-size":M.size,key:V,style:v?Tx:Pc},P?l(M.index,M.groupIndex,M.data,u):l(M.index,M.data,u))})})}),kx={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Ex={outline:"none",overflowX:"auto",position:"relative"},No=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Ix={position:yi(),top:0,width:"100%",zIndex:1};function wt(e,t){if(typeof e!="string")return{context:t}}function Nx(e,t){return{item:typeof e=="string"?void 0:t}}const Ax=y.memo(function(){const e=_e("HeaderComponent"),t=Mt("headerHeight"),n=_e("HeaderFooterTag"),r=Ln(y.useMemo(()=>s=>{t(vn(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...wt(e,o)})}):null}),_x=y.memo(function(){const e=_e("FooterComponent"),t=Mt("footerHeight"),n=_e("HeaderFooterTag"),r=Ln(y.useMemo(()=>s=>{t(vn(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...wt(e,o)})}):null});function Mc({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.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:w}=jc(a,u,l,d,void 0,f);return e("scrollTo",w),e("scrollBy",h),c.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?Ex:kx,...o},tabIndex:0,...i,...wt(l,s),children:r})})}function Dc({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.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=y.useRef(null),w=t("scrollerRef"),{scrollByCallback:v,scrollerRef:g,scrollToCallback:x}=jc(a,u,l,w,h);return _c(()=>{var b;return g.current=h||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",x),e("scrollBy",v),c.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...wt(l,s),children:r})})}const jx=({children:e})=>{const t=y.useContext(Nc),n=Mt("viewportHeight"),r=Mt("fixedItemHeight"),o=_e("alignToBottom"),s=_e("horizontalDirection"),i=y.useMemo(()=>Yl(n,l=>vn(l,s?"width":"height")),[n,s]),a=Ln(i,!0,_e("skipAnimationFrameInResizeObserver"));return y.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),c.jsx("div",{"data-viewport-type":"element",ref:a,style:No(o),children:e})},Rx=({children:e})=>{const t=y.useContext(Nc),n=Mt("windowViewportRect"),r=Mt("fixedItemHeight"),o=_e("customScrollParent"),s=ec(n,o,_e("skipAnimationFrameInResizeObserver")),i=_e("alignToBottom");return y.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:No(i),children:e})},Px=({children:e})=>{const t=_e("TopItemListComponent")||"div",n=_e("headerHeight"),r={...Ix,marginTop:`${n}px`},o=_e("context");return c.jsx(t,{style:r,...wt(t,o),children:e})},Ox=y.memo(function(e){const t=_e("useWindowScroll"),n=_e("topItemsIndexes").length>0,r=_e("customScrollParent"),o=_e("context");return c.jsxs(r||t?Lx:Dx,{...e,context:o,children:[n&&c.jsx(Px,{children:c.jsx(Oc,{showTopList:!0})}),c.jsxs(r||t?Rx:jx,{children:[c.jsx(Ax,{}),c.jsx(Oc,{}),c.jsx(_x,{})]})]})}),{Component:Mx,useEmitter:Ci,useEmitterValue:_e,usePublisher:Mt}=Ic(yx,{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"}},Ox),Dx=Mc({useEmitter:Ci,useEmitterValue:_e,usePublisher:Mt}),Lx=Dc({useEmitter:Ci,useEmitterValue:_e,usePublisher:Mt}),$x=Mx;tt(Ec,Ke(()=>{const e=X(u=>c.jsxs("td",{children:["Item $",u]})),t=X(null),n=X(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=X(null),o=X(null),s=X({}),i=X(Si),a=X(sr),l=(u,d=null)=>vt(z(s,oe(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")}})),yi();const Lc={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Fx={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:$c,floor:Ao,max:Fr,min:Ti,round:Fc}=Math;function Bc(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function Bx(e){return{...Fx,items:e}}function _o(e,t){return e&&e.width===t.width&&e.height===t.height}function zx(e,t){return e&&e.column===t.column&&e.row===t.row}const Hx=Ke(([{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:w,propsReady:v},{customScrollParent:g,useWindowScroll:x,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:N},C])=>{const k=X(0),I=X(0),A=X(Lc),R=X({height:0,width:0}),P=X({height:0,width:0}),L=Fe(),$=Fe(),H=X(0),M=X(null),q=X({column:0,row:0}),V=Fe(),Y=Fe(),B=X(!1),j=X(0),G=X(!0),Z=X(!1),ge=X(!1);Xe(z(w,Me(j),Ee(([D,J])=>!!J)),()=>{Pe(G,!1)}),Xe(z(ut(w,G,P,R,j,Z),Ee(([D,J,U,fe,,ue])=>D&&!J&&U.height!==0&&fe.height!==0&&!ue)),([,,,,D])=>{Pe(Z,!0),pi(1,()=>{Pe(L,D)}),Ut(z(u),()=>{Pe(t,[0,0]),Pe(G,!0)})}),me(z(Y,Ee(D=>D!=null&&D.scrollTop>0),Jt(0)),I),Xe(z(w,Me(Y),Ee(([,D])=>D!=null)),([,D])=>{D&&(Pe(R,D.viewport),Pe(P,D.item),Pe(q,D.gap),D.scrollTop>0&&(Pe(B,!0),Ut(z(u,Dn(1)),J=>{Pe(B,!1)}),Pe(l,{top:D.scrollTop})))}),me(z(R,oe(({height:D})=>D)),f),me(z(ut(Ce(R,_o),Ce(P,_o),Ce(q,(D,J)=>D&&D.column===J.column&&D.row===J.row),Ce(u)),oe(([D,J,U,fe])=>({gap:U,item:J,scrollTop:fe,viewport:D}))),V),me(z(ut(Ce(k),r,Ce(q,zx),Ce(P,_o),Ce(R,_o),Ce(M),Ce(I),Ce(B),Ce(G),Ce(j)),Ee(([,,,,,,,D])=>!D),oe(([D,[J,U],fe,ue,$e,Ge,qe,,ke,Oe])=>{const{column:Be,row:Ue}=fe,{height:st,width:ot}=ue,{width:ne}=$e;if(qe===0&&(D===0||ne===0))return Lc;if(ot===0){const gt=mi(Oe,D),hn=gt+Math.max(qe-1,0);return Bx(Bc(gt,hn,Ge))}const le=zc(ne,ot,Be);let xe,Se;ke?J===0&&U===0&&qe>0?(xe=0,Se=qe-1):(xe=le*Ao((J+Ue)/(st+Ue)),Se=le*$c((U+Ue)/(st+Ue))-1,Se=Ti(D-1,Fr(Se,le-1)),xe=Ti(Se,Fr(0,xe))):(xe=0,Se=-1);const be=Bc(xe,Se,Ge),{bottom:je,top:Qe}=Hc($e,fe,ue,be),Ye=$c(D/le),it=Ye*st+(Ye-1)*Ue-je;return{bottom:je,itemHeight:st,items:be,itemWidth:ot,offsetBottom:it,offsetTop:Qe,top:Qe}})),A),me(z(M,Ee(D=>D!==null),oe(D=>D.length)),k),me(z(ut(R,P,A,q),Ee(([D,J,{items:U}])=>U.length>0&&J.height!==0&&D.height!==0),oe(([D,J,{items:U},fe])=>{const{bottom:ue,top:$e}=Hc(D,fe,J,U);return[$e,ue]}),nt(Rr)),t);const de=X(!1);me(z(u,Me(de),oe(([D,J])=>J||D!==0)),de);const ee=At(z(ut(A,k),Ee(([{items:D}])=>D.length>0),Me(de),Ee(([[D,J],U])=>{const fe=D.items[D.items.length-1].index===J-1;return(U||D.bottom>0&&D.itemHeight>0&&D.offsetBottom===0&&D.items.length===J)&&fe}),oe(([[,D]])=>D-1),nt())),Ae=At(z(Ce(A),Ee(({items:D})=>D.length>0&&D[0].index===0),Jt(0),nt())),Te=At(z(Ce(A),Me(B),Ee(([{items:D},J])=>D.length>0&&!J),oe(([{items:D}])=>({endIndex:D[D.length-1].index,startIndex:D[0].index})),nt(ac),un(0)));me(Te,p.scrollSeekRangeChanged),me(z(L,Me(R,P,k,q),oe(([D,J,U,fe,ue])=>{const $e=hc(D),{align:Ge,behavior:qe,offset:ke}=$e;let Oe=$e.index;Oe==="LAST"&&(Oe=fe-1),Oe=Fr(0,Oe,Ti(fe-1,Oe));let Be=ki(J,ue,U,Oe);return Ge==="end"?Be=Fc(Be-J.height+U.height):Ge==="center"&&(Be=Fc(Be-J.height/2+U.height/2)),ke&&(Be+=ke),{behavior:qe,top:Be}})),l);const K=vt(z(A,oe(D=>D.offsetBottom+D.bottom)),0);return me(z(N,oe(D=>({height:D.visibleHeight,width:D.visibleWidth}))),R),{customScrollParent:g,data:M,deviation:H,footerHeight:o,gap:q,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:P,overscan:n,restoreStateFrom:Y,scrollBy:i,scrollContainerState:a,scrollHeight:$,scrollTo:l,scrollToIndex:L,scrollTop:u,smoothScrollTargetReached:d,totalCount:k,useWindowScroll:x,viewportDimensions:R,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:N,...p,gridState:A,horizontalDirection:ge,initialTopMostItemIndex:j,totalListHeight:K,...h,endReached:ee,propsReady:v,rangeChanged:Te,startReached:Ae,stateChanged:V,stateRestoreInProgress:B,...C}},tt(gi,yt,$r,Tc,wn,vi,xn));function zc(e,t,n){return Fr(1,Ao((e+n)/(Ao(t)+n)))}function Hc(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=ki(e,t,n,r[0].index);return{bottom:ki(e,t,n,r[r.length-1].index)+o,top:s}}function ki(e,t,n,r){const o=zc(e.width,n.width,t.column),s=Ao(r/o),i=s*n.height+Fr(0,s-1)*t.row;return i>0?i+t.row:i}const Ux=Ke(()=>{const e=X(f=>`Item ${f}`),t=X({}),n=X(null),r=X("virtuoso-grid-item"),o=X("virtuoso-grid-list"),s=X(Si),i=X("div"),a=X(sr),l=(f,h=null)=>vt(z(t,oe(p=>p[f]),nt()),h),u=X(!1),d=X(!1);return me(Ce(d),u),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:u,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),Wx=Ke(([e,t])=>({...e,...t}),tt(Hx,Ux)),Vx=y.memo(function(){const e=rt("gridState"),t=rt("listClassName"),n=rt("itemClassName"),r=rt("itemContent"),o=rt("computeItemKey"),s=rt("isSeeking"),i=Dt("scrollHeight"),a=rt("ItemComponent"),l=rt("ListComponent"),u=rt("ScrollSeekPlaceholder"),d=rt("context"),f=Dt("itemDimensions"),h=Dt("gap"),p=rt("log"),w=rt("stateRestoreInProgress"),v=Dt("reportReadyState"),g=Ln(y.useMemo(()=>x=>{const b=x.parentElement.parentElement.scrollHeight;i(b);const S=x.firstChild;if(S){const{height:N,width:C}=S.getBoundingClientRect();f({height:N,width:C})}h({column:Wc("column-gap",getComputedStyle(x).columnGap,p),row:Wc("row-gap",getComputedStyle(x).rowGap,p)})},[i,f,h,p]),!0,!1);return _c(()=>{e.itemHeight>0&&e.itemWidth>0&&v(!0)},[e]),w?null:c.jsx(l,{className:t,ref:g,...wt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(x=>{const b=o(x.index,x.data,d);return s?c.jsx(u,{...wt(u,d),height:e.itemHeight,index:x.index,width:e.itemWidth},b):y.createElement(a,{...wt(a,d),className:n,"data-index":x.index,key:b},r(x.index,x.data,d))})})}),Kx=y.memo(function(){const e=rt("HeaderComponent"),t=Dt("headerHeight"),n=rt("headerFooterTag"),r=Ln(y.useMemo(()=>s=>{t(vn(s,"height"))},[t]),!0,!1),o=rt("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...wt(e,o)})}):null}),qx=y.memo(function(){const e=rt("FooterComponent"),t=Dt("footerHeight"),n=rt("headerFooterTag"),r=Ln(y.useMemo(()=>s=>{t(vn(s,"height"))},[t]),!0,!1),o=rt("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...wt(e,o)})}):null}),Gx=({children:e})=>{const t=y.useContext(Ac),n=Dt("itemDimensions"),r=Dt("viewportDimensions"),o=Ln(y.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return y.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),c.jsx("div",{ref:o,style:No(!1),children:e})},Yx=({children:e})=>{const t=y.useContext(Ac),n=Dt("windowViewportRect"),r=Dt("itemDimensions"),o=rt("customScrollParent"),s=ec(n,o,!1);return y.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),c.jsx("div",{ref:s,style:No(!1),children:e})},Xx=y.memo(function({...e}){const t=rt("useWindowScroll"),n=rt("customScrollParent"),r=n||t?Zx:Jx,o=n||t?Yx:Gx,s=rt("context");return c.jsx(r,{...e,...wt(r,s),children:c.jsxs(o,{children:[c.jsx(Kx,{}),c.jsx(Vx,{}),c.jsx(qx,{})]})})}),{useEmitter:Uc,useEmitterValue:rt,usePublisher:Dt}=Ic(Wx,{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"}},Xx),Jx=Mc({useEmitter:Uc,useEmitterValue:rt,usePublisher:Dt}),Zx=Dc({useEmitter:Uc,useEmitterValue:rt,usePublisher:Dt});function Wc(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Et.WARN),t==="normal"?0:parseInt(t??"0",10)}const Qx=no.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 Ei({className:e,variant:t,...n}){return c.jsx("div",{className:Q(Qx({variant:t}),e),...n})}function ce(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function ev(e,t){const n=m.createContext(t),r=s=>{const{children:i,...a}=s,l=m.useMemo(()=>a,Object.values(a));return c.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=m.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function en(e,t=[]){let n=[];function r(s,i){const a=m.createContext(i),l=n.length;n=[...n,i];const u=f=>{var x;const{scope:h,children:p,...w}=f,v=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,g=m.useMemo(()=>w,Object.values(w));return c.jsx(v.Provider,{value:g,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,w=m.useContext(p);if(w)return w;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>m.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,tv(o,...t)]}function tv(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:u})=>{const f=l(s)[`__scope${u}`];return{...a,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var pt=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},nv=m[" useInsertionEffect ".trim().toString()]||pt;function Bn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=rv({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=m.useRef(e!==void 0);m.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const u=m.useCallback(d=>{var f;if(a){const h=ov(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 rv({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return nv(()=>{s.current=t},[t]),m.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function ov(e){return typeof e=="function"}function Vc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ii(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Vc(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():Vc(e[o],null)}}}}function Le(...e){return m.useCallback(Ii(...e),e)}var sv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ie=sv.reduce((e,t)=>{const n=Rn.createSlot(`Primitive.${t}`),r=m.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Kc(e,t){e&&ro.flushSync(()=>e.dispatchEvent(t))}function iv(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var jt=e=>{const{present:t,children:n}=e,r=av(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=Le(r.ref,lv(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};jt.displayName="Presence";function av(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=iv(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=jo(r.current);s.current=a==="mounted"?u:"none"},[a]),pt(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,p=jo(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]),pt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const v=jo(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&v&&(l("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},h=p=>{p.target===t&&(s.current=jo(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function jo(e){return(e==null?void 0:e.animationName)||"none"}function lv(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 cv=m[" useId ".trim().toString()]||(()=>{}),uv=0;function tn(e){const[t,n]=m.useState(cv());return pt(()=>{n(r=>r??String(uv++))},[e]),e||(t?`radix-${t}`:"")}var Ro="Collapsible",[dv,GC]=en(Ro),[fv,Ni]=dv(Ro),qc=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,u]=Bn({prop:r,defaultProp:o??!1,onChange:i,caller:Ro});return c.jsx(fv,{scope:n,disabled:s,contentId:tn(),open:l,onOpenToggle:m.useCallback(()=>u(d=>!d),[u]),children:c.jsx(Ie.div,{"data-state":_i(l),"data-disabled":s?"":void 0,...a,ref:t})})});qc.displayName=Ro;var Gc="CollapsibleTrigger",Yc=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=Ni(Gc,n);return c.jsx(Ie.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":_i(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:ce(e.onClick,o.onOpenToggle)})});Yc.displayName=Gc;var Ai="CollapsibleContent",hv=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ni(Ai,e.__scopeCollapsible);return c.jsx(jt,{present:n||o.open,children:({present:s})=>c.jsx(pv,{...r,ref:t,present:s})})});hv.displayName=Ai;var pv=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=Ni(Ai,n),[a,l]=m.useState(r),u=m.useRef(null),d=Le(t,u),f=m.useRef(0),h=f.current,p=m.useRef(0),w=p.current,v=i.open||a,g=m.useRef(v),x=m.useRef(void 0);return m.useEffect(()=>{const b=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(b)},[]),pt(()=>{const b=u.current;if(b){x.current=x.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const S=b.getBoundingClientRect();f.current=S.height,p.current=S.width,g.current||(b.style.transitionDuration=x.current.transitionDuration,b.style.animationName=x.current.animationName),l(r)}},[i.open,r]),c.jsx(Ie.div,{"data-state":_i(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!v,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":w?`${w}px`:void 0,...e.style},children:v&&o})});function _i(e){return e?"open":"closed"}var mv=qc;const Xc=mv,Jc=Yc,Br=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Q("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Br.displayName="Card";const zr=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Q("flex flex-col space-y-1.5 p-6",e),...t}));zr.displayName="CardHeader";const Hr=m.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:Q("text-2xl font-semibold leading-none tracking-tight",e),...t}));Hr.displayName="CardTitle";const Zc=m.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:Q("text-sm text-muted-foreground",e),...t}));Zc.displayName="CardDescription";const Po=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Q("p-6 pt-0",e),...t}));Po.displayName="CardContent";const Qc=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Q("flex items-center p-6 pt-0",e),...t}));Qc.displayName="CardFooter";function eu(){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 zn=eu();function gv(e){zn=e}const tu=/[&<>"']/,xv=new RegExp(tu.source,"g"),nu=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,vv=new RegExp(nu.source,"g"),wv={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ru=e=>wv[e];function bt(e,t){if(t){if(tu.test(e))return e.replace(xv,ru)}else if(nu.test(e))return e.replace(vv,ru);return e}const bv=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function ou(e){return e.replace(bv,(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 yv=/(^|[^\[])\^/g;function Ze(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(yv,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const Sv=/[^\w:]/g,Cv=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function su(e,t,n){if(e){let r;try{r=decodeURIComponent(ou(n)).replace(Sv,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!Cv.test(n)&&(n=Iv(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Oo={},Tv=/^[^:]+:\/*[^/]*$/,kv=/^([^:]+:)[\s\S]*$/,Ev=/^([^:]+:\/*[^/]*)[\s\S]*$/;function Iv(e,t){Oo[" "+e]||(Tv.test(e)?Oo[" "+e]=e+"/":Oo[" "+e]=Do(e,"/",!0)),e=Oo[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(kv,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(Ev,"$1")+t:e+t}const Mo={exec:function(){}};function iu(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 Do(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 Nv(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 Av(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 au(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function lu(e,t,n,r){const o=t.href,s=t.title?bt(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:bt(i)}}function _v(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
34
34
  `).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(`
35
- `)}class Ni{constructor(t){this.options=t||Bn}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:Do(r,`
36
- `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=Sv(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:o}}}heading(t){const n=this.rules.block.heading.exec(t);if(n){let r=n[2].trim();if(/#$/.test(r)){const o=Do(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,w,v=n[1].trim();const g=v.length>1,x={type:"list",raw:"",ordered:g,start:g?+v.slice(0,-1):"",loose:!1,items:[]};v=g?`\\d{1,9}\\${v.slice(-1)}`:`\\${v}`,this.options.pedantic&&(v=g?v:"[*+-]");const b=new RegExp(`^( {0,3}${v})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(w=!1,!(!(n=b.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
37
- `,1)[0].replace(/^\t+/,E=>" ".repeat(3*E.length)),f=t.split(`
35
+ `)}class ji{constructor(t){this.options=t||zn}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:Do(r,`
36
+ `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=_v(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=Do(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,w,v=n[1].trim();const g=v.length>1,x={type:"list",raw:"",ordered:g,start:g?+v.slice(0,-1):"",loose:!1,items:[]};v=g?`\\d{1,9}\\${v.slice(-1)}`:`\\${v}`,this.options.pedantic&&(v=g?v:"[*+-]");const b=new RegExp(`^( {0,3}${v})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(w=!1,!(!(n=b.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
37
+ `,1)[0].replace(/^\t+/,N=>" ".repeat(3*N.length)),f=t.split(`
38
38
  `,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+`
39
- `,t=t.substring(f.length+1),w=!0),!w){const E=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),C=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),I=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(h=t.split(`
40
- `,1)[0],f=h,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(T.test(f)||I.test(f)||E.test(f)||C.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())p+=`
41
- `+f.slice(i);else{if(l||d.search(/[^ ]/)>=4||T.test(d)||I.test(d)||C.test(d))break;p+=`
39
+ `,t=t.substring(f.length+1),w=!0),!w){const N=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)}}(?:\`\`\`|~~~)`),I=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(h=t.split(`
40
+ `,1)[0],f=h,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(k.test(f)||I.test(f)||N.test(f)||C.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())p+=`
41
+ `+f.slice(i);else{if(l||d.search(/[^ ]/)>=4||k.test(d)||I.test(d)||C.test(d))break;p+=`
42
42
  `+f}!l&&!f.trim()&&(l=!0),r+=h+`
43
- `,t=t.substring(h.length+1),d=f.slice(i)}}x.loose||(u?x.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(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 E=x.items[a].tokens.filter(T=>T.type==="space"),C=E.length>0&&E.some(T=>/\n.*\n/.test(T.raw));x.loose=C}if(x.loose)for(a=0;a<S;a++)x.items[a].loose=!0;return x}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):bt(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:nu(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
44
- `):[]};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]=nu(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)===`
45
- `?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:bt(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]):bt(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=Do(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=bv(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)),ou(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 ou(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 w=h.slice(1,-1);return{type:"em",raw:h,text:w,tokens:this.lexer.inlineTokens(w)}}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=bt(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=bt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=bt(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=bt(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=bt(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]):bt(r[0]):r[0]:o=bt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const pe={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:Mo,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};pe._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,pe._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,pe.def=et(pe.def).replace("label",pe._label).replace("title",pe._title).getRegex(),pe.bullet=/(?:[*+-]|\d{1,9}[.)])/,pe.listItemStart=et(/^( *)(bull) */).replace("bull",pe.bullet).getRegex(),pe.list=et(pe.list).replace(/bull/g,pe.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+pe.def.source+")").getRegex(),pe._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",pe._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,pe.html=et(pe.html,"i").replace("comment",pe._comment).replace("tag",pe._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),pe.paragraph=et(pe._paragraph).replace("hr",pe.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",pe._tag).getRegex(),pe.blockquote=et(pe.blockquote).replace("paragraph",pe.paragraph).getRegex(),pe.normal={...pe},pe.gfm={...pe.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},pe.gfm.table=et(pe.gfm.table).replace("hr",pe.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",pe._tag).getRegex(),pe.gfm.paragraph=et(pe._paragraph).replace("hr",pe.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",pe.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",pe._tag).getRegex(),pe.pedantic={...pe.normal,html:et(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",pe._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:Mo,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:et(pe.normal._paragraph).replace("hr",pe.hr).replace("heading",` *#{1,6} *[^
46
- ]`).replace("lheading",pe.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ae={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Mo,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:Mo,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};ae._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",ae.punctuation=et(ae.punctuation).replace(/punctuation/g,ae._punctuation).getRegex(),ae.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,ae.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,ae._comment=et(pe._comment).replace("(?:-->|$)","-->").getRegex(),ae.emStrong.lDelim=et(ae.emStrong.lDelim).replace(/punct/g,ae._punctuation).getRegex(),ae.emStrong.rDelimAst=et(ae.emStrong.rDelimAst,"g").replace(/punct/g,ae._punctuation).getRegex(),ae.emStrong.rDelimUnd=et(ae.emStrong.rDelimUnd,"g").replace(/punct/g,ae._punctuation).getRegex(),ae._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,ae._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,ae._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])?)+(?![-_])/,ae.autolink=et(ae.autolink).replace("scheme",ae._scheme).replace("email",ae._email).getRegex(),ae._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,ae.tag=et(ae.tag).replace("comment",ae._comment).replace("attribute",ae._attribute).getRegex(),ae._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ae._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,ae._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ae.link=et(ae.link).replace("label",ae._label).replace("href",ae._href).replace("title",ae._title).getRegex(),ae.reflink=et(ae.reflink).replace("label",ae._label).replace("ref",pe._label).getRegex(),ae.nolink=et(ae.nolink).replace("ref",pe._label).getRegex(),ae.reflinkSearch=et(ae.reflinkSearch,"g").replace("reflink",ae.reflink).replace("nolink",ae.nolink).getRegex(),ae.normal={...ae},ae.pedantic={...ae.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:et(/^!?\[(label)\]\((.*?)\)/).replace("label",ae._label).getRegex(),reflink:et(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ae._label).getRegex()},ae.gfm={...ae.normal,escape:et(ae.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},ae.gfm.url=et(ae.gfm.url,"i").replace("email",ae.gfm._extended_email).getRegex(),ae.breaks={...ae.gfm,br:et(ae.br).replace("{2,}","*").getRegex(),text:et(ae.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function Cv(e){return e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")}function su(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 Sn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Bn,this.options.tokenizer=this.options.tokenizer||new Ni,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:pe.normal,inline:ae.normal};this.options.pedantic?(n.block=pe.pedantic,n.inline=ae.pedantic):this.options.gfm&&(n.block=pe.gfm,this.options.breaks?n.inline=ae.breaks:n.inline=ae.gfm),this.tokenizer.rules=n}static get rules(){return{block:pe,inline:ae}}static lex(t,n){return new Sn(n).lex(t)}static lexInline(t,n){return new Sn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
43
+ `,t=t.substring(h.length+1),d=f.slice(i)}}x.loose||(u?x.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(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 N=x.items[a].tokens.filter(k=>k.type==="space"),C=N.length>0&&N.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]):bt(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:iu(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
44
+ `):[]};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]=iu(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)===`
45
+ `?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:bt(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]):bt(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=Do(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=Nv(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)),lu(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 lu(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 w=h.slice(1,-1);return{type:"em",raw:h,text:w,tokens:this.lexer.inlineTokens(w)}}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=bt(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=bt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=bt(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=bt(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=bt(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]):bt(r[0]):r[0]:o=bt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const ve={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:Mo,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};ve._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,ve._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,ve.def=Ze(ve.def).replace("label",ve._label).replace("title",ve._title).getRegex(),ve.bullet=/(?:[*+-]|\d{1,9}[.)])/,ve.listItemStart=Ze(/^( *)(bull) */).replace("bull",ve.bullet).getRegex(),ve.list=Ze(ve.list).replace(/bull/g,ve.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ve.def.source+")").getRegex(),ve._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",ve._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,ve.html=Ze(ve.html,"i").replace("comment",ve._comment).replace("tag",ve._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ve.paragraph=Ze(ve._paragraph).replace("hr",ve.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",ve._tag).getRegex(),ve.blockquote=Ze(ve.blockquote).replace("paragraph",ve.paragraph).getRegex(),ve.normal={...ve},ve.gfm={...ve.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},ve.gfm.table=Ze(ve.gfm.table).replace("hr",ve.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",ve._tag).getRegex(),ve.gfm.paragraph=Ze(ve._paragraph).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",ve.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",ve._tag).getRegex(),ve.pedantic={...ve.normal,html:Ze(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ve._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:Mo,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ze(ve.normal._paragraph).replace("hr",ve.hr).replace("heading",` *#{1,6} *[^
46
+ ]`).replace("lheading",ve.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ae={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Mo,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:Mo,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};ae._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",ae.punctuation=Ze(ae.punctuation).replace(/punctuation/g,ae._punctuation).getRegex(),ae.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,ae.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,ae._comment=Ze(ve._comment).replace("(?:-->|$)","-->").getRegex(),ae.emStrong.lDelim=Ze(ae.emStrong.lDelim).replace(/punct/g,ae._punctuation).getRegex(),ae.emStrong.rDelimAst=Ze(ae.emStrong.rDelimAst,"g").replace(/punct/g,ae._punctuation).getRegex(),ae.emStrong.rDelimUnd=Ze(ae.emStrong.rDelimUnd,"g").replace(/punct/g,ae._punctuation).getRegex(),ae._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,ae._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,ae._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])?)+(?![-_])/,ae.autolink=Ze(ae.autolink).replace("scheme",ae._scheme).replace("email",ae._email).getRegex(),ae._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,ae.tag=Ze(ae.tag).replace("comment",ae._comment).replace("attribute",ae._attribute).getRegex(),ae._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ae._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,ae._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ae.link=Ze(ae.link).replace("label",ae._label).replace("href",ae._href).replace("title",ae._title).getRegex(),ae.reflink=Ze(ae.reflink).replace("label",ae._label).replace("ref",ve._label).getRegex(),ae.nolink=Ze(ae.nolink).replace("ref",ve._label).getRegex(),ae.reflinkSearch=Ze(ae.reflinkSearch,"g").replace("reflink",ae.reflink).replace("nolink",ae.nolink).getRegex(),ae.normal={...ae},ae.pedantic={...ae.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:Ze(/^!?\[(label)\]\((.*?)\)/).replace("label",ae._label).getRegex(),reflink:Ze(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ae._label).getRegex()},ae.gfm={...ae.normal,escape:Ze(ae.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},ae.gfm.url=Ze(ae.gfm.url,"i").replace("email",ae.gfm._extended_email).getRegex(),ae.breaks={...ae.gfm,br:Ze(ae.br).replace("{2,}","*").getRegex(),text:Ze(ae.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function jv(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 cu(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 bn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||zn,this.options.tokenizer=this.options.tokenizer||new ji,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:ve.normal,inline:ae.normal};this.options.pedantic?(n.block=ve.pedantic,n.inline=ae.pedantic):this.options.gfm&&(n.block=ve.gfm,this.options.breaks?n.inline=ae.breaks:n.inline=ae.gfm),this.tokenizer.rules=n}static get rules(){return{block:ve,inline:ae}}static lex(t,n){return new bn(n).lex(t)}static lexInline(t,n){return new bn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
47
47
  `),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
48
  `: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+=`
49
49
  `+r.raw,o.text+=`
@@ -53,7 +53,7 @@ Check the top-level render call using <`+oe+">.")}return K}}function H(k,K){{if(
53
53
  `+r.raw,o.text+=`
54
54
  `+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+=`
55
55
  `+r.raw,o.text+=`
56
- `+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)+"["+ru("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)+"["+ru("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,su)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,su))){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,Cv)){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 Ai{constructor(t){this.options=t||Bn}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$/,"")+`
56
+ `+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)+"["+au("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)+"["+au("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,cu)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,cu))){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,jv)){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 Ri{constructor(t){this.options=t||zn}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$/,"")+`
57
57
  `,o?'<pre><code class="'+this.options.langPrefix+bt(o)+'">'+(r?t:bt(t,!0))+`</code></pre>
58
58
  `:"<pre><code>"+(r?t:bt(t,!0))+`</code></pre>
59
59
  `}blockquote(t){return`<blockquote>
@@ -73,14 +73,14 @@ ${t}</blockquote>
73
73
  `}tablerow(t){return`<tr>
74
74
  ${t}</tr>
75
75
  `}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
76
- `}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=tu(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=tu(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 iu{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 au{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 Cn{constructor(t){this.options=t||Bn,this.options.renderer=this.options.renderer||new Ai,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new iu,this.slugger=new au}static parse(t,n){return new Cn(n).parse(t)}static parseInline(t,n){return new Cn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,u,d,f,h,p,w,v,g,x,b,S,E,C,T;const I=t.length;for(o=0;o<I;o++){if(p=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[p.type]&&(T=this.options.extensions.renderers[p.type].call({parser:this},p),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type))){r+=T||"";continue}switch(p.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(p.tokens),p.depth,eu(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(w=p.ordered,v=p.start,g=p.loose,a=p.items.length,h="",s=0;s<a;s++)b=p.items[s],S=b.checked,E=b.task,x="",b.task&&(C=this.renderer.checkbox(S),g?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=C+" "+b.tokens[0].text,b.tokens[0].tokens&&b.tokens[0].tokens.length>0&&b.tokens[0].tokens[0].type==="text"&&(b.tokens[0].tokens[0].text=C+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:C}):x+=C),x+=this.parse(b.tokens,g),h+=this.renderer.listitem(x,E,S);r+=this.renderer.list(h,w,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<I&&t[o+1].type==="text";)p=t[++o],h+=`
77
- `+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const A='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}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 Lo{constructor(t){this.options=t||Bn}preprocess(t){return t}postprocess(t){return t}}Sp(Lo,"passThroughHooks",new Set(["preprocess","postprocess"]));function Tv(e,t,n){return r=>{if(r.message+=`
78
- Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+bt(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 lu(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...me.defaults,...s};const i=Tv(r.silent,r.async,o);if(typeof n>"u"||n===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(yv(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let 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&&me.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;me.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(me.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&&me.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function me(e,t,n){return lu(Sn.lex,Cn.parse)(e,t,n)}me.options=me.setOptions=function(e){return me.defaults={...me.defaults,...e},lv(me.defaults),me},me.getDefaults=Xc,me.defaults=Bn,me.use=function(...e){const t=me.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=me.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=me.defaults.renderer||new Ai;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=me.defaults.tokenizer||new Ni;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=me.defaults.hooks||new Lo;for(const s in n.hooks){const i=o[s];Lo.passThroughHooks.has(s)?o[s]=a=>{if(me.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=me.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}}me.setOptions(r)})},me.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(me,r)),r.type){case"table":{for(const o of r.header)n=n.concat(me.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(me.walkTokens(s.tokens,t));break}case"list":{n=n.concat(me.walkTokens(r.items,t));break}default:me.defaults.extensions&&me.defaults.extensions.childTokens&&me.defaults.extensions.childTokens[r.type]?me.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(me.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(me.walkTokens(r.tokens,t)))}return n},me.parseInline=lu(Sn.lexInline,Cn.parseInline),me.Parser=Cn,me.parser=Cn.parse,me.Renderer=Ai,me.TextRenderer=iu,me.Lexer=Sn,me.lexer=Sn.lex,me.Tokenizer=Ni,me.Slugger=au,me.Hooks=Lo,me.parse=me,me.options,me.setOptions,me.use,me.walkTokens,me.parseInline,Cn.parse,Sn.lex;function _i({content:e,className:t="",allowHtml:n=!1}){const r=y.useMemo(()=>{try{if(!n){const o=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return me.parse(o)}return me.parse(e)}catch(o){return console.error("[MarkdownContent] parse error",o),`<pre>Error rendering markdown: ${String(o)}</pre>`}},[e,n]);return c.jsx("div",{className:Q("markdown prose max-w-none break-words dark:prose-invert",t),dangerouslySetInnerHTML:{__html:r}})}async function cu(e,t){return await At(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function uu(e,t){return await(await cu(`/files/${e}/view`,t)).text()}async function kv(e,t){const n=await cu(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await At(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Ev(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await At("/files",{params:r})}const Iv=1,Nv=1e6;let ji=0;function Av(){return ji=(ji+1)%Number.MAX_SAFE_INTEGER,ji.toString()}const Ri=new Map,du=e=>{if(Ri.has(e))return;const t=setTimeout(()=>{Ri.delete(e),Ur({type:"REMOVE_TOAST",toastId:e})},Nv);Ri.set(e,t)},_v=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Iv)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?du(n):e.toasts.forEach(r=>{du(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)}}},Fo=[];let $o={toasts:[]};function Ur(e){$o=_v($o,e),Fo.forEach(t=>{t($o)})}function jv({...e}){const t=Av(),n=o=>Ur({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Ur({type:"DISMISS_TOAST",toastId:t});return Ur({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Pi(){const[e,t]=m.useState($o);return m.useEffect(()=>(Fo.push(t),()=>{const n=Fo.indexOf(t);n>-1&&Fo.splice(n,1)}),[e]),{...e,toast:jv,dismiss:n=>Ur({type:"DISMISS_TOAST",toastId:n})}}function gt(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Rv(e,t=globalThis==null?void 0:globalThis.document){const n=gt(e);m.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Pv="DismissableLayer",Oi="dismissableLayer.update",Ov="dismissableLayer.pointerDownOutside",Mv="dismissableLayer.focusOutside",fu,hu=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),zo=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=m.useContext(hu),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),w=Le(t,I=>f(I)),v=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=v.indexOf(g),b=d?v.indexOf(d):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,E=b>=x,C=Fv(I=>{const A=I.target,P=[...u.branches].some(j=>j.contains(A));!E||P||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},h),T=$v(I=>{const A=I.target;[...u.branches].some(j=>j.contains(A))||(s==null||s(I),i==null||i(I),I.defaultPrevented||a==null||a())},h);return Rv(I=>{b===u.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},h),m.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(fu=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),pu(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=fu)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),pu())},[d,u]),m.useEffect(()=>{const I=()=>p({});return document.addEventListener(Oi,I),()=>document.removeEventListener(Oi,I)},[]),c.jsx(Te.div,{...l,ref:w,style:{pointerEvents:S?E?"auto":"none":void 0,...e.style},onFocusCapture:le(e.onFocusCapture,T.onFocusCapture),onBlurCapture:le(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:le(e.onPointerDownCapture,C.onPointerDownCapture)})});zo.displayName=Pv;var Dv="DismissableLayerBranch",Lv=m.forwardRef((e,t)=>{const n=m.useContext(hu),r=m.useRef(null),o=Le(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(Te.div,{...e,ref:o})});Lv.displayName=Dv;function Fv(e,t=globalThis==null?void 0:globalThis.document){const n=gt(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){mu(Ov,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 $v(e,t=globalThis==null?void 0:globalThis.document){const n=gt(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&mu(Mv,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function pu(){const e=new CustomEvent(Oi);document.dispatchEvent(e)}function mu(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?Hc(o,s):o.dispatchEvent(s)}var Mi="focusScope.autoFocusOnMount",Di="focusScope.autoFocusOnUnmount",gu={bubbles:!1,cancelable:!0},zv="FocusScope",Bo=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=m.useState(null),u=gt(o),d=gt(s),f=m.useRef(null),h=Le(t,v=>l(v)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let v=function(S){if(p.paused||!a)return;const E=S.target;a.contains(E)?f.current=E:Tn(f.current,{select:!0})},g=function(S){if(p.paused||!a)return;const E=S.relatedTarget;E!==null&&(a.contains(E)||Tn(f.current,{select:!0}))},x=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Tn(a)};document.addEventListener("focusin",v),document.addEventListener("focusout",g);const b=new MutationObserver(x);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",g),b.disconnect()}}},[r,a,p.paused]),m.useEffect(()=>{if(a){wu.add(p);const v=document.activeElement;if(!a.contains(v)){const x=new CustomEvent(Mi,gu);a.addEventListener(Mi,u),a.dispatchEvent(x),x.defaultPrevented||(Bv(Kv(xu(a)),{select:!0}),document.activeElement===v&&Tn(a))}return()=>{a.removeEventListener(Mi,u),setTimeout(()=>{const x=new CustomEvent(Di,gu);a.addEventListener(Di,d),a.dispatchEvent(x),x.defaultPrevented||Tn(v??document.body,{select:!0}),a.removeEventListener(Di,d),wu.remove(p)},0)}}},[a,u,d,p]);const w=m.useCallback(v=>{if(!n&&!r||p.paused)return;const g=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,x=document.activeElement;if(g&&x){const b=v.currentTarget,[S,E]=Hv(b);S&&E?!v.shiftKey&&x===E?(v.preventDefault(),n&&Tn(S,{select:!0})):v.shiftKey&&x===S&&(v.preventDefault(),n&&Tn(E,{select:!0})):x===b&&v.preventDefault()}},[n,r,p.paused]);return c.jsx(Te.div,{tabIndex:-1,...i,ref:h,onKeyDown:w})});Bo.displayName=zv;function Bv(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Tn(r,{select:t}),document.activeElement!==n)return}function Hv(e){const t=xu(e),n=vu(t,e),r=vu(t.reverse(),e);return[n,r]}function xu(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 vu(e,t){for(const n of e)if(!Uv(n,{upTo:t}))return n}function Uv(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Wv(e){return e instanceof HTMLInputElement&&"select"in e}function Tn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Wv(e)&&t&&e.select()}}var wu=Vv();function Vv(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=bu(e,t),e.unshift(t)},remove(t){var n;e=bu(e,t),(n=e[0])==null||n.resume()}}}function bu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Kv(e){return e.filter(t=>t.tagName!=="A")}var qv="Portal",Ho=m.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=m.useState(!1);mt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Rs.createPortal(c.jsx(Te.div,{...r,ref:t}),i):null});Ho.displayName=qv;var Li=0;function Fi(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??yu()),document.body.insertAdjacentElement("beforeend",e[1]??yu()),Li++,()=>{Li===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Li--}},[])}function yu(){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 rn=function(){return rn=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},rn.apply(this,arguments)};function Su(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function Gv(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var Uo="right-scroll-bar-position",Wo="width-before-scroll-bar",Yv="with-scroll-bars-hidden",Xv="--removed-body-scroll-bar-size";function $i(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Jv(e,t){var n=y.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Zv=typeof window<"u"?m.useLayoutEffect:m.useEffect,Cu=new WeakMap;function Qv(e,t){var n=Jv(null,function(r){return e.forEach(function(o){return $i(o,r)})});return Zv(function(){var r=Cu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||$i(a,null)}),s.forEach(function(a){o.has(a)||$i(a,i)})}Cu.set(n,e)},[e]),n}function ew(e){return e}function tw(e,t){t===void 0&&(t=ew);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var 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 nw(e){e===void 0&&(e={});var t=tw(null);return t.options=rn({async:!0,ssr:!1},e),t}var Tu=function(e){var t=e.sideCar,n=Su(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return m.createElement(r,rn({},n))};Tu.isSideCarExport=!0;function rw(e,t){return e.useMedium(t),Tu}var ku=nw(),zi=function(){},Vo=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:zi,onWheelCapture:zi,onTouchMoveCapture:zi}),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,w=e.noIsolation,v=e.inert,g=e.allowPinchZoom,x=e.as,b=x===void 0?"div":x,S=e.gapMode,E=Su(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,T=Qv([n,t]),I=rn(rn({},E),o);return m.createElement(m.Fragment,null,d&&m.createElement(C,{sideCar:ku,removeScrollBar:u,shards:f,noRelative:p,noIsolation:w,inert:v,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:S}),i?m.cloneElement(m.Children.only(a),rn(rn({},I),{ref:T})):m.createElement(b,rn({},I,{className:l,ref:T}),a))});Vo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Vo.classNames={fullWidth:Wo,zeroRight:Uo};var ow=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function sw(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=ow();return t&&e.setAttribute("nonce",t),e}function iw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function aw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var lw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=sw())&&(iw(t,n),aw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},cw=function(){var e=lw();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Eu=function(){var e=cw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},uw={left:0,top:0,right:0,gap:0},Bi=function(e){return parseInt(e||"",10)||0},dw=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Bi(n),Bi(r),Bi(o)]},fw=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return uw;var t=dw(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},hw=Eu(),lr="data-scroll-locked",pw=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
79
- .`.concat(Yv,` {
76
+ `}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=su(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=su(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 uu{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 du{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 yn{constructor(t){this.options=t||zn,this.options.renderer=this.options.renderer||new Ri,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new uu,this.slugger=new du}static parse(t,n){return new yn(n).parse(t)}static parseInline(t,n){return new yn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,u,d,f,h,p,w,v,g,x,b,S,N,C,k;const I=t.length;for(o=0;o<I;o++){if(p=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[p.type]&&(k=this.options.extensions.renderers[p.type].call({parser:this},p),k!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type))){r+=k||"";continue}switch(p.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(p.tokens),p.depth,ou(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(w=p.ordered,v=p.start,g=p.loose,a=p.items.length,h="",s=0;s<a;s++)b=p.items[s],S=b.checked,N=b.task,x="",b.task&&(C=this.renderer.checkbox(S),g?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=C+" "+b.tokens[0].text,b.tokens[0].tokens&&b.tokens[0].tokens.length>0&&b.tokens[0].tokens[0].type==="text"&&(b.tokens[0].tokens[0].text=C+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:C}):x+=C),x+=this.parse(b.tokens,g),h+=this.renderer.listitem(x,N,S);r+=this.renderer.list(h,w,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<I&&t[o+1].type==="text";)p=t[++o],h+=`
77
+ `+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const A='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}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 Lo{constructor(t){this.options=t||zn}preprocess(t){return t}postprocess(t){return t}}Ep(Lo,"passThroughHooks",new Set(["preprocess","postprocess"]));function Rv(e,t,n){return r=>{if(r.message+=`
78
+ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+bt(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 fu(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...we.defaults,...s};const i=Rv(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(Av(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 fu(bn.lex,yn.parse)(e,t,n)}we.options=we.setOptions=function(e){return we.defaults={...we.defaults,...e},gv(we.defaults),we},we.getDefaults=eu,we.defaults=zn,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 Ri;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 ji;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 Lo;for(const s in n.hooks){const i=o[s];Lo.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=fu(bn.lexInline,yn.parseInline),we.Parser=yn,we.parser=yn.parse,we.Renderer=Ri,we.TextRenderer=uu,we.Lexer=bn,we.lexer=bn.lex,we.Tokenizer=ji,we.Slugger=du,we.Hooks=Lo,we.parse=we,we.options,we.setOptions,we.use,we.walkTokens,we.parseInline,yn.parse,bn.lex;function Pi({content:e,className:t="",allowHtml:n=!1}){const r=y.useMemo(()=>{try{if(!n){const o=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return we.parse(o)}return we.parse(e)}catch(o){return console.error("[MarkdownContent] parse error",o),`<pre>Error rendering markdown: ${String(o)}</pre>`}},[e,n]);return c.jsx("div",{className:Q("markdown prose max-w-none break-words dark:prose-invert",t),dangerouslySetInnerHTML:{__html:r}})}async function hu(e,t){return await It(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function pu(e,t){return await(await hu(`/files/${e}/view`,t)).text()}async function Pv(e,t){const n=await hu(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await It(`/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 Ov(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await It("/files",{params:r})}const Mv=1,Dv=1e6;let Oi=0;function Lv(){return Oi=(Oi+1)%Number.MAX_SAFE_INTEGER,Oi.toString()}const Mi=new Map,mu=e=>{if(Mi.has(e))return;const t=setTimeout(()=>{Mi.delete(e),Ur({type:"REMOVE_TOAST",toastId:e})},Dv);Mi.set(e,t)},$v=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Mv)};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?mu(n):e.toasts.forEach(r=>{mu(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)}}},$o=[];let Fo={toasts:[]};function Ur(e){Fo=$v(Fo,e),$o.forEach(t=>{t(Fo)})}function Fv({...e}){const t=Lv(),n=o=>Ur({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Ur({type:"DISMISS_TOAST",toastId:t});return Ur({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Di(){const[e,t]=m.useState(Fo);return m.useEffect(()=>($o.push(t),()=>{const n=$o.indexOf(t);n>-1&&$o.splice(n,1)}),[e]),{...e,toast:Fv,dismiss:n=>Ur({type:"DISMISS_TOAST",toastId:n})}}function mt(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Bv(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e);m.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var zv="DismissableLayer",Li="dismissableLayer.update",Hv="dismissableLayer.pointerDownOutside",Uv="dismissableLayer.focusOutside",gu,xu=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Bo=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=m.useContext(xu),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),w=Le(t,I=>f(I)),v=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=v.indexOf(g),b=d?v.indexOf(d):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,N=b>=x,C=Kv(I=>{const A=I.target,R=[...u.branches].some(P=>P.contains(A));!N||R||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},h),k=qv(I=>{const A=I.target;[...u.branches].some(P=>P.contains(A))||(s==null||s(I),i==null||i(I),I.defaultPrevented||a==null||a())},h);return Bv(I=>{b===u.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},h),m.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(gu=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),vu(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=gu)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),vu())},[d,u]),m.useEffect(()=>{const I=()=>p({});return document.addEventListener(Li,I),()=>document.removeEventListener(Li,I)},[]),c.jsx(Ie.div,{...l,ref:w,style:{pointerEvents:S?N?"auto":"none":void 0,...e.style},onFocusCapture:ce(e.onFocusCapture,k.onFocusCapture),onBlurCapture:ce(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:ce(e.onPointerDownCapture,C.onPointerDownCapture)})});Bo.displayName=zv;var Wv="DismissableLayerBranch",Vv=m.forwardRef((e,t)=>{const n=m.useContext(xu),r=m.useRef(null),o=Le(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(Ie.div,{...e,ref:o})});Vv.displayName=Wv;function Kv(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){wu(Hv,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 qv(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&wu(Uv,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 vu(){const e=new CustomEvent(Li);document.dispatchEvent(e)}function wu(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?Kc(o,s):o.dispatchEvent(s)}var $i="focusScope.autoFocusOnMount",Fi="focusScope.autoFocusOnUnmount",bu={bubbles:!1,cancelable:!0},Gv="FocusScope",zo=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=m.useState(null),u=mt(o),d=mt(s),f=m.useRef(null),h=Le(t,v=>l(v)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let v=function(S){if(p.paused||!a)return;const N=S.target;a.contains(N)?f.current=N:Sn(f.current,{select:!0})},g=function(S){if(p.paused||!a)return;const N=S.relatedTarget;N!==null&&(a.contains(N)||Sn(f.current,{select:!0}))},x=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Sn(a)};document.addEventListener("focusin",v),document.addEventListener("focusout",g);const b=new MutationObserver(x);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",g),b.disconnect()}}},[r,a,p.paused]),m.useEffect(()=>{if(a){Cu.add(p);const v=document.activeElement;if(!a.contains(v)){const x=new CustomEvent($i,bu);a.addEventListener($i,u),a.dispatchEvent(x),x.defaultPrevented||(Yv(ew(yu(a)),{select:!0}),document.activeElement===v&&Sn(a))}return()=>{a.removeEventListener($i,u),setTimeout(()=>{const x=new CustomEvent(Fi,bu);a.addEventListener(Fi,d),a.dispatchEvent(x),x.defaultPrevented||Sn(v??document.body,{select:!0}),a.removeEventListener(Fi,d),Cu.remove(p)},0)}}},[a,u,d,p]);const w=m.useCallback(v=>{if(!n&&!r||p.paused)return;const g=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,x=document.activeElement;if(g&&x){const b=v.currentTarget,[S,N]=Xv(b);S&&N?!v.shiftKey&&x===N?(v.preventDefault(),n&&Sn(S,{select:!0})):v.shiftKey&&x===S&&(v.preventDefault(),n&&Sn(N,{select:!0})):x===b&&v.preventDefault()}},[n,r,p.paused]);return c.jsx(Ie.div,{tabIndex:-1,...i,ref:h,onKeyDown:w})});zo.displayName=Gv;function Yv(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Sn(r,{select:t}),document.activeElement!==n)return}function Xv(e){const t=yu(e),n=Su(t,e),r=Su(t.reverse(),e);return[n,r]}function yu(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 Su(e,t){for(const n of e)if(!Jv(n,{upTo:t}))return n}function Jv(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 Zv(e){return e instanceof HTMLInputElement&&"select"in e}function Sn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Zv(e)&&t&&e.select()}}var Cu=Qv();function Qv(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Tu(e,t),e.unshift(t)},remove(t){var n;e=Tu(e,t),(n=e[0])==null||n.resume()}}}function Tu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ew(e){return e.filter(t=>t.tagName!=="A")}var tw="Portal",Ho=m.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=m.useState(!1);pt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Rs.createPortal(c.jsx(Ie.div,{...r,ref:t}),i):null});Ho.displayName=tw;var Bi=0;function zi(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??ku()),document.body.insertAdjacentElement("beforeend",e[1]??ku()),Bi++,()=>{Bi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Bi--}},[])}function ku(){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 nn=function(){return nn=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},nn.apply(this,arguments)};function Eu(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 nw(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 Uo="right-scroll-bar-position",Wo="width-before-scroll-bar",rw="with-scroll-bars-hidden",ow="--removed-body-scroll-bar-size";function Hi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function sw(e,t){var n=y.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var iw=typeof window<"u"?m.useLayoutEffect:m.useEffect,Iu=new WeakMap;function aw(e,t){var n=sw(null,function(r){return e.forEach(function(o){return Hi(o,r)})});return iw(function(){var r=Iu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Hi(a,null)}),s.forEach(function(a){o.has(a)||Hi(a,i)})}Iu.set(n,e)},[e]),n}function lw(e){return e}function cw(e,t){t===void 0&&(t=lw);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 uw(e){e===void 0&&(e={});var t=cw(null);return t.options=nn({async:!0,ssr:!1},e),t}var Nu=function(e){var t=e.sideCar,n=Eu(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return m.createElement(r,nn({},n))};Nu.isSideCarExport=!0;function dw(e,t){return e.useMedium(t),Nu}var Au=uw(),Ui=function(){},Vo=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:Ui,onWheelCapture:Ui,onTouchMoveCapture:Ui}),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,w=e.noIsolation,v=e.inert,g=e.allowPinchZoom,x=e.as,b=x===void 0?"div":x,S=e.gapMode,N=Eu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,k=aw([n,t]),I=nn(nn({},N),o);return m.createElement(m.Fragment,null,d&&m.createElement(C,{sideCar:Au,removeScrollBar:u,shards:f,noRelative:p,noIsolation:w,inert:v,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:S}),i?m.cloneElement(m.Children.only(a),nn(nn({},I),{ref:k})):m.createElement(b,nn({},I,{className:l,ref:k}),a))});Vo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Vo.classNames={fullWidth:Wo,zeroRight:Uo};var fw=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function hw(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=fw();return t&&e.setAttribute("nonce",t),e}function pw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function mw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var gw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=hw())&&(pw(t,n),mw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},xw=function(){var e=gw();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},_u=function(){var e=xw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},vw={left:0,top:0,right:0,gap:0},Wi=function(e){return parseInt(e||"",10)||0},ww=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[Wi(n),Wi(r),Wi(o)]},bw=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return vw;var t=ww(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])}},yw=_u(),ar="data-scroll-locked",Sw=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
79
+ .`.concat(rw,` {
80
80
  overflow: hidden `).concat(r,`;
81
81
  padding-right: `).concat(a,"px ").concat(r,`;
82
82
  }
83
- body[`).concat(lr,`] {
83
+ body[`).concat(ar,`] {
84
84
  overflow: hidden `).concat(r,`;
85
85
  overscroll-behavior: contain;
86
86
  `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
@@ -109,21 +109,21 @@ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An err
109
109
  margin-right: 0 `).concat(r,`;
110
110
  }
111
111
 
112
- body[`).concat(lr,`] {
113
- `).concat(Xv,": ").concat(a,`px;
112
+ body[`).concat(ar,`] {
113
+ `).concat(ow,": ").concat(a,`px;
114
114
  }
115
- `)},Iu=function(){var e=parseInt(document.body.getAttribute(lr)||"0",10);return isFinite(e)?e:0},mw=function(){m.useEffect(function(){return document.body.setAttribute(lr,(Iu()+1).toString()),function(){var e=Iu()-1;e<=0?document.body.removeAttribute(lr):document.body.setAttribute(lr,e.toString())}},[])},gw=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;mw();var s=m.useMemo(function(){return fw(o)},[o]);return m.createElement(hw,{styles:pw(s,!t,o,n?"":"!important")})},Hi=!1;if(typeof window<"u")try{var Ko=Object.defineProperty({},"passive",{get:function(){return Hi=!0,!0}});window.addEventListener("test",Ko,Ko),window.removeEventListener("test",Ko,Ko)}catch{Hi=!1}var cr=Hi?{passive:!1}:!1,xw=function(e){return e.tagName==="TEXTAREA"},Nu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!xw(e)&&n[t]==="visible")},vw=function(e){return Nu(e,"overflowY")},ww=function(e){return Nu(e,"overflowX")},Au=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=_u(e,r);if(o){var s=ju(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},bw=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},yw=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},_u=function(e,t){return e==="v"?vw(t):ww(t)},ju=function(e,t){return e==="v"?bw(t):yw(t)},Sw=function(e,t){return e==="h"&&t==="rtl"?-1:1},Cw=function(e,t,n,r,o){var s=Sw(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),u=!1,d=i>0,f=0,h=0;do{if(!a)break;var p=ju(e,a),w=p[0],v=p[1],g=p[2],x=v-g-s*w;(w||x)&&_u(e,a)&&(f+=x,h+=w);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},qo=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Ru=function(e){return[e.deltaX,e.deltaY]},Pu=function(e){return e&&"current"in e?e.current:e},Tw=function(e,t){return e[0]===t[0]&&e[1]===t[1]},kw=function(e){return`
115
+ `)},ju=function(){var e=parseInt(document.body.getAttribute(ar)||"0",10);return isFinite(e)?e:0},Cw=function(){m.useEffect(function(){return document.body.setAttribute(ar,(ju()+1).toString()),function(){var e=ju()-1;e<=0?document.body.removeAttribute(ar):document.body.setAttribute(ar,e.toString())}},[])},Tw=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Cw();var s=m.useMemo(function(){return bw(o)},[o]);return m.createElement(yw,{styles:Sw(s,!t,o,n?"":"!important")})},Vi=!1;if(typeof window<"u")try{var Ko=Object.defineProperty({},"passive",{get:function(){return Vi=!0,!0}});window.addEventListener("test",Ko,Ko),window.removeEventListener("test",Ko,Ko)}catch{Vi=!1}var lr=Vi?{passive:!1}:!1,kw=function(e){return e.tagName==="TEXTAREA"},Ru=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!kw(e)&&n[t]==="visible")},Ew=function(e){return Ru(e,"overflowY")},Iw=function(e){return Ru(e,"overflowX")},Pu=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Ou(e,r);if(o){var s=Mu(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Nw=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Aw=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Ou=function(e,t){return e==="v"?Ew(t):Iw(t)},Mu=function(e,t){return e==="v"?Nw(t):Aw(t)},_w=function(e,t){return e==="h"&&t==="rtl"?-1:1},jw=function(e,t,n,r,o){var s=_w(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=Mu(e,a),w=p[0],v=p[1],g=p[2],x=v-g-s*w;(w||x)&&Ou(e,a)&&(f+=x,h+=w);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},qo=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Du=function(e){return[e.deltaX,e.deltaY]},Lu=function(e){return e&&"current"in e?e.current:e},Rw=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Pw=function(e){return`
116
116
  .block-interactivity-`.concat(e,` {pointer-events: none;}
117
117
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
118
- `)},Ew=0,ur=[];function Iw(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(Ew++)[0],s=m.useState(Eu)[0],i=m.useRef(e);m.useEffect(function(){i.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var v=Gv([e.lockRef.current],(e.shards||[]).map(Pu),!0).filter(Boolean);return v.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),v.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=m.useCallback(function(v,g){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!i.current.allowPinchZoom;var x=qo(v),b=n.current,S="deltaX"in v?v.deltaX:b[0]-x[0],E="deltaY"in v?v.deltaY:b[1]-x[1],C,T=v.target,I=Math.abs(S)>Math.abs(E)?"h":"v";if("touches"in v&&I==="h"&&T.type==="range")return!1;var A=Au(I,T);if(!A)return!0;if(A?C=I:(C=I==="v"?"h":"v",A=Au(I,T)),!A)return!1;if(!r.current&&"changedTouches"in v&&(S||E)&&(r.current=C),!C)return!0;var P=r.current||C;return Cw(P,g,v,P==="h"?S:E)},[]),l=m.useCallback(function(v){var g=v;if(!(!ur.length||ur[ur.length-1]!==s)){var x="deltaY"in g?Ru(g):qo(g),b=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&Tw(C.delta,x)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Pu).filter(Boolean).filter(function(C){return C.contains(g.target)}),E=S.length>0?a(g,S[0]):!i.current.noIsolation;E&&g.cancelable&&g.preventDefault()}}},[]),u=m.useCallback(function(v,g,x,b){var S={name:v,delta:g,target:x,should:b,shadowParent:Nw(x)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(E){return E!==S})},1)},[]),d=m.useCallback(function(v){n.current=qo(v),r.current=void 0},[]),f=m.useCallback(function(v){u(v.type,Ru(v),v.target,a(v,e.lockRef.current))},[]),h=m.useCallback(function(v){u(v.type,qo(v),v.target,a(v,e.lockRef.current))},[]);m.useEffect(function(){return ur.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,cr),document.addEventListener("touchmove",l,cr),document.addEventListener("touchstart",d,cr),function(){ur=ur.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,cr),document.removeEventListener("touchmove",l,cr),document.removeEventListener("touchstart",d,cr)}},[]);var p=e.removeScrollBar,w=e.inert;return m.createElement(m.Fragment,null,w?m.createElement(s,{styles:kw(o)}):null,p?m.createElement(gw,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Nw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Aw=rw(ku,Iw);var Go=m.forwardRef(function(e,t){return m.createElement(Vo,rn({},e,{ref:t,sideCar:Aw}))});Go.classNames=Vo.classNames;var _w=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},dr=new WeakMap,Yo=new WeakMap,Xo={},Ui=0,Ou=function(e){return e&&(e.host||Ou(e.parentNode))},jw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Ou(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Rw=function(e,t,n,r){var o=jw(t,Array.isArray(e)?e:[e]);Xo[n]||(Xo[n]=new WeakMap);var s=Xo[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),w=p!==null&&p!=="false",v=(dr.get(h)||0)+1,g=(s.get(h)||0)+1;dr.set(h,v),s.set(h,g),i.push(h),v===1&&w&&Yo.set(h,!0),g===1&&h.setAttribute(n,"true"),w||h.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",h,x)}})};return d(t),a.clear(),Ui++,function(){i.forEach(function(f){var h=dr.get(f)-1,p=s.get(f)-1;dr.set(f,h),s.set(f,p),h||(Yo.has(f)||f.removeAttribute(r),Yo.delete(f)),p||f.removeAttribute(n)}),Ui--,Ui||(dr=new WeakMap,dr=new WeakMap,Yo=new WeakMap,Xo={})}},Wi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=_w(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Rw(r,o,n,"aria-hidden")):function(){return null}},Jo="Dialog",[Mu,BC]=tn(Jo),[Pw,Kt]=Mu(Jo),Du=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=m.useRef(null),l=m.useRef(null),[u,d]=zn({prop:r,defaultProp:o??!1,onChange:s,caller:Jo});return c.jsx(Pw,{scope:t,triggerRef:a,contentRef:l,contentId:nn(),titleId:nn(),descriptionId:nn(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Du.displayName=Jo;var Lu="DialogTrigger",Fu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Kt(Lu,n),s=Le(t,o.triggerRef);return c.jsx(Te.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":qi(o.open),...r,ref:s,onClick:le(e.onClick,o.onOpenToggle)})});Fu.displayName=Lu;var Vi="DialogPortal",[Ow,$u]=Mu(Vi,{forceMount:void 0}),zu=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=Kt(Vi,t);return c.jsx(Ow,{scope:t,forceMount:n,children:m.Children.map(r,i=>c.jsx(Pt,{present:n||s.open,children:c.jsx(Ho,{asChild:!0,container:o,children:i})}))})};zu.displayName=Vi;var Zo="DialogOverlay",Bu=m.forwardRef((e,t)=>{const n=$u(Zo,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Kt(Zo,e.__scopeDialog);return s.modal?c.jsx(Pt,{present:r||s.open,children:c.jsx(Dw,{...o,ref:t})}):null});Bu.displayName=Zo;var Mw=Rn.createSlot("DialogOverlay.RemoveScroll"),Dw=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Kt(Zo,n);return c.jsx(Go,{as:Mw,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(Te.div,{"data-state":qi(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Hn="DialogContent",Hu=m.forwardRef((e,t)=>{const n=$u(Hn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Kt(Hn,e.__scopeDialog);return c.jsx(Pt,{present:r||s.open,children:s.modal?c.jsx(Lw,{...o,ref:t}):c.jsx(Fw,{...o,ref:t})})});Hu.displayName=Hn;var Lw=m.forwardRef((e,t)=>{const n=Kt(Hn,e.__scopeDialog),r=m.useRef(null),o=Le(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return Wi(s)},[]),c.jsx(Uu,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:le(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:le(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:le(e.onFocusOutside,s=>s.preventDefault())})}),Fw=m.forwardRef((e,t)=>{const n=Kt(Hn,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return c.jsx(Uu,{...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()}})}),Uu=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=Kt(Hn,n),l=m.useRef(null),u=Le(t,l);return Fi(),c.jsxs(c.Fragment,{children:[c.jsx(Bo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(zo,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":qi(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx($w,{titleId:a.titleId}),c.jsx(Bw,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ki="DialogTitle",Wu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Kt(Ki,n);return c.jsx(Te.h2,{id:o.titleId,...r,ref:t})});Wu.displayName=Ki;var Vu="DialogDescription",Ku=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Kt(Vu,n);return c.jsx(Te.p,{id:o.descriptionId,...r,ref:t})});Ku.displayName=Vu;var qu="DialogClose",Gu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Kt(qu,n);return c.jsx(Te.button,{type:"button",...r,ref:t,onClick:le(e.onClick,()=>o.onOpenChange(!1))})});Gu.displayName=qu;function qi(e){return e?"open":"closed"}var Yu="DialogTitleWarning",[HC,Xu]=Kx(Yu,{contentName:Hn,titleName:Ki,docsSlug:"dialog"}),$w=({titleId:e})=>{const t=Xu(Yu),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
118
+ `)},Ow=0,cr=[];function Mw(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(Ow++)[0],s=m.useState(_u)[0],i=m.useRef(e);m.useEffect(function(){i.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var v=nw([e.lockRef.current],(e.shards||[]).map(Lu),!0).filter(Boolean);return v.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),v.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=m.useCallback(function(v,g){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!i.current.allowPinchZoom;var x=qo(v),b=n.current,S="deltaX"in v?v.deltaX:b[0]-x[0],N="deltaY"in v?v.deltaY:b[1]-x[1],C,k=v.target,I=Math.abs(S)>Math.abs(N)?"h":"v";if("touches"in v&&I==="h"&&k.type==="range")return!1;var A=Pu(I,k);if(!A)return!0;if(A?C=I:(C=I==="v"?"h":"v",A=Pu(I,k)),!A)return!1;if(!r.current&&"changedTouches"in v&&(S||N)&&(r.current=C),!C)return!0;var R=r.current||C;return jw(R,g,v,R==="h"?S:N)},[]),l=m.useCallback(function(v){var g=v;if(!(!cr.length||cr[cr.length-1]!==s)){var x="deltaY"in g?Du(g):qo(g),b=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&Rw(C.delta,x)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Lu).filter(Boolean).filter(function(C){return C.contains(g.target)}),N=S.length>0?a(g,S[0]):!i.current.noIsolation;N&&g.cancelable&&g.preventDefault()}}},[]),u=m.useCallback(function(v,g,x,b){var S={name:v,delta:g,target:x,should:b,shadowParent:Dw(x)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(N){return N!==S})},1)},[]),d=m.useCallback(function(v){n.current=qo(v),r.current=void 0},[]),f=m.useCallback(function(v){u(v.type,Du(v),v.target,a(v,e.lockRef.current))},[]),h=m.useCallback(function(v){u(v.type,qo(v),v.target,a(v,e.lockRef.current))},[]);m.useEffect(function(){return cr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,lr),document.addEventListener("touchmove",l,lr),document.addEventListener("touchstart",d,lr),function(){cr=cr.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,lr),document.removeEventListener("touchmove",l,lr),document.removeEventListener("touchstart",d,lr)}},[]);var p=e.removeScrollBar,w=e.inert;return m.createElement(m.Fragment,null,w?m.createElement(s,{styles:Pw(o)}):null,p?m.createElement(Tw,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Dw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Lw=dw(Au,Mw);var Go=m.forwardRef(function(e,t){return m.createElement(Vo,nn({},e,{ref:t,sideCar:Lw}))});Go.classNames=Vo.classNames;var $w=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ur=new WeakMap,Yo=new WeakMap,Xo={},Ki=0,$u=function(e){return e&&(e.host||$u(e.parentNode))},Fw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=$u(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})},Bw=function(e,t,n,r){var o=Fw(t,Array.isArray(e)?e:[e]);Xo[n]||(Xo[n]=new WeakMap);var s=Xo[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),w=p!==null&&p!=="false",v=(ur.get(h)||0)+1,g=(s.get(h)||0)+1;ur.set(h,v),s.set(h,g),i.push(h),v===1&&w&&Yo.set(h,!0),g===1&&h.setAttribute(n,"true"),w||h.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",h,x)}})};return d(t),a.clear(),Ki++,function(){i.forEach(function(f){var h=ur.get(f)-1,p=s.get(f)-1;ur.set(f,h),s.set(f,p),h||(Yo.has(f)||f.removeAttribute(r),Yo.delete(f)),p||f.removeAttribute(n)}),Ki--,Ki||(ur=new WeakMap,ur=new WeakMap,Yo=new WeakMap,Xo={})}},qi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=$w(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Bw(r,o,n,"aria-hidden")):function(){return null}},Jo="Dialog",[Fu,YC]=en(Jo),[zw,Vt]=Fu(Jo),Bu=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=m.useRef(null),l=m.useRef(null),[u,d]=Bn({prop:r,defaultProp:o??!1,onChange:s,caller:Jo});return c.jsx(zw,{scope:t,triggerRef:a,contentRef:l,contentId:tn(),titleId:tn(),descriptionId:tn(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Bu.displayName=Jo;var zu="DialogTrigger",Hu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Vt(zu,n),s=Le(t,o.triggerRef);return c.jsx(Ie.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Xi(o.open),...r,ref:s,onClick:ce(e.onClick,o.onOpenToggle)})});Hu.displayName=zu;var Gi="DialogPortal",[Hw,Uu]=Fu(Gi,{forceMount:void 0}),Wu=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=Vt(Gi,t);return c.jsx(Hw,{scope:t,forceMount:n,children:m.Children.map(r,i=>c.jsx(jt,{present:n||s.open,children:c.jsx(Ho,{asChild:!0,container:o,children:i})}))})};Wu.displayName=Gi;var Zo="DialogOverlay",Vu=m.forwardRef((e,t)=>{const n=Uu(Zo,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Vt(Zo,e.__scopeDialog);return s.modal?c.jsx(jt,{present:r||s.open,children:c.jsx(Ww,{...o,ref:t})}):null});Vu.displayName=Zo;var Uw=Rn.createSlot("DialogOverlay.RemoveScroll"),Ww=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Vt(Zo,n);return c.jsx(Go,{as:Uw,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(Ie.div,{"data-state":Xi(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Hn="DialogContent",Ku=m.forwardRef((e,t)=>{const n=Uu(Hn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Vt(Hn,e.__scopeDialog);return c.jsx(jt,{present:r||s.open,children:s.modal?c.jsx(Vw,{...o,ref:t}):c.jsx(Kw,{...o,ref:t})})});Ku.displayName=Hn;var Vw=m.forwardRef((e,t)=>{const n=Vt(Hn,e.__scopeDialog),r=m.useRef(null),o=Le(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return qi(s)},[]),c.jsx(qu,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ce(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ce(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ce(e.onFocusOutside,s=>s.preventDefault())})}),Kw=m.forwardRef((e,t)=>{const n=Vt(Hn,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return c.jsx(qu,{...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()}})}),qu=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=Vt(Hn,n),l=m.useRef(null),u=Le(t,l);return zi(),c.jsxs(c.Fragment,{children:[c.jsx(zo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(Bo,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Xi(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(qw,{titleId:a.titleId}),c.jsx(Yw,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Yi="DialogTitle",Gu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Vt(Yi,n);return c.jsx(Ie.h2,{id:o.titleId,...r,ref:t})});Gu.displayName=Yi;var Yu="DialogDescription",Xu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Vt(Yu,n);return c.jsx(Ie.p,{id:o.descriptionId,...r,ref:t})});Xu.displayName=Yu;var Ju="DialogClose",Zu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Vt(Ju,n);return c.jsx(Ie.button,{type:"button",...r,ref:t,onClick:ce(e.onClick,()=>o.onOpenChange(!1))})});Zu.displayName=Ju;function Xi(e){return e?"open":"closed"}var Qu="DialogTitleWarning",[XC,ed]=ev(Qu,{contentName:Hn,titleName:Yi,docsSlug:"dialog"}),qw=({titleId:e})=>{const t=ed(Qu),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
119
119
 
120
120
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
121
121
 
122
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},zw="DialogDescriptionWarning",Bw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Xu(zw).contentName}}.`;return m.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Ju=Du,Hw=Fu,Zu=zu,Qo=Bu,es=Hu,Un=Wu,ts=Ku,Qu=Gu;const Uw=Ju,Ww=Zu,ed=m.forwardRef(({className:e,...t},n)=>c.jsx(Qo,{ref:n,className:Q("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}));ed.displayName=Qo.displayName;const td=m.forwardRef(({className:e,children:t,...n},r)=>{const o=m.useMemo(()=>{let s=!1;function i(a){m.Children.forEach(a,l=>{if(s||!m.isValidElement(l))return;const u=l.type;if(u===Un||(u==null?void 0:u.displayName)===Un.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(Ww,{children:[c.jsx(ed,{}),c.jsxs(es,{ref:r,className:Q("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(Un,{className:"sr-only",children:"Dialog"}),t,c.jsxs(Qu,{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(se.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});td.displayName=es.displayName;const nd=({className:e,...t})=>c.jsx("div",{className:Q("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});nd.displayName="DialogHeader";const rd=m.forwardRef(({className:e,...t},n)=>c.jsx(Un,{ref:n,className:Q("text-lg font-semibold leading-none tracking-tight",e),...t}));rd.displayName=Un.displayName;const Vw=m.forwardRef(({className:e,...t},n)=>c.jsx(ts,{ref:n,className:Q("text-sm text-muted-foreground",e),...t}));Vw.displayName=ts.displayName;function Kw({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=y.useState(!1),[a,l]=y.useState(null),[u,d]=y.useState(null),{toast:f}=Pi(),h=y.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const x=await uu(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]);y.useEffect(()=>{e&&n&&h()},[e,n,h]);const p=async()=>{if(n)try{await kv(n),f({title:"Download started",description:`Downloading ${r}`})}catch(x){console.error("Failed to download file:",x),f({title:"Download failed",description:String(x),variant:"destructive"})}},w=async()=>{if(n)try{const x=await uu(n),b=new Blob([x],{type:o}),S=URL.createObjectURL(b);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(x){console.error("Failed to open file externally:",x),f({title:"Failed to open file",description:String(x),variant:"destructive"})}},v=()=>s?c.jsxs("div",{className:"flex items-center justify-center py-12",children:[c.jsx(se.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(He,{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(se.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),c.jsx("p",{className:"text-lg font-medium mb-2",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),g=()=>o.startsWith("image/")?c.jsx(se.Image,{className:"h-5 w-5"}):c.jsx(se.FileText,{className:"h-5 w-5"});return c.jsx(Uw,{open:e,onOpenChange:t,children:c.jsxs(td,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[c.jsx(nd,{children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[g(),c.jsxs("div",{children:[c.jsx(rd,{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(He,{variant:"outline",size:"sm",onClick:w,className:"flex items-center gap-2",children:[c.jsx(se.ExternalLink,{className:"h-4 w-4"}),"External"]}),c.jsxs(He,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[c.jsx(se.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),c.jsx("div",{className:"flex-1 overflow-hidden",children:v()})]})})}function od(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 sd(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Wr(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(Wr).filter(r=>r!==void 0);return n.length?n:void 0}if(sd(e))return;const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=Wr(r);o!==void 0&&(t[n]=o)}}return Object.keys(t).length?t:void 0}return e}function Gi(e){if(typeof e=="string")return e;if(sd(e))return"";try{const t=Wr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function id(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 id(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),w=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(h),v=p?p[2].trim():"",g=w?w[2].trim():"";n[i].push({title:v,description:g})}}return Object.values(n).some(i=>i.length>0)?n:null}const ns="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",Wn=1e5;function qw(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Gw(e){const t=e.find(r=>r.type==="tool_call"),n=e.find(r=>r.type==="tool_end");return{name:t==null?void 0:t.name,toolCallId:(n==null?void 0:n.toolCallId)??(t==null?void 0:t.id)}}function Yw(e){const t=e.filter(r=>r.type==="tool_call");return e.filter(r=>r.type==="tool_end").map(r=>{var o;return{name:(o=t.find(s=>s.id===r.toolCallId))==null?void 0:o.name,toolCallId:r.toolCallId,output:r.output}})}function Xw(e){const t=(r,o=Wn)=>{try{const s=Wr(r),i=typeof s=="string"?s:JSON.stringify(s??"");return i.length<=o?i:i.slice(0,o)+`
123
- … [truncated ${i.length-o} chars]`}catch{return""}},n=e.filter(r=>r.type==="tool_end");if(n.length)try{return n.length===1?t(n[0].output):t(n.map(r=>({toolCallId:r.toolCallId,output:r.output})))}catch{}return t(e)}function Jw(e){const t=e.find(r=>r.type==="tool_end");if(!t)return null;const n=t.output;return typeof n=="string"?n:null}function Zw(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function ad(e){const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(r=>{switch(r.type){case"text":return`t:${r.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"tool_end":return"end";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function Qw({className:e}){const[t,n]=y.useState(0);return y.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),c.jsxs("span",{"aria-live":"polite",className:Q("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const ld=y.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateToolMessages:u=!0,toolMessagePreviewLength:d=200,truncateUserMessages:f=!0,userMessagePreviewLength:h=200,customStyles:p={},onEdit:w,onRegenerate:v,onCancelEdit:g,onCopy:x}){const[b,S]=y.useState(!1),[E,C]=y.useState("collapsed"),[T,I]=y.useState(!1),{currentThreadId:A}=go(),{handleInterrupt:P}=Qs(),{toast:j}=Pi(),[M,L]=y.useState({}),[W,O]=y.useState(!1),[Y,q]=y.useState(null),J=l==="phone"||l==="half-screen",$=t.role,_=$==="tool",G=!(r&&$!=="user"),B=y.useMemo(()=>{switch($){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[$]),he=y.useMemo(()=>qw(t.content),[t.content]),de=y.useMemo(()=>Gw(t.content),[t.content]),xe=y.useMemo(()=>t.content.filter(re=>re.type==="image_url"),[t.content]),_e=y.useMemo(()=>t.content.filter(re=>re.type==="file"),[t.content]),Ce=y.useMemo(()=>t.content.filter(re=>re.type==="interrupt"),[t.content]),F=y.useMemo(()=>Xw(t.content),[t.content]);y.useMemo(()=>Jw(t.content),[t.content]);const D=y.useMemo(()=>F.length<=Wn?F:`${F.slice(0,Wn)}
124
- … [truncated ${F.length-Wn} chars]`,[F]),Z=y.useCallback(async(re="all")=>{const ge=re==="visible"&&_?D:_?F:he;async function ke(ve){try{await navigator.clipboard.writeText(ve)}catch{try{const Re=document.createElement("textarea");Re.value=ve,Re.setAttribute("readonly",""),Re.style.position="absolute",Re.style.left="-9999px",document.body.appendChild(Re),Re.select(),document.execCommand("copy"),document.body.removeChild(Re)}catch(Re){throw console.error("Failed to copy:",Re),Re}}}try{await ke(ge),S(!0),setTimeout(()=>S(!1),2e3),x==null||x(ge)}catch(ve){console.error("Failed to copy:",ve)}},[_,F,he,D,x]),ee=y.useCallback(()=>{if(!w)return;const re=_?F:he;w(t.id,re)},[w,t.id,_,F,he]),ce=y.useCallback(()=>{v==null||v(n)},[v,n]),ne=y.useCallback(async(re,ue,ge)=>{if(!G){re.preventDefault();return}if(M[ge]){re.preventDefault();return}try{const ke=String(ue.url??""),ve=ke.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(ve){re.preventDefault();const Re=ve[1],Ze=ue.name||`file_${Re}`,Ke=ue.mimeType||"application/octet-stream";q({id:Re,name:Ze,mimeType:Ke}),O(!0);return}if(ke.startsWith("data:")){re.preventDefault(),L(Ke=>({...Ke,[ge]:!0}));const Re=`${ue.name}_${ue.size}_${Date.now()}`,Ze=j({title:"Fetching file...",description:"",open:!0});try{const Ke=await Ev(A??void 0);if(!Ke||!Array.isArray(Ke))throw new Error("Invalid file list response");const at=Ke.find(Ct=>!Ct||typeof Ct!="object"||!((Ct.filename??"")===(ue.name??""))?!1:typeof ue.size=="number"&&typeof Ct.size=="number"?Ct.size===ue.size:!0);if(!(at!=null&&at.id))throw new Error(`File "${ue.name}" is not yet available on the server`);if(!at.id||!at.filename)throw new Error("Invalid file data received from server");q({id:at.id,name:ue.name||at.filename||`file_${at.id}`,mimeType:ue.mimeType||at.mime_type||"application/octet-stream"}),O(!0),Ze.update({id:Ze.id,title:"Success",description:`Opened ${ue.name}`,open:!0})}catch(Ke){console.error("Failed to fetch server file:",Ke);const at=Ke instanceof Error?Ke.message:"Unknown error occurred";Ze.update({id:Ze.id,title:"Failed",description:at}),j({title:"Failed to fetch file",description:at,open:!0})}finally{L(Ke=>({...Ke,[ge]:!1}))}}}catch(ke){console.error("File click error:",ke),L(ve=>({...ve,[ge]:!1}))}},[G,M,j,A]),Oe=y.useCallback(()=>{const ue=Q(J?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",B);switch($){case"user":return c.jsx(se.User,{className:ue});case"assistant":return c.jsx(se.Bot,{className:ue});case"tool":return c.jsx(se.Wrench,{className:ue});default:return c.jsx(se.Bot,{className:ue})}},[J,B,$]),Ye=y.useCallback(()=>{const re="group relative mb-4 flex w-full";switch($){case"user":return Q(re,"justify-end");case"assistant":case"tool":case"system":return Q(re,"justify-start");default:return re}},[$]),Ue=y.useCallback(()=>{const re=Q("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",J&&"px-3 py-2 text-sm");switch($){case"user":return Q(re,"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 Q(re,"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 Q(re,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return Q(re,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return Q(re,"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")}},[J,$]),je=y.useCallback(async re=>{try{const ue=re.id||`interrupt-${Date.now()}`;await P(ue,!0)}catch(ue){console.error("Failed to approve interrupt:",ue)}},[P]),Me=y.useCallback(async re=>{try{const ue=re.id||`interrupt-${Date.now()}`;await P(ue,!1)}catch(ue){console.error("Failed to reject interrupt:",ue)}},[P]),Je=y.useCallback(({part:re,i:ue})=>{if(re.type==="text"){const ge=re.text??"",ke=ge.trim(),ve=od(ke);return ve&&$!=="tool"?c.jsx(eb,{data:ve},ue):$==="user"&&f&&ke.length>h?c.jsxs(Kc,{open:T,onOpenChange:I,children:[c.jsx("div",{className:Q("text-sm text-[hsl(var(--chat-bubble-user-text))]",J&&"text-xs"),children:T?c.jsx(_i,{content:ke,allowHtml:!1}):c.jsxs("pre",{className:Q("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",J&&"text-xs"),children:[ke.substring(0,h),"..."]})}),c.jsx(qc,{asChild:!0,children:c.jsx(He,{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(se.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(se.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",ke.length-h," chars)"]})})})]},ue):c.jsx(_i,{content:ge,allowHtml:!1},ue)}if(re.type==="image_url"){const ge=re;return c.jsx("div",{className:"my-2",children:c.jsx("img",{src:ge.url,alt:ge.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},ue)}if(re.type==="file"){const ge=re,ke=ge.name||"file";return c.jsxs("a",{href:ge.url,onClick:ve=>ne(ve,ge,ue),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
125
- dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[M[ue]?c.jsx(se.Loader,{className:"h-4 w-4 animate-spin"}):null,c.jsxs("span",{className:"truncate max-w-[180px]",children:[ke,M[ue]?" (processing)":""]})]},ue)}return re.type==="interrupt"?c.jsx(nb,{interruptPart:re,onApprove:je,onReject:Me},ue):null},[ne,M,je,Me,$,f,h,T,J]),ze=y.useCallback(()=>c.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[c.jsx(se.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),nt=y.useCallback(()=>{const re=he.trim().length>0||xe.length>0||_e.length>0||Ce.length>0;if(!_&&!re&&!r)return ze();if(t.model==="reflection"){const ue=he.trim(),ge=od(ue);if(ge&&typeof ge=="object")return c.jsx(rb,{data:ge})}if(_&&de.name==="get_issues"){const ue=t.content.find(ve=>ve.type==="tool_end"),ge=(ue==null?void 0:ue.output)??F,ke=id(ge);if(ke)return c.jsx(ob,{issues:ke})}if(_){const ue=Yw(t.content);if(ue.length>0)return c.jsx("div",{className:"space-y-2",children:ue.map((ge,ke)=>{const ve=typeof ge.output=="string"?ge.output:Gi(ge.output),Re=ve.length>Wn?`${ve.slice(0,Wn)}
126
- … [truncated ${ve.length-Wn} chars]`:ve,Ze=E==="expanded";return c.jsxs(Kc,{open:Ze,onOpenChange:Ke=>C(Ke?"expanded":"preview"),children:[c.jsx("div",{className:"flex items-center gap-2 text-xs",children:c.jsx(Ci,{variant:"outline",children:(ge.name??"tool")+(ge.toolCallId?` • ${ge.toolCallId.slice(0,8)}`:"")})}),c.jsx("div",{className:"font-mono text-sm mt-1",children:c.jsx("pre",{className:"whitespace-pre-wrap break-words",children:Ze?Re:Re.slice(0,d)+(Re.length>d?"...":"")})}),c.jsx(qc,{asChild:!0,children:c.jsx(He,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:Ze?c.jsxs(c.Fragment,{children:[" ",c.jsx(se.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(se.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},ge.toolCallId??ke)})})}if(!_){const ue=c.jsx("div",{className:"space-y-2",children:t.content.map((ge,ke)=>c.jsx(Je,{part:ge,i:ke},ke))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[ue,c.jsx(Qw,{className:B})]}):ue}},[he,xe.length,_e.length,Ce.length,r,t.model,_,de.name,F,E,u,ze,B]),st=y.useMemo(()=>Zw(t),[t]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:Q(Ye(),p.container),children:c.jsxs("div",{className:Q(Ue(),p.content),children:[(i||a||_)&&c.jsxs("div",{className:Q("flex items-center justify-between mb-2 pb-2 border-b border-current/10",J&&"mb-1 pb-1",B,p.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[Oe(),a&&st&&c.jsx("span",{className:Q("font-medium",J?"text-xs":"text-sm"),children:st}),_&&de.name&&c.jsxs(Ci,{variant:"outline",className:Q("text-xs flex items-center gap-1 cursor-pointer",B,"border border-current/40",J&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":E!=="collapsed",onKeyDown:re=>{(re.key==="Enter"||re.key===" ")&&(re.preventDefault(),C(ue=>ue==="collapsed"?"preview":"collapsed"))},onClick:()=>C(re=>re==="collapsed"?"preview":"collapsed"),children:[c.jsx("span",{children:de.name}),c.jsx("span",{className:"inline-flex items-center",children:E!=="collapsed"?c.jsx(se.ChevronUp,{className:"h-3 w-3"}):c.jsx(se.ChevronDown,{className:"h-3 w-3"})})]}),_&&!de.name&&c.jsx(He,{variant:"ghost",size:"sm",className:Q("h-6 px-1",B,"hover:bg-foreground/10"),onClick:()=>C(re=>re==="collapsed"?"preview":"collapsed"),children:c.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",E!=="collapsed"?c.jsx(se.ChevronUp,{className:"h-3 w-3"}):c.jsx(se.ChevronDown,{className:"h-3 w-3"})]})})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.createdAt&&c.jsx("time",{className:Q("text-xs opacity-60",B,J&&"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:Q("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsxs("div",{className:"relative",children:[c.jsx(He,{variant:"ghost",size:"sm",onClick:()=>Z(_?"visible":"all"),className:Q("h-6 w-6 p-0 hover:bg-foreground/10",B,J&&"h-5 w-5"),"aria-label":_?"Copy visible":"Copy message",title:_?"Copy visible portion":"Copy message",children:c.jsx(se.Copy,{className:Q(b?"text-success":B,J?"h-3 w-3":"h-4 w-4")})}),_&&c.jsx(He,{variant:"ghost",size:"sm",onClick:()=>Z("all"),className:Q("h-6 px-1 text-xs hover:bg-foreground/10",B),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),$==="user"&&w&&c.jsx(He,{variant:"ghost",size:"sm",onClick:ee,className:Q("h-6 w-6 p-0 hover:bg-foreground/10",B,J&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(se.Edit,{className:Q(B,J?"h-3 w-3":"h-4 w-4")})}),$==="assistant"&&v&&c.jsx(He,{variant:"ghost",size:"sm",onClick:ce,className:Q("h-6 w-6 p-0 hover:bg-foreground/10",B,J&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(se.RotateCcw,{className:Q(B,J?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsx("div",{className:"relative",children:nt()}),_&&E==="expanded"&&(de.toolCallId||de.name)&&c.jsxs("div",{className:Q("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",J&&"text-xs"),children:[de.name&&c.jsxs("div",{children:["Function: ",de.name]}),de.toolCallId&&c.jsxs("div",{children:["Call ID: ",de.toolCallId]})]}),!(i||a||_)&&s&&!o&&c.jsxs("div",{className:Q("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsx(He,{variant:"ghost",size:"sm",onClick:()=>Z(),className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",J&&"h-5 w-5"),children:c.jsx(se.Copy,{className:Q(b?"text-success":"text-current",J?"h-3 w-3":"h-4 w-4")})}),$==="user"&&w&&c.jsx(He,{variant:"ghost",size:"sm",onClick:ee,className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",J&&"h-5 w-5"),children:c.jsx(se.Edit,{className:Q("text-current",J?"h-3 w-3":"h-4 w-4")})}),$==="assistant"&&v&&c.jsx(He,{variant:"ghost",size:"sm",onClick:ce,className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",J&&"h-5 w-5"),children:c.jsx(se.RotateCcw,{className:Q("text-current",J?"h-3 w-3":"h-4 w-4")})})]})]})}),Y&&c.jsx(Kw,{isOpen:W,onClose:()=>{O(!1),q(null)},fileId:Y.id,fileName:Y.name,mimeType:Y.mimeType})]})},(e,t)=>{var i,a,l,u,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&ad(e.message)===ad(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(w=>e[w]===t[w]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((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 eb({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?c.jsx("div",{className:ns,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:Gi(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:ns,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:ns,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:tb(i)})]},s))})})}return c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Gi(e)})}function tb(e){if(e==null)return String(e);const t=typeof e;if(t==="string"||t==="number"||t==="boolean")return String(e);if(Array.isArray(e)&&e.every(r=>r===null||["string","number","boolean"].includes(typeof r)))return e.join(", ");try{return c.jsx("code",{className:"text-xs",children:JSON.stringify(Wr(e))})}catch{return String(e)}}function nb({interruptPart:e,onApprove:t,onReject:n}){const r=e.title??"Approve the result?";return c.jsxs(zr,{className:"border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10",children:[c.jsxs(Br,{className:"pb-3",children:[c.jsx(Hr,{className:"text-blue-900 dark:text-blue-100 text-base",children:r}),c.jsx(Gc,{className:"text-blue-700 dark:text-blue-300",children:"Please approve or reject this action to continue."})]}),c.jsx(Yc,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(He,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",children:"Reject"}),c.jsx(He,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",children:"Approve"})]})})]})}function rb({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 ob({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:ns,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 cd=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Yi=y.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:w=!0,isNavigatingCheckpoint:v=!1,onScrollAway:g,onAtBottom:x},b)=>{const S=y.useRef(null),E=y.useRef(null),C=y.useRef(!1),[T,I]=y.useState(!0),A=y.useCallback(M=>{I(M),g&&g(!M),x&&x(M)},[g,x]),P=y.useMemo(()=>{if(a)return async()=>{if(!C.current){C.current=!0;try{await a()}finally{C.current=!1}}}},[a]),j=y.useMemo(()=>!w||v?!1:T?"auto":!1,[T,w,v]);return e.length===0?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(_x,{ref:M=>{S.current=M},scrollerRef:M=>{E.current=M instanceof HTMLDivElement?M:null},data:e,followOutput:j,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{P&&P()},atBottomStateChange:A,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(M,L)=>cd(L,M),itemContent:(M,L)=>{const W=cd(L,M);return c.jsx("div",{className:"mb-4 last:mb-0","data-message-id":W,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(ld,{message:L,messageIndex:M,isStreamingMessage:t&&n===L.id,streamingDebounceMs:r,isEditing:i===L.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:l,onRegenerate:()=>u(M),onCancelEdit:d})})}})})});Yi.displayName="MessageList";const rs=1e4;function sb(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
122
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Gw="DialogDescriptionWarning",Yw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ed(Gw).contentName}}.`;return m.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},td=Bu,Xw=Hu,nd=Wu,Qo=Vu,es=Ku,Un=Gu,ts=Xu,rd=Zu;const Jw=td,Zw=nd,od=m.forwardRef(({className:e,...t},n)=>c.jsx(Qo,{ref:n,className:Q("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}));od.displayName=Qo.displayName;const sd=m.forwardRef(({className:e,children:t,...n},r)=>{const o=m.useMemo(()=>{let s=!1;function i(a){m.Children.forEach(a,l=>{if(s||!m.isValidElement(l))return;const u=l.type;if(u===Un||(u==null?void 0:u.displayName)===Un.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(Zw,{children:[c.jsx(od,{}),c.jsxs(es,{ref:r,className:Q("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(Un,{className:"sr-only",children:"Dialog"}),t,c.jsxs(rd,{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(re.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});sd.displayName=es.displayName;const id=({className:e,...t})=>c.jsx("div",{className:Q("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});id.displayName="DialogHeader";const ad=m.forwardRef(({className:e,...t},n)=>c.jsx(Un,{ref:n,className:Q("text-lg font-semibold leading-none tracking-tight",e),...t}));ad.displayName=Un.displayName;const Qw=m.forwardRef(({className:e,...t},n)=>c.jsx(ts,{ref:n,className:Q("text-sm text-muted-foreground",e),...t}));Qw.displayName=ts.displayName;function eb({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=y.useState(!1),[a,l]=y.useState(null),[u,d]=y.useState(null),{toast:f}=Di(),h=y.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const x=await pu(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]);y.useEffect(()=>{e&&n&&h()},[e,n,h]);const p=async()=>{if(n)try{await Pv(n),f({title:"Download started",description:`Downloading ${r}`})}catch(x){console.error("Failed to download file:",x),f({title:"Download failed",description:String(x),variant:"destructive"})}},w=async()=>{if(n)try{const x=await pu(n),b=new Blob([x],{type:o}),S=URL.createObjectURL(b);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(x){console.error("Failed to open file externally:",x),f({title:"Failed to open file",description:String(x),variant:"destructive"})}},v=()=>s?c.jsxs("div",{className:"flex items-center justify-center py-12",children:[c.jsx(re.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(He,{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(re.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),c.jsx("p",{className:"text-lg font-medium mb-2",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),g=()=>o.startsWith("image/")?c.jsx(re.Image,{className:"h-5 w-5"}):c.jsx(re.FileText,{className:"h-5 w-5"});return c.jsx(Jw,{open:e,onOpenChange:t,children:c.jsxs(sd,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[c.jsx(id,{children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[g(),c.jsxs("div",{children:[c.jsx(ad,{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(He,{variant:"outline",size:"sm",onClick:w,className:"flex items-center gap-2",children:[c.jsx(re.ExternalLink,{className:"h-4 w-4"}),"External"]}),c.jsxs(He,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[c.jsx(re.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),c.jsx("div",{className:"flex-1 overflow-hidden",children:v()})]})})}function ld(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 cd(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Wr(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(Wr).filter(r=>r!==void 0);return n.length?n:void 0}if(cd(e))return;const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=Wr(r);o!==void 0&&(t[n]=o)}}return Object.keys(t).length?t:void 0}return e}function Ji(e){if(typeof e=="string")return e;if(cd(e))return"";try{const t=Wr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function ud(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 ud(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),w=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(h),v=p?p[2].trim():"",g=w?w[2].trim():"";n[i].push({title:v,description:g})}}return Object.values(n).some(i=>i.length>0)?n:null}const ns="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",Wn=1e5;function tb(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function nb(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 rb(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 ob(e){const t=(r,o=Wn)=>{try{const s=Wr(r),i=typeof s=="string"?s:JSON.stringify(s??"");return i.length<=o?i:i.slice(0,o)+`
123
+ … [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 sb(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 ib(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function dd(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 ab({className:e}){const[t,n]=y.useState(0);return y.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),c.jsxs("span",{"aria-live":"polite",className:Q("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const fd=y.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateToolMessages:u=!0,toolMessagePreviewLength:d=200,truncateUserMessages:f=!0,userMessagePreviewLength:h=200,customStyles:p={},onEdit:w,onRegenerate:v,onCancelEdit:g,onCopy:x}){const[b,S]=y.useState(!1),[N,C]=y.useState("collapsed"),[k,I]=y.useState(!1),{currentThreadId:A}=go(),{handleInterrupt:R}=ni(),{toast:P}=Di(),[L,$]=y.useState({}),[H,M]=y.useState(!1),[q,V]=y.useState(null),Y=l==="phone"||l==="half-screen",B=t.role,j=B==="tool",G=!(r&&B!=="user"),Z=y.useMemo(()=>{switch(B){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))]"}},[B]),ge=y.useMemo(()=>tb(t.content),[t.content]),de=y.useMemo(()=>nb(t.content),[t.content]),ee=y.useMemo(()=>t.content.filter(ne=>ne.type==="image_url"),[t.content]),Ae=y.useMemo(()=>t.content.filter(ne=>ne.type==="file"),[t.content]),Te=y.useMemo(()=>t.content.filter(ne=>ne.type==="interrupt"),[t.content]),K=y.useMemo(()=>ob(t.content),[t.content]);y.useMemo(()=>sb(t.content),[t.content]);const D=y.useMemo(()=>K.length<=Wn?K:`${K.slice(0,Wn)}
124
+ … [truncated ${K.length-Wn} chars]`,[K]),J=y.useCallback(async(ne="all")=>{const xe=ne==="visible"&&j?D:j?K:ge;async function Se(be){try{await navigator.clipboard.writeText(be)}catch{try{const je=document.createElement("textarea");je.value=be,je.setAttribute("readonly",""),je.style.position="absolute",je.style.left="-9999px",document.body.appendChild(je),je.select(),document.execCommand("copy"),document.body.removeChild(je)}catch(je){throw console.error("Failed to copy:",je),je}}}try{await Se(xe),S(!0),setTimeout(()=>S(!1),2e3),x==null||x(xe)}catch(be){console.error("Failed to copy:",be)}},[j,K,ge,D,x]),U=y.useCallback(()=>{if(!w)return;const ne=j?K:ge;w(t.id,ne)},[w,t.id,j,K,ge]),fe=y.useCallback(()=>{v==null||v(n)},[v,n]),ue=y.useCallback(async(ne,le,xe)=>{if(!G){ne.preventDefault();return}if(L[xe]){ne.preventDefault();return}try{const Se=String(le.url??""),be=Se.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(be){ne.preventDefault();const je=be[1],Qe=le.name||`file_${je}`,Ye=le.mimeType||"application/octet-stream";V({id:je,name:Qe,mimeType:Ye}),M(!0);return}if(Se.startsWith("data:")){ne.preventDefault(),$(Ye=>({...Ye,[xe]:!0}));const je=`${le.name}_${le.size}_${Date.now()}`,Qe=P({title:"Fetching file...",description:"",open:!0});try{const Ye=await Ov(A??void 0);if(!Ye||!Array.isArray(Ye))throw new Error("Invalid file list response");const it=Ye.find(gt=>!gt||typeof gt!="object"||!((gt.filename??"")===(le.name??""))?!1:typeof le.size=="number"&&typeof gt.size=="number"?gt.size===le.size:!0);if(!(it!=null&&it.id))throw new Error(`File "${le.name}" is not yet available on the server`);if(!it.id||!it.filename)throw new Error("Invalid file data received from server");V({id:it.id,name:le.name||it.filename||`file_${it.id}`,mimeType:le.mimeType||it.mime_type||"application/octet-stream"}),M(!0),Qe.update({id:Qe.id,title:"Success",description:`Opened ${le.name}`,open:!0})}catch(Ye){console.error("Failed to fetch server file:",Ye);const it=Ye instanceof Error?Ye.message:"Unknown error occurred";Qe.update({id:Qe.id,title:"Failed",description:it}),P({title:"Failed to fetch file",description:it,open:!0})}finally{$(Ye=>({...Ye,[xe]:!1}))}}}catch(Se){console.error("File click error:",Se),$(be=>({...be,[xe]:!1}))}},[G,L,P,A]),$e=y.useCallback(()=>{const le=Q(Y?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",Z);switch(B){case"user":return c.jsx(re.User,{className:le});case"assistant":return c.jsx(re.Bot,{className:le});case"tool":return c.jsx(re.Wrench,{className:le});default:return c.jsx(re.Bot,{className:le})}},[Y,Z,B]),Ge=y.useCallback(()=>{const ne="group relative mb-4 flex w-full";switch(B){case"user":return Q(ne,"justify-end");case"assistant":case"tool":case"system":return Q(ne,"justify-start");default:return ne}},[B]),qe=y.useCallback(()=>{const ne=Q("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",Y&&"px-3 py-2 text-sm");switch(B){case"user":return Q(ne,"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 Q(ne,"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 Q(ne,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return Q(ne,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return Q(ne,"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")}},[Y,B]),ke=y.useCallback(async ne=>{try{const le=ne.id||`interrupt-${Date.now()}`;await R(le,!0)}catch(le){console.error("Failed to approve interrupt:",le)}},[R]),Oe=y.useCallback(async ne=>{try{const le=ne.id||`interrupt-${Date.now()}`;await R(le,!1)}catch(le){console.error("Failed to reject interrupt:",le)}},[R]),Be=y.useCallback(({part:ne,i:le})=>{if(ne.type==="text"){const xe=ne.text??"",Se=xe.trim(),be=ld(Se);return be&&B!=="tool"?c.jsx(lb,{data:be},le):B==="user"&&f&&Se.length>h?c.jsxs(Xc,{open:k,onOpenChange:I,children:[c.jsx("div",{className:Q("text-sm text-[hsl(var(--chat-bubble-user-text))]",Y&&"text-xs"),children:k?c.jsx(Pi,{content:Se,allowHtml:!1}):c.jsxs("pre",{className:Q("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",Y&&"text-xs"),children:[Se.substring(0,h),"..."]})}),c.jsx(Jc,{asChild:!0,children:c.jsx(He,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:k?c.jsxs(c.Fragment,{children:[c.jsx(re.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(re.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",Se.length-h," chars)"]})})})]},le):c.jsx(Pi,{content:xe,allowHtml:!1},le)}if(ne.type==="image_url"){const xe=ne;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"})},le)}if(ne.type==="file"){const xe=ne,Se=xe.name||"file";return c.jsxs("a",{href:xe.url,onClick:be=>ue(be,xe,le),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
125
+ dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[L[le]?c.jsx(re.Loader,{className:"h-4 w-4 animate-spin"}):null,c.jsxs("span",{className:"truncate max-w-[180px]",children:[Se,L[le]?" (processing)":""]})]},le)}return ne.type==="interrupt"?c.jsx(ub,{interruptPart:ne,onApprove:ke,onReject:Oe},le):null},[ue,L,ke,Oe,B,f,h,k,Y]),Ue=y.useCallback(()=>c.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[c.jsx(re.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),st=y.useCallback(()=>{const ne=ge.trim().length>0||ee.length>0||Ae.length>0||Te.length>0;if(!j&&!ne&&!r)return Ue();if(t.model==="reflection"){const le=ge.trim(),xe=ld(le);if(xe&&typeof xe=="object")return c.jsx(db,{data:xe})}if(j&&de.name==="get_issues"){const le=t.content.find(be=>be.type==="tool_end"),xe=(le==null?void 0:le.output)??K,Se=ud(xe);if(Se)return c.jsx(fb,{issues:Se})}if(j){const le=rb(t.content);if(le.length>0)return c.jsx("div",{className:"space-y-2",children:le.map((xe,Se)=>{const be=typeof xe.output=="string"?xe.output:Ji(xe.output),je=be.length>Wn?`${be.slice(0,Wn)}
126
+ … [truncated ${be.length-Wn} chars]`:be,Qe=N==="expanded";return c.jsxs(Xc,{open:Qe,onOpenChange:Ye=>C(Ye?"expanded":"preview"),children:[c.jsx("div",{className:"flex items-center gap-2 text-xs",children:c.jsx(Ei,{variant:"outline",children:(xe.name??"tool")+(xe.toolCallId?` • ${xe.toolCallId.slice(0,8)}`:"")})}),c.jsx("div",{className:"font-mono text-sm mt-1",children:c.jsx("pre",{className:"whitespace-pre-wrap break-words",children:Qe?je:je.slice(0,d)+(je.length>d?"...":"")})}),c.jsx(Jc,{asChild:!0,children:c.jsx(He,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:Qe?c.jsxs(c.Fragment,{children:[" ",c.jsx(re.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(re.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},xe.toolCallId??Se)})})}if(!j){const le=c.jsx("div",{className:"space-y-2",children:t.content.map((xe,Se)=>c.jsx(Be,{part:xe,i:Se},Se))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[le,c.jsx(ab,{className:Z})]}):le}},[ge,ee.length,Ae.length,Te.length,r,t.model,j,de.name,K,N,u,Ue,Z]),ot=y.useMemo(()=>ib(t),[t]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:Q(Ge(),p.container),children:c.jsxs("div",{className:Q(qe(),p.content),children:[(i||a||j)&&c.jsxs("div",{className:Q("flex items-center justify-between mb-2 pb-2 border-b border-current/10",Y&&"mb-1 pb-1",Z,p.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[$e(),a&&ot&&c.jsx("span",{className:Q("font-medium",Y?"text-xs":"text-sm"),children:ot}),j&&de.name&&c.jsxs(Ei,{variant:"outline",className:Q("text-xs flex items-center gap-1 cursor-pointer",Z,"border border-current/40",Y&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":N!=="collapsed",onKeyDown:ne=>{(ne.key==="Enter"||ne.key===" ")&&(ne.preventDefault(),C(le=>le==="collapsed"?"preview":"collapsed"))},onClick:()=>C(ne=>ne==="collapsed"?"preview":"collapsed"),children:[c.jsx("span",{children:de.name}),c.jsx("span",{className:"inline-flex items-center",children:N!=="collapsed"?c.jsx(re.ChevronUp,{className:"h-3 w-3"}):c.jsx(re.ChevronDown,{className:"h-3 w-3"})})]}),j&&!de.name&&c.jsx(He,{variant:"ghost",size:"sm",className:Q("h-6 px-1",Z,"hover:bg-foreground/10"),onClick:()=>C(ne=>ne==="collapsed"?"preview":"collapsed"),children:c.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",N!=="collapsed"?c.jsx(re.ChevronUp,{className:"h-3 w-3"}):c.jsx(re.ChevronDown,{className:"h-3 w-3"})]})})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.createdAt&&c.jsx("time",{className:Q("text-xs opacity-60",Z,Y&&"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:Q("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsxs("div",{className:"relative",children:[c.jsx(He,{variant:"ghost",size:"sm",onClick:()=>J(j?"visible":"all"),className:Q("h-6 w-6 p-0 hover:bg-foreground/10",Z,Y&&"h-5 w-5"),"aria-label":j?"Copy visible":"Copy message",title:j?"Copy visible portion":"Copy message",children:c.jsx(re.Copy,{className:Q(b?"text-success":Z,Y?"h-3 w-3":"h-4 w-4")})}),j&&c.jsx(He,{variant:"ghost",size:"sm",onClick:()=>J("all"),className:Q("h-6 px-1 text-xs hover:bg-foreground/10",Z),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),B==="user"&&w&&c.jsx(He,{variant:"ghost",size:"sm",onClick:U,className:Q("h-6 w-6 p-0 hover:bg-foreground/10",Z,Y&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(re.Edit,{className:Q(Z,Y?"h-3 w-3":"h-4 w-4")})}),B==="assistant"&&v&&c.jsx(He,{variant:"ghost",size:"sm",onClick:fe,className:Q("h-6 w-6 p-0 hover:bg-foreground/10",Z,Y&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(re.RotateCcw,{className:Q(Z,Y?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsx("div",{className:"relative",children:st()}),j&&N==="expanded"&&(de.toolCallId||de.name)&&c.jsxs("div",{className:Q("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",Y&&"text-xs"),children:[de.name&&c.jsxs("div",{children:["Function: ",de.name]}),de.toolCallId&&c.jsxs("div",{children:["Call ID: ",de.toolCallId]})]}),!(i||a||j)&&s&&!o&&c.jsxs("div",{className:Q("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsx(He,{variant:"ghost",size:"sm",onClick:()=>J(),className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",Y&&"h-5 w-5"),children:c.jsx(re.Copy,{className:Q(b?"text-success":"text-current",Y?"h-3 w-3":"h-4 w-4")})}),B==="user"&&w&&c.jsx(He,{variant:"ghost",size:"sm",onClick:U,className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",Y&&"h-5 w-5"),children:c.jsx(re.Edit,{className:Q("text-current",Y?"h-3 w-3":"h-4 w-4")})}),B==="assistant"&&v&&c.jsx(He,{variant:"ghost",size:"sm",onClick:fe,className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",Y&&"h-5 w-5"),children:c.jsx(re.RotateCcw,{className:Q("text-current",Y?"h-3 w-3":"h-4 w-4")})})]})]})}),q&&c.jsx(eb,{isOpen:H,onClose:()=>{M(!1),V(null)},fileId:q.id,fileName:q.name,mimeType:q.mimeType})]})},(e,t)=>{var i,a,l,u,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&dd(e.message)===dd(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(w=>e[w]===t[w]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((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 lb({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?c.jsx("div",{className:ns,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:Ji(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:ns,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:ns,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:cb(i)})]},s))})})}return c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Ji(e)})}function cb(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(Wr(e))})}catch{return String(e)}}function ub({interruptPart:e,onApprove:t,onReject:n}){const r=e.title??"Approve the result?";return c.jsxs(Br,{className:"border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10",children:[c.jsxs(zr,{className:"pb-3",children:[c.jsx(Hr,{className:"text-blue-900 dark:text-blue-100 text-base",children:r}),c.jsx(Zc,{className:"text-blue-700 dark:text-blue-300",children:"Please approve or reject this action to continue."})]}),c.jsx(Qc,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(He,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",children:"Reject"}),c.jsx(He,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",children:"Approve"})]})})]})}function db({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 fb({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:ns,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 hd=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Zi=y.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:w=!0,isNavigatingCheckpoint:v=!1,onScrollAway:g,onAtBottom:x},b)=>{const S=y.useRef(null),N=y.useRef(null),C=y.useRef(!1),[k,I]=y.useState(!0),A=y.useCallback(L=>{I(L),g&&g(!L),x&&x(L)},[g,x]),R=y.useMemo(()=>{if(a)return async()=>{if(!C.current){C.current=!0;try{await a()}finally{C.current=!1}}}},[a]),P=y.useMemo(()=>!w||v?!1:k?"auto":!1,[k,w,v]);return e.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($x,{ref:L=>{S.current=L},scrollerRef:L=>{N.current=L instanceof HTMLDivElement?L:null},data:e,followOutput:P,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{R&&R()},atBottomStateChange:A,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(L,$)=>hd($,L),itemContent:(L,$)=>{const H=hd($,L);return c.jsx("div",{className:"mb-4 last:mb-0","data-message-id":H,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(fd,{message:$,messageIndex:L,isStreamingMessage:t&&n===$.id,streamingDebounceMs:r,isEditing:i===$.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:l,onRegenerate:()=>u(L),onCancelEdit:d})})}})})});Zi.displayName="MessageList";const rs=1e4;function hb(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
127
  `).replace(/<p>(.*?)<\/p>/gi,`$1
128
128
 
129
129
  `).replace(/<h([1-6])>(.*?)<\/h[1-6]>/gi,(o,s,i)=>`${"#".repeat(parseInt(s))} ${i}
@@ -131,4 +131,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
131
131
  `).replace(/<ul>/gi,"").replace(/<\/ul>/gi,`
132
132
  `).replace(/<ol>/gi,"").replace(/<\/ol>/gi,`
133
133
  `).replace(/<li>(.*?)<\/li>/gi,`- $1
134
- `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function ib(e,t=rs){if(!e||typeof e!="string")throw new Error("Invalid content: must be a non-empty string");if(e.length>t)throw new Error(`Message exceeds maximum length of ${t} characters`);return e}function ab(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),ib(t),sb(t)}function Xi(e){const t=e+"CollectionProvider",[n,r]=tn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=v=>{const{scope:g,children:x}=v,b=y.useRef(null),S=y.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:S,collectionRef:b,children:x})};i.displayName=t;const a=e+"CollectionSlot",l=Rn.createSlot(a),u=y.forwardRef((v,g)=>{const{scope:x,children:b}=v,S=s(a,x),E=Le(g,S.collectionRef);return c.jsx(l,{ref:E,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=Rn.createSlot(d),p=y.forwardRef((v,g)=>{const{scope:x,children:b,...S}=v,E=y.useRef(null),C=Le(g,E),T=s(d,x);return y.useEffect(()=>(T.itemMap.set(E,{ref:E,...S}),()=>void T.itemMap.delete(E))),c.jsx(h,{[f]:"",ref:C,children:b})});p.displayName=d;function w(v){const g=s(e+"CollectionConsumer",v);return y.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const S=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((T,I)=>S.indexOf(T.ref.current)-S.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},w,r]}var lb=m.createContext(void 0);function os(e){const t=m.useContext(lb);return e||t||"ltr"}const cb=["top","right","bottom","left"],kn=Math.min,Ot=Math.max,ss=Math.round,is=Math.floor,on=e=>({x:e,y:e}),ub={left:"right",right:"left",bottom:"top",top:"bottom"},db={start:"end",end:"start"};function Ji(e,t,n){return Ot(e,kn(t,n))}function pn(e,t){return typeof e=="function"?e(t):e}function mn(e){return e.split("-")[0]}function fr(e){return e.split("-")[1]}function Zi(e){return e==="x"?"y":"x"}function Qi(e){return e==="y"?"height":"width"}const fb=new Set(["top","bottom"]);function sn(e){return fb.has(mn(e))?"y":"x"}function ea(e){return Zi(sn(e))}function hb(e,t,n){n===void 0&&(n=!1);const r=fr(e),o=ea(e),s=Qi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=as(i)),[i,as(i)]}function pb(e){const t=as(e);return[ta(e),t,ta(t)]}function ta(e){return e.replace(/start|end/g,t=>db[t])}const ud=["left","right"],dd=["right","left"],mb=["top","bottom"],gb=["bottom","top"];function xb(e,t,n){switch(e){case"top":case"bottom":return n?t?dd:ud:t?ud:dd;case"left":case"right":return t?mb:gb;default:return[]}}function vb(e,t,n,r){const o=fr(e);let s=xb(mn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(ta)))),s}function as(e){return e.replace(/left|right|bottom|top/g,t=>ub[t])}function wb(e){return{top:0,right:0,bottom:0,left:0,...e}}function fd(e){return typeof e!="number"?wb(e):{top:e,right:e,bottom:e,left:e}}function ls(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 hd(e,t,n){let{reference:r,floating:o}=e;const s=sn(t),i=ea(t),a=Qi(i),l=mn(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(fr(t)){case"start":p[i]-=h*(n&&u?-1:1);break;case"end":p[i]+=h*(n&&u?-1:1);break}return p}const bb=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}=hd(u,r,l),h=r,p={},w=0;for(let v=0;v<a.length;v++){const{name:g,fn:x}=a[v],{x:b,y:S,data:E,reset:C}=await x({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,[g]:{...p[g],...E}},C&&w<=50&&(w++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=hd(u,h,l)),v=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function Vr(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}=pn(t,e),w=fd(p),g=a[h?f==="floating"?"reference":"floating":f],x=ls(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:l})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=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=ls(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(x.top-C.top+w.top)/E.y,bottom:(C.bottom-x.bottom+w.bottom)/E.y,left:(x.left-C.left+w.left)/E.x,right:(C.right-x.right+w.right)/E.x}}const yb=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:u,padding:d=0}=pn(e,t)||{};if(u==null)return{};const f=fd(d),h={x:n,y:r},p=ea(o),w=Qi(p),v=await i.getDimensions(u),g=p==="y",x=g?"top":"left",b=g?"bottom":"right",S=g?"clientHeight":"clientWidth",E=s.reference[w]+s.reference[p]-h[p]-s.floating[w],C=h[p]-s.reference[p],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let I=T?T[S]:0;(!I||!await(i.isElement==null?void 0:i.isElement(T)))&&(I=a.floating[S]||s.floating[w]);const A=E/2-C/2,P=I/2-v[w]/2-1,j=kn(f[x],P),M=kn(f[b],P),L=j,W=I-v[w]-M,O=I/2-v[w]/2+A,Y=Ji(L,O,W),q=!l.arrow&&fr(o)!=null&&O!==Y&&s.reference[w]/2-(O<L?j:M)-v[w]/2<0,J=q?O<L?O-L:O-W:0;return{[p]:h[p]+J,data:{[p]:Y,centerOffset:O-Y-J,...q&&{alignmentOffset:J}},reset:q}}}),Sb=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:v=!0,...g}=pn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=mn(o),b=sn(a),S=mn(a)===a,E=await(l.isRTL==null?void 0:l.isRTL(u.floating)),C=h||(S||!v?[as(a)]:pb(a)),T=w!=="none";!h&&T&&C.push(...vb(a,v,w,E));const I=[a,...C],A=await Vr(t,g),P=[];let j=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&P.push(A[x]),f){const O=hb(o,i,E);P.push(A[O[0]],A[O[1]])}if(j=[...j,{placement:o,overflows:P}],!P.every(O=>O<=0)){var M,L;const O=(((M=s.flip)==null?void 0:M.index)||0)+1,Y=I[O];if(Y&&(!(f==="alignment"?b!==sn(Y):!1)||j.every($=>sn($.placement)===b?$.overflows[0]>0:!0)))return{data:{index:O,overflows:j},reset:{placement:Y}};let q=(L=j.filter(J=>J.overflows[0]<=0).sort((J,$)=>J.overflows[1]-$.overflows[1])[0])==null?void 0:L.placement;if(!q)switch(p){case"bestFit":{var W;const J=(W=j.filter($=>{if(T){const _=sn($.placement);return _===b||_==="y"}return!0}).map($=>[$.placement,$.overflows.filter(_=>_>0).reduce((_,G)=>_+G,0)]).sort(($,_)=>$[1]-_[1])[0])==null?void 0:W[0];J&&(q=J);break}case"initialPlacement":q=a;break}if(o!==q)return{reset:{placement:q}}}return{}}}};function pd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function md(e){return cb.some(t=>e[t]>=0)}const Cb=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=pn(e,t);switch(r){case"referenceHidden":{const s=await Vr(t,{...o,elementContext:"reference"}),i=pd(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:md(i)}}}case"escaped":{const s=await Vr(t,{...o,altBoundary:!0}),i=pd(s,n.floating);return{data:{escapedOffsets:i,escaped:md(i)}}}default:return{}}}}},gd=new Set(["left","top"]);async function Tb(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=mn(n),a=fr(n),l=sn(n)==="y",u=gd.has(i)?-1:1,d=s&&l?-1:1,f=pn(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:w}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof w=="number"&&(p=a==="end"?w*-1:w),l?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const kb=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 Tb(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}}}}},Eb=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x,y:b}=g;return{x,y:b}}},...l}=pn(e,t),u={x:n,y:r},d=await Vr(t,l),f=sn(mn(o)),h=Zi(f);let p=u[h],w=u[f];if(s){const g=h==="y"?"top":"left",x=h==="y"?"bottom":"right",b=p+d[g],S=p-d[x];p=Ji(b,p,S)}if(i){const g=f==="y"?"top":"left",x=f==="y"?"bottom":"right",b=w+d[g],S=w-d[x];w=Ji(b,w,S)}const v=a.fn({...t,[h]:p,[f]:w});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[h]:s,[f]:i}}}}}},Ib=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:u=!0}=pn(e,t),d={x:n,y:r},f=sn(o),h=Zi(f);let p=d[h],w=d[f];const v=pn(a,t),g=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(l){const S=h==="y"?"height":"width",E=s.reference[h]-s.floating[S]+g.mainAxis,C=s.reference[h]+s.reference[S]-g.mainAxis;p<E?p=E:p>C&&(p=C)}if(u){var x,b;const S=h==="y"?"width":"height",E=gd.has(mn(o)),C=s.reference[f]-s.floating[S]+(E&&((x=i.offset)==null?void 0:x[f])||0)+(E?0:g.crossAxis),T=s.reference[f]+s.reference[S]+(E?0:((b=i.offset)==null?void 0:b[f])||0)-(E?g.crossAxis:0);w<C?w=C:w>T&&(w=T)}return{[h]:p,[f]:w}}}},Nb=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...u}=pn(e,t),d=await Vr(t,u),f=mn(o),h=fr(o),p=sn(o)==="y",{width:w,height:v}=s.floating;let g,x;f==="top"||f==="bottom"?(g=f,x=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=f,g=h==="end"?"top":"bottom");const b=v-d.top-d.bottom,S=w-d.left-d.right,E=kn(v-d[g],b),C=kn(w-d[x],S),T=!t.middlewareData.shift;let I=E,A=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=b),T&&!h){const j=Ot(d.left,0),M=Ot(d.right,0),L=Ot(d.top,0),W=Ot(d.bottom,0);p?A=w-2*(j!==0||M!==0?j+M:Ot(d.left,d.right)):I=v-2*(L!==0||W!==0?L+W:Ot(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:I});const P=await i.getDimensions(a.floating);return w!==P.width||v!==P.height?{reset:{rects:!0}}:{}}}};function cs(){return typeof window<"u"}function hr(e){return xd(e)?(e.nodeName||"").toLowerCase():"#document"}function Mt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function an(e){var t;return(t=(xd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function xd(e){return cs()?e instanceof Node||e instanceof Mt(e).Node:!1}function qt(e){return cs()?e instanceof Element||e instanceof Mt(e).Element:!1}function ln(e){return cs()?e instanceof HTMLElement||e instanceof Mt(e).HTMLElement:!1}function vd(e){return!cs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Mt(e).ShadowRoot}const Ab=new Set(["inline","contents"]);function Kr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Gt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Ab.has(o)}const _b=new Set(["table","td","th"]);function jb(e){return _b.has(hr(e))}const Rb=[":popover-open",":modal"];function us(e){return Rb.some(t=>{try{return e.matches(t)}catch{return!1}})}const Pb=["transform","translate","scale","rotate","perspective"],Ob=["transform","translate","scale","rotate","perspective","filter"],Mb=["paint","layout","strict","content"];function na(e){const t=ra(),n=qt(e)?Gt(e):e;return Pb.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||Ob.some(r=>(n.willChange||"").includes(r))||Mb.some(r=>(n.contain||"").includes(r))}function Db(e){let t=En(e);for(;ln(t)&&!pr(t);){if(na(t))return t;if(us(t))return null;t=En(t)}return null}function ra(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Lb=new Set(["html","body","#document"]);function pr(e){return Lb.has(hr(e))}function Gt(e){return Mt(e).getComputedStyle(e)}function ds(e){return qt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function En(e){if(hr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||vd(e)&&e.host||an(e);return vd(t)?t.host:t}function wd(e){const t=En(e);return pr(t)?e.ownerDocument?e.ownerDocument.body:e.body:ln(t)&&Kr(t)?t:wd(t)}function qr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=wd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Mt(o);if(s){const a=oa(i);return t.concat(i,i.visualViewport||[],Kr(o)?o:[],a&&n?qr(a):[])}return t.concat(o,qr(o,[],n))}function oa(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function bd(e){const t=Gt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=ln(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=ss(n)!==s||ss(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function sa(e){return qt(e)?e:e.contextElement}function mr(e){const t=sa(e);if(!ln(t))return on(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=bd(t);let i=(s?ss(n.width):n.width)/r,a=(s?ss(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Fb=on(0);function yd(e){const t=Mt(e);return!ra()||!t.visualViewport?Fb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function $b(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Mt(e)?!1:t}function Vn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=sa(e);let i=on(1);t&&(r?qt(r)&&(i=mr(r)):i=mr(e));const a=$b(s,n,r)?yd(s):on(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=Mt(s),p=r&&qt(r)?Mt(r):r;let w=h,v=oa(w);for(;v&&r&&p!==w;){const g=mr(v),x=v.getBoundingClientRect(),b=Gt(v),S=x.left+(v.clientLeft+parseFloat(b.paddingLeft))*g.x,E=x.top+(v.clientTop+parseFloat(b.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=S,u+=E,w=Mt(v),v=oa(w)}}return ls({width:d,height:f,x:l,y:u})}function fs(e,t){const n=ds(e).scrollLeft;return t?t.left+n:Vn(an(e)).left+n}function Sd(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-fs(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function zb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=an(r),a=t?us(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=on(1);const d=on(0),f=ln(r);if((f||!f&&!s)&&((hr(r)!=="body"||Kr(i))&&(l=ds(r)),ln(r))){const p=Vn(r);u=mr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?Sd(i,l):on(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 Bb(e){return Array.from(e.getClientRects())}function Hb(e){const t=an(e),n=ds(e),r=e.ownerDocument.body,o=Ot(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Ot(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+fs(e);const a=-n.scrollTop;return Gt(r).direction==="rtl"&&(i+=Ot(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Cd=25;function Ub(e,t){const n=Mt(e),r=an(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=ra();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const u=fs(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,w=Math.abs(r.clientWidth-f.clientWidth-p);w<=Cd&&(s-=w)}else u<=Cd&&(s+=u);return{width:s,height:i,x:a,y:l}}const Wb=new Set(["absolute","fixed"]);function Vb(e,t){const n=Vn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=ln(e)?mr(e):on(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 Td(e,t,n){let r;if(t==="viewport")r=Ub(e,n);else if(t==="document")r=Hb(an(e));else if(qt(t))r=Vb(t,n);else{const o=yd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ls(r)}function kd(e,t){const n=En(e);return n===t||!qt(n)||pr(n)?!1:Gt(n).position==="fixed"||kd(n,t)}function Kb(e,t){const n=t.get(e);if(n)return n;let r=qr(e,[],!1).filter(a=>qt(a)&&hr(a)!=="body"),o=null;const s=Gt(e).position==="fixed";let i=s?En(e):e;for(;qt(i)&&!pr(i);){const a=Gt(i),l=na(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Wb.has(o.position)||Kr(i)&&!l&&kd(e,i))?r=r.filter(d=>d!==i):o=a,i=En(i)}return t.set(e,r),r}function qb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?us(t)?[]:Kb(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=Td(t,d,o);return u.top=Ot(f.top,u.top),u.right=kn(f.right,u.right),u.bottom=kn(f.bottom,u.bottom),u.left=Ot(f.left,u.left),u},Td(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Gb(e){const{width:t,height:n}=bd(e);return{width:t,height:n}}function Yb(e,t,n){const r=ln(t),o=an(t),s=n==="fixed",i=Vn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=on(0);function u(){l.x=fs(o)}if(r||!r&&!s)if((hr(t)!=="body"||Kr(o))&&(a=ds(t)),r){const p=Vn(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?Sd(o,a):on(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 ia(e){return Gt(e).position==="static"}function Ed(e,t){if(!ln(e)||Gt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return an(e)===n&&(n=n.ownerDocument.body),n}function Id(e,t){const n=Mt(e);if(us(e))return n;if(!ln(e)){let o=En(e);for(;o&&!pr(o);){if(qt(o)&&!ia(o))return o;o=En(o)}return n}let r=Ed(e,t);for(;r&&jb(r)&&ia(r);)r=Ed(r,t);return r&&pr(r)&&ia(r)&&!na(r)?n:r||Db(e)||n}const Xb=async function(e){const t=this.getOffsetParent||Id,n=this.getDimensions,r=await n(e.floating);return{reference:Yb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Jb(e){return Gt(e).direction==="rtl"}const Zb={convertOffsetParentRelativeRectToViewportRelativeRect:zb,getDocumentElement:an,getClippingRect:qb,getOffsetParent:Id,getElementRects:Xb,getClientRects:Bb,getDimensions:Gb,getScale:mr,isElement:qt,isRTL:Jb};function Nd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Qb(e,t){let n=null,r;const o=an(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:p}=u;if(a||t(),!h||!p)return;const w=is(f),v=is(o.clientWidth-(d+h)),g=is(o.clientHeight-(f+p)),x=is(d),S={rootMargin:-w+"px "+-v+"px "+-g+"px "+-x+"px",threshold:Ot(0,kn(1,l))||1};let E=!0;function C(T){const I=T[0].intersectionRatio;if(I!==l){if(!E)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!Nd(u,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function ey(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=sa(e),d=o||s?[...u?qr(u):[],...qr(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const f=u&&a?Qb(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(x=>{let[b]=x;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 w,v=l?Vn(e):null;l&&g();function g(){const x=Vn(e);v&&!Nd(v,x)&&n(),v=x,w=requestAnimationFrame(g)}return n(),()=>{var x;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(x=p)==null||x.disconnect(),p=null,l&&cancelAnimationFrame(w)}}const ty=kb,ny=Eb,ry=Sb,oy=Nb,sy=Cb,Ad=yb,iy=Ib,ay=(e,t,n)=>{const r=new Map,o={platform:Zb,...n},s={...o.platform,_c:r};return bb(e,t,{...o,platform:s})};var ly=typeof document<"u",cy=function(){},hs=ly?y.useLayoutEffect:cy;function ps(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(!ps(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)&&!ps(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function _d(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function jd(e,t){const n=_d(e);return Math.round(t*n)/n}function aa(e){const t=m.useRef(e);return hs(()=>{t.current=e}),t}function uy(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=m.useState(r);ps(h,r)||p(r);const[w,v]=m.useState(null),[g,x]=m.useState(null),b=m.useCallback($=>{$!==T.current&&(T.current=$,v($))},[]),S=m.useCallback($=>{$!==I.current&&(I.current=$,x($))},[]),E=s||w,C=i||g,T=m.useRef(null),I=m.useRef(null),A=m.useRef(d),P=l!=null,j=aa(l),M=aa(o),L=aa(u),W=m.useCallback(()=>{if(!T.current||!I.current)return;const $={placement:t,strategy:n,middleware:h};M.current&&($.platform=M.current),ay(T.current,I.current,$).then(_=>{const G={..._,isPositioned:L.current!==!1};O.current&&!ps(A.current,G)&&(A.current=G,no.flushSync(()=>{f(G)}))})},[h,t,n,M,L]);hs(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f($=>({...$,isPositioned:!1})))},[u]);const O=m.useRef(!1);hs(()=>(O.current=!0,()=>{O.current=!1}),[]),hs(()=>{if(E&&(T.current=E),C&&(I.current=C),E&&C){if(j.current)return j.current(E,C,W);W()}},[E,C,W,j,P]);const Y=m.useMemo(()=>({reference:T,floating:I,setReference:b,setFloating:S}),[b,S]),q=m.useMemo(()=>({reference:E,floating:C}),[E,C]),J=m.useMemo(()=>{const $={position:n,left:0,top:0};if(!q.floating)return $;const _=jd(q.floating,d.x),G=jd(q.floating,d.y);return a?{...$,transform:"translate("+_+"px, "+G+"px)",..._d(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:_,top:G}},[n,a,q.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:W,refs:Y,elements:q,floatingStyles:J}),[d,W,Y,q,J])}const dy=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Ad({element:r.current,padding:o}).fn(n):{}:r?Ad({element:r,padding:o}).fn(n):{}}}},fy=(e,t)=>({...ty(e),options:[e,t]}),hy=(e,t)=>({...ny(e),options:[e,t]}),py=(e,t)=>({...iy(e),options:[e,t]}),my=(e,t)=>({...ry(e),options:[e,t]}),gy=(e,t)=>({...oy(e),options:[e,t]}),xy=(e,t)=>({...sy(e),options:[e,t]}),vy=(e,t)=>({...dy(e),options:[e,t]});var wy="Arrow",Rd=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(Te.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"})})});Rd.displayName=wy;var by=Rd;function Pd(e){const[t,n]=m.useState(void 0);return mt(()=>{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 la="Popper",[Od,ms]=tn(la),[yy,Md]=Od(la),Dd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(yy,{scope:t,anchor:r,onAnchorChange:o,children:n})};Dd.displayName=la;var Ld="PopperAnchor",Fd=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Md(Ld,n),i=m.useRef(null),a=Le(t,i),l=m.useRef(null);return m.useEffect(()=>{const u=l.current;l.current=(r==null?void 0:r.current)||i.current,u!==l.current&&s.onAnchorChange(l.current)}),r?null:c.jsx(Te.div,{...o,ref:a})});Fd.displayName=Ld;var ca="PopperContent",[Sy,Cy]=Od(ca),$d=m.forwardRef((e,t)=>{var F,D,Z,ee,ce,ne;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:w,...v}=e,g=Md(ca,n),[x,b]=m.useState(null),S=Le(t,Oe=>b(Oe)),[E,C]=m.useState(null),T=Pd(E),I=(T==null?void 0:T.width)??0,A=(T==null?void 0:T.height)??0,P=r+(s!=="center"?"-"+s:""),j=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},M=Array.isArray(u)?u:[u],L=M.length>0,W={padding:j,boundary:M.filter(ky),altBoundary:L},{refs:O,floatingStyles:Y,placement:q,isPositioned:J,middlewareData:$}=uy({strategy:"fixed",placement:P,whileElementsMounted:(...Oe)=>ey(...Oe,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[fy({mainAxis:o+A,alignmentAxis:i}),l&&hy({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?py():void 0,...W}),l&&my({...W}),gy({...W,apply:({elements:Oe,rects:Ye,availableWidth:Ue,availableHeight:je})=>{const{width:Me,height:Je}=Ye.reference,ze=Oe.floating.style;ze.setProperty("--radix-popper-available-width",`${Ue}px`),ze.setProperty("--radix-popper-available-height",`${je}px`),ze.setProperty("--radix-popper-anchor-width",`${Me}px`),ze.setProperty("--radix-popper-anchor-height",`${Je}px`)}}),E&&vy({element:E,padding:a}),Ey({arrowWidth:I,arrowHeight:A}),h&&xy({strategy:"referenceHidden",...W})]}),[_,G]=Hd(q),B=gt(w);mt(()=>{J&&(B==null||B())},[J,B]);const he=(F=$.arrow)==null?void 0:F.x,de=(D=$.arrow)==null?void 0:D.y,xe=((Z=$.arrow)==null?void 0:Z.centerOffset)!==0,[_e,Ce]=m.useState();return mt(()=>{x&&Ce(window.getComputedStyle(x).zIndex)},[x]),c.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:J?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:_e,"--radix-popper-transform-origin":[(ee=$.transformOrigin)==null?void 0:ee.x,(ce=$.transformOrigin)==null?void 0:ce.y].join(" "),...((ne=$.hide)==null?void 0:ne.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(Sy,{scope:n,placedSide:_,onArrowChange:C,arrowX:he,arrowY:de,shouldHideArrow:xe,children:c.jsx(Te.div,{"data-side":_,"data-align":G,...v,ref:S,style:{...v.style,animation:J?void 0:"none"}})})})});$d.displayName=ca;var zd="PopperArrow",Ty={top:"bottom",right:"left",bottom:"top",left:"right"},Bd=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Cy(zd,r),i=Ty[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(by,{...o,ref:n,style:{...o.style,display:"block"}})})});Bd.displayName=zd;function ky(e){return e!==null}var Ey=e=>({name:"transformOrigin",options:e,fn(t){var g,x,b;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[u,d]=Hd(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((x=o.arrow)==null?void 0:x.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let w="",v="";return u==="bottom"?(w=i?f:`${h}px`,v=`${-l}px`):u==="top"?(w=i?f:`${h}px`,v=`${r.floating.height+l}px`):u==="right"?(w=`${-l}px`,v=i?f:`${p}px`):u==="left"&&(w=`${r.floating.width+l}px`,v=i?f:`${p}px`),{data:{x:w,y:v}}}});function Hd(e){const[t,n="center"]=e.split("-");return[t,n]}var Ud=Dd,Wd=Fd,Vd=$d,Kd=Bd,ua="rovingFocusGroup.onEntryFocus",Iy={bubbles:!1,cancelable:!0},Gr="RovingFocusGroup",[da,qd,Ny]=Xi(Gr),[Ay,Gd]=tn(Gr,[Ny]),[_y,jy]=Ay(Gr),Yd=m.forwardRef((e,t)=>c.jsx(da.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(da.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Ry,{...e,ref:t})})}));Yd.displayName=Gr;var Ry=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=m.useRef(null),p=Le(t,h),w=os(s),[v,g]=zn({prop:i,defaultProp:a??null,onChange:l,caller:Gr}),[x,b]=m.useState(!1),S=gt(u),E=qd(n),C=m.useRef(!1),[T,I]=m.useState(0);return m.useEffect(()=>{const A=h.current;if(A)return A.addEventListener(ua,S),()=>A.removeEventListener(ua,S)},[S]),c.jsx(_y,{scope:n,orientation:r,dir:w,loop:o,currentTabStopId:v,onItemFocus:m.useCallback(A=>g(A),[g]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>I(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>I(A=>A-1),[]),children:c.jsx(Te.div,{tabIndex:x||T===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:le(e.onMouseDown,()=>{C.current=!0}),onFocus:le(e.onFocus,A=>{const P=!C.current;if(A.target===A.currentTarget&&P&&!x){const j=new CustomEvent(ua,Iy);if(A.currentTarget.dispatchEvent(j),!j.defaultPrevented){const M=E().filter(q=>q.focusable),L=M.find(q=>q.active),W=M.find(q=>q.id===v),Y=[L,W,...M].filter(Boolean).map(q=>q.ref.current);Zd(Y,d)}}C.current=!1}),onBlur:le(e.onBlur,()=>b(!1))})})}),Xd="RovingFocusGroupItem",Jd=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=nn(),u=s||l,d=jy(Xd,n),f=d.currentTabStopId===u,h=qd(n),{onFocusableItemAdd:p,onFocusableItemRemove:w,currentTabStopId:v}=d;return m.useEffect(()=>{if(r)return p(),()=>w()},[r,p,w]),c.jsx(da.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(Te.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:le(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:le(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:le(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=My(g,d.orientation,d.dir);if(x!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let S=h().filter(E=>E.focusable).map(E=>E.ref.current);if(x==="last")S.reverse();else if(x==="prev"||x==="next"){x==="prev"&&S.reverse();const E=S.indexOf(g.currentTarget);S=d.loop?Dy(S,E+1):S.slice(E+1)}setTimeout(()=>Zd(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:v!=null}):i})})});Jd.displayName=Xd;var Py={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Oy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function My(e,t,n){const r=Oy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Py[r]}function Zd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Dy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ly=Yd,Fy=Jd,fa=["Enter"," "],$y=["ArrowDown","PageUp","Home"],Qd=["ArrowUp","PageDown","End"],zy=[...$y,...Qd],By={ltr:[...fa,"ArrowRight"],rtl:[...fa,"ArrowLeft"]},Hy={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Yr="Menu",[Xr,Uy,Wy]=Xi(Yr),[Kn,ef]=tn(Yr,[Wy,ms,Gd]),gs=ms(),tf=Gd(),[Vy,qn]=Kn(Yr),[Ky,Jr]=Kn(Yr),nf=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=gs(t),[l,u]=m.useState(null),d=m.useRef(!1),f=gt(s),h=os(o);return m.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),c.jsx(Ud,{...a,children:c.jsx(Vy,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(Ky,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};nf.displayName=Yr;var qy="MenuAnchor",ha=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=gs(n);return c.jsx(Wd,{...o,...r,ref:t})});ha.displayName=qy;var pa="MenuPortal",[Gy,rf]=Kn(pa,{forceMount:void 0}),of=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=qn(pa,t);return c.jsx(Gy,{scope:t,forceMount:n,children:c.jsx(Pt,{present:n||s.open,children:c.jsx(Ho,{asChild:!0,container:o,children:r})})})};of.displayName=pa;var $t="MenuContent",[Yy,ma]=Kn($t),sf=m.forwardRef((e,t)=>{const n=rf($t,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=qn($t,e.__scopeMenu),i=Jr($t,e.__scopeMenu);return c.jsx(Xr.Provider,{scope:e.__scopeMenu,children:c.jsx(Pt,{present:r||s.open,children:c.jsx(Xr.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(Xy,{...o,ref:t}):c.jsx(Jy,{...o,ref:t})})})})}),Xy=m.forwardRef((e,t)=>{const n=qn($t,e.__scopeMenu),r=m.useRef(null),o=Le(t,r);return m.useEffect(()=>{const s=r.current;if(s)return Wi(s)},[]),c.jsx(ga,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:le(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Jy=m.forwardRef((e,t)=>{const n=qn($t,e.__scopeMenu);return c.jsx(ga,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Zy=Rn.createSlot("MenuContent.ScrollLock"),ga=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:w,...v}=e,g=qn($t,n),x=Jr($t,n),b=gs(n),S=tf(n),E=Uy(n),[C,T]=m.useState(null),I=m.useRef(null),A=Le(t,I,g.onContentChange),P=m.useRef(0),j=m.useRef(""),M=m.useRef(0),L=m.useRef(null),W=m.useRef("right"),O=m.useRef(0),Y=w?Go:m.Fragment,q=w?{as:Zy,allowPinchZoom:!0}:void 0,J=_=>{var F,D;const G=j.current+_,B=E().filter(Z=>!Z.disabled),he=document.activeElement,de=(F=B.find(Z=>Z.ref.current===he))==null?void 0:F.textValue,xe=B.map(Z=>Z.textValue),_e=u0(xe,G,de),Ce=(D=B.find(Z=>Z.textValue===_e))==null?void 0:D.ref.current;(function Z(ee){j.current=ee,window.clearTimeout(P.current),ee!==""&&(P.current=window.setTimeout(()=>Z(""),1e3))})(G),Ce&&setTimeout(()=>Ce.focus())};m.useEffect(()=>()=>window.clearTimeout(P.current),[]),Fi();const $=m.useCallback(_=>{var B,he;return W.current===((B=L.current)==null?void 0:B.side)&&f0(_,(he=L.current)==null?void 0:he.area)},[]);return c.jsx(Yy,{scope:n,searchRef:j,onItemEnter:m.useCallback(_=>{$(_)&&_.preventDefault()},[$]),onItemLeave:m.useCallback(_=>{var G;$(_)||((G=I.current)==null||G.focus(),T(null))},[$]),onTriggerLeave:m.useCallback(_=>{$(_)&&_.preventDefault()},[$]),pointerGraceTimerRef:M,onPointerGraceIntentChange:m.useCallback(_=>{L.current=_},[]),children:c.jsx(Y,{...q,children:c.jsx(Bo,{asChild:!0,trapped:o,onMountAutoFocus:le(s,_=>{var G;_.preventDefault(),(G=I.current)==null||G.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(zo,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:c.jsx(Ly,{asChild:!0,...S,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:le(l,_=>{x.isUsingKeyboardRef.current||_.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(Vd,{role:"menu","aria-orientation":"vertical","data-state":Cf(g.open),"data-radix-menu-content":"",dir:x.dir,...b,...v,ref:A,style:{outline:"none",...v.style},onKeyDown:le(v.onKeyDown,_=>{const B=_.target.closest("[data-radix-menu-content]")===_.currentTarget,he=_.ctrlKey||_.altKey||_.metaKey,de=_.key.length===1;B&&(_.key==="Tab"&&_.preventDefault(),!he&&de&&J(_.key));const xe=I.current;if(_.target!==xe||!zy.includes(_.key))return;_.preventDefault();const Ce=E().filter(F=>!F.disabled).map(F=>F.ref.current);Qd.includes(_.key)&&Ce.reverse(),l0(Ce)}),onBlur:le(e.onBlur,_=>{_.currentTarget.contains(_.target)||(window.clearTimeout(P.current),j.current="")}),onPointerMove:le(e.onPointerMove,Qr(_=>{const G=_.target,B=O.current!==_.clientX;if(_.currentTarget.contains(G)&&B){const he=_.clientX>O.current?"right":"left";W.current=he,O.current=_.clientX}}))})})})})})})});sf.displayName=$t;var Qy="MenuGroup",xa=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Te.div,{role:"group",...r,ref:t})});xa.displayName=Qy;var e0="MenuLabel",af=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Te.div,{...r,ref:t})});af.displayName=e0;var xs="MenuItem",lf="menu.itemSelect",vs=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=Jr(xs,e.__scopeMenu),a=ma(xs,e.__scopeMenu),l=Le(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(lf,{bubbles:!0,cancelable:!0});f.addEventListener(lf,p=>r==null?void 0:r(p),{once:!0}),Hc(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(cf,{...o,ref:l,disabled:n,onClick:le(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:le(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:le(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||fa.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});vs.displayName=xs;var cf=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ma(xs,n),a=tf(n),l=m.useRef(null),u=Le(t,l),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const w=l.current;w&&p((w.textContent??"").trim())},[s.children]),c.jsx(Xr.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(Fy,{asChild:!0,...a,focusable:!r,children:c.jsx(Te.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:le(e.onPointerMove,Qr(w=>{r?i.onItemLeave(w):(i.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:le(e.onPointerLeave,Qr(w=>i.onItemLeave(w))),onFocus:le(e.onFocus,()=>f(!0)),onBlur:le(e.onBlur,()=>f(!1))})})})}),t0="MenuCheckboxItem",uf=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(mf,{scope:e.__scopeMenu,checked:n,children:c.jsx(vs,{role:"menuitemcheckbox","aria-checked":ws(n)?"mixed":n,...o,ref:t,"data-state":wa(n),onSelect:le(o.onSelect,()=>r==null?void 0:r(ws(n)?!0:!n),{checkForDefaultPrevented:!1})})})});uf.displayName=t0;var df="MenuRadioGroup",[n0,r0]=Kn(df,{value:void 0,onValueChange:()=>{}}),ff=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=gt(r);return c.jsx(n0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(xa,{...o,ref:t})})});ff.displayName=df;var hf="MenuRadioItem",pf=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=r0(hf,e.__scopeMenu),s=n===o.value;return c.jsx(mf,{scope:e.__scopeMenu,checked:s,children:c.jsx(vs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":wa(s),onSelect:le(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});pf.displayName=hf;var va="MenuItemIndicator",[mf,o0]=Kn(va,{checked:!1}),gf=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=o0(va,n);return c.jsx(Pt,{present:r||ws(s.checked)||s.checked===!0,children:c.jsx(Te.span,{...o,ref:t,"data-state":wa(s.checked)})})});gf.displayName=va;var s0="MenuSeparator",xf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Te.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});xf.displayName=s0;var i0="MenuArrow",vf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=gs(n);return c.jsx(Kd,{...o,...r,ref:t})});vf.displayName=i0;var a0="MenuSub",[UC,wf]=Kn(a0),Zr="MenuSubTrigger",bf=m.forwardRef((e,t)=>{const n=qn(Zr,e.__scopeMenu),r=Jr(Zr,e.__scopeMenu),o=wf(Zr,e.__scopeMenu),s=ma(Zr,e.__scopeMenu),i=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},d=m.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return m.useEffect(()=>d,[d]),m.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),c.jsx(ha,{asChild:!0,...u,children:c.jsx(cf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Cf(n.open),...e,ref:Ti(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:le(e.onPointerMove,Qr(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:le(e.onPointerLeave,Qr(f=>{var p,w;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const v=(w=n.content)==null?void 0:w.dataset.side,g=v==="right",x=g?-5:5,b=h[g?"left":"right"],S=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+x,y:f.clientY},{x:b,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:b,y:h.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:le(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||By[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});bf.displayName=Zr;var yf="MenuSubContent",Sf=m.forwardRef((e,t)=>{const n=rf($t,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=qn($t,e.__scopeMenu),i=Jr($t,e.__scopeMenu),a=wf(yf,e.__scopeMenu),l=m.useRef(null),u=Le(t,l);return c.jsx(Xr.Provider,{scope:e.__scopeMenu,children:c.jsx(Pt,{present:r||s.open,children:c.jsx(Xr.Slot,{scope:e.__scopeMenu,children:c.jsx(ga,{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:le(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:le(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:le(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=Hy[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});Sf.displayName=yf;function Cf(e){return e?"open":"closed"}function ws(e){return e==="indeterminate"}function wa(e){return ws(e)?"indeterminate":e?"checked":"unchecked"}function l0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function c0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function u0(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=c0(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function d0(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],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 f0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return d0(n,t)}function Qr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var h0=nf,p0=ha,m0=of,g0=sf,x0=xa,v0=af,w0=vs,b0=uf,y0=ff,S0=pf,C0=gf,T0=xf,k0=vf,E0=bf,I0=Sf,bs="DropdownMenu",[N0,WC]=tn(bs,[ef]),St=ef(),[A0,Tf]=N0(bs),kf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=St(t),u=m.useRef(null),[d,f]=zn({prop:o,defaultProp:s??!1,onChange:i,caller:bs});return c.jsx(A0,{scope:t,triggerId:nn(),triggerRef:u,contentId:nn(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(h0,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};kf.displayName=bs;var Ef="DropdownMenuTrigger",If=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Tf(Ef,n),i=St(n);return c.jsx(p0,{asChild:!0,...i,children:c.jsx(Te.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:Ti(t,s.triggerRef),onPointerDown:le(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:le(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});If.displayName=Ef;var _0="DropdownMenuPortal",Nf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=St(t);return c.jsx(m0,{...r,...n})};Nf.displayName=_0;var Af="DropdownMenuContent",_f=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Tf(Af,n),s=St(n),i=m.useRef(!1);return c.jsx(g0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:le(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:le(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)"}})});_f.displayName=Af;var j0="DropdownMenuGroup",R0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(x0,{...o,...r,ref:t})});R0.displayName=j0;var P0="DropdownMenuLabel",jf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(v0,{...o,...r,ref:t})});jf.displayName=P0;var O0="DropdownMenuItem",Rf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(w0,{...o,...r,ref:t})});Rf.displayName=O0;var M0="DropdownMenuCheckboxItem",Pf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(b0,{...o,...r,ref:t})});Pf.displayName=M0;var D0="DropdownMenuRadioGroup",L0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(y0,{...o,...r,ref:t})});L0.displayName=D0;var F0="DropdownMenuRadioItem",Of=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(S0,{...o,...r,ref:t})});Of.displayName=F0;var $0="DropdownMenuItemIndicator",Mf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(C0,{...o,...r,ref:t})});Mf.displayName=$0;var z0="DropdownMenuSeparator",Df=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(T0,{...o,...r,ref:t})});Df.displayName=z0;var B0="DropdownMenuArrow",H0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(k0,{...o,...r,ref:t})});H0.displayName=B0;var U0="DropdownMenuSubTrigger",Lf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(E0,{...o,...r,ref:t})});Lf.displayName=U0;var W0="DropdownMenuSubContent",Ff=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(I0,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Ff.displayName=W0;var V0=kf,K0=If,q0=Nf,$f=_f,zf=jf,Bf=Rf,Hf=Pf,Uf=Of,Wf=Mf,Vf=Df,Kf=Lf,qf=Ff;const G0=V0,Y0=K0,X0=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(Kf,{ref:o,className:Q("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(se.ChevronRight,{className:"ml-auto h-4 w-4"})]}));X0.displayName=Kf.displayName;const J0=m.forwardRef(({className:e,...t},n)=>c.jsx(qf,{ref:n,className:Q("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));J0.displayName=qf.displayName;const Gf=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(q0,{children:c.jsx($f,{ref:r,sideOffset:t,className:Q("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})}));Gf.displayName=$f.displayName;const ba=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Bf,{ref:r,className:Q("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}));ba.displayName=Bf.displayName;const Z0=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(Hf,{ref:o,className:Q("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(Wf,{children:c.jsx(se.Check,{className:"h-4 w-4"})})}),t]}));Z0.displayName=Hf.displayName;const Q0=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Uf,{ref:r,className:Q("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(Wf,{children:c.jsx(se.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Q0.displayName=Uf.displayName;const eS=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(zf,{ref:r,className:Q("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));eS.displayName=zf.displayName;const tS=m.forwardRef(({className:e,...t},n)=>c.jsx(Vf,{ref:n,className:Q("-mx-1 my-1 h-px bg-muted",e),...t}));tS.displayName=Vf.displayName;function ys({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:h,onError:p}){const{api:w}=Gs(),{currentThreadId:v,isLoadingThread:g,listCheckpoints:x,navigateToCheckpoint:b,returnToLatest:S}=go(),{messages:E,hasMoreHistory:C,isLoadingHistory:T,send:I,stop:A,loadOlderMessages:P}=Qs(),{isStreaming:j,error:M,streamingAssistantId:L,lastCheckpointId:W,lastCheckpointNs:O}=Bl(),[Y,q]=y.useState(null),[J,$]=y.useState(""),[_,G]=y.useState(null),[B,he]=y.useState([]),[de,xe]=y.useState(0),[_e,Ce]=y.useState(0),[F,D]=y.useState(!1),[Z,ee]=y.useState(null),[ce,ne]=y.useState(null),[Oe,Ye]=y.useState(!1),[Ue,je]=y.useState(null),[Me,Je]=y.useState([]),[ze,nt]=y.useState(null),[st,re]=y.useState(null),[ue,ge]=y.useState(!1),ke=y.useRef(null),ve=y.useRef(null),Re=y.useRef(null),Ze=y.useCallback(()=>{ke.current&&(ke.current.value=""),ve.current&&(ve.current.value=""),xe(H=>H+1),Ce(H=>H+1)},[]),Ke=y.useRef(!1);y.useEffect(()=>{Ke.current&&!j&&(he([]),Ze()),Ke.current=j},[j,Ze]);const[at,Ct]=y.useState("desktop");y.useEffect(()=>{const H=()=>{const U=window.innerWidth;Ct(U<640?"phone":U<1024?"tablet":"desktop")};return H(),window.addEventListener("resize",H),()=>window.removeEventListener("resize",H)},[]),y.useEffect(()=>{let H=!1;if(!v){Je([]),nt(null),re(null),Re.current=null;return}const U={threadId:v,checkpointId:W??null,checkpointNs:O??null},be=Re.current;if(!(be&&be.threadId===U.threadId&&be.checkpointId===U.checkpointId&&be.checkpointNs===U.checkpointNs))return x(v).then(We=>{var tr;if(H)return;const Xe=((We==null?void 0:We.checkpoints)??[]).slice().sort((k,K)=>new Date(K.createdAt).getTime()-new Date(k.createdAt).getTime());Je(Xe);const lt=ze,Xt=lt&&Xe.some(k=>k.checkpointId===lt)?lt:((tr=Xe[0])==null?void 0:tr.checkpointId)??null;let dn=null;if(Xt){const k=Xe.find(K=>K.checkpointId===Xt);dn=(k==null?void 0:k.checkpointNs)??null}nt(Xt),re(dn),Re.current=U}).catch(We=>{console.error("ChatInterface - listCheckpoints error:",We),H||(Je([]),Re.current=null)}),()=>{H=!0}},[v,W,O,ze,x]),y.useEffect(()=>{W&&(nt(W),re(O??null))},[W,O]);const Tt=y.useCallback(async()=>{if(!(!C||T))try{await P()}catch(H){console.warn("loadOlderMessages failed",H)}},[C,T,P]);y.useEffect(()=>{(async()=>{if(!w.baseUrl){je(null);return}try{const U=await w.getAgent("default");je(U.uiDefaultMessage||null)}catch(U){console.warn("Failed to fetch default message:",U),je(null)}})()},[w]),y.useEffect(()=>{M&&!Oe&&(p==null||p(M))},[M,Oe,p]);const wr=H=>{if(H.length>rs)return`Message too long (${H.length}/${rs} characters)`;try{return ab(H),null}catch(U){return(U==null?void 0:U.message)||"Invalid message"}},br=async H=>{const U=H.trim();if(!(!U&&B.length===0)){if(U){const be=wr(U);if(be){G(be);return}}try{await I(U||"",{checkpointId:ze??W??void 0,checkpointNs:st??O??void 0,payloadExtras:Y?{edit:!0,originalMessageId:Y}:void 0,attachments:B}),f==null||f(U),G(null),he([]),Ze(),q(null),$("")}catch(be){const We=(be==null?void 0:be.message)||"Failed to send message";G(We),p==null||p(We)}}},Jn=y.useCallback((H,U)=>{u&&(q(H),$(U),G(null))},[u]),_n=y.useCallback(()=>{q(null),$(""),G(null)},[]),yr=y.useCallback((H,U)=>{Jn(H,U)},[Jn]),jn=y.useCallback(H=>{const U=be=>{const We=be.content||[],Xe=We.filter(lt=>lt.type==="text").map(lt=>lt.text).join("");if(Xe)return Xe;try{return JSON.stringify(We,null,2)}catch{return String(We)}};for(let be=H-1;be>=0;be--)if(E[be].role==="user"){const We=U(E[be]);We&&I(We,{checkpointId:ze??W??void 0,checkpointNs:st??O??void 0});break}},[E,I,ze,st,W,O]),Zn=H=>{const U=Array.from(H.target.files||[]);he(be=>[...be,...U]),H.target.value=""},un=H=>{he(U=>{const be=U.filter((We,Xe)=>H!==Xe);return be.length===0&&Ze(),be})},Qn=async H=>{const U=(H.target.files||[])[0];if(U){ee(null),ne(null),D(!0);try{await I("",{checkpointId:ze??W??void 0,checkpointNs:st??O??void 0,attachments:[U]});const be=`Uploaded ${U.name} - processing through chat stream`;ne(be)}catch(be){const We=be instanceof Error?be.message:"Failed to upload Excel file";console.error("Excel upload failed",be),ee(We),p==null||p(We)}finally{D(!1),H.target.value="",Ze()}}},er=H=>{if(!H)return"Unknown";const U=Date.parse(H);return Number.isNaN(U)?H:new Date(U).toLocaleString()},N=async H=>{if(v){ge(!0);try{if(!H){await S(),nt(null),re(null);return}const U=Me.find(We=>We.checkpointId===H),be=(U==null?void 0:U.checkpointNs)??null;await b(H,be),nt(H),re(be)}finally{ge(!1)}}},z=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,te=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${d.messagesArea||""}`,we=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return c.jsxs("div",{className:z,children:[!!M&&!Oe&&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:M}),c.jsx(He,{variant:"ghost",size:"sm",onClick:()=>Ye(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(se.X,{size:16})})]}),v&&Me.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:ze??"",onChange:H=>{const U=H.target.value||null;N(U)},children:[c.jsx("option",{value:"",children:"Latest"}),Me.map(H=>c.jsxs("option",{value:H.checkpointId,children:[er(H.createdAt),H.preview?` — ${H.preview.slice(0,40)}`:""]},H.checkpointId))]})]}),c.jsxs("div",{className:`relative ${te}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(Yi,{className:"h-full",style:{height:"100%"},messages:E,isStreaming:j,streamingAssistantId:L,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:at,enableMessageEditing:u,editingMessageId:Y,onStartReached:()=>{Tt()},onEdit:yr,onRegenerate:jn,onCancelEdit:_n,emptyMessage:Ue??void 0,isNavigatingCheckpoint:ue}),g&&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(se.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:we,children:[Y&&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(se.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(He,{variant:"ghost",size:"sm",onClick:_n,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(se.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:ke,type:"file",multiple:!0,onChange:H=>Zn(H),className:"hidden"},de),B.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:B.map((H,U)=>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(se.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:H.name}),c.jsx(He,{variant:"ghost",size:"sm",onClick:()=>un(U),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 ${H.name}`,children:c.jsx(se.X,{size:12})})]},U))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:ve,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Qn,className:"hidden"},_e),F&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(se.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),ce&&!F&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:ce}),Z&&!F&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Z})]})]}),_&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:_}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(G0,{children:[c.jsx(Y0,{asChild:!0,children:c.jsx(He,{type:"button",size:"icon",variant:"outline",disabled:j,title:"More input actions",className:d.moreButton||"",children:c.jsx(se.Plus,{size:16})})}),c.jsxs(Gf,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(ba,{onClick:()=>{var H;return(H=ke.current)==null?void 0:H.click()},className:"cursor-pointer",children:[c.jsx(se.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(ba,{onClick:()=>{var H;F||(H=ve.current)==null||H.click()},className:`cursor-pointer ${F?"opacity-60 pointer-events-none":""}`,children:[c.jsx(se.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx(bg,{initialValue:J,editingMessageId:Y,placeholder:Y?"Edit your message...":t,isStreaming:j,disabled:!1,maxLength:rs,onSend:br,onCancelEdit:_n,onStop:A,allowEmptySend:B.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${Y?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${_?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const Ss=m.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:Q("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}));Ss.displayName="Input";function ya(e,[t,n]){return Math.min(n,Math.max(t,e))}function nS(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Sa="ScrollArea",[Yf,VC]=tn(Sa),[rS,zt]=Yf(Sa),Xf=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=m.useState(null),[u,d]=m.useState(null),[f,h]=m.useState(null),[p,w]=m.useState(null),[v,g]=m.useState(null),[x,b]=m.useState(0),[S,E]=m.useState(0),[C,T]=m.useState(!1),[I,A]=m.useState(!1),P=Le(t,M=>l(M)),j=os(o);return c.jsx(rS,{scope:n,type:r,dir:j,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:w,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:v,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:E,children:c.jsx(Te.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}})})});Xf.displayName=Sa;var Jf="ScrollAreaViewport",Zf=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=zt(Jf,n),a=m.useRef(null),l=Le(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(Te.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})})]})});Zf.displayName=Jf;var cn="ScrollAreaScrollbar",Ca=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=zt(cn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return m.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?c.jsx(oS,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(sS,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(Qf,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(Ta,{...r,ref:t}):null});Ca.displayName=cn;var oS=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=zt(cn,e.__scopeScrollArea),[s,i]=m.useState(!1);return m.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const u=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),c.jsx(Pt,{present:n||s,children:c.jsx(Qf,{"data-state":s?"visible":"hidden",...r,ref:t})})}),sS=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=zt(cn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Es(()=>l("SCROLL_END"),100),[a,l]=nS("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return m.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,l]),m.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const p=u[d];f!==p&&(l("SCROLL"),i()),f=p};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),c.jsx(Pt,{present:n||a!=="hidden",children:c.jsx(Ta,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:le(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:le(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Qf=m.forwardRef((e,t)=>{const n=zt(cn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",l=Es(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return gr(n.viewport,l),gr(n.content,l),c.jsx(Pt,{present:r||s,children:c.jsx(Ta,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Ta=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=zt(cn,e.__scopeScrollArea),s=m.useRef(null),i=m.useRef(0),[a,l]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=oh(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 dS(h,i.current,a,p)}return n==="horizontal"?c.jsx(iS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=sh(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(aS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=sh(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}),iS=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=zt(cn,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Le(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(th,{"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":ks(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),ah(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:Ts(i.paddingLeft),paddingEnd:Ts(i.paddingRight)}})}})}),aS=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=zt(cn,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Le(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(th,{"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":ks(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),ah(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:Ts(i.paddingTop),paddingEnd:Ts(i.paddingBottom)}})}})}),[lS,eh]=Yf(cn),th=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,p=zt(cn,n),[w,v]=m.useState(null),g=Le(t,P=>v(P)),x=m.useRef(null),b=m.useRef(""),S=p.viewport,E=r.content-r.viewport,C=gt(d),T=gt(l),I=Es(f,10);function A(P){if(x.current){const j=P.clientX-x.current.left,M=P.clientY-x.current.top;u({x:j,y:M})}}return m.useEffect(()=>{const P=j=>{const M=j.target;(w==null?void 0:w.contains(M))&&C(j,E)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[S,w,E,C]),m.useEffect(T,[r,T]),gr(w,I),gr(p.content,I),c.jsx(lS,{scope:n,scrollbar:w,hasThumb:o,onThumbChange:gt(s),onThumbPointerUp:gt(i),onThumbPositionChange:T,onThumbPointerDown:gt(a),children:c.jsx(Te.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:le(e.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),x.current=w.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(P))}),onPointerMove:le(e.onPointerMove,A),onPointerUp:le(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=""),x.current=null})})})}),Cs="ScrollAreaThumb",nh=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=eh(Cs,e.__scopeScrollArea);return c.jsx(Pt,{present:n||o.hasThumb,children:c.jsx(cS,{ref:t,...r})})}),cS=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=zt(Cs,n),i=eh(Cs,n),{onThumbPositionChange:a}=i,l=Le(t,f=>i.onThumbChange(f)),u=m.useRef(void 0),d=Es(()=>{u.current&&(u.current(),u.current=void 0)},100);return m.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const p=fS(f,a);u.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),c.jsx(Te.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:le(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),w=f.clientX-p.left,v=f.clientY-p.top;i.onThumbPointerDown({x:w,y:v})}),onPointerUp:le(e.onPointerUp,i.onThumbPointerUp)})});nh.displayName=Cs;var ka="ScrollAreaCorner",rh=m.forwardRef((e,t)=>{const n=zt(ka,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(uS,{...e,ref:t}):null});rh.displayName=ka;var uS=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=zt(ka,n),[s,i]=m.useState(0),[a,l]=m.useState(0),u=!!(s&&a);return gr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),gr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?c.jsx(Te.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 Ts(e){return e?parseInt(e,10):0}function oh(e,t){const n=e/t;return isNaN(n)?0:n}function ks(e){const t=oh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function dS(e,t,n,r="ltr"){const o=ks(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 ih([l,u],f)(e)}function sh(e,t,n="ltr"){const r=ks(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=ya(e,l);return ih([0,i],[0,a])(u)}function ih(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 ah(e,t){return e>0&&e<t}var fS=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function Es(e,t){const n=gt(e),r=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),m.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function gr(e,t){const n=gt(t);mt(()=>{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 lh=Xf,hS=Zf,pS=rh;const ch=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(lh,{ref:r,className:Q("relative overflow-hidden",e),...n,children:[c.jsx(hS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(uh,{}),c.jsx(pS,{})]}));ch.displayName=lh.displayName;const uh=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(Ca,{ref:r,orientation:t,className:Q("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(nh,{className:"relative flex-1 rounded-full bg-border"})}));uh.displayName=Ca.displayName;function Ea({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{loadThread:f,threads:h,currentThreadId:p,createThread:w,deleteThread:v,renameThread:g,isLoadingThreads:x}=go(),[b,S]=y.useState(h??[]),[E,C]=y.useState(null),[T,I]=y.useState(""),[A,P]=y.useState(!1);y.useEffect(()=>{S(h??[])},[h]);const j=async _=>{try{await f(_),a==null||a(_),l==null||l(_)}catch(G){console.error("Failed to select thread:",G)}},M=async()=>{try{P(!0);const _=await w();u==null||u(_),a==null||a(_)}catch(_){console.error("Failed to create thread:",_)}finally{P(!1)}},L=async(_,G)=>{if(G.stopPropagation(),!!confirm("Delete this thread?"))try{await v(_),d==null||d(_)}catch(B){console.error("Failed to delete thread:",B)}},W=(_,G)=>{G.stopPropagation(),C(_.threadId),I(_.title||`Thread ${_.threadId.slice(0,8)}`)},O=async _=>{if(T.trim())try{await g(_,T.trim()),C(null),I("")}catch(G){console.error("Failed to update title:",G)}},Y=()=>{C(null),I("")},q=(_,G)=>{_.key==="Enter"?O(G):_.key==="Escape"&&Y()},J=_=>{if(!_)return"";try{const G=new Date(_),he=new Date().getTime()-G.getTime(),de=Math.floor(he/(1e3*60*60*24));return de===0?G.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):de===1?"Yesterday":de<7?`${de} days ago`:G.toLocaleDateString()}catch{return""}},$=_=>_.title||`Thread ${_.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(He,{onClick:M,disabled:A||x,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:A?"Creating...":"New Chat",children:c.jsx(se.MessageSquarePlus,{size:20})})}),c.jsx(ch,{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:x?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(se.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):b.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(se.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"})]}):b.slice().sort((_,G)=>new Date(G.updatedAt||G.createdAt||"").getTime()-new Date(_.updatedAt||_.createdAt||"").getTime()).map(_=>c.jsxs("div",{onClick:()=>j(_.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??p)===_.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:E===_.threadId?c.jsxs("div",{className:"flex items-center gap-2",onClick:G=>G.stopPropagation(),children:[c.jsx(Ss,{value:T,onChange:G=>I(G.target.value),onKeyDown:G=>q(G,_.threadId),className:"h-6 text-sm",autoFocus:!0}),c.jsx(He,{variant:"ghost",size:"sm",onClick:()=>O(_.threadId),className:"h-6 w-6 p-0",children:c.jsx(se.Check,{size:12})}),c.jsx(He,{variant:"ghost",size:"sm",onClick:Y,className:"h-6 w-6 p-0",children:c.jsx(se.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:$(_)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(se.Calendar,{size:10}),c.jsx("span",{children:J(_.updatedAt||_.createdAt)})]})]})}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&E!==_.threadId&&c.jsx(He,{variant:"ghost",size:"sm",onClick:G=>W(_,G),className:"h-6 w-6 p-0",title:"Edit title",children:c.jsx(se.Edit3,{size:12})}),n&&c.jsx(He,{variant:"ghost",size:"sm",onClick:G=>L(_.threadId,G),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(se.Trash2,{size:12})})]})]}),i===_.threadId&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},_.threadId))})})]})}function xr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function mS(e){if(typeof e!="string")return;const t=e.trim();if(t)return fn(t)}function dh(){const e=[xr("__API_BASE_URL__"),xr("__CHAT_API_BASE_URL__"),xr("__CHAT_API_URL__")];for(const t of e){const n=mS(t);if(n)return n}}function fh(){const e=[xr("__API_AUTH_TOKEN__"),xr("__CHAT_API_KEY__"),xr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function hh(...e){for(const t of e)if(typeof t=="string"&&t.trim())return fn(t);return fn()}function ph(){const e={},t=dh(),n=fh();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function mh(){const e=ph(),t=xn.getAuthToken(),n=dh();return{apiBaseUrl:hh(e.baseUrl,xn.baseUrl,n),apiKey:t||e.apiKey||fh()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const gh="chat-settings";function gS(){try{const e=localStorage.getItem(gh);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function xS(e){try{const t={...e,apiBaseUrl:fn(e.apiBaseUrl)};localStorage.setItem(gh,JSON.stringify(t)),t.apiKey&&xn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function vS(){const e=mh(),t=gS(),n=xn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:hh(xn.baseUrl,r,e.apiBaseUrl)}}function wS(e){xn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),xS(e)}var bS="Label",xh=m.forwardRef((e,t)=>c.jsx(Te.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())}}));xh.displayName=bS;var vh=xh;const yS=to.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Bt=m.forwardRef(({className:e,...t},n)=>c.jsx(vh,{ref:n,className:Q(yS(),e),...t}));Bt.displayName=vh.displayName;function wh(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Is="Switch",[SS,KC]=tn(Is),[CS,TS]=SS(Is),bh=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:u,form:d,...f}=e,[h,p]=m.useState(null),w=Le(t,S=>p(S)),v=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[x,b]=zn({prop:o,defaultProp:s??!1,onChange:u,caller:Is});return c.jsxs(CS,{scope:n,checked:x,disabled:a,children:[c.jsx(Te.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":Th(x),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:w,onClick:le(e.onClick,S=>{b(E=>!E),g&&(v.current=S.isPropagationStopped(),v.current||S.stopPropagation())})}),g&&c.jsx(Ch,{control:h,bubbles:!v.current,name:r,value:l,checked:x,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});bh.displayName=Is;var yh="SwitchThumb",Sh=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=TS(yh,n);return c.jsx(Te.span,{"data-state":Th(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Sh.displayName=yh;var kS="SwitchBubbleInput",Ch=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=Le(i,s),l=wh(n),u=Pd(t);return m.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const w=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(w)}},[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}})});Ch.displayName=kS;function Th(e){return e?"checked":"unchecked"}var kh=bh,ES=Sh;const In=m.forwardRef(({className:e,...t},n)=>c.jsx(kh,{className:Q("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(ES,{className:Q("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")})}));In.displayName=kh.displayName;var Eh=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),IS="VisuallyHidden",NS=m.forwardRef((e,t)=>c.jsx(Te.span,{...e,ref:t,style:{...Eh,...e.style}}));NS.displayName=IS;var AS=[" ","Enter","ArrowUp","ArrowDown"],_S=[" ","Enter"],Gn="Select",[Ns,As,jS]=Xi(Gn),[vr,qC]=tn(Gn,[jS,ms]),_s=ms(),[RS,Nn]=vr(Gn),[PS,OS]=vr(Gn),Ih=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:w}=e,v=_s(t),[g,x]=m.useState(null),[b,S]=m.useState(null),[E,C]=m.useState(!1),T=os(u),[I,A]=zn({prop:r,defaultProp:o??!1,onChange:s,caller:Gn}),[P,j]=zn({prop:i,defaultProp:a,onChange:l,caller:Gn}),M=m.useRef(null),L=g?w||!!g.closest("form"):!0,[W,O]=m.useState(new Set),Y=Array.from(W).map(q=>q.props.value).join(";");return c.jsx(Ud,{...v,children:c.jsxs(RS,{required:p,scope:t,trigger:g,onTriggerChange:x,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:E,onValueNodeHasChildrenChange:C,contentId:nn(),value:P,onValueChange:j,open:I,onOpenChange:A,dir:T,triggerPointerDownPosRef:M,disabled:h,children:[c.jsx(Ns.Provider,{scope:t,children:c.jsx(PS,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(q=>{O(J=>new Set(J).add(q))},[]),onNativeOptionRemove:m.useCallback(q=>{O(J=>{const $=new Set(J);return $.delete(q),$})},[]),children:n})}),L?c.jsxs(Jh,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:P,onChange:q=>j(q.target.value),disabled:h,form:w,children:[P===void 0?c.jsx("option",{value:""}):null,Array.from(W)]},Y):null]})})};Ih.displayName=Gn;var Nh="SelectTrigger",Ah=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=_s(n),i=Nn(Nh,n),a=i.disabled||r,l=Le(t,i.onTriggerChange),u=As(n),d=m.useRef("touch"),[f,h,p]=Qh(v=>{const g=u().filter(S=>!S.disabled),x=g.find(S=>S.value===i.value),b=ep(g,v,x);b!==void 0&&i.onValueChange(b.value)}),w=v=>{a||(i.onOpenChange(!0),p()),v&&(i.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return c.jsx(Wd,{asChild:!0,...s,children:c.jsx(Te.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":Zh(i.value)?"":void 0,...o,ref:l,onClick:le(o.onClick,v=>{v.currentTarget.focus(),d.current!=="mouse"&&w(v)}),onPointerDown:le(o.onPointerDown,v=>{d.current=v.pointerType;const g=v.target;g.hasPointerCapture(v.pointerId)&&g.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(w(v),v.preventDefault())}),onKeyDown:le(o.onKeyDown,v=>{const g=f.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&h(v.key),!(g&&v.key===" ")&&AS.includes(v.key)&&(w(),v.preventDefault())})})})});Ah.displayName=Nh;var _h="SelectValue",jh=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Nn(_h,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=Le(t,l.onValueNodeChange);return mt(()=>{u(d)},[u,d]),c.jsx(Te.span,{...a,ref:f,style:{pointerEvents:"none"},children:Zh(l.value)?c.jsx(c.Fragment,{children:i}):s})});jh.displayName=_h;var MS="SelectIcon",Rh=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(Te.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Rh.displayName=MS;var DS="SelectPortal",Ph=e=>c.jsx(Ho,{asChild:!0,...e});Ph.displayName=DS;var Yn="SelectContent",Oh=m.forwardRef((e,t)=>{const n=Nn(Yn,e.__scopeSelect),[r,o]=m.useState();if(mt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?no.createPortal(c.jsx(Mh,{scope:e.__scopeSelect,children:c.jsx(Ns.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(Dh,{...e,ref:t})});Oh.displayName=Yn;var Yt=10,[Mh,An]=vr(Yn),LS="SelectContentImpl",FS=Rn.createSlot("SelectContent.RemoveScroll"),Dh=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:w,hideWhenDetached:v,avoidCollisions:g,...x}=e,b=Nn(Yn,n),[S,E]=m.useState(null),[C,T]=m.useState(null),I=Le(t,F=>E(F)),[A,P]=m.useState(null),[j,M]=m.useState(null),L=As(n),[W,O]=m.useState(!1),Y=m.useRef(!1);m.useEffect(()=>{if(S)return Wi(S)},[S]),Fi();const q=m.useCallback(F=>{const[D,...Z]=L().map(ne=>ne.ref.current),[ee]=Z.slice(-1),ce=document.activeElement;for(const ne of F)if(ne===ce||(ne==null||ne.scrollIntoView({block:"nearest"}),ne===D&&C&&(C.scrollTop=0),ne===ee&&C&&(C.scrollTop=C.scrollHeight),ne==null||ne.focus(),document.activeElement!==ce))return},[L,C]),J=m.useCallback(()=>q([A,S]),[q,A,S]);m.useEffect(()=>{W&&J()},[W,J]);const{onOpenChange:$,triggerPointerDownPosRef:_}=b;m.useEffect(()=>{if(S){let F={x:0,y:0};const D=ee=>{var ce,ne;F={x:Math.abs(Math.round(ee.pageX)-(((ce=_.current)==null?void 0:ce.x)??0)),y:Math.abs(Math.round(ee.pageY)-(((ne=_.current)==null?void 0:ne.y)??0))}},Z=ee=>{F.x<=10&&F.y<=10?ee.preventDefault():S.contains(ee.target)||$(!1),document.removeEventListener("pointermove",D),_.current=null};return _.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",Z,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",Z,{capture:!0})}}},[S,$,_]),m.useEffect(()=>{const F=()=>$(!1);return window.addEventListener("blur",F),window.addEventListener("resize",F),()=>{window.removeEventListener("blur",F),window.removeEventListener("resize",F)}},[$]);const[G,B]=Qh(F=>{const D=L().filter(ce=>!ce.disabled),Z=D.find(ce=>ce.ref.current===document.activeElement),ee=ep(D,F,Z);ee&&setTimeout(()=>ee.ref.current.focus())}),he=m.useCallback((F,D,Z)=>{const ee=!Y.current&&!Z;(b.value!==void 0&&b.value===D||ee)&&(P(F),ee&&(Y.current=!0))},[b.value]),de=m.useCallback(()=>S==null?void 0:S.focus(),[S]),xe=m.useCallback((F,D,Z)=>{const ee=!Y.current&&!Z;(b.value!==void 0&&b.value===D||ee)&&M(F)},[b.value]),_e=r==="popper"?Ia:Lh,Ce=_e===Ia?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:w,hideWhenDetached:v,avoidCollisions:g}:{};return c.jsx(Mh,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:he,selectedItem:A,onItemLeave:de,itemTextRefCallback:xe,focusSelectedItem:J,selectedItemText:j,position:r,isPositioned:W,searchRef:G,children:c.jsx(Go,{as:FS,allowPinchZoom:!0,children:c.jsx(Bo,{asChild:!0,trapped:b.open,onMountAutoFocus:F=>{F.preventDefault()},onUnmountAutoFocus:le(o,F=>{var D;(D=b.trigger)==null||D.focus({preventScroll:!0}),F.preventDefault()}),children:c.jsx(zo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:F=>F.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:c.jsx(_e,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:F=>F.preventDefault(),...x,...Ce,onPlaced:()=>O(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:le(x.onKeyDown,F=>{const D=F.ctrlKey||F.altKey||F.metaKey;if(F.key==="Tab"&&F.preventDefault(),!D&&F.key.length===1&&B(F.key),["ArrowUp","ArrowDown","Home","End"].includes(F.key)){let ee=L().filter(ce=>!ce.disabled).map(ce=>ce.ref.current);if(["ArrowUp","End"].includes(F.key)&&(ee=ee.slice().reverse()),["ArrowUp","ArrowDown"].includes(F.key)){const ce=F.target,ne=ee.indexOf(ce);ee=ee.slice(ne+1)}setTimeout(()=>q(ee)),F.preventDefault()}})})})})})})});Dh.displayName=LS;var $S="SelectItemAlignedPosition",Lh=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Nn(Yn,n),i=An(Yn,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=Le(t,I=>d(I)),h=As(n),p=m.useRef(!1),w=m.useRef(!0),{viewport:v,selectedItem:g,selectedItemText:x,focusSelectedItem:b}=i,S=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&v&&g&&x){const I=s.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),P=s.valueNode.getBoundingClientRect(),j=x.getBoundingClientRect();if(s.dir!=="rtl"){const ce=j.left-A.left,ne=P.left-ce,Oe=I.left-ne,Ye=I.width+Oe,Ue=Math.max(Ye,A.width),je=window.innerWidth-Yt,Me=ya(ne,[Yt,Math.max(Yt,je-Ue)]);a.style.minWidth=Ye+"px",a.style.left=Me+"px"}else{const ce=A.right-j.right,ne=window.innerWidth-P.right-ce,Oe=window.innerWidth-I.right-ne,Ye=I.width+Oe,Ue=Math.max(Ye,A.width),je=window.innerWidth-Yt,Me=ya(ne,[Yt,Math.max(Yt,je-Ue)]);a.style.minWidth=Ye+"px",a.style.right=Me+"px"}const M=h(),L=window.innerHeight-Yt*2,W=v.scrollHeight,O=window.getComputedStyle(u),Y=parseInt(O.borderTopWidth,10),q=parseInt(O.paddingTop,10),J=parseInt(O.borderBottomWidth,10),$=parseInt(O.paddingBottom,10),_=Y+q+W+$+J,G=Math.min(g.offsetHeight*5,_),B=window.getComputedStyle(v),he=parseInt(B.paddingTop,10),de=parseInt(B.paddingBottom,10),xe=I.top+I.height/2-Yt,_e=L-xe,Ce=g.offsetHeight/2,F=g.offsetTop+Ce,D=Y+q+F,Z=_-D;if(D<=xe){const ce=M.length>0&&g===M[M.length-1].ref.current;a.style.bottom="0px";const ne=u.clientHeight-v.offsetTop-v.offsetHeight,Oe=Math.max(_e,Ce+(ce?de:0)+ne+J),Ye=D+Oe;a.style.height=Ye+"px"}else{const ce=M.length>0&&g===M[0].ref.current;a.style.top="0px";const Oe=Math.max(xe,Y+v.offsetTop+(ce?he:0)+Ce)+Z;a.style.height=Oe+"px",v.scrollTop=D-xe+v.offsetTop}a.style.margin=`${Yt}px 0`,a.style.minHeight=G+"px",a.style.maxHeight=L+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,v,g,x,s.dir,r]);mt(()=>S(),[S]);const[E,C]=m.useState();mt(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const T=m.useCallback(I=>{I&&w.current===!0&&(S(),b==null||b(),w.current=!1)},[S,b]);return c.jsx(BS,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:T,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:c.jsx(Te.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Lh.displayName=$S;var zS="SelectPopperPosition",Ia=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Yt,...s}=e,i=_s(n);return c.jsx(Vd,{...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)"}})});Ia.displayName=zS;var[BS,Na]=vr(Yn,{}),Aa="SelectViewport",Fh=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=An(Aa,n),i=Na(Aa,n),a=Le(t,s.onViewportChange),l=m.useRef(0);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),c.jsx(Ns.Slot,{scope:n,children:c.jsx(Te.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:le(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 w=window.innerHeight-Yt*2,v=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),x=Math.max(v,g);if(x<w){const b=x+p,S=Math.min(w,b),E=b-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Fh.displayName=Aa;var $h="SelectGroup",[HS,US]=vr($h),WS=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=nn();return c.jsx(HS,{scope:n,id:o,children:c.jsx(Te.div,{role:"group","aria-labelledby":o,...r,ref:t})})});WS.displayName=$h;var zh="SelectLabel",Bh=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=US(zh,n);return c.jsx(Te.div,{id:o.id,...r,ref:t})});Bh.displayName=zh;var js="SelectItem",[VS,Hh]=vr(js),Uh=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Nn(js,n),l=An(js,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),w=Le(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),v=nn(),g=m.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 c.jsx(VS,{scope:n,value:r,disabled:o,textId:v,isSelected:u,onItemTextChange:m.useCallback(b=>{f(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:c.jsx(Ns.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(Te.div,{role:"option","aria-labelledby":v,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:w,onFocus:le(i.onFocus,()=>p(!0)),onBlur:le(i.onBlur,()=>p(!1)),onClick:le(i.onClick,()=>{g.current!=="mouse"&&x()}),onPointerUp:le(i.onPointerUp,()=>{g.current==="mouse"&&x()}),onPointerDown:le(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:le(i.onPointerMove,b=>{var S;g.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):g.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:le(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:le(i.onKeyDown,b=>{var E;((E=l.searchRef)==null?void 0:E.current)!==""&&b.key===" "||(_S.includes(b.key)&&x(),b.key===" "&&b.preventDefault())})})})})});Uh.displayName=js;var eo="SelectItemText",Wh=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Nn(eo,n),a=An(eo,n),l=Hh(eo,n),u=OS(eo,n),[d,f]=m.useState(null),h=Le(t,x=>f(x),l.onItemTextChange,x=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,x,l.value,l.disabled)}),p=d==null?void 0:d.textContent,w=m.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:v,onNativeOptionRemove:g}=u;return mt(()=>(v(w),()=>g(w)),[v,g,w]),c.jsxs(c.Fragment,{children:[c.jsx(Te.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?no.createPortal(s.children,i.valueNode):null]})});Wh.displayName=eo;var Vh="SelectItemIndicator",Kh=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Hh(Vh,n).isSelected?c.jsx(Te.span,{"aria-hidden":!0,...r,ref:t}):null});Kh.displayName=Vh;var _a="SelectScrollUpButton",qh=m.forwardRef((e,t)=>{const n=An(_a,e.__scopeSelect),r=Na(_a,e.__scopeSelect),[o,s]=m.useState(!1),i=Le(t,r.onScrollButtonChange);return mt(()=>{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(Yh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});qh.displayName=_a;var ja="SelectScrollDownButton",Gh=m.forwardRef((e,t)=>{const n=An(ja,e.__scopeSelect),r=Na(ja,e.__scopeSelect),[o,s]=m.useState(!1),i=Le(t,r.onScrollButtonChange);return mt(()=>{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(Yh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Gh.displayName=ja;var Yh=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=An("SelectScrollButton",n),i=m.useRef(null),a=As(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),mt(()=>{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(Te.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:le(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:le(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:le(o.onPointerLeave,()=>{l()})})}),KS="SelectSeparator",Xh=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(Te.div,{"aria-hidden":!0,...r,ref:t})});Xh.displayName=KS;var Ra="SelectArrow",qS=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_s(n),s=Nn(Ra,n),i=An(Ra,n);return s.open&&i.position==="popper"?c.jsx(Kd,{...o,...r,ref:t}):null});qS.displayName=Ra;var GS="SelectBubbleInput",Jh=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=Le(r,o),i=wh(t);return m.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(Te.select,{...n,style:{...Eh,...n.style},ref:s,defaultValue:t})});Jh.displayName=GS;function Zh(e){return e===""||e===void 0}function Qh(e){const t=gt(e),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(i=>{const a=n.current+i;t(a),function l(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function ep(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=YS(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function YS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var XS=Ih,tp=Ah,JS=jh,ZS=Rh,QS=Ph,np=Oh,eC=Fh,rp=Bh,op=Uh,tC=Wh,nC=Kh,sp=qh,ip=Gh,ap=Xh;const lp=XS,cp=JS,Pa=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(tp,{ref:r,className:Q("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(ZS,{asChild:!0,children:c.jsx(se.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Pa.displayName=tp.displayName;const up=m.forwardRef(({className:e,...t},n)=>c.jsx(sp,{ref:n,className:Q("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(se.ChevronUp,{className:"h-4 w-4"})}));up.displayName=sp.displayName;const dp=m.forwardRef(({className:e,...t},n)=>c.jsx(ip,{ref:n,className:Q("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(se.ChevronDown,{className:"h-4 w-4"})}));dp.displayName=ip.displayName;const Oa=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(QS,{children:c.jsxs(np,{ref:o,className:Q("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(up,{}),c.jsx(eC,{className:Q("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(dp,{})]})}));Oa.displayName=np.displayName;const rC=m.forwardRef(({className:e,...t},n)=>c.jsx(rp,{ref:n,className:Q("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));rC.displayName=rp.displayName;const Xn=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(op,{ref:r,className:Q("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(nC,{children:c.jsx(se.Check,{className:"h-4 w-4"})})}),c.jsx(tC,{children:t})]}));Xn.displayName=op.displayName;const oC=m.forwardRef(({className:e,...t},n)=>c.jsx(ap,{ref:n,className:Q("-mx-1 my-1 h-px bg-muted",e),...t}));oC.displayName=ap.displayName;var sC="Separator",fp="horizontal",iC=["horizontal","vertical"],hp=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=fp,...o}=e,s=aC(r)?r:fp,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(Te.div,{"data-orientation":s,...a,...o,ref:t})});hp.displayName=sC;function aC(e){return iC.includes(e)}var pp=hp;const mp=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(pp,{ref:o,decorative:n,orientation:t,className:Q("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));mp.displayName=pp.displayName;const lC=Ju,cC=Hw,uC=Zu,gp=m.forwardRef(({className:e,...t},n)=>c.jsx(Qo,{className:Q("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}));gp.displayName=Qo.displayName;const dC=to.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"}}),xp=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(uC,{children:[c.jsx(gp,{}),c.jsxs(es,{ref:o,className:Q(dC({side:e}),t),...r,children:[n,c.jsxs(Qu,{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(se.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));xp.displayName=es.displayName;const vp=({className:e,...t})=>c.jsx("div",{className:Q("flex flex-col space-y-2 text-center sm:text-left",e),...t});vp.displayName="SheetHeader";const wp=m.forwardRef(({className:e,...t},n)=>c.jsx(Un,{ref:n,className:Q("text-lg font-semibold text-foreground",e),...t}));wp.displayName=Un.displayName;const bp=m.forwardRef(({className:e,...t},n)=>c.jsx(ts,{ref:n,className:Q("text-sm text-muted-foreground",e),...t}));bp.displayName=ts.displayName;const fC={api:{baseUrl:"http://localhost:8000/api",authToken:"",enableAuth:!1},ui:{layout:"sidebar",theme:"light",showTimestamps:!0,showAgentNames:!0,compactMessages:!1},behavior:{autoSave:!0,enableStreaming:!0,showTypingIndicator:!0}};function hC({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=y.useState(!1),[s,i]=y.useState(!1),[a,l]=y.useState(e),[u,d]=y.useState(!1),{toast:f}=Pi();y.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),y.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(fC),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},w=()=>{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 c.jsxs(lC,{open:r,onOpenChange:o,children:[c.jsx(cC,{asChild:!0,children:c.jsxs(He,{variant:"outline",size:"sm",className:n,children:[c.jsx(se.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(Ci,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(xp,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(vp,{children:[c.jsx(wp,{children:"Chat Settings"}),c.jsx(bp,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),c.jsxs("div",{className:"space-y-6 py-6",children:[c.jsxs(zr,{children:[c.jsx(Br,{className:"pb-3",children:c.jsxs(Hr,{className:"text-lg flex items-center gap-2",children:[c.jsx(se.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(Bt,{htmlFor:"api-url",children:"API Base URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ss,{id:"api-url",value:a.api.baseUrl,onChange:g=>l(x=>({...x,api:{...x.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(He,{variant:"outline",onClick:v,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Bt,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(In,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>l(x=>({...x,api:{...x.api,enableAuth:g}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(Bt,{htmlFor:"auth-token",children:"Authentication Token"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ss,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>l(x=>({...x,api:{...x.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(He,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(se.EyeOff,{className:"h-4 w-4"}):c.jsx(se.Eye,{className:"h-4 w-4"})})]})]})]})]}),c.jsxs(zr,{children:[c.jsx(Br,{className:"pb-3",children:c.jsxs(Hr,{className:"text-lg flex items-center gap-2",children:[c.jsx(se.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(Bt,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(lp,{value:a.ui.layout,onValueChange:g=>l(x=>({...x,ui:{...x.ui,layout:g}})),children:[c.jsx(Pa,{children:c.jsx(cp,{})}),c.jsxs(Oa,{children:[c.jsx(Xn,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(Xn,{value:"fullscreen",children:"Fullscreen"}),c.jsx(Xn,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Bt,{htmlFor:"theme",children:"Theme"}),c.jsxs(lp,{value:a.ui.theme,onValueChange:g=>l(x=>({...x,ui:{...x.ui,theme:g}})),children:[c.jsx(Pa,{children:c.jsx(cp,{})}),c.jsxs(Oa,{children:[c.jsx(Xn,{value:"light",children:"Light"}),c.jsx(Xn,{value:"dark",children:"Dark"}),c.jsx(Xn,{value:"system",children:"System"})]})]})]}),c.jsx(mp,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Bt,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(In,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,showTimestamps:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Bt,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(In,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,showAgentNames:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Bt,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(In,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,compactMessages:g}}))})]})]})]})]}),c.jsxs(zr,{children:[c.jsx(Br,{className:"pb-3",children:c.jsxs(Hr,{className:"text-lg flex items-center gap-2",children:[c.jsx(se.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(Bt,{htmlFor:"auto-save",children:"Auto-save Conversations"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),c.jsx(In,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,autoSave:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Bt,{htmlFor:"enable-streaming",children:"Enable Streaming"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),c.jsx(In,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,enableStreaming:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Bt,{htmlFor:"typing-indicator",children:"Typing Indicator"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),c.jsx(In,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,showTypingIndicator:g}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(He,{variant:"outline",onClick:p,children:[c.jsx(se.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(He,{variant:"outline",onClick:w,children:"Cancel"}),c.jsxs(He,{onClick:h,disabled:!u,children:[c.jsx(se.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function pC({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),l=y.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?c.jsx(xo,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsx(ys,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?c.jsx(xo,{...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(Ea,{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(ys,{onError:s.onError,enableFileUpload:!0})})]})})}):c.jsx(xo,{...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(Ea,{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(ys,{onError:s.onError,enableFileUpload:!0})})]})})}Ie.ChatApi=Al,Ie.ChatInterface=ys,Ie.ChatProviders=xo,Ie.ChatSettings=hC,Ie.MarkdownContent=_i,Ie.MessageComponent=ld,Ie.MessageList=Yi,Ie.ThreadManager=Ea,Ie.applySettings=wS,Ie.chatApiClient=xn,Ie.default=pC,Ie.del=Nl,Ie.get=At,Ie.getChatToken=kl,Ie.getCurrentSettings=vS,Ie.getDefaultApiConfig=ph,Ie.getDefaultChatSettings=mh,Ie.onChatTokenChanged=El,Ie.post=qs,Ie.put=Il,Ie.setChatToken=Ks,Ie.useApi=Gs,Ie.useChatStream=Pl,Ie.useMessages=Qs,Ie.useMessagesReducer=jl,Ie.useStream=Bl,Ie.useThreads=go,Object.defineProperties(Ie,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
134
+ `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function pb(e,t=rs){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 mb(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),pb(t),hb(t)}function Qi(e){const t=e+"CollectionProvider",[n,r]=en(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=v=>{const{scope:g,children:x}=v,b=y.useRef(null),S=y.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:S,collectionRef:b,children:x})};i.displayName=t;const a=e+"CollectionSlot",l=Rn.createSlot(a),u=y.forwardRef((v,g)=>{const{scope:x,children:b}=v,S=s(a,x),N=Le(g,S.collectionRef);return c.jsx(l,{ref:N,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=Rn.createSlot(d),p=y.forwardRef((v,g)=>{const{scope:x,children:b,...S}=v,N=y.useRef(null),C=Le(g,N),k=s(d,x);return y.useEffect(()=>(k.itemMap.set(N,{ref:N,...S}),()=>void k.itemMap.delete(N))),c.jsx(h,{[f]:"",ref:C,children:b})});p.displayName=d;function w(v){const g=s(e+"CollectionConsumer",v);return y.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const S=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((k,I)=>S.indexOf(k.ref.current)-S.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},w,r]}var gb=m.createContext(void 0);function os(e){const t=m.useContext(gb);return e||t||"ltr"}const xb=["top","right","bottom","left"],Cn=Math.min,Rt=Math.max,ss=Math.round,is=Math.floor,rn=e=>({x:e,y:e}),vb={left:"right",right:"left",bottom:"top",top:"bottom"},wb={start:"end",end:"start"};function ea(e,t,n){return Rt(e,Cn(t,n))}function dn(e,t){return typeof e=="function"?e(t):e}function fn(e){return e.split("-")[0]}function dr(e){return e.split("-")[1]}function ta(e){return e==="x"?"y":"x"}function na(e){return e==="y"?"height":"width"}const bb=new Set(["top","bottom"]);function on(e){return bb.has(fn(e))?"y":"x"}function ra(e){return ta(on(e))}function yb(e,t,n){n===void 0&&(n=!1);const r=dr(e),o=ra(e),s=na(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=as(i)),[i,as(i)]}function Sb(e){const t=as(e);return[oa(e),t,oa(t)]}function oa(e){return e.replace(/start|end/g,t=>wb[t])}const pd=["left","right"],md=["right","left"],Cb=["top","bottom"],Tb=["bottom","top"];function kb(e,t,n){switch(e){case"top":case"bottom":return n?t?md:pd:t?pd:md;case"left":case"right":return t?Cb:Tb;default:return[]}}function Eb(e,t,n,r){const o=dr(e);let s=kb(fn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(oa)))),s}function as(e){return e.replace(/left|right|bottom|top/g,t=>vb[t])}function Ib(e){return{top:0,right:0,bottom:0,left:0,...e}}function gd(e){return typeof e!="number"?Ib(e):{top:e,right:e,bottom:e,left:e}}function ls(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 xd(e,t,n){let{reference:r,floating:o}=e;const s=on(t),i=ra(t),a=na(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 Nb=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}=xd(u,r,l),h=r,p={},w=0;for(let v=0;v<a.length;v++){const{name:g,fn:x}=a[v],{x:b,y:S,data:N,reset:C}=await x({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,[g]:{...p[g],...N}},C&&w<=50&&(w++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=xd(u,h,l)),v=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function Vr(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}=dn(t,e),w=gd(p),g=a[h?f==="floating"?"reference":"floating":f],x=ls(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:l})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),N=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=ls(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(x.top-C.top+w.top)/N.y,bottom:(C.bottom-x.bottom+w.bottom)/N.y,left:(x.left-C.left+w.left)/N.x,right:(C.right-x.right+w.right)/N.x}}const Ab=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}=dn(e,t)||{};if(u==null)return{};const f=gd(d),h={x:n,y:r},p=ra(o),w=na(p),v=await i.getDimensions(u),g=p==="y",x=g?"top":"left",b=g?"bottom":"right",S=g?"clientHeight":"clientWidth",N=s.reference[w]+s.reference[p]-h[p]-s.floating[w],C=h[p]-s.reference[p],k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let I=k?k[S]:0;(!I||!await(i.isElement==null?void 0:i.isElement(k)))&&(I=a.floating[S]||s.floating[w]);const A=N/2-C/2,R=I/2-v[w]/2-1,P=Cn(f[x],R),L=Cn(f[b],R),$=P,H=I-v[w]-L,M=I/2-v[w]/2+A,q=ea($,M,H),V=!l.arrow&&dr(o)!=null&&M!==q&&s.reference[w]/2-(M<$?P:L)-v[w]/2<0,Y=V?M<$?M-$:M-H:0;return{[p]:h[p]+Y,data:{[p]:q,centerOffset:M-q-Y,...V&&{alignmentOffset:Y}},reset:V}}}),_b=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:w="none",flipAlignment:v=!0,...g}=dn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=fn(o),b=on(a),S=fn(a)===a,N=await(l.isRTL==null?void 0:l.isRTL(u.floating)),C=h||(S||!v?[as(a)]:Sb(a)),k=w!=="none";!h&&k&&C.push(...Eb(a,v,w,N));const I=[a,...C],A=await Vr(t,g),R=[];let P=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&R.push(A[x]),f){const M=yb(o,i,N);R.push(A[M[0]],A[M[1]])}if(P=[...P,{placement:o,overflows:R}],!R.every(M=>M<=0)){var L,$;const M=(((L=s.flip)==null?void 0:L.index)||0)+1,q=I[M];if(q&&(!(f==="alignment"?b!==on(q):!1)||P.every(B=>on(B.placement)===b?B.overflows[0]>0:!0)))return{data:{index:M,overflows:P},reset:{placement:q}};let V=($=P.filter(Y=>Y.overflows[0]<=0).sort((Y,B)=>Y.overflows[1]-B.overflows[1])[0])==null?void 0:$.placement;if(!V)switch(p){case"bestFit":{var H;const Y=(H=P.filter(B=>{if(k){const j=on(B.placement);return j===b||j==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(j=>j>0).reduce((j,G)=>j+G,0)]).sort((B,j)=>B[1]-j[1])[0])==null?void 0:H[0];Y&&(V=Y);break}case"initialPlacement":V=a;break}if(o!==V)return{reset:{placement:V}}}return{}}}};function vd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function wd(e){return xb.some(t=>e[t]>=0)}const jb=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=dn(e,t);switch(r){case"referenceHidden":{const s=await Vr(t,{...o,elementContext:"reference"}),i=vd(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:wd(i)}}}case"escaped":{const s=await Vr(t,{...o,altBoundary:!0}),i=vd(s,n.floating);return{data:{escapedOffsets:i,escaped:wd(i)}}}default:return{}}}}},bd=new Set(["left","top"]);async function Rb(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=on(n)==="y",u=bd.has(i)?-1:1,d=s&&l?-1:1,f=dn(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:w}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof w=="number"&&(p=a==="end"?w*-1:w),l?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const Pb=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 Rb(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}}}}},Ob=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x,y:b}=g;return{x,y:b}}},...l}=dn(e,t),u={x:n,y:r},d=await Vr(t,l),f=on(fn(o)),h=ta(f);let p=u[h],w=u[f];if(s){const g=h==="y"?"top":"left",x=h==="y"?"bottom":"right",b=p+d[g],S=p-d[x];p=ea(b,p,S)}if(i){const g=f==="y"?"top":"left",x=f==="y"?"bottom":"right",b=w+d[g],S=w-d[x];w=ea(b,w,S)}const v=a.fn({...t,[h]:p,[f]:w});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[h]:s,[f]:i}}}}}},Mb=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}=dn(e,t),d={x:n,y:r},f=on(o),h=ta(f);let p=d[h],w=d[f];const v=dn(a,t),g=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(l){const S=h==="y"?"height":"width",N=s.reference[h]-s.floating[S]+g.mainAxis,C=s.reference[h]+s.reference[S]-g.mainAxis;p<N?p=N:p>C&&(p=C)}if(u){var x,b;const S=h==="y"?"width":"height",N=bd.has(fn(o)),C=s.reference[f]-s.floating[S]+(N&&((x=i.offset)==null?void 0:x[f])||0)+(N?0:g.crossAxis),k=s.reference[f]+s.reference[S]+(N?0:((b=i.offset)==null?void 0:b[f])||0)-(N?g.crossAxis:0);w<C?w=C:w>k&&(w=k)}return{[h]:p,[f]:w}}}},Db=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}=dn(e,t),d=await Vr(t,u),f=fn(o),h=dr(o),p=on(o)==="y",{width:w,height:v}=s.floating;let g,x;f==="top"||f==="bottom"?(g=f,x=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=f,g=h==="end"?"top":"bottom");const b=v-d.top-d.bottom,S=w-d.left-d.right,N=Cn(v-d[g],b),C=Cn(w-d[x],S),k=!t.middlewareData.shift;let I=N,A=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=b),k&&!h){const P=Rt(d.left,0),L=Rt(d.right,0),$=Rt(d.top,0),H=Rt(d.bottom,0);p?A=w-2*(P!==0||L!==0?P+L:Rt(d.left,d.right)):I=v-2*($!==0||H!==0?$+H:Rt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:I});const R=await i.getDimensions(a.floating);return w!==R.width||v!==R.height?{reset:{rects:!0}}:{}}}};function cs(){return typeof window<"u"}function fr(e){return yd(e)?(e.nodeName||"").toLowerCase():"#document"}function Pt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function sn(e){var t;return(t=(yd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function yd(e){return cs()?e instanceof Node||e instanceof Pt(e).Node:!1}function Kt(e){return cs()?e instanceof Element||e instanceof Pt(e).Element:!1}function an(e){return cs()?e instanceof HTMLElement||e instanceof Pt(e).HTMLElement:!1}function Sd(e){return!cs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Pt(e).ShadowRoot}const Lb=new Set(["inline","contents"]);function Kr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=qt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Lb.has(o)}const $b=new Set(["table","td","th"]);function Fb(e){return $b.has(fr(e))}const Bb=[":popover-open",":modal"];function us(e){return Bb.some(t=>{try{return e.matches(t)}catch{return!1}})}const zb=["transform","translate","scale","rotate","perspective"],Hb=["transform","translate","scale","rotate","perspective","filter"],Ub=["paint","layout","strict","content"];function sa(e){const t=ia(),n=Kt(e)?qt(e):e;return zb.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)||Hb.some(r=>(n.willChange||"").includes(r))||Ub.some(r=>(n.contain||"").includes(r))}function Wb(e){let t=Tn(e);for(;an(t)&&!hr(t);){if(sa(t))return t;if(us(t))return null;t=Tn(t)}return null}function ia(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Vb=new Set(["html","body","#document"]);function hr(e){return Vb.has(fr(e))}function qt(e){return Pt(e).getComputedStyle(e)}function ds(e){return Kt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Tn(e){if(fr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Sd(e)&&e.host||sn(e);return Sd(t)?t.host:t}function Cd(e){const t=Tn(e);return hr(t)?e.ownerDocument?e.ownerDocument.body:e.body:an(t)&&Kr(t)?t:Cd(t)}function qr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Cd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Pt(o);if(s){const a=aa(i);return t.concat(i,i.visualViewport||[],Kr(o)?o:[],a&&n?qr(a):[])}return t.concat(o,qr(o,[],n))}function aa(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Td(e){const t=qt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=an(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=ss(n)!==s||ss(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function la(e){return Kt(e)?e:e.contextElement}function pr(e){const t=la(e);if(!an(t))return rn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Td(t);let i=(s?ss(n.width):n.width)/r,a=(s?ss(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Kb=rn(0);function kd(e){const t=Pt(e);return!ia()||!t.visualViewport?Kb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function qb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Pt(e)?!1:t}function Vn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=la(e);let i=rn(1);t&&(r?Kt(r)&&(i=pr(r)):i=pr(e));const a=qb(s,n,r)?kd(s):rn(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=Pt(s),p=r&&Kt(r)?Pt(r):r;let w=h,v=aa(w);for(;v&&r&&p!==w;){const g=pr(v),x=v.getBoundingClientRect(),b=qt(v),S=x.left+(v.clientLeft+parseFloat(b.paddingLeft))*g.x,N=x.top+(v.clientTop+parseFloat(b.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=S,u+=N,w=Pt(v),v=aa(w)}}return ls({width:d,height:f,x:l,y:u})}function fs(e,t){const n=ds(e).scrollLeft;return t?t.left+n:Vn(sn(e)).left+n}function Ed(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-fs(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Gb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=sn(r),a=t?us(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=rn(1);const d=rn(0),f=an(r);if((f||!f&&!s)&&((fr(r)!=="body"||Kr(i))&&(l=ds(r)),an(r))){const p=Vn(r);u=pr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?Ed(i,l):rn(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 Yb(e){return Array.from(e.getClientRects())}function Xb(e){const t=sn(e),n=ds(e),r=e.ownerDocument.body,o=Rt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Rt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+fs(e);const a=-n.scrollTop;return qt(r).direction==="rtl"&&(i+=Rt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Id=25;function Jb(e,t){const n=Pt(e),r=sn(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=ia();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const u=fs(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,w=Math.abs(r.clientWidth-f.clientWidth-p);w<=Id&&(s-=w)}else u<=Id&&(s+=u);return{width:s,height:i,x:a,y:l}}const Zb=new Set(["absolute","fixed"]);function Qb(e,t){const n=Vn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=an(e)?pr(e):rn(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 Nd(e,t,n){let r;if(t==="viewport")r=Jb(e,n);else if(t==="document")r=Xb(sn(e));else if(Kt(t))r=Qb(t,n);else{const o=kd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ls(r)}function Ad(e,t){const n=Tn(e);return n===t||!Kt(n)||hr(n)?!1:qt(n).position==="fixed"||Ad(n,t)}function ey(e,t){const n=t.get(e);if(n)return n;let r=qr(e,[],!1).filter(a=>Kt(a)&&fr(a)!=="body"),o=null;const s=qt(e).position==="fixed";let i=s?Tn(e):e;for(;Kt(i)&&!hr(i);){const a=qt(i),l=sa(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Zb.has(o.position)||Kr(i)&&!l&&Ad(e,i))?r=r.filter(d=>d!==i):o=a,i=Tn(i)}return t.set(e,r),r}function ty(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?us(t)?[]:ey(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=Nd(t,d,o);return u.top=Rt(f.top,u.top),u.right=Cn(f.right,u.right),u.bottom=Cn(f.bottom,u.bottom),u.left=Rt(f.left,u.left),u},Nd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function ny(e){const{width:t,height:n}=Td(e);return{width:t,height:n}}function ry(e,t,n){const r=an(t),o=sn(t),s=n==="fixed",i=Vn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=rn(0);function u(){l.x=fs(o)}if(r||!r&&!s)if((fr(t)!=="body"||Kr(o))&&(a=ds(t)),r){const p=Vn(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?Ed(o,a):rn(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 ca(e){return qt(e).position==="static"}function _d(e,t){if(!an(e)||qt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return sn(e)===n&&(n=n.ownerDocument.body),n}function jd(e,t){const n=Pt(e);if(us(e))return n;if(!an(e)){let o=Tn(e);for(;o&&!hr(o);){if(Kt(o)&&!ca(o))return o;o=Tn(o)}return n}let r=_d(e,t);for(;r&&Fb(r)&&ca(r);)r=_d(r,t);return r&&hr(r)&&ca(r)&&!sa(r)?n:r||Wb(e)||n}const oy=async function(e){const t=this.getOffsetParent||jd,n=this.getDimensions,r=await n(e.floating);return{reference:ry(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function sy(e){return qt(e).direction==="rtl"}const iy={convertOffsetParentRelativeRectToViewportRelativeRect:Gb,getDocumentElement:sn,getClippingRect:ty,getOffsetParent:jd,getElementRects:oy,getClientRects:Yb,getDimensions:ny,getScale:pr,isElement:Kt,isRTL:sy};function Rd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ay(e,t){let n=null,r;const o=sn(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 w=is(f),v=is(o.clientWidth-(d+h)),g=is(o.clientHeight-(f+p)),x=is(d),S={rootMargin:-w+"px "+-v+"px "+-g+"px "+-x+"px",threshold:Rt(0,Cn(1,l))||1};let N=!0;function C(k){const I=k[0].intersectionRatio;if(I!==l){if(!N)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!Rd(u,e.getBoundingClientRect())&&i(),N=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function ly(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=la(e),d=o||s?[...u?qr(u):[],...qr(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const f=u&&a?ay(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(x=>{let[b]=x;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 w,v=l?Vn(e):null;l&&g();function g(){const x=Vn(e);v&&!Rd(v,x)&&n(),v=x,w=requestAnimationFrame(g)}return n(),()=>{var x;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(x=p)==null||x.disconnect(),p=null,l&&cancelAnimationFrame(w)}}const cy=Pb,uy=Ob,dy=_b,fy=Db,hy=jb,Pd=Ab,py=Mb,my=(e,t,n)=>{const r=new Map,o={platform:iy,...n},s={...o.platform,_c:r};return Nb(e,t,{...o,platform:s})};var gy=typeof document<"u",xy=function(){},hs=gy?y.useLayoutEffect:xy;function ps(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(!ps(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)&&!ps(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Od(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Md(e,t){const n=Od(e);return Math.round(t*n)/n}function ua(e){const t=m.useRef(e);return hs(()=>{t.current=e}),t}function vy(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=m.useState(r);ps(h,r)||p(r);const[w,v]=m.useState(null),[g,x]=m.useState(null),b=m.useCallback(B=>{B!==k.current&&(k.current=B,v(B))},[]),S=m.useCallback(B=>{B!==I.current&&(I.current=B,x(B))},[]),N=s||w,C=i||g,k=m.useRef(null),I=m.useRef(null),A=m.useRef(d),R=l!=null,P=ua(l),L=ua(o),$=ua(u),H=m.useCallback(()=>{if(!k.current||!I.current)return;const B={placement:t,strategy:n,middleware:h};L.current&&(B.platform=L.current),my(k.current,I.current,B).then(j=>{const G={...j,isPositioned:$.current!==!1};M.current&&!ps(A.current,G)&&(A.current=G,ro.flushSync(()=>{f(G)}))})},[h,t,n,L,$]);hs(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(B=>({...B,isPositioned:!1})))},[u]);const M=m.useRef(!1);hs(()=>(M.current=!0,()=>{M.current=!1}),[]),hs(()=>{if(N&&(k.current=N),C&&(I.current=C),N&&C){if(P.current)return P.current(N,C,H);H()}},[N,C,H,P,R]);const q=m.useMemo(()=>({reference:k,floating:I,setReference:b,setFloating:S}),[b,S]),V=m.useMemo(()=>({reference:N,floating:C}),[N,C]),Y=m.useMemo(()=>{const B={position:n,left:0,top:0};if(!V.floating)return B;const j=Md(V.floating,d.x),G=Md(V.floating,d.y);return a?{...B,transform:"translate("+j+"px, "+G+"px)",...Od(V.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:j,top:G}},[n,a,V.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:H,refs:q,elements:V,floatingStyles:Y}),[d,H,q,V,Y])}const wy=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?Pd({element:r.current,padding:o}).fn(n):{}:r?Pd({element:r,padding:o}).fn(n):{}}}},by=(e,t)=>({...cy(e),options:[e,t]}),yy=(e,t)=>({...uy(e),options:[e,t]}),Sy=(e,t)=>({...py(e),options:[e,t]}),Cy=(e,t)=>({...dy(e),options:[e,t]}),Ty=(e,t)=>({...fy(e),options:[e,t]}),ky=(e,t)=>({...hy(e),options:[e,t]}),Ey=(e,t)=>({...wy(e),options:[e,t]});var Iy="Arrow",Dd=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(Ie.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});Dd.displayName=Iy;var Ny=Dd;function Ld(e){const[t,n]=m.useState(void 0);return pt(()=>{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 da="Popper",[$d,ms]=en(da),[Ay,Fd]=$d(da),Bd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(Ay,{scope:t,anchor:r,onAnchorChange:o,children:n})};Bd.displayName=da;var zd="PopperAnchor",Hd=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Fd(zd,n),i=m.useRef(null),a=Le(t,i),l=m.useRef(null);return m.useEffect(()=>{const u=l.current;l.current=(r==null?void 0:r.current)||i.current,u!==l.current&&s.onAnchorChange(l.current)}),r?null:c.jsx(Ie.div,{...o,ref:a})});Hd.displayName=zd;var fa="PopperContent",[_y,jy]=$d(fa),Ud=m.forwardRef((e,t)=>{var K,D,J,U,fe,ue;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:w,...v}=e,g=Fd(fa,n),[x,b]=m.useState(null),S=Le(t,$e=>b($e)),[N,C]=m.useState(null),k=Ld(N),I=(k==null?void 0:k.width)??0,A=(k==null?void 0:k.height)??0,R=r+(s!=="center"?"-"+s:""),P=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},L=Array.isArray(u)?u:[u],$=L.length>0,H={padding:P,boundary:L.filter(Py),altBoundary:$},{refs:M,floatingStyles:q,placement:V,isPositioned:Y,middlewareData:B}=vy({strategy:"fixed",placement:R,whileElementsMounted:(...$e)=>ly(...$e,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[by({mainAxis:o+A,alignmentAxis:i}),l&&yy({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Sy():void 0,...H}),l&&Cy({...H}),Ty({...H,apply:({elements:$e,rects:Ge,availableWidth:qe,availableHeight:ke})=>{const{width:Oe,height:Be}=Ge.reference,Ue=$e.floating.style;Ue.setProperty("--radix-popper-available-width",`${qe}px`),Ue.setProperty("--radix-popper-available-height",`${ke}px`),Ue.setProperty("--radix-popper-anchor-width",`${Oe}px`),Ue.setProperty("--radix-popper-anchor-height",`${Be}px`)}}),N&&Ey({element:N,padding:a}),Oy({arrowWidth:I,arrowHeight:A}),h&&ky({strategy:"referenceHidden",...H})]}),[j,G]=Kd(V),Z=mt(w);pt(()=>{Y&&(Z==null||Z())},[Y,Z]);const ge=(K=B.arrow)==null?void 0:K.x,de=(D=B.arrow)==null?void 0:D.y,ee=((J=B.arrow)==null?void 0:J.centerOffset)!==0,[Ae,Te]=m.useState();return pt(()=>{x&&Te(window.getComputedStyle(x).zIndex)},[x]),c.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...q,transform:Y?q.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ae,"--radix-popper-transform-origin":[(U=B.transformOrigin)==null?void 0:U.x,(fe=B.transformOrigin)==null?void 0:fe.y].join(" "),...((ue=B.hide)==null?void 0:ue.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(_y,{scope:n,placedSide:j,onArrowChange:C,arrowX:ge,arrowY:de,shouldHideArrow:ee,children:c.jsx(Ie.div,{"data-side":j,"data-align":G,...v,ref:S,style:{...v.style,animation:Y?void 0:"none"}})})})});Ud.displayName=fa;var Wd="PopperArrow",Ry={top:"bottom",right:"left",bottom:"top",left:"right"},Vd=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=jy(Wd,r),i=Ry[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(Ny,{...o,ref:n,style:{...o.style,display:"block"}})})});Vd.displayName=Wd;function Py(e){return e!==null}var Oy=e=>({name:"transformOrigin",options:e,fn(t){var g,x,b;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[u,d]=Kd(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((x=o.arrow)==null?void 0:x.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let w="",v="";return u==="bottom"?(w=i?f:`${h}px`,v=`${-l}px`):u==="top"?(w=i?f:`${h}px`,v=`${r.floating.height+l}px`):u==="right"?(w=`${-l}px`,v=i?f:`${p}px`):u==="left"&&(w=`${r.floating.width+l}px`,v=i?f:`${p}px`),{data:{x:w,y:v}}}});function Kd(e){const[t,n="center"]=e.split("-");return[t,n]}var qd=Bd,Gd=Hd,Yd=Ud,Xd=Vd,ha="rovingFocusGroup.onEntryFocus",My={bubbles:!1,cancelable:!0},Gr="RovingFocusGroup",[pa,Jd,Dy]=Qi(Gr),[Ly,Zd]=en(Gr,[Dy]),[$y,Fy]=Ly(Gr),Qd=m.forwardRef((e,t)=>c.jsx(pa.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(pa.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(By,{...e,ref:t})})}));Qd.displayName=Gr;var By=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=m.useRef(null),p=Le(t,h),w=os(s),[v,g]=Bn({prop:i,defaultProp:a??null,onChange:l,caller:Gr}),[x,b]=m.useState(!1),S=mt(u),N=Jd(n),C=m.useRef(!1),[k,I]=m.useState(0);return m.useEffect(()=>{const A=h.current;if(A)return A.addEventListener(ha,S),()=>A.removeEventListener(ha,S)},[S]),c.jsx($y,{scope:n,orientation:r,dir:w,loop:o,currentTabStopId:v,onItemFocus:m.useCallback(A=>g(A),[g]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>I(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>I(A=>A-1),[]),children:c.jsx(Ie.div,{tabIndex:x||k===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:ce(e.onMouseDown,()=>{C.current=!0}),onFocus:ce(e.onFocus,A=>{const R=!C.current;if(A.target===A.currentTarget&&R&&!x){const P=new CustomEvent(ha,My);if(A.currentTarget.dispatchEvent(P),!P.defaultPrevented){const L=N().filter(V=>V.focusable),$=L.find(V=>V.active),H=L.find(V=>V.id===v),q=[$,H,...L].filter(Boolean).map(V=>V.ref.current);nf(q,d)}}C.current=!1}),onBlur:ce(e.onBlur,()=>b(!1))})})}),ef="RovingFocusGroupItem",tf=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=tn(),u=s||l,d=Fy(ef,n),f=d.currentTabStopId===u,h=Jd(n),{onFocusableItemAdd:p,onFocusableItemRemove:w,currentTabStopId:v}=d;return m.useEffect(()=>{if(r)return p(),()=>w()},[r,p,w]),c.jsx(pa.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:ce(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:ce(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:ce(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=Uy(g,d.orientation,d.dir);if(x!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let S=h().filter(N=>N.focusable).map(N=>N.ref.current);if(x==="last")S.reverse();else if(x==="prev"||x==="next"){x==="prev"&&S.reverse();const N=S.indexOf(g.currentTarget);S=d.loop?Wy(S,N+1):S.slice(N+1)}setTimeout(()=>nf(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:v!=null}):i})})});tf.displayName=ef;var zy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Hy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Uy(e,t,n){const r=Hy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return zy[r]}function nf(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Wy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Vy=Qd,Ky=tf,ma=["Enter"," "],qy=["ArrowDown","PageUp","Home"],rf=["ArrowUp","PageDown","End"],Gy=[...qy,...rf],Yy={ltr:[...ma,"ArrowRight"],rtl:[...ma,"ArrowLeft"]},Xy={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Yr="Menu",[Xr,Jy,Zy]=Qi(Yr),[Kn,of]=en(Yr,[Zy,ms,Zd]),gs=ms(),sf=Zd(),[Qy,qn]=Kn(Yr),[e0,Jr]=Kn(Yr),af=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=gs(t),[l,u]=m.useState(null),d=m.useRef(!1),f=mt(s),h=os(o);return m.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),c.jsx(qd,{...a,children:c.jsx(Qy,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(e0,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};af.displayName=Yr;var t0="MenuAnchor",ga=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=gs(n);return c.jsx(Gd,{...o,...r,ref:t})});ga.displayName=t0;var xa="MenuPortal",[n0,lf]=Kn(xa,{forceMount:void 0}),cf=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=qn(xa,t);return c.jsx(n0,{scope:t,forceMount:n,children:c.jsx(jt,{present:n||s.open,children:c.jsx(Ho,{asChild:!0,container:o,children:r})})})};cf.displayName=xa;var Lt="MenuContent",[r0,va]=Kn(Lt),uf=m.forwardRef((e,t)=>{const n=lf(Lt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=qn(Lt,e.__scopeMenu),i=Jr(Lt,e.__scopeMenu);return c.jsx(Xr.Provider,{scope:e.__scopeMenu,children:c.jsx(jt,{present:r||s.open,children:c.jsx(Xr.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(o0,{...o,ref:t}):c.jsx(s0,{...o,ref:t})})})})}),o0=m.forwardRef((e,t)=>{const n=qn(Lt,e.__scopeMenu),r=m.useRef(null),o=Le(t,r);return m.useEffect(()=>{const s=r.current;if(s)return qi(s)},[]),c.jsx(wa,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ce(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),s0=m.forwardRef((e,t)=>{const n=qn(Lt,e.__scopeMenu);return c.jsx(wa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),i0=Rn.createSlot("MenuContent.ScrollLock"),wa=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:w,...v}=e,g=qn(Lt,n),x=Jr(Lt,n),b=gs(n),S=sf(n),N=Jy(n),[C,k]=m.useState(null),I=m.useRef(null),A=Le(t,I,g.onContentChange),R=m.useRef(0),P=m.useRef(""),L=m.useRef(0),$=m.useRef(null),H=m.useRef("right"),M=m.useRef(0),q=w?Go:m.Fragment,V=w?{as:i0,allowPinchZoom:!0}:void 0,Y=j=>{var K,D;const G=P.current+j,Z=N().filter(J=>!J.disabled),ge=document.activeElement,de=(K=Z.find(J=>J.ref.current===ge))==null?void 0:K.textValue,ee=Z.map(J=>J.textValue),Ae=v0(ee,G,de),Te=(D=Z.find(J=>J.textValue===Ae))==null?void 0:D.ref.current;(function J(U){P.current=U,window.clearTimeout(R.current),U!==""&&(R.current=window.setTimeout(()=>J(""),1e3))})(G),Te&&setTimeout(()=>Te.focus())};m.useEffect(()=>()=>window.clearTimeout(R.current),[]),zi();const B=m.useCallback(j=>{var Z,ge;return H.current===((Z=$.current)==null?void 0:Z.side)&&b0(j,(ge=$.current)==null?void 0:ge.area)},[]);return c.jsx(r0,{scope:n,searchRef:P,onItemEnter:m.useCallback(j=>{B(j)&&j.preventDefault()},[B]),onItemLeave:m.useCallback(j=>{var G;B(j)||((G=I.current)==null||G.focus(),k(null))},[B]),onTriggerLeave:m.useCallback(j=>{B(j)&&j.preventDefault()},[B]),pointerGraceTimerRef:L,onPointerGraceIntentChange:m.useCallback(j=>{$.current=j},[]),children:c.jsx(q,{...V,children:c.jsx(zo,{asChild:!0,trapped:o,onMountAutoFocus:ce(s,j=>{var G;j.preventDefault(),(G=I.current)==null||G.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(Bo,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:c.jsx(Vy,{asChild:!0,...S,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:ce(l,j=>{x.isUsingKeyboardRef.current||j.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(Yd,{role:"menu","aria-orientation":"vertical","data-state":If(g.open),"data-radix-menu-content":"",dir:x.dir,...b,...v,ref:A,style:{outline:"none",...v.style},onKeyDown:ce(v.onKeyDown,j=>{const Z=j.target.closest("[data-radix-menu-content]")===j.currentTarget,ge=j.ctrlKey||j.altKey||j.metaKey,de=j.key.length===1;Z&&(j.key==="Tab"&&j.preventDefault(),!ge&&de&&Y(j.key));const ee=I.current;if(j.target!==ee||!Gy.includes(j.key))return;j.preventDefault();const Te=N().filter(K=>!K.disabled).map(K=>K.ref.current);rf.includes(j.key)&&Te.reverse(),g0(Te)}),onBlur:ce(e.onBlur,j=>{j.currentTarget.contains(j.target)||(window.clearTimeout(R.current),P.current="")}),onPointerMove:ce(e.onPointerMove,Qr(j=>{const G=j.target,Z=M.current!==j.clientX;if(j.currentTarget.contains(G)&&Z){const ge=j.clientX>M.current?"right":"left";H.current=ge,M.current=j.clientX}}))})})})})})})});uf.displayName=Lt;var a0="MenuGroup",ba=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ie.div,{role:"group",...r,ref:t})});ba.displayName=a0;var l0="MenuLabel",df=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ie.div,{...r,ref:t})});df.displayName=l0;var xs="MenuItem",ff="menu.itemSelect",vs=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=Jr(xs,e.__scopeMenu),a=va(xs,e.__scopeMenu),l=Le(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(ff,{bubbles:!0,cancelable:!0});f.addEventListener(ff,p=>r==null?void 0:r(p),{once:!0}),Kc(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(hf,{...o,ref:l,disabled:n,onClick:ce(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:ce(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:ce(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||ma.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});vs.displayName=xs;var hf=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=va(xs,n),a=sf(n),l=m.useRef(null),u=Le(t,l),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const w=l.current;w&&p((w.textContent??"").trim())},[s.children]),c.jsx(Xr.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(Ky,{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:ce(e.onPointerMove,Qr(w=>{r?i.onItemLeave(w):(i.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ce(e.onPointerLeave,Qr(w=>i.onItemLeave(w))),onFocus:ce(e.onFocus,()=>f(!0)),onBlur:ce(e.onBlur,()=>f(!1))})})})}),c0="MenuCheckboxItem",pf=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(wf,{scope:e.__scopeMenu,checked:n,children:c.jsx(vs,{role:"menuitemcheckbox","aria-checked":ws(n)?"mixed":n,...o,ref:t,"data-state":Sa(n),onSelect:ce(o.onSelect,()=>r==null?void 0:r(ws(n)?!0:!n),{checkForDefaultPrevented:!1})})})});pf.displayName=c0;var mf="MenuRadioGroup",[u0,d0]=Kn(mf,{value:void 0,onValueChange:()=>{}}),gf=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=mt(r);return c.jsx(u0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(ba,{...o,ref:t})})});gf.displayName=mf;var xf="MenuRadioItem",vf=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=d0(xf,e.__scopeMenu),s=n===o.value;return c.jsx(wf,{scope:e.__scopeMenu,checked:s,children:c.jsx(vs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Sa(s),onSelect:ce(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});vf.displayName=xf;var ya="MenuItemIndicator",[wf,f0]=Kn(ya,{checked:!1}),bf=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=f0(ya,n);return c.jsx(jt,{present:r||ws(s.checked)||s.checked===!0,children:c.jsx(Ie.span,{...o,ref:t,"data-state":Sa(s.checked)})})});bf.displayName=ya;var h0="MenuSeparator",yf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ie.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});yf.displayName=h0;var p0="MenuArrow",Sf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=gs(n);return c.jsx(Xd,{...o,...r,ref:t})});Sf.displayName=p0;var m0="MenuSub",[JC,Cf]=Kn(m0),Zr="MenuSubTrigger",Tf=m.forwardRef((e,t)=>{const n=qn(Zr,e.__scopeMenu),r=Jr(Zr,e.__scopeMenu),o=Cf(Zr,e.__scopeMenu),s=va(Zr,e.__scopeMenu),i=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},d=m.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return m.useEffect(()=>d,[d]),m.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),c.jsx(ga,{asChild:!0,...u,children:c.jsx(hf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":If(n.open),...e,ref:Ii(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:ce(e.onPointerMove,Qr(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:ce(e.onPointerLeave,Qr(f=>{var p,w;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const v=(w=n.content)==null?void 0:w.dataset.side,g=v==="right",x=g?-5:5,b=h[g?"left":"right"],S=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+x,y:f.clientY},{x:b,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:b,y:h.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ce(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||Yy[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});Tf.displayName=Zr;var kf="MenuSubContent",Ef=m.forwardRef((e,t)=>{const n=lf(Lt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=qn(Lt,e.__scopeMenu),i=Jr(Lt,e.__scopeMenu),a=Cf(kf,e.__scopeMenu),l=m.useRef(null),u=Le(t,l);return c.jsx(Xr.Provider,{scope:e.__scopeMenu,children:c.jsx(jt,{present:r||s.open,children:c.jsx(Xr.Slot,{scope:e.__scopeMenu,children:c.jsx(wa,{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:ce(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ce(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ce(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=Xy[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});Ef.displayName=kf;function If(e){return e?"open":"closed"}function ws(e){return e==="indeterminate"}function Sa(e){return ws(e)?"indeterminate":e?"checked":"unchecked"}function g0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function x0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function v0(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=x0(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 w0(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 b0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return w0(n,t)}function Qr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var y0=af,S0=ga,C0=cf,T0=uf,k0=ba,E0=df,I0=vs,N0=pf,A0=gf,_0=vf,j0=bf,R0=yf,P0=Sf,O0=Tf,M0=Ef,bs="DropdownMenu",[D0,ZC]=en(bs,[of]),St=of(),[L0,Nf]=D0(bs),Af=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=St(t),u=m.useRef(null),[d,f]=Bn({prop:o,defaultProp:s??!1,onChange:i,caller:bs});return c.jsx(L0,{scope:t,triggerId:tn(),triggerRef:u,contentId:tn(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(y0,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Af.displayName=bs;var _f="DropdownMenuTrigger",jf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Nf(_f,n),i=St(n);return c.jsx(S0,{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:Ii(t,s.triggerRef),onPointerDown:ce(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ce(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});jf.displayName=_f;var $0="DropdownMenuPortal",Rf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=St(t);return c.jsx(C0,{...r,...n})};Rf.displayName=$0;var Pf="DropdownMenuContent",Of=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Nf(Pf,n),s=St(n),i=m.useRef(!1);return c.jsx(T0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ce(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ce(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)"}})});Of.displayName=Pf;var F0="DropdownMenuGroup",B0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(k0,{...o,...r,ref:t})});B0.displayName=F0;var z0="DropdownMenuLabel",Mf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(E0,{...o,...r,ref:t})});Mf.displayName=z0;var H0="DropdownMenuItem",Df=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(I0,{...o,...r,ref:t})});Df.displayName=H0;var U0="DropdownMenuCheckboxItem",Lf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(N0,{...o,...r,ref:t})});Lf.displayName=U0;var W0="DropdownMenuRadioGroup",V0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(A0,{...o,...r,ref:t})});V0.displayName=W0;var K0="DropdownMenuRadioItem",$f=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(_0,{...o,...r,ref:t})});$f.displayName=K0;var q0="DropdownMenuItemIndicator",Ff=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(j0,{...o,...r,ref:t})});Ff.displayName=q0;var G0="DropdownMenuSeparator",Bf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(R0,{...o,...r,ref:t})});Bf.displayName=G0;var Y0="DropdownMenuArrow",X0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(P0,{...o,...r,ref:t})});X0.displayName=Y0;var J0="DropdownMenuSubTrigger",zf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(O0,{...o,...r,ref:t})});zf.displayName=J0;var Z0="DropdownMenuSubContent",Hf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(M0,{...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)"}})});Hf.displayName=Z0;var Q0=Af,eS=jf,tS=Rf,Uf=Of,Wf=Mf,Vf=Df,Kf=Lf,qf=$f,Gf=Ff,Yf=Bf,Xf=zf,Jf=Hf;const nS=Q0,rS=eS,oS=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(Xf,{ref:o,className:Q("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(re.ChevronRight,{className:"ml-auto h-4 w-4"})]}));oS.displayName=Xf.displayName;const sS=m.forwardRef(({className:e,...t},n)=>c.jsx(Jf,{ref:n,className:Q("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}));sS.displayName=Jf.displayName;const Zf=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(tS,{children:c.jsx(Uf,{ref:r,sideOffset:t,className:Q("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})}));Zf.displayName=Uf.displayName;const Ca=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Vf,{ref:r,className:Q("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}));Ca.displayName=Vf.displayName;const iS=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(Kf,{ref:o,className:Q("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(Gf,{children:c.jsx(re.Check,{className:"h-4 w-4"})})}),t]}));iS.displayName=Kf.displayName;const aS=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(qf,{ref:r,className:Q("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(Gf,{children:c.jsx(re.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));aS.displayName=qf.displayName;const lS=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Wf,{ref:r,className:Q("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));lS.displayName=Wf.displayName;const cS=m.forwardRef(({className:e,...t},n)=>c.jsx(Yf,{ref:n,className:Q("-mx-1 my-1 h-px bg-muted",e),...t}));cS.displayName=Yf.displayName;function ys({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:h,onError:p}){const{api:w}=Gs(),{currentThreadId:v,isLoadingThread:g,listCheckpoints:x,navigateToCheckpoint:b,returnToLatest:S}=go(),{messages:N,hasMoreHistory:C,isLoadingHistory:k,send:I,stop:A,loadOlderMessages:R}=ni(),{isStreaming:P,error:L,streamingAssistantId:$,lastCheckpointId:H,lastCheckpointNs:M}=Vl(),[q,V]=y.useState(null),[Y,B]=y.useState(""),[j,G]=y.useState(null),[Z,ge]=y.useState([]),[de,ee]=y.useState(0),[Ae,Te]=y.useState(0),[K,D]=y.useState(!1),[J,U]=y.useState(null),[fe,ue]=y.useState(null),[$e,Ge]=y.useState(!1),[qe,ke]=y.useState(null),[Oe,Be]=y.useState([]),[Ue,st]=y.useState(null),[ot,ne]=y.useState(null),[le,xe]=y.useState(!1),Se=y.useRef(null),be=y.useRef(null),je=y.useRef(null),Qe=y.useCallback(()=>{Se.current&&(Se.current.value=""),be.current&&(be.current.value=""),ee(se=>se+1),Te(se=>se+1)},[]),Ye=y.useRef(!1);y.useEffect(()=>{Ye.current&&!P&&(ge([]),Qe()),Ye.current=P},[P,Qe]);const[it,gt]=y.useState("desktop");y.useEffect(()=>{const se=()=>{const E=window.innerWidth;gt(E<640?"phone":E<1024?"tablet":"desktop")};return se(),window.addEventListener("resize",se),()=>window.removeEventListener("resize",se)},[]),y.useEffect(()=>{let se=!1;if(!v){Be([]),st(null),ne(null),je.current=null;return}const E={threadId:v,checkpointId:H??null,checkpointNs:M??null},_=je.current;if(!(_&&_.threadId===E.threadId&&_.checkpointId===E.checkpointId&&_.checkpointNs===E.checkpointNs))return x(v).then(W=>{var ht;if(se)return;const ie=((W==null?void 0:W.checkpoints)??[]).slice().sort((T,F)=>new Date(F.createdAt).getTime()-new Date(T.createdAt).getTime());Be(ie);const pe=Ue,he=pe&&ie.some(T=>T.checkpointId===pe)?pe:((ht=ie[0])==null?void 0:ht.checkpointId)??null;let et=null;if(he){const T=ie.find(F=>F.checkpointId===he);et=(T==null?void 0:T.checkpointNs)??null}st(he),ne(et),je.current=E}).catch(W=>{console.error("ChatInterface - listCheckpoints error:",W),se||(Be([]),je.current=null)}),()=>{se=!0}},[v,H,M,Ue,x]),y.useEffect(()=>{H&&(st(H),ne(M??null))},[H,M]);const hn=y.useCallback(async()=>{if(!(!C||k))try{await R()}catch(se){console.warn("loadOlderMessages failed",se)}},[C,k,R]);y.useEffect(()=>{(async()=>{if(!w.baseUrl){ke(null);return}try{const E=await w.getAgent("default");ke(E.uiDefaultMessage||null)}catch(E){console.warn("Failed to fetch default message:",E),ke(null)}})()},[w]),y.useEffect(()=>{L&&!$e&&(p==null||p(L))},[L,$e,p]);const Jn=se=>{if(se.length>rs)return`Message too long (${se.length}/${rs} characters)`;try{return mb(se),null}catch(E){return(E==null?void 0:E.message)||"Invalid message"}},vr=async se=>{const E=se.trim();if(!(!E&&Z.length===0)){if(E){const _=Jn(E);if(_){G(_);return}}try{await I(E||"",{checkpointId:Ue??H??void 0,checkpointNs:ot??M??void 0,payloadExtras:q?{edit:!0,originalMessageId:q}:void 0,attachments:Z}),f==null||f(E),G(null),ge([]),Qe(),V(null),B("")}catch(_){const W=(_==null?void 0:_.message)||"Failed to send message";G(W),p==null||p(W)}}},Zn=y.useCallback((se,E)=>{u&&(V(se),B(E),G(null))},[u]),Nn=y.useCallback(()=>{V(null),B(""),G(null)},[]),Bt=y.useCallback((se,E)=>{Zn(se,E)},[Zn]),An=y.useCallback(se=>{const E=_=>{const W=_.content||[],ie=W.filter(pe=>pe.type==="text").map(pe=>pe.text).join("");if(ie)return ie;try{return JSON.stringify(W,null,2)}catch{return String(W)}};for(let _=se-1;_>=0;_--)if(N[_].role==="user"){const W=E(N[_]);W&&I(W,{checkpointId:Ue??H??void 0,checkpointNs:ot??M??void 0});break}},[N,I,Ue,ot,H,M]),Qn=se=>{const E=Array.from(se.target.files||[]);ge(_=>[..._,...E]),se.target.value=""},Yt=se=>{ge(E=>{const _=E.filter((W,ie)=>se!==ie);return _.length===0&&Qe(),_})},_n=async se=>{const E=(se.target.files||[])[0];if(E){U(null),ue(null),D(!0);try{await I("",{checkpointId:Ue??H??void 0,checkpointNs:ot??M??void 0,attachments:[E]});const _=`Uploaded ${E.name} - processing through chat stream`;ue(_)}catch(_){const W=_ instanceof Error?_.message:"Failed to upload Excel file";console.error("Excel upload failed",_),U(W),p==null||p(W)}finally{D(!1),se.target.value="",Qe()}}},jn=se=>{if(!se)return"Unknown";const E=Date.parse(se);return Number.isNaN(E)?se:new Date(E).toLocaleString()},er=async se=>{if(v){xe(!0);try{if(!se){await S(),st(null),ne(null);return}const E=Oe.find(W=>W.checkpointId===se),_=(E==null?void 0:E.checkpointNs)??null;await b(se,_),st(se),ne(_)}finally{xe(!1)}}},wr=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,br=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${d.messagesArea||""}`,to=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return c.jsxs("div",{className:wr,children:[!!L&&!$e&&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:L}),c.jsx(He,{variant:"ghost",size:"sm",onClick:()=>Ge(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(re.X,{size:16})})]}),v&&Oe.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:Ue??"",onChange:se=>{const E=se.target.value||null;er(E)},children:[c.jsx("option",{value:"",children:"Latest"}),Oe.map(se=>c.jsxs("option",{value:se.checkpointId,children:[jn(se.createdAt),se.preview?` — ${se.preview.slice(0,40)}`:""]},se.checkpointId))]})]}),c.jsxs("div",{className:`relative ${br}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(Zi,{className:"h-full",style:{height:"100%"},messages:N,isStreaming:P,streamingAssistantId:$,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:it,enableMessageEditing:u,editingMessageId:q,onStartReached:()=>{hn()},onEdit:Bt,onRegenerate:An,onCancelEdit:Nn,emptyMessage:qe??void 0,isNavigatingCheckpoint:le}),g&&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(re.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:to,children:[q&&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(re.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(He,{variant:"ghost",size:"sm",onClick:Nn,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(re.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:Se,type:"file",multiple:!0,onChange:se=>Qn(se),className:"hidden"},de),Z.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:Z.map((se,E)=>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(re.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:se.name}),c.jsx(He,{variant:"ghost",size:"sm",onClick:()=>Yt(E),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 ${se.name}`,children:c.jsx(re.X,{size:12})})]},E))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:be,type:"file",accept:".xls,.xlsx,.xlsm",onChange:_n,className:"hidden"},Ae),K&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(re.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),fe&&!K&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:fe}),J&&!K&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:J})]})]}),j&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:j}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(nS,{children:[c.jsx(rS,{asChild:!0,children:c.jsx(He,{type:"button",size:"icon",variant:"outline",disabled:P,title:"More input actions",className:d.moreButton||"",children:c.jsx(re.Plus,{size:16})})}),c.jsxs(Zf,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(Ca,{onClick:()=>{var se;return(se=Se.current)==null?void 0:se.click()},className:"cursor-pointer",children:[c.jsx(re.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(Ca,{onClick:()=>{var se;K||(se=be.current)==null||se.click()},className:`cursor-pointer ${K?"opacity-60 pointer-events-none":""}`,children:[c.jsx(re.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx(Ng,{initialValue:Y,editingMessageId:q,placeholder:q?"Edit your message...":t,isStreaming:P,disabled:!1,maxLength:rs,onSend:vr,onCancelEdit:Nn,onStop:A,allowEmptySend:Z.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${q?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${j?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const Ss=m.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:Q("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}));Ss.displayName="Input";function Ta(e,[t,n]){return Math.min(n,Math.max(t,e))}function uS(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var ka="ScrollArea",[Qf,QC]=en(ka),[dS,$t]=Qf(ka),eh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=m.useState(null),[u,d]=m.useState(null),[f,h]=m.useState(null),[p,w]=m.useState(null),[v,g]=m.useState(null),[x,b]=m.useState(0),[S,N]=m.useState(0),[C,k]=m.useState(!1),[I,A]=m.useState(!1),R=Le(t,L=>l(L)),P=os(o);return c.jsx(dS,{scope:n,type:r,dir:P,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:w,scrollbarXEnabled:C,onScrollbarXEnabledChange:k,scrollbarY:v,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:N,children:c.jsx(Ie.div,{dir:P,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});eh.displayName=ka;var th="ScrollAreaViewport",nh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=$t(th,n),a=m.useRef(null),l=Le(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})})]})});nh.displayName=th;var ln="ScrollAreaScrollbar",Ea=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=$t(ln,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return m.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?c.jsx(fS,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(hS,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(rh,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(Ia,{...r,ref:t}):null});Ea.displayName=ln;var fS=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=$t(ln,e.__scopeScrollArea),[s,i]=m.useState(!1);return m.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const u=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),c.jsx(jt,{present:n||s,children:c.jsx(rh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),hS=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=$t(ln,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Es(()=>l("SCROLL_END"),100),[a,l]=uS("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return m.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,l]),m.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const p=u[d];f!==p&&(l("SCROLL"),i()),f=p};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),c.jsx(jt,{present:n||a!=="hidden",children:c.jsx(Ia,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ce(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ce(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),rh=m.forwardRef((e,t)=>{const n=$t(ln,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",l=Es(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return mr(n.viewport,l),mr(n.content,l),c.jsx(jt,{present:r||s,children:c.jsx(Ia,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Ia=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=$t(ln,e.__scopeScrollArea),s=m.useRef(null),i=m.useRef(0),[a,l]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=lh(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 wS(h,i.current,a,p)}return n==="horizontal"?c.jsx(pS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=ch(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(mS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=ch(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}),pS=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=$t(ln,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Le(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(sh,{"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":ks(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),dh(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:Ts(i.paddingLeft),paddingEnd:Ts(i.paddingRight)}})}})}),mS=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=$t(ln,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Le(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(sh,{"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":ks(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),dh(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:Ts(i.paddingTop),paddingEnd:Ts(i.paddingBottom)}})}})}),[gS,oh]=Qf(ln),sh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,p=$t(ln,n),[w,v]=m.useState(null),g=Le(t,R=>v(R)),x=m.useRef(null),b=m.useRef(""),S=p.viewport,N=r.content-r.viewport,C=mt(d),k=mt(l),I=Es(f,10);function A(R){if(x.current){const P=R.clientX-x.current.left,L=R.clientY-x.current.top;u({x:P,y:L})}}return m.useEffect(()=>{const R=P=>{const L=P.target;(w==null?void 0:w.contains(L))&&C(P,N)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[S,w,N,C]),m.useEffect(k,[r,k]),mr(w,I),mr(p.content,I),c.jsx(gS,{scope:n,scrollbar:w,hasThumb:o,onThumbChange:mt(s),onThumbPointerUp:mt(i),onThumbPositionChange:k,onThumbPointerDown:mt(a),children:c.jsx(Ie.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:ce(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),x.current=w.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(R))}),onPointerMove:ce(e.onPointerMove,A),onPointerUp:ce(e.onPointerUp,R=>{const P=R.target;P.hasPointerCapture(R.pointerId)&&P.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),x.current=null})})})}),Cs="ScrollAreaThumb",ih=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=oh(Cs,e.__scopeScrollArea);return c.jsx(jt,{present:n||o.hasThumb,children:c.jsx(xS,{ref:t,...r})})}),xS=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=$t(Cs,n),i=oh(Cs,n),{onThumbPositionChange:a}=i,l=Le(t,f=>i.onThumbChange(f)),u=m.useRef(void 0),d=Es(()=>{u.current&&(u.current(),u.current=void 0)},100);return m.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const p=bS(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:ce(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),w=f.clientX-p.left,v=f.clientY-p.top;i.onThumbPointerDown({x:w,y:v})}),onPointerUp:ce(e.onPointerUp,i.onThumbPointerUp)})});ih.displayName=Cs;var Na="ScrollAreaCorner",ah=m.forwardRef((e,t)=>{const n=$t(Na,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(vS,{...e,ref:t}):null});ah.displayName=Na;var vS=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=$t(Na,n),[s,i]=m.useState(0),[a,l]=m.useState(0),u=!!(s&&a);return mr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),mr(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 Ts(e){return e?parseInt(e,10):0}function lh(e,t){const n=e/t;return isNaN(n)?0:n}function ks(e){const t=lh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function wS(e,t,n,r="ltr"){const o=ks(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 uh([l,u],f)(e)}function ch(e,t,n="ltr"){const r=ks(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=Ta(e,l);return uh([0,i],[0,a])(u)}function uh(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 dh(e,t){return e>0&&e<t}var bS=(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 Es(e,t){const n=mt(e),r=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),m.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function mr(e,t){const n=mt(t);pt(()=>{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 fh=eh,yS=nh,SS=ah;const hh=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(fh,{ref:r,className:Q("relative overflow-hidden",e),...n,children:[c.jsx(yS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(ph,{}),c.jsx(SS,{})]}));hh.displayName=fh.displayName;const ph=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(Ea,{ref:r,orientation:t,className:Q("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(ih,{className:"relative flex-1 rounded-full bg-border"})}));ph.displayName=Ea.displayName;function Aa({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{loadThread:f,threads:h,currentThreadId:p,createThread:w,deleteThread:v,renameThread:g,isLoadingThreads:x}=go(),[b,S]=y.useState(h??[]),[N,C]=y.useState(null),[k,I]=y.useState(""),[A,R]=y.useState(!1);y.useEffect(()=>{S(h??[])},[h]);const P=async j=>{try{await f(j),a==null||a(j),l==null||l(j)}catch(G){console.error("Failed to select thread:",G)}},L=async()=>{try{R(!0);const j=await w();u==null||u(j),a==null||a(j)}catch(j){console.error("Failed to create thread:",j)}finally{R(!1)}},$=async(j,G)=>{if(G.stopPropagation(),!!confirm("Delete this thread?"))try{await v(j),d==null||d(j)}catch(Z){console.error("Failed to delete thread:",Z)}},H=(j,G)=>{G.stopPropagation(),C(j.threadId),I(j.title||`Thread ${j.threadId.slice(0,8)}`)},M=async j=>{if(k.trim())try{await g(j,k.trim()),C(null),I("")}catch(G){console.error("Failed to update title:",G)}},q=()=>{C(null),I("")},V=(j,G)=>{j.key==="Enter"?M(G):j.key==="Escape"&&q()},Y=j=>{if(!j)return"";try{const G=new Date(j),ge=new Date().getTime()-G.getTime(),de=Math.floor(ge/(1e3*60*60*24));return de===0?G.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):de===1?"Yesterday":de<7?`${de} days ago`:G.toLocaleDateString()}catch{return""}},B=j=>j.title||`Thread ${j.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(He,{onClick:L,disabled:A||x,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:A?"Creating...":"New Chat",children:c.jsx(re.MessageSquarePlus,{size:20})})}),c.jsx(hh,{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:x?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(re.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):b.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(re.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"})]}):b.slice().sort((j,G)=>new Date(G.updatedAt||G.createdAt||"").getTime()-new Date(j.updatedAt||j.createdAt||"").getTime()).map(j=>c.jsxs("div",{onClick:()=>P(j.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??p)===j.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:N===j.threadId?c.jsxs("div",{className:"flex items-center gap-2",onClick:G=>G.stopPropagation(),children:[c.jsx(Ss,{value:k,onChange:G=>I(G.target.value),onKeyDown:G=>V(G,j.threadId),className:"h-6 text-sm",autoFocus:!0}),c.jsx(He,{variant:"ghost",size:"sm",onClick:()=>M(j.threadId),className:"h-6 w-6 p-0",children:c.jsx(re.Check,{size:12})}),c.jsx(He,{variant:"ghost",size:"sm",onClick:q,className:"h-6 w-6 p-0",children:c.jsx(re.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:B(j)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(re.Calendar,{size:10}),c.jsx("span",{children:Y(j.updatedAt||j.createdAt)})]})]})}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&N!==j.threadId&&c.jsx(He,{variant:"ghost",size:"sm",onClick:G=>H(j,G),className:"h-6 w-6 p-0",title:"Edit title",children:c.jsx(re.Edit3,{size:12})}),n&&c.jsx(He,{variant:"ghost",size:"sm",onClick:G=>$(j.threadId,G),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(re.Trash2,{size:12})})]})]}),i===j.threadId&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},j.threadId))})})]})}function gr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function CS(e){if(typeof e!="string")return;const t=e.trim();if(t)return cn(t)}function mh(){const e=[gr("__API_BASE_URL__"),gr("__CHAT_API_BASE_URL__"),gr("__CHAT_API_URL__")];for(const t of e){const n=CS(t);if(n)return n}}function gh(){const e=[gr("__API_AUTH_TOKEN__"),gr("__CHAT_API_KEY__"),gr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function xh(...e){for(const t of e)if(typeof t=="string"&&t.trim())return cn(t);return cn()}function vh(){const e={},t=mh(),n=gh();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function wh(){const e=vh(),t=mn.getAuthToken(),n=mh();return{apiBaseUrl:xh(e.baseUrl,mn.baseUrl,n),apiKey:t||e.apiKey||gh()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const bh="chat-settings";function TS(){try{const e=localStorage.getItem(bh);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function kS(e){try{const t={...e,apiBaseUrl:cn(e.apiBaseUrl)};localStorage.setItem(bh,JSON.stringify(t)),t.apiKey&&mn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function ES(){const e=wh(),t=TS(),n=mn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:xh(mn.baseUrl,r,e.apiBaseUrl)}}function IS(e){mn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),kS(e)}var NS="Label",yh=m.forwardRef((e,t)=>c.jsx(Ie.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));yh.displayName=NS;var Sh=yh;const AS=no.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ft=m.forwardRef(({className:e,...t},n)=>c.jsx(Sh,{ref:n,className:Q(AS(),e),...t}));Ft.displayName=Sh.displayName;function Ch(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Is="Switch",[_S,eT]=en(Is),[jS,RS]=_S(Is),Th=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:u,form:d,...f}=e,[h,p]=m.useState(null),w=Le(t,S=>p(S)),v=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[x,b]=Bn({prop:o,defaultProp:s??!1,onChange:u,caller:Is});return c.jsxs(jS,{scope:n,checked:x,disabled:a,children:[c.jsx(Ie.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":Nh(x),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:w,onClick:ce(e.onClick,S=>{b(N=>!N),g&&(v.current=S.isPropagationStopped(),v.current||S.stopPropagation())})}),g&&c.jsx(Ih,{control:h,bubbles:!v.current,name:r,value:l,checked:x,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Th.displayName=Is;var kh="SwitchThumb",Eh=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=RS(kh,n);return c.jsx(Ie.span,{"data-state":Nh(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Eh.displayName=kh;var PS="SwitchBubbleInput",Ih=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=Le(i,s),l=Ch(n),u=Ld(t);return m.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const w=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(w)}},[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}})});Ih.displayName=PS;function Nh(e){return e?"checked":"unchecked"}var Ah=Th,OS=Eh;const kn=m.forwardRef(({className:e,...t},n)=>c.jsx(Ah,{className:Q("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(OS,{className:Q("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")})}));kn.displayName=Ah.displayName;var _h=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"}),MS="VisuallyHidden",DS=m.forwardRef((e,t)=>c.jsx(Ie.span,{...e,ref:t,style:{..._h,...e.style}}));DS.displayName=MS;var LS=[" ","Enter","ArrowUp","ArrowDown"],$S=[" ","Enter"],Gn="Select",[Ns,As,FS]=Qi(Gn),[xr,tT]=en(Gn,[FS,ms]),_s=ms(),[BS,En]=xr(Gn),[zS,HS]=xr(Gn),jh=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:w}=e,v=_s(t),[g,x]=m.useState(null),[b,S]=m.useState(null),[N,C]=m.useState(!1),k=os(u),[I,A]=Bn({prop:r,defaultProp:o??!1,onChange:s,caller:Gn}),[R,P]=Bn({prop:i,defaultProp:a,onChange:l,caller:Gn}),L=m.useRef(null),$=g?w||!!g.closest("form"):!0,[H,M]=m.useState(new Set),q=Array.from(H).map(V=>V.props.value).join(";");return c.jsx(qd,{...v,children:c.jsxs(BS,{required:p,scope:t,trigger:g,onTriggerChange:x,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:N,onValueNodeHasChildrenChange:C,contentId:tn(),value:R,onValueChange:P,open:I,onOpenChange:A,dir:k,triggerPointerDownPosRef:L,disabled:h,children:[c.jsx(Ns.Provider,{scope:t,children:c.jsx(zS,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(V=>{M(Y=>new Set(Y).add(V))},[]),onNativeOptionRemove:m.useCallback(V=>{M(Y=>{const B=new Set(Y);return B.delete(V),B})},[]),children:n})}),$?c.jsxs(tp,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:R,onChange:V=>P(V.target.value),disabled:h,form:w,children:[R===void 0?c.jsx("option",{value:""}):null,Array.from(H)]},q):null]})})};jh.displayName=Gn;var Rh="SelectTrigger",Ph=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=_s(n),i=En(Rh,n),a=i.disabled||r,l=Le(t,i.onTriggerChange),u=As(n),d=m.useRef("touch"),[f,h,p]=rp(v=>{const g=u().filter(S=>!S.disabled),x=g.find(S=>S.value===i.value),b=op(g,v,x);b!==void 0&&i.onValueChange(b.value)}),w=v=>{a||(i.onOpenChange(!0),p()),v&&(i.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return c.jsx(Gd,{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":np(i.value)?"":void 0,...o,ref:l,onClick:ce(o.onClick,v=>{v.currentTarget.focus(),d.current!=="mouse"&&w(v)}),onPointerDown:ce(o.onPointerDown,v=>{d.current=v.pointerType;const g=v.target;g.hasPointerCapture(v.pointerId)&&g.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(w(v),v.preventDefault())}),onKeyDown:ce(o.onKeyDown,v=>{const g=f.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&h(v.key),!(g&&v.key===" ")&&LS.includes(v.key)&&(w(),v.preventDefault())})})})});Ph.displayName=Rh;var Oh="SelectValue",Mh=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=En(Oh,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=Le(t,l.onValueNodeChange);return pt(()=>{u(d)},[u,d]),c.jsx(Ie.span,{...a,ref:f,style:{pointerEvents:"none"},children:np(l.value)?c.jsx(c.Fragment,{children:i}):s})});Mh.displayName=Oh;var US="SelectIcon",Dh=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(Ie.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Dh.displayName=US;var WS="SelectPortal",Lh=e=>c.jsx(Ho,{asChild:!0,...e});Lh.displayName=WS;var Yn="SelectContent",$h=m.forwardRef((e,t)=>{const n=En(Yn,e.__scopeSelect),[r,o]=m.useState();if(pt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?ro.createPortal(c.jsx(Fh,{scope:e.__scopeSelect,children:c.jsx(Ns.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(Bh,{...e,ref:t})});$h.displayName=Yn;var Gt=10,[Fh,In]=xr(Yn),VS="SelectContentImpl",KS=Rn.createSlot("SelectContent.RemoveScroll"),Bh=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:w,hideWhenDetached:v,avoidCollisions:g,...x}=e,b=En(Yn,n),[S,N]=m.useState(null),[C,k]=m.useState(null),I=Le(t,K=>N(K)),[A,R]=m.useState(null),[P,L]=m.useState(null),$=As(n),[H,M]=m.useState(!1),q=m.useRef(!1);m.useEffect(()=>{if(S)return qi(S)},[S]),zi();const V=m.useCallback(K=>{const[D,...J]=$().map(ue=>ue.ref.current),[U]=J.slice(-1),fe=document.activeElement;for(const ue of K)if(ue===fe||(ue==null||ue.scrollIntoView({block:"nearest"}),ue===D&&C&&(C.scrollTop=0),ue===U&&C&&(C.scrollTop=C.scrollHeight),ue==null||ue.focus(),document.activeElement!==fe))return},[$,C]),Y=m.useCallback(()=>V([A,S]),[V,A,S]);m.useEffect(()=>{H&&Y()},[H,Y]);const{onOpenChange:B,triggerPointerDownPosRef:j}=b;m.useEffect(()=>{if(S){let K={x:0,y:0};const D=U=>{var fe,ue;K={x:Math.abs(Math.round(U.pageX)-(((fe=j.current)==null?void 0:fe.x)??0)),y:Math.abs(Math.round(U.pageY)-(((ue=j.current)==null?void 0:ue.y)??0))}},J=U=>{K.x<=10&&K.y<=10?U.preventDefault():S.contains(U.target)||B(!1),document.removeEventListener("pointermove",D),j.current=null};return j.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",J,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",J,{capture:!0})}}},[S,B,j]),m.useEffect(()=>{const K=()=>B(!1);return window.addEventListener("blur",K),window.addEventListener("resize",K),()=>{window.removeEventListener("blur",K),window.removeEventListener("resize",K)}},[B]);const[G,Z]=rp(K=>{const D=$().filter(fe=>!fe.disabled),J=D.find(fe=>fe.ref.current===document.activeElement),U=op(D,K,J);U&&setTimeout(()=>U.ref.current.focus())}),ge=m.useCallback((K,D,J)=>{const U=!q.current&&!J;(b.value!==void 0&&b.value===D||U)&&(R(K),U&&(q.current=!0))},[b.value]),de=m.useCallback(()=>S==null?void 0:S.focus(),[S]),ee=m.useCallback((K,D,J)=>{const U=!q.current&&!J;(b.value!==void 0&&b.value===D||U)&&L(K)},[b.value]),Ae=r==="popper"?_a:zh,Te=Ae===_a?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:w,hideWhenDetached:v,avoidCollisions:g}:{};return c.jsx(Fh,{scope:n,content:S,viewport:C,onViewportChange:k,itemRefCallback:ge,selectedItem:A,onItemLeave:de,itemTextRefCallback:ee,focusSelectedItem:Y,selectedItemText:P,position:r,isPositioned:H,searchRef:G,children:c.jsx(Go,{as:KS,allowPinchZoom:!0,children:c.jsx(zo,{asChild:!0,trapped:b.open,onMountAutoFocus:K=>{K.preventDefault()},onUnmountAutoFocus:ce(o,K=>{var D;(D=b.trigger)==null||D.focus({preventScroll:!0}),K.preventDefault()}),children:c.jsx(Bo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:K=>K.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:c.jsx(Ae,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:K=>K.preventDefault(),...x,...Te,onPlaced:()=>M(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:ce(x.onKeyDown,K=>{const D=K.ctrlKey||K.altKey||K.metaKey;if(K.key==="Tab"&&K.preventDefault(),!D&&K.key.length===1&&Z(K.key),["ArrowUp","ArrowDown","Home","End"].includes(K.key)){let U=$().filter(fe=>!fe.disabled).map(fe=>fe.ref.current);if(["ArrowUp","End"].includes(K.key)&&(U=U.slice().reverse()),["ArrowUp","ArrowDown"].includes(K.key)){const fe=K.target,ue=U.indexOf(fe);U=U.slice(ue+1)}setTimeout(()=>V(U)),K.preventDefault()}})})})})})})});Bh.displayName=VS;var qS="SelectItemAlignedPosition",zh=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=En(Yn,n),i=In(Yn,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=Le(t,I=>d(I)),h=As(n),p=m.useRef(!1),w=m.useRef(!0),{viewport:v,selectedItem:g,selectedItemText:x,focusSelectedItem:b}=i,S=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&v&&g&&x){const I=s.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),P=x.getBoundingClientRect();if(s.dir!=="rtl"){const fe=P.left-A.left,ue=R.left-fe,$e=I.left-ue,Ge=I.width+$e,qe=Math.max(Ge,A.width),ke=window.innerWidth-Gt,Oe=Ta(ue,[Gt,Math.max(Gt,ke-qe)]);a.style.minWidth=Ge+"px",a.style.left=Oe+"px"}else{const fe=A.right-P.right,ue=window.innerWidth-R.right-fe,$e=window.innerWidth-I.right-ue,Ge=I.width+$e,qe=Math.max(Ge,A.width),ke=window.innerWidth-Gt,Oe=Ta(ue,[Gt,Math.max(Gt,ke-qe)]);a.style.minWidth=Ge+"px",a.style.right=Oe+"px"}const L=h(),$=window.innerHeight-Gt*2,H=v.scrollHeight,M=window.getComputedStyle(u),q=parseInt(M.borderTopWidth,10),V=parseInt(M.paddingTop,10),Y=parseInt(M.borderBottomWidth,10),B=parseInt(M.paddingBottom,10),j=q+V+H+B+Y,G=Math.min(g.offsetHeight*5,j),Z=window.getComputedStyle(v),ge=parseInt(Z.paddingTop,10),de=parseInt(Z.paddingBottom,10),ee=I.top+I.height/2-Gt,Ae=$-ee,Te=g.offsetHeight/2,K=g.offsetTop+Te,D=q+V+K,J=j-D;if(D<=ee){const fe=L.length>0&&g===L[L.length-1].ref.current;a.style.bottom="0px";const ue=u.clientHeight-v.offsetTop-v.offsetHeight,$e=Math.max(Ae,Te+(fe?de:0)+ue+Y),Ge=D+$e;a.style.height=Ge+"px"}else{const fe=L.length>0&&g===L[0].ref.current;a.style.top="0px";const $e=Math.max(ee,q+v.offsetTop+(fe?ge:0)+Te)+J;a.style.height=$e+"px",v.scrollTop=D-ee+v.offsetTop}a.style.margin=`${Gt}px 0`,a.style.minHeight=G+"px",a.style.maxHeight=$+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,v,g,x,s.dir,r]);pt(()=>S(),[S]);const[N,C]=m.useState();pt(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const k=m.useCallback(I=>{I&&w.current===!0&&(S(),b==null||b(),w.current=!1)},[S,b]);return c.jsx(YS,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:k,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:N},children:c.jsx(Ie.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});zh.displayName=qS;var GS="SelectPopperPosition",_a=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Gt,...s}=e,i=_s(n);return c.jsx(Yd,{...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)"}})});_a.displayName=GS;var[YS,ja]=xr(Yn,{}),Ra="SelectViewport",Hh=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=In(Ra,n),i=ja(Ra,n),a=Le(t,s.onViewportChange),l=m.useRef(0);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),c.jsx(Ns.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:ce(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 w=window.innerHeight-Gt*2,v=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),x=Math.max(v,g);if(x<w){const b=x+p,S=Math.min(w,b),N=b-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=N>0?N:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Hh.displayName=Ra;var Uh="SelectGroup",[XS,JS]=xr(Uh),ZS=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=tn();return c.jsx(XS,{scope:n,id:o,children:c.jsx(Ie.div,{role:"group","aria-labelledby":o,...r,ref:t})})});ZS.displayName=Uh;var Wh="SelectLabel",Vh=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=JS(Wh,n);return c.jsx(Ie.div,{id:o.id,...r,ref:t})});Vh.displayName=Wh;var js="SelectItem",[QS,Kh]=xr(js),qh=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=En(js,n),l=In(js,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),w=Le(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),v=tn(),g=m.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 c.jsx(QS,{scope:n,value:r,disabled:o,textId:v,isSelected:u,onItemTextChange:m.useCallback(b=>{f(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:c.jsx(Ns.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:w,onFocus:ce(i.onFocus,()=>p(!0)),onBlur:ce(i.onBlur,()=>p(!1)),onClick:ce(i.onClick,()=>{g.current!=="mouse"&&x()}),onPointerUp:ce(i.onPointerUp,()=>{g.current==="mouse"&&x()}),onPointerDown:ce(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:ce(i.onPointerMove,b=>{var S;g.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):g.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ce(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ce(i.onKeyDown,b=>{var N;((N=l.searchRef)==null?void 0:N.current)!==""&&b.key===" "||($S.includes(b.key)&&x(),b.key===" "&&b.preventDefault())})})})})});qh.displayName=js;var eo="SelectItemText",Gh=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=En(eo,n),a=In(eo,n),l=Kh(eo,n),u=HS(eo,n),[d,f]=m.useState(null),h=Le(t,x=>f(x),l.onItemTextChange,x=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,x,l.value,l.disabled)}),p=d==null?void 0:d.textContent,w=m.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:v,onNativeOptionRemove:g}=u;return pt(()=>(v(w),()=>g(w)),[v,g,w]),c.jsxs(c.Fragment,{children:[c.jsx(Ie.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?ro.createPortal(s.children,i.valueNode):null]})});Gh.displayName=eo;var Yh="SelectItemIndicator",Xh=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Kh(Yh,n).isSelected?c.jsx(Ie.span,{"aria-hidden":!0,...r,ref:t}):null});Xh.displayName=Yh;var Pa="SelectScrollUpButton",Jh=m.forwardRef((e,t)=>{const n=In(Pa,e.__scopeSelect),r=ja(Pa,e.__scopeSelect),[o,s]=m.useState(!1),i=Le(t,r.onScrollButtonChange);return pt(()=>{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(Qh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Jh.displayName=Pa;var Oa="SelectScrollDownButton",Zh=m.forwardRef((e,t)=>{const n=In(Oa,e.__scopeSelect),r=ja(Oa,e.__scopeSelect),[o,s]=m.useState(!1),i=Le(t,r.onScrollButtonChange);return pt(()=>{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(Qh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Zh.displayName=Oa;var Qh=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=In("SelectScrollButton",n),i=m.useRef(null),a=As(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),pt(()=>{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:ce(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ce(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ce(o.onPointerLeave,()=>{l()})})}),eC="SelectSeparator",ep=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(Ie.div,{"aria-hidden":!0,...r,ref:t})});ep.displayName=eC;var Ma="SelectArrow",tC=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_s(n),s=En(Ma,n),i=In(Ma,n);return s.open&&i.position==="popper"?c.jsx(Xd,{...o,...r,ref:t}):null});tC.displayName=Ma;var nC="SelectBubbleInput",tp=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=Le(r,o),i=Ch(t);return m.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(Ie.select,{...n,style:{..._h,...n.style},ref:s,defaultValue:t})});tp.displayName=nC;function np(e){return e===""||e===void 0}function rp(e){const t=mt(e),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(i=>{const a=n.current+i;t(a),function l(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function op(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=rC(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 rC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var oC=jh,sp=Ph,sC=Mh,iC=Dh,aC=Lh,ip=$h,lC=Hh,ap=Vh,lp=qh,cC=Gh,uC=Xh,cp=Jh,up=Zh,dp=ep;const fp=oC,hp=sC,Da=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(sp,{ref:r,className:Q("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(iC,{asChild:!0,children:c.jsx(re.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Da.displayName=sp.displayName;const pp=m.forwardRef(({className:e,...t},n)=>c.jsx(cp,{ref:n,className:Q("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(re.ChevronUp,{className:"h-4 w-4"})}));pp.displayName=cp.displayName;const mp=m.forwardRef(({className:e,...t},n)=>c.jsx(up,{ref:n,className:Q("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(re.ChevronDown,{className:"h-4 w-4"})}));mp.displayName=up.displayName;const La=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(aC,{children:c.jsxs(ip,{ref:o,className:Q("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(pp,{}),c.jsx(lC,{className:Q("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(mp,{})]})}));La.displayName=ip.displayName;const dC=m.forwardRef(({className:e,...t},n)=>c.jsx(ap,{ref:n,className:Q("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));dC.displayName=ap.displayName;const Xn=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(lp,{ref:r,className:Q("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(uC,{children:c.jsx(re.Check,{className:"h-4 w-4"})})}),c.jsx(cC,{children:t})]}));Xn.displayName=lp.displayName;const fC=m.forwardRef(({className:e,...t},n)=>c.jsx(dp,{ref:n,className:Q("-mx-1 my-1 h-px bg-muted",e),...t}));fC.displayName=dp.displayName;var hC="Separator",gp="horizontal",pC=["horizontal","vertical"],xp=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=gp,...o}=e,s=mC(r)?r:gp,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})});xp.displayName=hC;function mC(e){return pC.includes(e)}var vp=xp;const wp=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(vp,{ref:o,decorative:n,orientation:t,className:Q("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));wp.displayName=vp.displayName;const gC=td,xC=Xw,vC=nd,bp=m.forwardRef(({className:e,...t},n)=>c.jsx(Qo,{className:Q("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}));bp.displayName=Qo.displayName;const wC=no.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"}}),yp=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(vC,{children:[c.jsx(bp,{}),c.jsxs(es,{ref:o,className:Q(wC({side:e}),t),...r,children:[n,c.jsxs(rd,{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(re.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));yp.displayName=es.displayName;const Sp=({className:e,...t})=>c.jsx("div",{className:Q("flex flex-col space-y-2 text-center sm:text-left",e),...t});Sp.displayName="SheetHeader";const Cp=m.forwardRef(({className:e,...t},n)=>c.jsx(Un,{ref:n,className:Q("text-lg font-semibold text-foreground",e),...t}));Cp.displayName=Un.displayName;const Tp=m.forwardRef(({className:e,...t},n)=>c.jsx(ts,{ref:n,className:Q("text-sm text-muted-foreground",e),...t}));Tp.displayName=ts.displayName;const bC={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 yC({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=y.useState(!1),[s,i]=y.useState(!1),[a,l]=y.useState(e),[u,d]=y.useState(!1),{toast:f}=Di();y.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),y.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(bC),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},w=()=>{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 c.jsxs(gC,{open:r,onOpenChange:o,children:[c.jsx(xC,{asChild:!0,children:c.jsxs(He,{variant:"outline",size:"sm",className:n,children:[c.jsx(re.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(Ei,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(yp,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(Sp,{children:[c.jsx(Cp,{children:"Chat Settings"}),c.jsx(Tp,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),c.jsxs("div",{className:"space-y-6 py-6",children:[c.jsxs(Br,{children:[c.jsx(zr,{className:"pb-3",children:c.jsxs(Hr,{className:"text-lg flex items-center gap-2",children:[c.jsx(re.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(Ft,{htmlFor:"api-url",children:"API Base URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ss,{id:"api-url",value:a.api.baseUrl,onChange:g=>l(x=>({...x,api:{...x.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(He,{variant:"outline",onClick:v,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Ft,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(kn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>l(x=>({...x,api:{...x.api,enableAuth:g}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ft,{htmlFor:"auth-token",children:"Authentication Token"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ss,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>l(x=>({...x,api:{...x.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(He,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(re.EyeOff,{className:"h-4 w-4"}):c.jsx(re.Eye,{className:"h-4 w-4"})})]})]})]})]}),c.jsxs(Br,{children:[c.jsx(zr,{className:"pb-3",children:c.jsxs(Hr,{className:"text-lg flex items-center gap-2",children:[c.jsx(re.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(Ft,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(fp,{value:a.ui.layout,onValueChange:g=>l(x=>({...x,ui:{...x.ui,layout:g}})),children:[c.jsx(Da,{children:c.jsx(hp,{})}),c.jsxs(La,{children:[c.jsx(Xn,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(Xn,{value:"fullscreen",children:"Fullscreen"}),c.jsx(Xn,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ft,{htmlFor:"theme",children:"Theme"}),c.jsxs(fp,{value:a.ui.theme,onValueChange:g=>l(x=>({...x,ui:{...x.ui,theme:g}})),children:[c.jsx(Da,{children:c.jsx(hp,{})}),c.jsxs(La,{children:[c.jsx(Xn,{value:"light",children:"Light"}),c.jsx(Xn,{value:"dark",children:"Dark"}),c.jsx(Xn,{value:"system",children:"System"})]})]})]}),c.jsx(wp,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Ft,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(kn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,showTimestamps:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Ft,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(kn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,showAgentNames:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Ft,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(kn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,compactMessages:g}}))})]})]})]})]}),c.jsxs(Br,{children:[c.jsx(zr,{className:"pb-3",children:c.jsxs(Hr,{className:"text-lg flex items-center gap-2",children:[c.jsx(re.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(Ft,{htmlFor:"auto-save",children:"Auto-save Conversations"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),c.jsx(kn,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,autoSave:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Ft,{htmlFor:"enable-streaming",children:"Enable Streaming"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),c.jsx(kn,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,enableStreaming:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Ft,{htmlFor:"typing-indicator",children:"Typing Indicator"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),c.jsx(kn,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,showTypingIndicator:g}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(He,{variant:"outline",onClick:p,children:[c.jsx(re.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(He,{variant:"outline",onClick:w,children:"Cancel"}),c.jsxs(He,{onClick:h,disabled:!u,children:[c.jsx(re.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function SC({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=y.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?c.jsx(xo,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsx(ys,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?c.jsx(xo,{...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(Aa,{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(ys,{onError:s.onError,enableFileUpload:!0})})]})})}):c.jsx(xo,{...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(Aa,{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(ys,{onError:s.onError,enableFileUpload:!0})})]})})}Ne.ChatApi=Rl,Ne.ChatInterface=ys,Ne.ChatProviders=xo,Ne.ChatSettings=yC,Ne.MarkdownContent=Pi,Ne.MessageComponent=fd,Ne.MessageList=Zi,Ne.ThreadManager=Aa,Ne.applySettings=IS,Ne.chatApiClient=mn,Ne.default=SC,Ne.del=jl,Ne.get=It,Ne.getChatToken=Nl,Ne.getCurrentSettings=ES,Ne.getDefaultApiConfig=vh,Ne.getDefaultChatSettings=wh,Ne.onChatTokenChanged=Al,Ne.post=qs,Ne.put=_l,Ne.setChatToken=Ks,Ne.useApi=Gs,Ne.useChatStream=Dl,Ne.useMessages=ni,Ne.useMessagesReducer=Ol,Ne.useStream=Vl,Ne.useThreads=go,Object.defineProperties(Ne,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});