teodor-new-chat-ui 4.3.21 → 4.3.23

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(_e,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom"],w):(_e=typeof globalThis<"u"?globalThis:_e||self,w(_e.NewChatUI={},_e.React,_e.LucideReact,_e.reactSlot,_e.classVarianceAuthority,_e.clsx,_e.tailwindMerge,_e.ReactDOM))})(this,function(_e,w,ae,tr,Io,Tm,km,li){"use strict";var RT=Object.defineProperty;var PT=(_e,w,ae)=>w in _e?RT(_e,w,{enumerable:!0,configurable:!0,writable:!0,value:ae}):_e[w]=ae;var Sm=(_e,w,ae)=>PT(_e,typeof w!="symbol"?w+"":w,ae);function Sl(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=Sl(w),No=Sl(li);var ci={exports:{}},Wr={};/**
1
+ (function(_e,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom"],w):(_e=typeof globalThis<"u"?globalThis:_e||self,w(_e.NewChatUI={},_e.React,_e.LucideReact,_e.reactSlot,_e.classVarianceAuthority,_e.clsx,_e.tailwindMerge,_e.ReactDOM))})(this,function(_e,w,ae,rr,Ao,km,Em,ci){"use strict";var PT=Object.defineProperty;var OT=(_e,w,ae)=>w in _e?PT(_e,w,{enumerable:!0,configurable:!0,writable:!0,value:ae}):_e[w]=ae;var Cm=(_e,w,ae)=>OT(_e,typeof w!="symbol"?w+"":w,ae);function Sl(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=Sl(w),_o=Sl(ci);var ui={exports:{}},Kr={};/**
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 Cl;function Em(){if(Cl)return Wr;Cl=1;var e=w,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,l,u){var d,f={},h=null,p=null;u!==void 0&&(h=""+u),l.key!==void 0&&(h=""+l.key),l.ref!==void 0&&(p=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(f[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)f[d]===void 0&&(f[d]=l[d]);return{$$typeof:t,type:a,key:h,ref:p,props:f,_owner:o.current}}return Wr.Fragment=n,Wr.jsx=i,Wr.jsxs=i,Wr}var Vr={};/**
9
+ */var Cl;function Im(){if(Cl)return Kr;Cl=1;var e=w,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,l,u){var d,f={},h=null,p=null;u!==void 0&&(h=""+u),l.key!==void 0&&(h=""+l.key),l.ref!==void 0&&(p=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(f[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)f[d]===void 0&&(f[d]=l[d]);return{$$typeof:t,type:a,key:h,ref:p,props:f,_owner:o.current}}return Kr.Fragment=n,Kr.jsx=i,Kr.jsxs=i,Kr}var qr={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,41 +14,41 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var Tl;function Im(){return Tl||(Tl=1,process.env.NODE_ENV!=="production"&&function(){var e=w,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),v=Symbol.iterator,x="@@iterator";function g(E){if(E===null||typeof E!="object")return null;var H=v&&E[v]||E[x];return typeof H=="function"?H:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(E){{for(var H=arguments.length,oe=new Array(H>1?H-1:0),ke=1;ke<H;ke++)oe[ke-1]=arguments[ke];S("error",E,oe)}}function S(E,H,oe){{var ke=y.ReactDebugCurrentFrame,Ge=ke.getStackAddendum();Ge!==""&&(H+="%s",oe=oe.concat([Ge]));var Qe=oe.map(function(Ue){return String(Ue)});Qe.unshift("Warning: "+H),Function.prototype.apply.call(console[E],console,Qe)}}var k=!1,C=!1,T=!1,I=!1,A=!1,j;j=Symbol.for("react.module.reference");function P(E){return!!(typeof E=="string"||typeof E=="function"||E===r||E===s||A||E===o||E===u||E===d||I||E===p||k||C||T||typeof E=="object"&&E!==null&&(E.$$typeof===h||E.$$typeof===f||E.$$typeof===i||E.$$typeof===a||E.$$typeof===l||E.$$typeof===j||E.getModuleId!==void 0))}function D(E,H,oe){var ke=E.displayName;if(ke)return ke;var Ge=H.displayName||H.name||"";return Ge!==""?oe+"("+Ge+")":oe}function L(E){return E.displayName||"Context"}function B(E){if(E==null)return null;if(typeof E.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof E=="function")return E.displayName||E.name||null;if(typeof E=="string")return E;switch(E){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case u:return"Suspense";case d:return"SuspenseList"}if(typeof E=="object")switch(E.$$typeof){case a:var H=E;return L(H)+".Consumer";case i:var oe=E;return L(oe._context)+".Provider";case l:return D(E,E.render,"ForwardRef");case f:var ke=E.displayName||null;return ke!==null?ke:B(E.type)||"Memo";case h:{var Ge=E,Qe=Ge._payload,Ue=Ge._init;try{return B(Ue(Qe))}catch{return null}}}return null}var M=Object.assign,X=0,W,V,z,$,pe,F,Z;function he(){}he.__reactDisabledLog=!0;function ve(){{if(X===0){W=console.log,V=console.info,z=console.warn,$=console.error,pe=console.group,F=console.groupCollapsed,Z=console.groupEnd;var E={configurable:!0,enumerable:!0,value:he,writable:!0};Object.defineProperties(console,{info:E,log:E,warn:E,error:E,group:E,groupCollapsed:E,groupEnd:E})}X++}}function be(){{if(X--,X===0){var E={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:M({},E,{value:W}),info:M({},E,{value:V}),warn:M({},E,{value:z}),error:M({},E,{value:$}),group:M({},E,{value:pe}),groupCollapsed:M({},E,{value:F}),groupEnd:M({},E,{value:Z})})}X<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Te=y.ReactCurrentDispatcher,K;function O(E,H,oe){{if(K===void 0)try{throw Error()}catch(Ge){var ke=Ge.stack.trim().match(/\n( *(at )?)/);K=ke&&ke[1]||""}return`
18
- `+K+E}}var J=!1,te;{var de=typeof WeakMap=="function"?WeakMap:Map;te=new de}function le(E,H){if(!E||J)return"";{var oe=te.get(E);if(oe!==void 0)return oe}var ke;J=!0;var Ge=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Qe;Qe=Te.current,Te.current=null,ve();try{if(H){var Ue=function(){throw Error()};if(Object.defineProperty(Ue.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ue,[])}catch(kt){ke=kt}Reflect.construct(E,[],Ue)}else{try{Ue.call()}catch(kt){ke=kt}E.call(Ue.prototype)}}else{try{throw Error()}catch(kt){ke=kt}E()}}catch(kt){if(kt&&ke&&typeof kt.stack=="string"){for(var je=kt.stack.split(`
17
+ */var Tl;function Nm(){return Tl||(Tl=1,process.env.NODE_ENV!=="production"&&function(){var e=w,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),v=Symbol.iterator,x="@@iterator";function g(E){if(E===null||typeof E!="object")return null;var H=v&&E[v]||E[x];return typeof H=="function"?H:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(E){{for(var H=arguments.length,re=new Array(H>1?H-1:0),ke=1;ke<H;ke++)re[ke-1]=arguments[ke];S("error",E,re)}}function S(E,H,re){{var ke=y.ReactDebugCurrentFrame,qe=ke.getStackAddendum();qe!==""&&(H+="%s",re=re.concat([qe]));var Ze=re.map(function(He){return String(He)});Ze.unshift("Warning: "+H),Function.prototype.apply.call(console[E],console,Ze)}}var k=!1,C=!1,T=!1,I=!1,A=!1,j;j=Symbol.for("react.module.reference");function P(E){return!!(typeof E=="string"||typeof E=="function"||E===r||E===s||A||E===o||E===u||E===d||I||E===p||k||C||T||typeof E=="object"&&E!==null&&(E.$$typeof===h||E.$$typeof===f||E.$$typeof===i||E.$$typeof===a||E.$$typeof===l||E.$$typeof===j||E.getModuleId!==void 0))}function D(E,H,re){var ke=E.displayName;if(ke)return ke;var qe=H.displayName||H.name||"";return qe!==""?re+"("+qe+")":re}function L(E){return E.displayName||"Context"}function B(E){if(E==null)return null;if(typeof E.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof E=="function")return E.displayName||E.name||null;if(typeof E=="string")return E;switch(E){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case u:return"Suspense";case d:return"SuspenseList"}if(typeof E=="object")switch(E.$$typeof){case a:var H=E;return L(H)+".Consumer";case i:var re=E;return L(re._context)+".Provider";case l:return D(E,E.render,"ForwardRef");case f:var ke=E.displayName||null;return ke!==null?ke:B(E.type)||"Memo";case h:{var qe=E,Ze=qe._payload,He=qe._init;try{return B(He(Ze))}catch{return null}}}return null}var M=Object.assign,X=0,W,V,z,$,pe,F,Q;function he(){}he.__reactDisabledLog=!0;function ve(){{if(X===0){W=console.log,V=console.info,z=console.warn,$=console.error,pe=console.group,F=console.groupCollapsed,Q=console.groupEnd;var E={configurable:!0,enumerable:!0,value:he,writable:!0};Object.defineProperties(console,{info:E,log:E,warn:E,error:E,group:E,groupCollapsed:E,groupEnd:E})}X++}}function be(){{if(X--,X===0){var E={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:M({},E,{value:W}),info:M({},E,{value:V}),warn:M({},E,{value:z}),error:M({},E,{value:$}),group:M({},E,{value:pe}),groupCollapsed:M({},E,{value:F}),groupEnd:M({},E,{value:Q})})}X<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Te=y.ReactCurrentDispatcher,q;function O(E,H,re){{if(q===void 0)try{throw Error()}catch(qe){var ke=qe.stack.trim().match(/\n( *(at )?)/);q=ke&&ke[1]||""}return`
18
+ `+q+E}}var J=!1,te;{var de=typeof WeakMap=="function"?WeakMap:Map;te=new de}function le(E,H){if(!E||J)return"";{var re=te.get(E);if(re!==void 0)return re}var ke;J=!0;var qe=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Ze;Ze=Te.current,Te.current=null,ve();try{if(H){var He=function(){throw Error()};if(Object.defineProperty(He.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(He,[])}catch(kt){ke=kt}Reflect.construct(E,[],He)}else{try{He.call()}catch(kt){ke=kt}E.call(He.prototype)}}else{try{throw Error()}catch(kt){ke=kt}E()}}catch(kt){if(kt&&ke&&typeof kt.stack=="string"){for(var je=kt.stack.split(`
19
19
  `),St=ke.stack.split(`
20
- `),dt=je.length-1,pt=St.length-1;dt>=1&&pt>=0&&je[dt]!==St[pt];)pt--;for(;dt>=1&&pt>=0;dt--,pt--)if(je[dt]!==St[pt]){if(dt!==1||pt!==1)do if(dt--,pt--,pt<0||je[dt]!==St[pt]){var Mt=`
21
- `+je[dt].replace(" at new "," at ");return E.displayName&&Mt.includes("<anonymous>")&&(Mt=Mt.replace("<anonymous>",E.displayName)),typeof E=="function"&&te.set(E,Mt),Mt}while(dt>=1&&pt>=0);break}}}finally{J=!1,Te.current=Qe,be(),Error.prepareStackTrace=Ge}var On=E?E.displayName||E.name:"",Kt=On?O(On):"";return typeof E=="function"&&te.set(E,Kt),Kt}function ie(E,H,oe){return le(E,!1)}function tt(E){var H=E.prototype;return!!(H&&H.isReactComponent)}function et(E,H,oe){if(E==null)return"";if(typeof E=="function")return le(E,tt(E));if(typeof E=="string")return O(E);switch(E){case u:return O("Suspense");case d:return O("SuspenseList")}if(typeof E=="object")switch(E.$$typeof){case l:return ie(E.render);case f:return et(E.type,H,oe);case h:{var ke=E,Ge=ke._payload,Qe=ke._init;try{return et(Qe(Ge),H,oe)}catch{}}}return""}var Oe=Object.prototype.hasOwnProperty,He={},ht=y.ReactDebugCurrentFrame;function nt(E){if(E){var H=E._owner,oe=et(E.type,E._source,H?H.type:null);ht.setExtraStackFrame(oe)}else ht.setExtraStackFrame(null)}function Me(E,H,oe,ke,Ge){{var Qe=Function.call.bind(Oe);for(var Ue in E)if(Qe(E,Ue)){var je=void 0;try{if(typeof E[Ue]!="function"){var St=Error((ke||"React class")+": "+oe+" type `"+Ue+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof E[Ue]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw St.name="Invariant Violation",St}je=E[Ue](H,Ue,ke,oe,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(dt){je=dt}je&&!(je instanceof Error)&&(nt(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).",ke||"React class",oe,Ue,typeof je),nt(null)),je instanceof Error&&!(je.message in He)&&(He[je.message]=!0,nt(Ge),b("Failed %s type: %s",oe,je.message),nt(null))}}}var bt=Array.isArray;function ne(E){return bt(E)}function se(E){{var H=typeof Symbol=="function"&&Symbol.toStringTag,oe=H&&E[Symbol.toStringTag]||E.constructor.name||"Object";return oe}}function ge(E){try{return we(E),!1}catch{return!0}}function we(E){return""+E}function xe(E){if(ge(E))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",se(E)),we(E)}var ze=y.ReactCurrentOwner,st={key:!0,ref:!0,__self:!0,__source:!0},Fe,ut;function xt(E){if(Oe.call(E,"ref")){var H=Object.getOwnPropertyDescriptor(E,"ref").get;if(H&&H.isReactWarning)return!1}return E.ref!==void 0}function Ot(E){if(Oe.call(E,"key")){var H=Object.getOwnPropertyDescriptor(E,"key").get;if(H&&H.isReactWarning)return!1}return E.key!==void 0}function tn(E,H){typeof E.ref=="string"&&ze.current}function Hr(E,H){{var oe=function(){Fe||(Fe=!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)",H))};oe.isReactWarning=!0,Object.defineProperty(E,"key",{get:oe,configurable:!0})}}function Yn(E,H){{var oe=function(){ut||(ut=!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)",H))};oe.isReactWarning=!0,Object.defineProperty(E,"ref",{get:oe,configurable:!0})}}var Tn=function(E,H,oe,ke,Ge,Qe,Ue){var je={$$typeof:t,type:E,key:H,ref:oe,props:Ue,_owner:Qe};return je._store={},Object.defineProperty(je._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(je,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ke}),Object.defineProperty(je,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Ge}),Object.freeze&&(Object.freeze(je.props),Object.freeze(je)),je};function Xn(E,H,oe,ke,Ge){{var Qe,Ue={},je=null,St=null;oe!==void 0&&(xe(oe),je=""+oe),Ot(H)&&(xe(H.key),je=""+H.key),xt(H)&&(St=H.ref,tn(H,Ge));for(Qe in H)Oe.call(H,Qe)&&!st.hasOwnProperty(Qe)&&(Ue[Qe]=H[Qe]);if(E&&E.defaultProps){var dt=E.defaultProps;for(Qe in dt)Ue[Qe]===void 0&&(Ue[Qe]=dt[Qe])}if(je||St){var pt=typeof E=="function"?E.displayName||E.name||"Unknown":E;je&&Hr(Ue,pt),St&&Yn(Ue,pt)}return Tn(E,je,St,Ge,ke,ze.current,Ue)}}var nn=y.ReactCurrentOwner,br=y.ReactDebugCurrentFrame;function jn(E){if(E){var H=E._owner,oe=et(E.type,E._source,H?H.type:null);br.setExtraStackFrame(oe)}else br.setExtraStackFrame(null)}var wr;wr=!1;function Rn(E){return typeof E=="object"&&E!==null&&E.$$typeof===t}function _t(){{if(nn.current){var E=B(nn.current.type);if(E)return`
20
+ `),dt=je.length-1,pt=St.length-1;dt>=1&&pt>=0&&je[dt]!==St[pt];)pt--;for(;dt>=1&&pt>=0;dt--,pt--)if(je[dt]!==St[pt]){if(dt!==1||pt!==1)do if(dt--,pt--,pt<0||je[dt]!==St[pt]){var $t=`
21
+ `+je[dt].replace(" at new "," at ");return E.displayName&&$t.includes("<anonymous>")&&($t=$t.replace("<anonymous>",E.displayName)),typeof E=="function"&&te.set(E,$t),$t}while(dt>=1&&pt>=0);break}}}finally{J=!1,Te.current=Ze,be(),Error.prepareStackTrace=qe}var $n=E?E.displayName||E.name:"",Yt=$n?O($n):"";return typeof E=="function"&&te.set(E,Yt),Yt}function ie(E,H,re){return le(E,!1)}function et(E){var H=E.prototype;return!!(H&&H.isReactComponent)}function Qe(E,H,re){if(E==null)return"";if(typeof E=="function")return le(E,et(E));if(typeof E=="string")return O(E);switch(E){case u:return O("Suspense");case d:return O("SuspenseList")}if(typeof E=="object")switch(E.$$typeof){case l:return ie(E.render);case f:return Qe(E.type,H,re);case h:{var ke=E,qe=ke._payload,Ze=ke._init;try{return Qe(Ze(qe),H,re)}catch{}}}return""}var Oe=Object.prototype.hasOwnProperty,Be={},ht=y.ReactDebugCurrentFrame;function tt(E){if(E){var H=E._owner,re=Qe(E.type,E._source,H?H.type:null);ht.setExtraStackFrame(re)}else ht.setExtraStackFrame(null)}function Me(E,H,re,ke,qe){{var Ze=Function.call.bind(Oe);for(var He in E)if(Ze(E,He)){var je=void 0;try{if(typeof E[He]!="function"){var St=Error((ke||"React class")+": "+re+" type `"+He+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof E[He]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw St.name="Invariant Violation",St}je=E[He](H,He,ke,re,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(dt){je=dt}je&&!(je instanceof Error)&&(tt(qe),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).",ke||"React class",re,He,typeof je),tt(null)),je instanceof Error&&!(je.message in Be)&&(Be[je.message]=!0,tt(qe),b("Failed %s type: %s",re,je.message),tt(null))}}}var bt=Array.isArray;function ne(E){return bt(E)}function oe(E){{var H=typeof Symbol=="function"&&Symbol.toStringTag,re=H&&E[Symbol.toStringTag]||E.constructor.name||"Object";return re}}function ge(E){try{return we(E),!1}catch{return!0}}function we(E){return""+E}function xe(E){if(ge(E))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",oe(E)),we(E)}var Fe=y.ReactCurrentOwner,ot={key:!0,ref:!0,__self:!0,__source:!0},$e,ut;function xt(E){if(Oe.call(E,"ref")){var H=Object.getOwnPropertyDescriptor(E,"ref").get;if(H&&H.isReactWarning)return!1}return E.ref!==void 0}function Pt(E){if(Oe.call(E,"key")){var H=Object.getOwnPropertyDescriptor(E,"key").get;if(H&&H.isReactWarning)return!1}return E.key!==void 0}function rn(E,H){typeof E.ref=="string"&&Fe.current}function Ur(E,H){{var re=function(){$e||($e=!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)",H))};re.isReactWarning=!0,Object.defineProperty(E,"key",{get:re,configurable:!0})}}function Zn(E,H){{var re=function(){ut||(ut=!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)",H))};re.isReactWarning=!0,Object.defineProperty(E,"ref",{get:re,configurable:!0})}}var En=function(E,H,re,ke,qe,Ze,He){var je={$$typeof:t,type:E,key:H,ref:re,props:He,_owner:Ze};return je._store={},Object.defineProperty(je._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(je,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ke}),Object.defineProperty(je,"_source",{configurable:!1,enumerable:!1,writable:!1,value:qe}),Object.freeze&&(Object.freeze(je.props),Object.freeze(je)),je};function Qn(E,H,re,ke,qe){{var Ze,He={},je=null,St=null;re!==void 0&&(xe(re),je=""+re),Pt(H)&&(xe(H.key),je=""+H.key),xt(H)&&(St=H.ref,rn(H,qe));for(Ze in H)Oe.call(H,Ze)&&!ot.hasOwnProperty(Ze)&&(He[Ze]=H[Ze]);if(E&&E.defaultProps){var dt=E.defaultProps;for(Ze in dt)He[Ze]===void 0&&(He[Ze]=dt[Ze])}if(je||St){var pt=typeof E=="function"?E.displayName||E.name||"Unknown":E;je&&Ur(He,pt),St&&Zn(He,pt)}return En(E,je,St,qe,ke,Fe.current,He)}}var on=y.ReactCurrentOwner,Sr=y.ReactDebugCurrentFrame;function Mn(E){if(E){var H=E._owner,re=Qe(E.type,E._source,H?H.type:null);Sr.setExtraStackFrame(re)}else Sr.setExtraStackFrame(null)}var Cr;Cr=!1;function Dn(E){return typeof E=="object"&&E!==null&&E.$$typeof===t}function Ot(){{if(on.current){var E=B(on.current.type);if(E)return`
22
22
 
23
- Check the render method of \``+E+"`."}return""}}function me(E){return""}var Ee={};function Pe(E){{var H=_t();if(!H){var oe=typeof E=="string"?E:E.displayName||E.name;oe&&(H=`
23
+ Check the render method of \``+E+"`."}return""}}function me(E){return""}var Ee={};function Pe(E){{var H=Ot();if(!H){var re=typeof E=="string"?E:E.displayName||E.name;re&&(H=`
24
24
 
25
- Check the top-level render call using <`+oe+">.")}return H}}function it(E,H){{if(!E._store||E._store.validated||E.key!=null)return;E._store.validated=!0;var oe=Pe(H);if(Ee[oe])return;Ee[oe]=!0;var ke="";E&&E._owner&&E._owner!==nn.current&&(ke=" It was passed a child from "+B(E._owner.type)+"."),jn(E),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',oe,ke),jn(null)}}function Ft(E,H){{if(typeof E!="object")return;if(ne(E))for(var oe=0;oe<E.length;oe++){var ke=E[oe];Rn(ke)&&it(ke,H)}else if(Rn(E))E._store&&(E._store.validated=!0);else if(E){var Ge=g(E);if(typeof Ge=="function"&&Ge!==E.entries)for(var Qe=Ge.call(E),Ue;!(Ue=Qe.next()).done;)Rn(Ue.value)&&it(Ue.value,H)}}}function Jn(E){{var H=E.type;if(H==null||typeof H=="string")return;var oe;if(typeof H=="function")oe=H.propTypes;else if(typeof H=="object"&&(H.$$typeof===l||H.$$typeof===f))oe=H.propTypes;else return;if(oe){var ke=B(H);Me(oe,E.props,"prop",ke,E)}else if(H.PropTypes!==void 0&&!wr){wr=!0;var Ge=B(H);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ge||"Unknown")}typeof H.getDefaultProps=="function"&&!H.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function kn(E){{for(var H=Object.keys(E.props),oe=0;oe<H.length;oe++){var ke=H[oe];if(ke!=="children"&&ke!=="key"){jn(E),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ke),jn(null);break}}E.ref!==null&&(jn(E),b("Invalid attribute `ref` supplied to `React.Fragment`."),jn(null))}}var Ur={};function Pn(E,H,oe,ke,Ge,Qe){{var Ue=P(E);if(!Ue){var je="";(E===void 0||typeof E=="object"&&E!==null&&Object.keys(E).length===0)&&(je+=" 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 St=me();St?je+=St:je+=_t();var dt;E===null?dt="null":ne(E)?dt="array":E!==void 0&&E.$$typeof===t?(dt="<"+(B(E.type)||"Unknown")+" />",je=" Did you accidentally export a JSX literal instead of a component?"):dt=typeof E,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",dt,je)}var pt=Xn(E,H,oe,Ge,Qe);if(pt==null)return pt;if(Ue){var Mt=H.children;if(Mt!==void 0)if(ke)if(ne(Mt)){for(var On=0;On<Mt.length;On++)Ft(Mt[On],E);Object.freeze&&Object.freeze(Mt)}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 Ft(Mt,E)}if(Oe.call(H,"key")){var Kt=B(E),kt=Object.keys(H).filter(function(yl){return yl!=="key"}),ko=kt.length>0?"{key: someKey, "+kt.join(": ..., ")+": ...}":"{key: someKey}";if(!Ur[Kt+ko]){var xl=kt.length>0?"{"+kt.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+re+">.")}return H}}function st(E,H){{if(!E._store||E._store.validated||E.key!=null)return;E._store.validated=!0;var re=Pe(H);if(Ee[re])return;Ee[re]=!0;var ke="";E&&E._owner&&E._owner!==on.current&&(ke=" It was passed a child from "+B(E._owner.type)+"."),Mn(E),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',re,ke),Mn(null)}}function Ht(E,H){{if(typeof E!="object")return;if(ne(E))for(var re=0;re<E.length;re++){var ke=E[re];Dn(ke)&&st(ke,H)}else if(Dn(E))E._store&&(E._store.validated=!0);else if(E){var qe=g(E);if(typeof qe=="function"&&qe!==E.entries)for(var Ze=qe.call(E),He;!(He=Ze.next()).done;)Dn(He.value)&&st(He.value,H)}}}function er(E){{var H=E.type;if(H==null||typeof H=="string")return;var re;if(typeof H=="function")re=H.propTypes;else if(typeof H=="object"&&(H.$$typeof===l||H.$$typeof===f))re=H.propTypes;else return;if(re){var ke=B(H);Me(re,E.props,"prop",ke,E)}else if(H.PropTypes!==void 0&&!Cr){Cr=!0;var qe=B(H);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",qe||"Unknown")}typeof H.getDefaultProps=="function"&&!H.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function In(E){{for(var H=Object.keys(E.props),re=0;re<H.length;re++){var ke=H[re];if(ke!=="children"&&ke!=="key"){Mn(E),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ke),Mn(null);break}}E.ref!==null&&(Mn(E),b("Invalid attribute `ref` supplied to `React.Fragment`."),Mn(null))}}var Wr={};function Ln(E,H,re,ke,qe,Ze){{var He=P(E);if(!He){var je="";(E===void 0||typeof E=="object"&&E!==null&&Object.keys(E).length===0)&&(je+=" 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 St=me();St?je+=St:je+=Ot();var dt;E===null?dt="null":ne(E)?dt="array":E!==void 0&&E.$$typeof===t?(dt="<"+(B(E.type)||"Unknown")+" />",je=" Did you accidentally export a JSX literal instead of a component?"):dt=typeof E,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",dt,je)}var pt=Qn(E,H,re,qe,Ze);if(pt==null)return pt;if(He){var $t=H.children;if($t!==void 0)if(ke)if(ne($t)){for(var $n=0;$n<$t.length;$n++)Ht($t[$n],E);Object.freeze&&Object.freeze($t)}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 Ht($t,E)}if(Oe.call(H,"key")){var Yt=B(E),kt=Object.keys(H).filter(function(vl){return vl!=="key"}),Io=kt.length>0?"{key: someKey, "+kt.join(": ..., ")+": ...}":"{key: someKey}";if(!Wr[Yt+Io]){var yl=kt.length>0?"{"+kt.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
26
26
  let props = %s;
27
27
  <%s {...props} />
28
28
  React keys must be passed directly to JSX without using spread:
29
29
  let props = %s;
30
- <%s key={someKey} {...props} />`,ko,Kt,xl,Kt),Ur[Kt+ko]=!0}}return E===r?kn(pt):Jn(pt),pt}}function Zn(E,H,oe){return Pn(E,H,oe,!0)}function To(E,H,oe){return Pn(E,H,oe,!1)}var gl=To,ii=Zn;Vr.Fragment=r,Vr.jsx=gl,Vr.jsxs=ii}()),Vr}process.env.NODE_ENV==="production"?ci.exports=Em():ci.exports=Im();var c=ci.exports;function kl(e,t){return function(){return e.apply(t,arguments)}}const{toString:Nm}=Object.prototype,{getPrototypeOf:ui}=Object,{iterator:Ao,toStringTag:El}=Symbol,_o=(e=>t=>{const n=Nm.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),rn=e=>(e=e.toLowerCase(),t=>_o(t)===e),jo=e=>t=>typeof t===e,{isArray:Tr}=Array,kr=jo("undefined");function Kr(e){return e!==null&&!kr(e)&&e.constructor!==null&&!kr(e.constructor)&&Dt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Il=rn("ArrayBuffer");function Am(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Il(e.buffer),t}const _m=jo("string"),Dt=jo("function"),Nl=jo("number"),qr=e=>e!==null&&typeof e=="object",jm=e=>e===!0||e===!1,Ro=e=>{if(_o(e)!=="object")return!1;const t=ui(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(El in e)&&!(Ao in e)},Rm=e=>{if(!qr(e)||Kr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Pm=rn("Date"),Om=rn("File"),Mm=rn("Blob"),Dm=rn("FileList"),Lm=e=>qr(e)&&Dt(e.pipe),$m=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Dt(e.append)&&((t=_o(e))==="formdata"||t==="object"&&Dt(e.toString)&&e.toString()==="[object FormData]"))},Fm=rn("URLSearchParams"),[zm,Bm,Hm,Um]=["ReadableStream","Request","Response","Headers"].map(rn),Wm=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Gr(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(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 Al(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 nr=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,_l=e=>!kr(e)&&e!==nr;function di(){const{caseless:e,skipUndefined:t}=_l(this)&&this||{},n={},r=(o,s)=>{const i=e&&Al(n,s)||s;Ro(n[i])&&Ro(o)?n[i]=di(n[i],o):Ro(o)?n[i]=di({},o):Tr(o)?n[i]=o.slice():(!t||!kr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Gr(arguments[o],r);return n}const Vm=(e,t,n,{allOwnKeys:r}={})=>(Gr(t,(o,s)=>{n&&Dt(o)?e[s]=kl(o,n):e[s]=o},{allOwnKeys:r}),e),Km=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),qm=(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)},Gm=(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&&ui(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Ym=(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},Xm=e=>{if(!e)return null;if(Tr(e))return e;let t=e.length;if(!Nl(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Jm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ui(Uint8Array)),Zm=(e,t)=>{const r=(e&&e[Ao]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Qm=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},eg=rn("HTMLFormElement"),tg=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),jl=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),ng=rn("RegExp"),Rl=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Gr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},rg=e=>{Rl(e,(t,n)=>{if(Dt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Dt(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},og=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return Tr(e)?r(e):r(String(e).split(t)),n},sg=()=>{},ig=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function ag(e){return!!(e&&Dt(e.append)&&e[El]==="FormData"&&e[Ao])}const lg=e=>{const t=new Array(10),n=(r,o)=>{if(qr(r)){if(t.indexOf(r)>=0)return;if(Kr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=Tr(r)?[]:{};return Gr(r,(i,a)=>{const l=n(i,o+1);!kr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},cg=rn("AsyncFunction"),ug=e=>e&&(qr(e)||Dt(e))&&Dt(e.then)&&Dt(e.catch),Pl=((e,t)=>e?setImmediate:t?((n,r)=>(nr.addEventListener("message",({source:o,data:s})=>{o===nr&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),nr.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Dt(nr.postMessage)),dg=typeof queueMicrotask<"u"?queueMicrotask.bind(nr):typeof process<"u"&&process.nextTick||Pl,R={isArray:Tr,isArrayBuffer:Il,isBuffer:Kr,isFormData:$m,isArrayBufferView:Am,isString:_m,isNumber:Nl,isBoolean:jm,isObject:qr,isPlainObject:Ro,isEmptyObject:Rm,isReadableStream:zm,isRequest:Bm,isResponse:Hm,isHeaders:Um,isUndefined:kr,isDate:Pm,isFile:Om,isBlob:Mm,isRegExp:ng,isFunction:Dt,isStream:Lm,isURLSearchParams:Fm,isTypedArray:Jm,isFileList:Dm,forEach:Gr,merge:di,extend:Vm,trim:Wm,stripBOM:Km,inherits:qm,toFlatObject:Gm,kindOf:_o,kindOfTest:rn,endsWith:Ym,toArray:Xm,forEachEntry:Zm,matchAll:Qm,isHTMLForm:eg,hasOwnProperty:jl,hasOwnProp:jl,reduceDescriptors:Rl,freezeMethods:rg,toObjectSet:og,toCamelCase:tg,noop:sg,toFiniteNumber:ig,findKey:Al,global:nr,isContextDefined:_l,isSpecCompliantForm:ag,toJSONObject:lg,isAsyncFn:cg,isThenable:ug,setImmediate:Pl,asap:dg,isIterable:e=>e!=null&&Dt(e[Ao])};function Le(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(Le,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 Ol=Le.prototype,Ml={};["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=>{Ml[e]={value:e}}),Object.defineProperties(Le,Ml),Object.defineProperty(Ol,"isAxiosError",{value:!0}),Le.from=(e,t,n,r,o,s)=>{const i=Object.create(Ol);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 Le.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 fg=null;function fi(e){return R.isPlainObject(e)||R.isArray(e)}function Dl(e){return R.endsWith(e,"[]")?e.slice(0,-2):e}function Ll(e,t,n){return e?e.concat(t).map(function(o,s){return o=Dl(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function hg(e){return R.isArray(e)&&!e.some(fi)}const pg=R.toFlatObject(R,{},null,function(t){return/^is[A-Z]/.test(t)});function Po(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(x,g){return!R.isUndefined(g[x])});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(v){if(v===null)return"";if(R.isDate(v))return v.toISOString();if(R.isBoolean(v))return v.toString();if(!l&&R.isBlob(v))throw new Le("Blob is not supported. Use a Buffer instead.");return R.isArrayBuffer(v)||R.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,x,g){let y=v;if(v&&!g&&typeof v=="object"){if(R.endsWith(x,"{}"))x=r?x:x.slice(0,-2),v=JSON.stringify(v);else if(R.isArray(v)&&hg(v)||(R.isFileList(v)||R.endsWith(x,"[]"))&&(y=R.toArray(v)))return x=Dl(x),y.forEach(function(S,k){!(R.isUndefined(S)||S===null)&&t.append(i===!0?Ll([x],k,s):i===null?x:x+"[]",u(S))}),!1}return fi(v)?!0:(t.append(Ll(g,x,s),u(v)),!1)}const f=[],h=Object.assign(pg,{defaultVisitor:d,convertValue:u,isVisitable:fi});function p(v,x){if(!R.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+x.join("."));f.push(v),R.forEach(v,function(y,b){(!(R.isUndefined(y)||y===null)&&o.call(t,y,R.isString(b)?b.trim():b,x,h))===!0&&p(y,x?x.concat(b):[b])}),f.pop()}}if(!R.isObject(e))throw new TypeError("data must be an object");return p(e),t}function $l(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function hi(e,t){this._pairs=[],e&&Po(e,this,t)}const Fl=hi.prototype;Fl.append=function(t,n){this._pairs.push([t,n])},Fl.toString=function(t){const n=t?function(r){return t.call(this,r,$l)}:$l;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function mg(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function zl(e,t,n){if(!t)return e;const r=n&&n.encode||mg;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 hi(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Bl{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 Hl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},gg={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:hi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},pi=typeof window<"u"&&typeof document<"u",mi=typeof navigator=="object"&&navigator||void 0,xg=pi&&(!mi||["ReactNative","NativeScript","NS"].indexOf(mi.product)<0),yg=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",vg=pi&&window.location.href||"http://localhost",Et={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:pi,hasStandardBrowserEnv:xg,hasStandardBrowserWebWorkerEnv:yg,navigator:mi,origin:vg},Symbol.toStringTag,{value:"Module"})),...gg};function bg(e,t){return Po(e,new Et.classes.URLSearchParams,{visitor:function(n,r,o,s){return Et.isNode&&R.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function wg(e){return R.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Sg(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 Ul(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]=Sg(o[i])),!a)}if(R.isFormData(e)&&R.isFunction(e.entries)){const n={};return R.forEachEntry(e,(r,o)=>{t(wg(r),o,n,0)}),n}return null}function Cg(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 Yr={transitional:Hl,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(Ul(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 bg(t,this.formSerializer).toString();if((a=R.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Po(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Cg(t)):t}],transformResponse:[function(t){const n=this.transitional||Yr.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"?Le.from(a,Le.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:Et.classes.FormData,Blob:Et.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=>{Yr.headers[e]={}});const Tg=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"]),kg=e=>{const t={};let n,r,o;return e&&e.split(`
31
- `).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&Tg[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Wl=Symbol("internals");function Xr(e){return e&&String(e).trim().toLowerCase()}function Oo(e){return e===!1||e==null?e:R.isArray(e)?e.map(Oo):String(e)}function Eg(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 Ig=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function gi(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 Ng(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Ag(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 Lt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,u){const d=Xr(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]=Oo(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())&&!Ig(t))i(kg(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=Xr(t),t){const r=R.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Eg(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=Xr(t),t){const r=R.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||gi(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Xr(i),i){const a=R.findKey(r,i);a&&(!n||gi(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||gi(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]=Oo(o),delete n[s];return}const a=t?Ng(s):String(s).trim();a!==s&&delete n[s],n[a]=Oo(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(`
32
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[Wl]=this[Wl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Xr(i);r[a]||(Ag(o,i),r[a]=!0)}return R.isArray(t)?t.forEach(s):s(t),this}};Lt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),R.reduceDescriptors(Lt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),R.freezeMethods(Lt);function xi(e,t){const n=this||Yr,r=t||n,o=Lt.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 Vl(e){return!!(e&&e.__CANCEL__)}function Er(e,t,n){Le.call(this,e??"canceled",Le.ERR_CANCELED,t,n),this.name="CanceledError"}R.inherits(Er,Le,{__CANCEL__:!0});function Kl(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Le("Request failed with status code "+n.status,[Le.ERR_BAD_REQUEST,Le.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function _g(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function jg(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 Rg(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 Mo=(e,t,n=3)=>{let r=0;const o=jg(50,250);return Rg(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)},ql=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Gl=e=>(...t)=>R.asap(()=>e(...t)),Pg=Et.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Et.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Et.origin),Et.navigator&&/(msie|trident)/i.test(Et.navigator.userAgent)):()=>!0,Og=Et.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 Mg(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Dg(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Yl(e,t,n){let r=!Mg(t);return e&&(r||n==!1)?Dg(e,t):t}const Xl=e=>e instanceof Lt?{...e}:e;function rr(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(Xl(u),Xl(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 Jl=e=>{const t=rr({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Lt.from(i),t.url=zl(Yl(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(Et.hasStandardBrowserEnv||Et.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(Et.hasStandardBrowserEnv&&(r&&R.isFunction(r)&&(r=r(t)),r||r!==!1&&Pg(t.url))){const l=o&&s&&Og.read(s);l&&i.set(o,l)}return t},Lg=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Jl(e);let s=o.data;const i=Lt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=o,d,f,h,p,v;function x(){p&&p(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function y(){if(!g)return;const S=Lt.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};Kl(function(I){n(I),x()},function(I){r(I),x()},C),g=null}"onloadend"in g?g.onloadend=y:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(y)},g.onabort=function(){g&&(r(new Le("Request aborted",Le.ECONNABORTED,e,g)),g=null)},g.onerror=function(k){const C=k&&k.message?k.message:"Network Error",T=new Le(C,Le.ERR_NETWORK,e,g);T.event=k||null,r(T),g=null},g.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||Hl;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Le(k,C.clarifyTimeoutError?Le.ETIMEDOUT:Le.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&R.forEach(i.toJSON(),function(k,C){g.setRequestHeader(C,k)}),R.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,v]=Mo(u,!0),g.addEventListener("progress",h)),l&&g.upload&&([f,p]=Mo(l),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=S=>{g&&(r(!S||S.type?new Er(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=_g(o.url);if(b&&Et.protocols.indexOf(b)===-1){r(new Le("Unsupported protocol "+b+":",Le.ERR_BAD_REQUEST,e));return}g.send(s||null)})},$g=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(u){if(!o){o=!0,a();const d=u instanceof Error?u:this.reason;r.abort(d instanceof Le?d:new Er(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Le(`timeout ${t} of ms exceeded`,Le.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}},Fg=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},zg=async function*(e,t){for await(const n of Bg(e))yield*Fg(n,t)},Bg=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()}},Zl=(e,t,n,r)=>{const o=zg(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})},Ql=64*1024,{isFunction:Do}=R,Hg=(({Request:e,Response:t})=>({Request:e,Response:t}))(R.global),{ReadableStream:ec,TextEncoder:tc}=R.global,nc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Ug=e=>{e=R.merge.call({skipUndefined:!0},Hg,e);const{fetch:t,Request:n,Response:r}=e,o=t?Do(t):typeof fetch=="function",s=Do(n),i=Do(r);if(!o)return!1;const a=o&&Do(ec),l=o&&(typeof tc=="function"?(v=>x=>v.encode(x))(new tc):async v=>new Uint8Array(await new n(v).arrayBuffer())),u=s&&a&&nc(()=>{let v=!1;const x=new n(Et.origin,{body:new ec,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!x}),d=i&&a&&nc(()=>R.isReadableStream(new r("").body)),f={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!f[v]&&(f[v]=(x,g)=>{let y=x&&x[v];if(y)return y.call(x);throw new Le(`Response type '${v}' is not supported`,Le.ERR_NOT_SUPPORT,g)})});const h=async v=>{if(v==null)return 0;if(R.isBlob(v))return v.size;if(R.isSpecCompliantForm(v))return(await new n(Et.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(R.isArrayBufferView(v)||R.isArrayBuffer(v))return v.byteLength;if(R.isURLSearchParams(v)&&(v=v+""),R.isString(v))return(await l(v)).byteLength},p=async(v,x)=>{const g=R.toFiniteNumber(v.getContentLength());return g??h(x)};return async v=>{let{url:x,method:g,data:y,signal:b,cancelToken:S,timeout:k,onDownloadProgress:C,onUploadProgress:T,responseType:I,headers:A,withCredentials:j="same-origin",fetchOptions:P}=Jl(v),D=t||fetch;I=I?(I+"").toLowerCase():"text";let L=$g([b,S&&S.toAbortSignal()],k),B=null;const M=L&&L.unsubscribe&&(()=>{L.unsubscribe()});let X;try{if(T&&u&&g!=="get"&&g!=="head"&&(X=await p(A,y))!==0){let F=new n(x,{method:"POST",body:y,duplex:"half"}),Z;if(R.isFormData(y)&&(Z=F.headers.get("content-type"))&&A.setContentType(Z),F.body){const[he,ve]=ql(X,Mo(Gl(T)));y=Zl(F.body,Ql,he,ve)}}R.isString(j)||(j=j?"include":"omit");const W=s&&"credentials"in n.prototype,V={...P,signal:L,method:g.toUpperCase(),headers:A.normalize().toJSON(),body:y,duplex:"half",credentials:W?j:void 0};B=s&&new n(x,V);let z=await(s?D(B,P):D(x,V));const $=d&&(I==="stream"||I==="response");if(d&&(C||$&&M)){const F={};["status","statusText","headers"].forEach(be=>{F[be]=z[be]});const Z=R.toFiniteNumber(z.headers.get("content-length")),[he,ve]=C&&ql(Z,Mo(Gl(C),!0))||[];z=new r(Zl(z.body,Ql,he,()=>{ve&&ve(),M&&M()}),F)}I=I||"text";let pe=await f[R.findKey(f,I)||"text"](z,v);return!$&&M&&M(),await new Promise((F,Z)=>{Kl(F,Z,{data:pe,headers:Lt.from(z.headers),status:z.status,statusText:z.statusText,config:v,request:B})})}catch(W){throw M&&M(),W&&W.name==="TypeError"&&/Load failed|fetch/i.test(W.message)?Object.assign(new Le("Network Error",Le.ERR_NETWORK,v,B),{cause:W.cause||W}):Le.from(W,W&&W.code,v,B)}}},Wg=new Map,rc=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=Wg;for(;a--;)l=s[a],u=d.get(l),u===void 0&&d.set(l,u=a?new Map:Ug(t)),d=u;return u};rc();const yi={http:fg,xhr:Lg,fetch:{get:rc}};R.forEach(yi,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const oc=e=>`- ${e}`,Vg=e=>R.isFunction(e)||e===null||e===!1,sc={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,!Vg(r)&&(o=yi[(a=String(r)).toLowerCase()],o===void 0))throw new Le(`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 :
30
+ <%s key={someKey} {...props} />`,Io,Yt,yl,Yt),Wr[Yt+Io]=!0}}return E===r?In(pt):er(pt),pt}}function tr(E,H,re){return Ln(E,H,re,!0)}function Eo(E,H,re){return Ln(E,H,re,!1)}var xl=Eo,li=tr;qr.Fragment=r,qr.jsx=xl,qr.jsxs=li}()),qr}process.env.NODE_ENV==="production"?ui.exports=Im():ui.exports=Nm();var c=ui.exports;function kl(e,t){return function(){return e.apply(t,arguments)}}const{toString:Am}=Object.prototype,{getPrototypeOf:di}=Object,{iterator:jo,toStringTag:El}=Symbol,Ro=(e=>t=>{const n=Am.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),sn=e=>(e=e.toLowerCase(),t=>Ro(t)===e),Po=e=>t=>typeof t===e,{isArray:kr}=Array,Er=Po("undefined");function Gr(e){return e!==null&&!Er(e)&&e.constructor!==null&&!Er(e.constructor)&&Ft(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Il=sn("ArrayBuffer");function _m(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Il(e.buffer),t}const jm=Po("string"),Ft=Po("function"),Nl=Po("number"),Yr=e=>e!==null&&typeof e=="object",Rm=e=>e===!0||e===!1,Oo=e=>{if(Ro(e)!=="object")return!1;const t=di(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(El in e)&&!(jo in e)},Pm=e=>{if(!Yr(e)||Gr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Om=sn("Date"),Mm=sn("File"),Dm=sn("Blob"),Lm=sn("FileList"),$m=e=>Yr(e)&&Ft(e.pipe),Fm=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ft(e.append)&&((t=Ro(e))==="formdata"||t==="object"&&Ft(e.toString)&&e.toString()==="[object FormData]"))},zm=sn("URLSearchParams"),[Bm,Hm,Um,Wm]=["ReadableStream","Request","Response","Headers"].map(sn),Vm=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Xr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),kr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Gr(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 Al(e,t){if(Gr(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 or=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,_l=e=>!Er(e)&&e!==or;function fi(){const{caseless:e,skipUndefined:t}=_l(this)&&this||{},n={},r=(o,s)=>{const i=e&&Al(n,s)||s;Oo(n[i])&&Oo(o)?n[i]=fi(n[i],o):Oo(o)?n[i]=fi({},o):kr(o)?n[i]=o.slice():(!t||!Er(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Xr(arguments[o],r);return n}const Km=(e,t,n,{allOwnKeys:r}={})=>(Xr(t,(o,s)=>{n&&Ft(o)?e[s]=kl(o,n):e[s]=o},{allOwnKeys:r}),e),qm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Gm=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Ym=(e,t,n,r)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!r||r(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=n!==!1&&di(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Xm=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Jm=e=>{if(!e)return null;if(kr(e))return e;let t=e.length;if(!Nl(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Zm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&di(Uint8Array)),Qm=(e,t)=>{const r=(e&&e[jo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},eg=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},tg=sn("HTMLFormElement"),ng=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),jl=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),rg=sn("RegExp"),Rl=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Xr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},og=e=>{Rl(e,(t,n)=>{if(Ft(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ft(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},sg=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return kr(e)?r(e):r(String(e).split(t)),n},ig=()=>{},ag=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function lg(e){return!!(e&&Ft(e.append)&&e[El]==="FormData"&&e[jo])}const cg=e=>{const t=new Array(10),n=(r,o)=>{if(Yr(r)){if(t.indexOf(r)>=0)return;if(Gr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=kr(r)?[]:{};return Xr(r,(i,a)=>{const l=n(i,o+1);!Er(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},ug=sn("AsyncFunction"),dg=e=>e&&(Yr(e)||Ft(e))&&Ft(e.then)&&Ft(e.catch),Pl=((e,t)=>e?setImmediate:t?((n,r)=>(or.addEventListener("message",({source:o,data:s})=>{o===or&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),or.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ft(or.postMessage)),fg=typeof queueMicrotask<"u"?queueMicrotask.bind(or):typeof process<"u"&&process.nextTick||Pl,R={isArray:kr,isArrayBuffer:Il,isBuffer:Gr,isFormData:Fm,isArrayBufferView:_m,isString:jm,isNumber:Nl,isBoolean:Rm,isObject:Yr,isPlainObject:Oo,isEmptyObject:Pm,isReadableStream:Bm,isRequest:Hm,isResponse:Um,isHeaders:Wm,isUndefined:Er,isDate:Om,isFile:Mm,isBlob:Dm,isRegExp:rg,isFunction:Ft,isStream:$m,isURLSearchParams:zm,isTypedArray:Zm,isFileList:Lm,forEach:Xr,merge:fi,extend:Km,trim:Vm,stripBOM:qm,inherits:Gm,toFlatObject:Ym,kindOf:Ro,kindOfTest:sn,endsWith:Xm,toArray:Jm,forEachEntry:Qm,matchAll:eg,isHTMLForm:tg,hasOwnProperty:jl,hasOwnProp:jl,reduceDescriptors:Rl,freezeMethods:og,toObjectSet:sg,toCamelCase:ng,noop:ig,toFiniteNumber:ag,findKey:Al,global:or,isContextDefined:_l,isSpecCompliantForm:lg,toJSONObject:cg,isAsyncFn:ug,isThenable:dg,setImmediate:Pl,asap:fg,isIterable:e=>e!=null&&Ft(e[jo])};function De(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(De,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 Ol=De.prototype,Ml={};["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=>{Ml[e]={value:e}}),Object.defineProperties(De,Ml),Object.defineProperty(Ol,"isAxiosError",{value:!0}),De.from=(e,t,n,r,o,s)=>{const i=Object.create(Ol);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 De.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const hg=null;function hi(e){return R.isPlainObject(e)||R.isArray(e)}function Dl(e){return R.endsWith(e,"[]")?e.slice(0,-2):e}function Ll(e,t,n){return e?e.concat(t).map(function(o,s){return o=Dl(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function pg(e){return R.isArray(e)&&!e.some(hi)}const mg=R.toFlatObject(R,{},null,function(t){return/^is[A-Z]/.test(t)});function Mo(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(x,g){return!R.isUndefined(g[x])});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(v){if(v===null)return"";if(R.isDate(v))return v.toISOString();if(R.isBoolean(v))return v.toString();if(!l&&R.isBlob(v))throw new De("Blob is not supported. Use a Buffer instead.");return R.isArrayBuffer(v)||R.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,x,g){let y=v;if(v&&!g&&typeof v=="object"){if(R.endsWith(x,"{}"))x=r?x:x.slice(0,-2),v=JSON.stringify(v);else if(R.isArray(v)&&pg(v)||(R.isFileList(v)||R.endsWith(x,"[]"))&&(y=R.toArray(v)))return x=Dl(x),y.forEach(function(S,k){!(R.isUndefined(S)||S===null)&&t.append(i===!0?Ll([x],k,s):i===null?x:x+"[]",u(S))}),!1}return hi(v)?!0:(t.append(Ll(g,x,s),u(v)),!1)}const f=[],h=Object.assign(mg,{defaultVisitor:d,convertValue:u,isVisitable:hi});function p(v,x){if(!R.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+x.join("."));f.push(v),R.forEach(v,function(y,b){(!(R.isUndefined(y)||y===null)&&o.call(t,y,R.isString(b)?b.trim():b,x,h))===!0&&p(y,x?x.concat(b):[b])}),f.pop()}}if(!R.isObject(e))throw new TypeError("data must be an object");return p(e),t}function $l(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function pi(e,t){this._pairs=[],e&&Mo(e,this,t)}const Fl=pi.prototype;Fl.append=function(t,n){this._pairs.push([t,n])},Fl.toString=function(t){const n=t?function(r){return t.call(this,r,$l)}:$l;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function gg(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function zl(e,t,n){if(!t)return e;const r=n&&n.encode||gg;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 pi(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Bl{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 Hl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},xg={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:pi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},mi=typeof window<"u"&&typeof document<"u",gi=typeof navigator=="object"&&navigator||void 0,yg=mi&&(!gi||["ReactNative","NativeScript","NS"].indexOf(gi.product)<0),vg=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",bg=mi&&window.location.href||"http://localhost",At={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:mi,hasStandardBrowserEnv:yg,hasStandardBrowserWebWorkerEnv:vg,navigator:gi,origin:bg},Symbol.toStringTag,{value:"Module"})),...xg};function wg(e,t){return Mo(e,new At.classes.URLSearchParams,{visitor:function(n,r,o,s){return At.isNode&&R.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Sg(e){return R.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Cg(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}function Ul(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]=Cg(o[i])),!a)}if(R.isFormData(e)&&R.isFunction(e.entries)){const n={};return R.forEachEntry(e,(r,o)=>{t(Sg(r),o,n,0)}),n}return null}function Tg(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 Jr={transitional:Hl,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(Ul(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 wg(t,this.formSerializer).toString();if((a=R.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Mo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Tg(t)):t}],transformResponse:[function(t){const n=this.transitional||Jr.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"?De.from(a,De.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:At.classes.FormData,Blob:At.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};R.forEach(["delete","get","head","post","put","patch"],e=>{Jr.headers[e]={}});const kg=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"]),Eg=e=>{const t={};let n,r,o;return e&&e.split(`
31
+ `).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&kg[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Wl=Symbol("internals");function Zr(e){return e&&String(e).trim().toLowerCase()}function Do(e){return e===!1||e==null?e:R.isArray(e)?e.map(Do):String(e)}function Ig(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const Ng=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function xi(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 Ag(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function _g(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 zt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,u){const d=Zr(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]=Do(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())&&!Ng(t))i(Eg(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=Zr(t),t){const r=R.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Ig(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=Zr(t),t){const r=R.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||xi(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Zr(i),i){const a=R.findKey(r,i);a&&(!n||xi(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||xi(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]=Do(o),delete n[s];return}const a=t?Ag(s):String(s).trim();a!==s&&delete n[s],n[a]=Do(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(`
32
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[Wl]=this[Wl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Zr(i);r[a]||(_g(o,i),r[a]=!0)}return R.isArray(t)?t.forEach(s):s(t),this}};zt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),R.reduceDescriptors(zt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),R.freezeMethods(zt);function yi(e,t){const n=this||Jr,r=t||n,o=zt.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 Vl(e){return!!(e&&e.__CANCEL__)}function Ir(e,t,n){De.call(this,e??"canceled",De.ERR_CANCELED,t,n),this.name="CanceledError"}R.inherits(Ir,De,{__CANCEL__:!0});function Kl(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new De("Request failed with status code "+n.status,[De.ERR_BAD_REQUEST,De.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function jg(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Rg(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const u=Date.now(),d=r[s];i||(i=u),n[o]=l,r[o]=u;let f=s,h=0;for(;f!==o;)h+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const p=d&&u-d;return p?Math.round(h*1e3/p):void 0}}function Pg(e,t){let n=0,r=1e3/t,o,s;const i=(u,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...u)};return[(...u)=>{const d=Date.now(),f=d-n;f>=r?i(u,d):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const Lo=(e,t,n=3)=>{let r=0;const o=Rg(50,250);return Pg(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,u=o(l),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:u||void 0,estimated:u&&a&&d?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},ql=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Gl=e=>(...t)=>R.asap(()=>e(...t)),Og=At.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,At.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(At.origin),At.navigator&&/(msie|trident)/i.test(At.navigator.userAgent)):()=>!0,Mg=At.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];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 Dg(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Lg(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Yl(e,t,n){let r=!Dg(t);return e&&(r||n==!1)?Lg(e,t):t}const Xl=e=>e instanceof zt?{...e}:e;function sr(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(Xl(u),Xl(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 Jl=e=>{const t=sr({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=zt.from(i),t.url=zl(Yl(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(At.hasStandardBrowserEnv||At.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(At.hasStandardBrowserEnv&&(r&&R.isFunction(r)&&(r=r(t)),r||r!==!1&&Og(t.url))){const l=o&&s&&Mg.read(s);l&&i.set(o,l)}return t},$g=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Jl(e);let s=o.data;const i=zt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=o,d,f,h,p,v;function x(){p&&p(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function y(){if(!g)return;const S=zt.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};Kl(function(I){n(I),x()},function(I){r(I),x()},C),g=null}"onloadend"in g?g.onloadend=y:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(y)},g.onabort=function(){g&&(r(new De("Request aborted",De.ECONNABORTED,e,g)),g=null)},g.onerror=function(k){const C=k&&k.message?k.message:"Network Error",T=new De(C,De.ERR_NETWORK,e,g);T.event=k||null,r(T),g=null},g.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||Hl;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new De(k,C.clarifyTimeoutError?De.ETIMEDOUT:De.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&R.forEach(i.toJSON(),function(k,C){g.setRequestHeader(C,k)}),R.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,v]=Lo(u,!0),g.addEventListener("progress",h)),l&&g.upload&&([f,p]=Lo(l),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=S=>{g&&(r(!S||S.type?new Ir(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=jg(o.url);if(b&&At.protocols.indexOf(b)===-1){r(new De("Unsupported protocol "+b+":",De.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Fg=(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 De?d:new Ir(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new De(`timeout ${t} of ms exceeded`,De.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}},zg=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},Bg=async function*(e,t){for await(const n of Hg(e))yield*zg(n,t)},Hg=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},Zl=(e,t,n,r)=>{const o=Bg(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:u,value:d}=await o.next();if(u){a(),l.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}l.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Ql=64*1024,{isFunction:$o}=R,Ug=(({Request:e,Response:t})=>({Request:e,Response:t}))(R.global),{ReadableStream:ec,TextEncoder:tc}=R.global,nc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Wg=e=>{e=R.merge.call({skipUndefined:!0},Ug,e);const{fetch:t,Request:n,Response:r}=e,o=t?$o(t):typeof fetch=="function",s=$o(n),i=$o(r);if(!o)return!1;const a=o&&$o(ec),l=o&&(typeof tc=="function"?(v=>x=>v.encode(x))(new tc):async v=>new Uint8Array(await new n(v).arrayBuffer())),u=s&&a&&nc(()=>{let v=!1;const x=new n(At.origin,{body:new ec,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!x}),d=i&&a&&nc(()=>R.isReadableStream(new r("").body)),f={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!f[v]&&(f[v]=(x,g)=>{let y=x&&x[v];if(y)return y.call(x);throw new De(`Response type '${v}' is not supported`,De.ERR_NOT_SUPPORT,g)})});const h=async v=>{if(v==null)return 0;if(R.isBlob(v))return v.size;if(R.isSpecCompliantForm(v))return(await new n(At.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(R.isArrayBufferView(v)||R.isArrayBuffer(v))return v.byteLength;if(R.isURLSearchParams(v)&&(v=v+""),R.isString(v))return(await l(v)).byteLength},p=async(v,x)=>{const g=R.toFiniteNumber(v.getContentLength());return g??h(x)};return async v=>{let{url:x,method:g,data:y,signal:b,cancelToken:S,timeout:k,onDownloadProgress:C,onUploadProgress:T,responseType:I,headers:A,withCredentials:j="same-origin",fetchOptions:P}=Jl(v),D=t||fetch;I=I?(I+"").toLowerCase():"text";let L=Fg([b,S&&S.toAbortSignal()],k),B=null;const M=L&&L.unsubscribe&&(()=>{L.unsubscribe()});let X;try{if(T&&u&&g!=="get"&&g!=="head"&&(X=await p(A,y))!==0){let F=new n(x,{method:"POST",body:y,duplex:"half"}),Q;if(R.isFormData(y)&&(Q=F.headers.get("content-type"))&&A.setContentType(Q),F.body){const[he,ve]=ql(X,Lo(Gl(T)));y=Zl(F.body,Ql,he,ve)}}R.isString(j)||(j=j?"include":"omit");const W=s&&"credentials"in n.prototype,V={...P,signal:L,method:g.toUpperCase(),headers:A.normalize().toJSON(),body:y,duplex:"half",credentials:W?j:void 0};B=s&&new n(x,V);let z=await(s?D(B,P):D(x,V));const $=d&&(I==="stream"||I==="response");if(d&&(C||$&&M)){const F={};["status","statusText","headers"].forEach(be=>{F[be]=z[be]});const Q=R.toFiniteNumber(z.headers.get("content-length")),[he,ve]=C&&ql(Q,Lo(Gl(C),!0))||[];z=new r(Zl(z.body,Ql,he,()=>{ve&&ve(),M&&M()}),F)}I=I||"text";let pe=await f[R.findKey(f,I)||"text"](z,v);return!$&&M&&M(),await new Promise((F,Q)=>{Kl(F,Q,{data:pe,headers:zt.from(z.headers),status:z.status,statusText:z.statusText,config:v,request:B})})}catch(W){throw M&&M(),W&&W.name==="TypeError"&&/Load failed|fetch/i.test(W.message)?Object.assign(new De("Network Error",De.ERR_NETWORK,v,B),{cause:W.cause||W}):De.from(W,W&&W.code,v,B)}}},Vg=new Map,rc=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,u,d=Vg;for(;a--;)l=s[a],u=d.get(l),u===void 0&&d.set(l,u=a?new Map:Wg(t)),d=u;return u};rc();const vi={http:hg,xhr:$g,fetch:{get:rc}};R.forEach(vi,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const oc=e=>`- ${e}`,Kg=e=>R.isFunction(e)||e===null||e===!1,sc={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,!Kg(r)&&(o=vi[(a=String(r)).toLowerCase()],o===void 0))throw new De(`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 :
33
33
  `+i.map(oc).join(`
34
- `):" "+oc(i[0]):"as no adapter specified";throw new Le("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:yi};function vi(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Er(null,e)}function ic(e){return vi(e),e.headers=Lt.from(e.headers),e.data=xi.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),sc.getAdapter(e.adapter||Yr.adapter,e)(e).then(function(r){return vi(e),r.data=xi.call(e,e.transformResponse,r),r.headers=Lt.from(r.headers),r},function(r){return Vl(r)||(vi(e),r&&r.response&&(r.response.data=xi.call(e,e.transformResponse,r.response),r.response.headers=Lt.from(r.response.headers))),Promise.reject(r)})}const ac="1.12.2",Lo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Lo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const lc={};Lo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+ac+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Le(o(i," has been removed"+(n?" in "+n:"")),Le.ERR_DEPRECATED);return n&&!lc[i]&&(lc[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}},Lo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Kg(e,t,n){if(typeof e!="object")throw new Le("options must be an object",Le.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 Le("option "+s+" must be "+l,Le.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Le("Unknown option "+s,Le.ERR_BAD_OPTION)}}const $o={assertOptions:Kg,validators:Lo},dn=$o.validators;let or=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Bl,response:new Bl}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
35
- `+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=rr(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&$o.assertOptions(r,{silentJSONParsing:dn.transitional(dn.boolean),forcedJSONParsing:dn.transitional(dn.boolean),clarifyTimeoutError:dn.transitional(dn.boolean)},!1),o!=null&&(R.isFunction(o)?n.paramsSerializer={serialize:o}:$o.assertOptions(o,{encode:dn.function,serialize:dn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),$o.assertOptions(n,{baseUrl:dn.spelling("baseURL"),withXsrfToken:dn.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"],v=>{delete s[v]}),n.headers=Lt.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(x){typeof x.runWhen=="function"&&x.runWhen(n)===!1||(l=l&&x.synchronous,a.unshift(x.fulfilled,x.rejected))});const u=[];this.interceptors.response.forEach(function(x){u.push(x.fulfilled,x.rejected)});let d,f=0,h;if(!l){const v=[ic.bind(this),void 0];for(v.unshift(...a),v.push(...u),h=v.length,d=Promise.resolve(n);f<h;)d=d.then(v[f++],v[f++]);return d}h=a.length;let p=n;for(;f<h;){const v=a[f++],x=a[f++];try{p=v(p)}catch(g){x.call(this,g);break}}try{d=ic.call(this,p)}catch(v){return Promise.reject(v)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=rr(this.defaults,t);const n=Yl(t.baseURL,t.url,t.allowAbsoluteUrls);return zl(n,t.params,t.paramsSerializer)}};R.forEach(["delete","get","head","options"],function(t){or.prototype[t]=function(n,r){return this.request(rr(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(rr(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}or.prototype[t]=n(),or.prototype[t+"Form"]=n(!0)});let qg=class Cm{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 Er(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 Cm(function(o){t=o}),cancel:t}}};function Gg(e){return function(n){return e.apply(null,n)}}function Yg(e){return R.isObject(e)&&e.isAxiosError===!0}const bi={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(bi).forEach(([e,t])=>{bi[t]=e});function cc(e){const t=new or(e),n=kl(or.prototype.request,t);return R.extend(n,or.prototype,t,{allOwnKeys:!0}),R.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return cc(rr(e,o))},n}const mt=cc(Yr);mt.Axios=or,mt.CanceledError=Er,mt.CancelToken=qg,mt.isCancel=Vl,mt.VERSION=ac,mt.toFormData=Po,mt.AxiosError=Le,mt.Cancel=mt.CanceledError,mt.all=function(t){return Promise.all(t)},mt.spread=Gg,mt.isAxiosError=Yg,mt.mergeConfig=rr,mt.AxiosHeaders=Lt,mt.formToJSON=e=>Ul(R.isHTMLForm(e)?new FormData(e):e),mt.getAdapter=sc.getAdapter,mt.HttpStatusCode=bi,mt.default=mt;const{Axios:zT,AxiosError:BT,CanceledError:HT,isCancel:UT,CancelToken:WT,VERSION:VT,all:KT,Cancel:qT,isAxiosError:GT,spread:YT,toFormData:XT,AxiosHeaders:JT,HttpStatusCode:ZT,formToJSON:QT,getAdapter:ek,mergeConfig:tk}=mt,uc=typeof window<"u"?window.__API_BASE_URL__:void 0,dc=uc?En(uc):void 0;function En(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Fo=null;const wi=new Set;function fc(){return Fo}function Si(e){Fo=e,wi.forEach(t=>t(e))}function hc(e){return wi.add(e),()=>wi.delete(e)}const Gt=mt.create({...dc?{baseURL:dc}:{},timeout:3e4,withCredentials:!0});Gt.interceptors.request.use(e=>(Fo&&(e.headers.Authorization=`Bearer ${Fo}`),e)),Gt.interceptors.response.use(e=>e,e=>Promise.reject(e));async function fn(e,t){return Gt.defaults.baseURL?(await Gt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function pc(e,t,n){return Gt.defaults.baseURL?(await Gt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function mc(e,t,n){return Gt.defaults.baseURL?(await Gt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function gc(e,t){return Gt.defaults.baseURL?(await Gt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function In(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class xc{get baseUrl(){const t=Gt.defaults.baseURL;return t?En(String(t)):""}updateConfig(t){t.baseUrl&&(Gt.defaults.baseURL=En(String(t.baseUrl))),t.authToken!==void 0&&Si(t.authToken)}getAuthToken(){return fc()}setAuthToken(t){Si(t)}onTokenChange(t){return hc(t)}async listThreads(){const t=await fn("/threads"),n=In(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await pc("/threads",t?{title:t}:void 0);return In(r)}async updateThread(t,n){const r=await mc(`/threads/${t}`,{title:n});return In(r)}async deleteThread(t){const n=await gc(`/threads/${t}`);return In(n)}async threadInfo(t){const n=await fn(`/threads/${t}/info`);return In(n)}async listAgents(){const t=await fn("/agents"),n=In(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await fn(`/agents/${t}`);return In(n)}async getAgentSchema(t){const n=await fn(`/agents/${t}/schema`);return In(n)}async getStateHistory(t){const n=await fn(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return In(n)}}const Dn=new xc,yc=w.createContext(null);function Xg({children:e,apiConfig:t}){const n=Dn;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(yc.Provider,{value:r,children:e})}function Ci(){const e=w.useContext(yc);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function Jg(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 Zg(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const u=await Jg(l);a.push({filename:l.name,data:u,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const Qg={human:"user",user:"user",ai:"assistant",assistant:"assistant",tool:"tool",function:"tool",system:"system"};function Ti(e){if(!e||typeof e!="object")return!1;const t=e;return"values"in t&&"config"in t&&typeof t.values=="object"&&t.values!==null&&typeof t.config=="object"&&t.config!==null}function zo(e,t){return`${e??""}::${t??""}`}function vc(e){const t=Array.isArray(e==null?void 0:e.checkpoints)?(e==null?void 0:e.checkpoints)??[]:e!=null&&e.checkpoints?Object.values(e.checkpoints):[],n=(e==null?void 0:e.threadId)??"",r=t[0];if(!Ti(r))return{threadId:n,latest:null,checkpoints:[],interrupt:null,snapshots:{}};const{orderedSnapshots:o,snapshotMap:s}=tx(t),i=bc(r,0);return{threadId:n,latest:i,checkpoints:o,interrupt:(i==null?void 0:i.interrupt)??null,snapshots:s}}function bc(e,t){var C,T;if(!Ti(e))return null;const n=e.values??{},r=Array.isArray(n==null?void 0:n.messages)?n.messages:[],o=e.tasks,s=r.map((I,A)=>ix(I,A)).filter(I=>!!I),i=zt((C=e.config)==null?void 0:C.configurable),a=ft(i,["checkpoint_id","checkpointId"]),l=ft(i,["checkpoint_ns","checkpointNs"]),u=zt((T=e.parentConfig)==null?void 0:T.configurable),d=ft(u,["checkpoint_id","checkpointId"])??null,f=ft(u,["checkpoint_ns","checkpointNs"])??null,h=e==null?void 0:e.createdAt,p=typeof h=="string"&&h.trim()?h:new Date(Date.now()-t).toISOString(),v=nx(s),x=s[s.length-1]??null,g=zt(e==null?void 0:e.metadata),y=ft(g,["branch_label","branchLabel"]),b=zt(e==null?void 0:e.parentConfig),S=zt(b==null?void 0:b.configurable),k=ft(S,["checkpoint_id","checkpointId"]);return{messages:s,checkpointId:a??null,checkpointNs:l??null,nextCursor:d,nextCursorNs:f,interrupt:ex(o,s,t),createdAt:p,preview:v??null,role:(x==null?void 0:x.role)??null,parentId:k??null,branchLabel:y??null,lastMessageId:(x==null?void 0:x.id)??null,hasMessages:s.length>0,messagesLen:s.length}}function ex(e,t,n){const r=ox(e,n);return r||rx(t,n)}function tx(e){const t=new Map;e.forEach((o,s)=>{if(!Ti(o))return;const i=bc(o,s);if(!(i!=null&&i.checkpointId))return;const a=zo(i.checkpointId,i.checkpointNs??null);t.has(a)||t.set(a,i)});const n=Array.from(t.values());n.sort((o,s)=>Sc(s.createdAt??"")-Sc(o.createdAt??""));const r={};for(const[o,s]of t.entries())r[o]=s;return{orderedSnapshots:n,snapshotMap:r}}function nx(e){var t;for(let n=e.length-1;n>=0;n--){const r=((t=e[n])==null?void 0:t.content)??[];for(let o=0;o<r.length;o++){const s=r[o];if(s&&s.type==="text"&&typeof s.text=="string"){const i=s.text.trim();if(i)return i}}}return null}function rx(e,t){var n;for(let r=e.length-1;r>=0;r--){const o=((n=e[r])==null?void 0:n.content)??[];for(let s=o.length-1;s>=0;s--){const i=o[s];if((i==null?void 0:i.type)==="interrupt"){const a=i;return{id:typeof a.id=="string"&&a.id.trim()?a.id:`interrupt-${t}-${r}-${s}`,value:a.value}}}}return null}function ox(e,t){if(!Array.isArray(e)||!e.length)return null;for(let n=e.length-1;n>=0;n--){const r=sx(e[n],`task-${t}-${n}`);if(!r)continue;const o=r.id||`task-${t}-${n}`;if(Array.isArray(r.interrupts)&&r.interrupts.length)for(let s=r.interrupts.length-1;s>=0;s--){const i=Jr(r.interrupts[s],`${o}-interrupt-${s}`);if(i)return i}if(r.state!==void 0&&r.state!==null){const s=Jr(r.state,`${o}-state`);if(s)return s}}return null}function sx(e,t){if(!e)return null;if(Array.isArray(e)){const[a,l,u,,d,,f,...h]=e,p=typeof a=="string"&&a.trim()?a:t,v=typeof l=="string"&&l.trim()?l:Array.isArray(u)&&typeof u[0]=="string"?String(u[0]):"task",x=Array.isArray(d)?d:void 0,g=h.length?h[h.length-1]:void 0;return{id:p,name:v,interrupts:x,state:g!==void 0?g:f}}const n=zt(e);if(!n)return null;const r=ft(n,["id","task_id","taskId"])??t,o=ft(n,["name"])??"task",s=Array.isArray(n.interrupts)?n.interrupts:void 0,i=Object.prototype.hasOwnProperty.call(n,"state")?n.state:void 0;return{id:r,name:o,interrupts:s,state:i}}function Jr(e,t,n=0,r=new Set){if(n>6||e==null)return null;if(typeof e=="object"){if(r.has(e))return null;r.add(e)}const o=wc(e,t);if(o)return o;if(Array.isArray(e)){for(let s=e.length-1;s>=0;s--){const i=Jr(e[s],t,n+1,r);if(i)return i}return null}if(typeof e=="object"){const s=e,i=["interrupt","pending_interrupt","pendingInterrupt","value","data","payload","result","response"];for(const a of i)if(a in s){const l=Jr(s[a],t,n+1,r);if(l)return l}for(const[a,l]of Object.entries(s)){if(i.includes(a)||a==="messages"||a==="results")continue;const u=Jr(l,t,n+1,r);if(u)return u}}return null}function wc(e,t){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){const n=e,r=ft(n,["type","event","kind"]),o=ft(n,["id","interrupt_id","interruptId","value_id"])??(r&&r.toLowerCase().includes("interrupt")?t:void 0);if(!(Object.prototype.hasOwnProperty.call(n,"value")||Object.prototype.hasOwnProperty.call(n,"data")||Object.prototype.hasOwnProperty.call(n,"payload"))&&!(r&&r.toLowerCase().includes("interrupt")))return null;const i=Object.prototype.hasOwnProperty.call(n,"value")?n.value:Object.prototype.hasOwnProperty.call(n,"data")?n.data:Object.prototype.hasOwnProperty.call(n,"payload")?n.payload:n,a=o&&o.trim()?o:t;return a?{id:a,value:i}:null}if(Array.isArray(e)){for(let n=e.length-1;n>=0;n--){const r=wc(e[n],t);if(r)return r}return e.length>=2&&typeof e[0]=="string"&&e[0].trim()?{id:e[0],value:e[1]}:null}if(typeof e=="string"){const n=e.trim();return n?{id:t||n,value:n}:null}return null}function Sc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function ix(e,t){if(!e||typeof e!="object")return null;const n=e,r=zt(e)??{},o=zt(n.data)??r,s=String(n.type??o.type??o.role??"").toLowerCase(),i=Qg[s];if(!i)return null;const a=o.id??o.message_id??o.run_id??null,l=typeof a=="string"&&a.trim()?a:`history-${i}-${t}`,u=zt(o.additional_kwargs)??zt(o.additionalKwargs),d=zt(o.response_metadata)??zt(o.responseMetadata),f=ft(u,["createdAt","created_at"])??ft(o,["created_at","createdAt"]),h=ft(u,["checkpointId","checkpoint_id"]),p=ft(u,["checkpointNs","checkpoint_ns"]),v=ax(o.content),x={id:l,role:i,content:v};f&&(x.createdAt=f),typeof o.name=="string"&&o.name.trim()&&(x.name=o.name),typeof(d==null?void 0:d.model_name)=="string"&&(x.model=String(d.model_name)),!x.model&&typeof o.model=="string"&&(x.model=o.model),h&&(x.checkpointId=h),p&&(x.checkpointNs=p);const g=fx(u,["createdAt","created_at","checkpointId","checkpoint_id","checkpointNs","checkpoint_ns","tool_calls"]),y=d?{...d}:void 0;g&&Object.keys(g).length&&(x.additionalKwargs=g),y&&Object.keys(y).length&&(x.responseMetadata=y);const b=lx((u==null?void 0:u.tool_calls)??o.tool_calls);if(b.length&&(x.content=[...x.content,...b]),i==="tool"){const S=ux(o,x.content);S&&(x.content=S)}return x}function ax(e){if(!e)return[];if(Array.isArray(e))return e.map(t=>Cc(t)).filter(t=>!!t);if(typeof e=="string")return e.trim()?[{type:"text",text:e.trim()}]:[];if(typeof e=="object"){const t=Cc(e);return t?[t]:[]}return[]}function Cc(e){if(!e||typeof e!="object")return typeof e=="string"&&e.trim()?{type:"text",text:e}:null;const t=e,n=String(t.type??"").toLowerCase();if(!n||n==="text"){const o=typeof t.text=="string"?t.text:typeof t.value=="string"?t.value:"";return o.trim()?{type:"text",text:o}:null}if(n==="image"||n==="image_url"){const o=ft(t,["url","src"]);if(!o)return null;const s={type:"image_url",url:o};return typeof t.mimeType=="string"&&(s.mimeType=t.mimeType),typeof t.alt=="string"&&(s.alt=t.alt),s}if(n==="file"){const o=ft(t,["url"]);if(!o)return null;const s={type:"file",url:o};return typeof t.mimeType=="string"&&(s.mimeType=t.mimeType),typeof t.name=="string"&&(s.name=t.name),typeof t.size=="number"&&(s.size=t.size),typeof t.sourceType=="string"&&(s.sourceType=t.sourceType),s}if(n==="tool_call")return cx(t)??null;if(n==="tool_end"){const o=ft(t,["tool_call_id","toolCallId","id"]);if(!o)return null;const s={type:"tool_end",toolCallId:o,output:"output"in t?t.output:t.content};return typeof t.error=="string"&&(s.error=t.error),s}if(n==="interrupt")return{type:"interrupt",value:t.value,...t};if(n==="tool"){const o=ft(t,["text","content"]);if(o)return{type:"text",text:o}}const r=typeof t.content=="string"?t.content:typeof t.value=="string"?t.value:JSON.stringify(t);return r?{type:"text",text:r}:null}function lx(e){return Array.isArray(e)?e.map((t,n)=>{if(!t||typeof t!="object")return null;const r=t,o=ft(r,["id","call_id"]),s=zt(r.function),i=ft(s,["name"])??"tool",a=s==null?void 0:s.arguments,l=Tc(a);return{type:"tool_call",id:o??`tool_call_${n}`,name:i,args:l}}).filter(t=>!!t):[]}function cx(e){const t=ft(e,["id","call_id"]),n=ft(e,["name"]);if(!t||!n)return null;const r=Tc(e.args??e.arguments);return{type:"tool_call",id:t,name:n,args:r}}function ux(e,t){const n=ft(e,["tool_call_id","toolCallId","id"]);if(!n)return t;const r=e.content??e.output,o=typeof r=="string"?dx(r):r,s={type:"tool_end",toolCallId:n,output:o};return typeof e.error=="string"&&(s.error=e.error),[s]}function Tc(e){if(!e)return{};if(typeof e=="string")try{const t=JSON.parse(e);return typeof t=="object"&&t!==null?t:{raw:e}}catch{return{raw:e}}return typeof e=="object"&&!Array.isArray(e)?{...e}:{}}function dx(e){try{return JSON.parse(e)}catch{return e}}function zt(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function ft(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r}}function fx(e,t){if(!e)return;const n={};let r=!1;for(const[o,s]of Object.entries(e)){if(t.includes(o)){r=!0;continue}s!==void 0&&(n[o]=s)}return r?Object.keys(n).length?n:void 0:e}function hx(e){return e.type!=="thread_info"&&e.type!=="token"}const px={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,messagesStreamMeta:{},pendingInterrupt:null};function mx(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:ki(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,pendingInterrupt:null};return console.log("[MessageReducer] 📊 After reset - messages count:",r.messages.length),r}case"seed":{const r=ki(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),console.log("[MessageReducer] seed action (REPLACE mode):",{incomingCount:t.payload.messages.length,sanitizedCount:r.length,previousCount:e.messages.length,checkpointId:o.lastCheckpointId}),o}case"prepend":{const r=ki(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 Ec(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Ec(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 kc(e=[]){const[t,n]=w.useReducer(mx,{...px,messages:e}),r=w.useRef([]),o=w.useRef(null),s=w.useRef(null),i=w.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=w.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=w.useCallback(d=>{r.current.push(d),a()},[a]);w.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const u=w.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:d=>n({type:"user_message",payload:{message:d}}),onEvent:l}),[l]);return{state:t,dispatch:n,...u}}function Ec(e,t){var n,r,o,s;if(t.type==="message_start"&&t.role==="assistant"){const i=t.id,a=yx(t.model);if(e.messages.some(d=>d.id===i)){const d=e.messagesStreamMeta??{},f={...d,[i]:d[i]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:i,messagesStreamMeta:f}}const u={id:i,role:"assistant",name:a||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:i,messages:[...e.messages,u]}}if(t.type==="message_delta"){const i=e.assemblingId??Ei(e.messages);if(!i)return e;const a=e.messages,l=a.findIndex(S=>S.id===i&&S.role==="assistant");if(l===-1)return e;const u=a[l],d=e.messagesStreamMeta??{},f=d[i]??{lastSeq:null,lastText:jc(u.content)},h=t.seq??null;if(h!==null&&typeof h=="number"&&typeof f.lastSeq=="number"&&h<=f.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:h,lastSeq:f.lastSeq}),e;const{newParts:p,newMeta:v,changed:x}=gx(u.content,t.delta,f,h);if(!x)return e;const g={...u,content:p},y=Ic(a,l,g),b={...d,[i]:v};return{...e,messages:y,messagesStreamMeta:b}}if(t.type==="message_end"){const i=e.assemblingId??Ei(e.messages);if(!i)return{...e,assemblingId:null};const a=e.messages,l=a.findIndex(u=>u.id===i&&u.role==="assistant");if(l>=0){const u=a[l];if(!((n=u.content)==null?void 0:n.some(f=>{var h;return(f==null?void 0:f.type)==="text"&&((h=f.text)==null?void 0:h.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:u.id,contentTypes:(r=u.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=u.content)==null?void 0:o.map(h=>(h==null?void 0:h.type)==="text"?String(h.text).slice(0,100):h==null?void 0:h.type)});const f=[...a.slice(0,l),...a.slice(l+1)];return{...e,assemblingId:null,messages:f}}}return e}if(t.type==="tool_start"){const i=t.id??t.call_id,a=t.name??t.tool??"tool";if(!i)return e;const l=`tool-${i}`,u={type:"tool_call",id:i,name:a,args:t.args};if(e.messages.find(h=>h.id===l))return{...e,toolIndex:{...e.toolIndex,[i]:l}};const f={id:l,role:"tool",name:a,createdAt:new Date().toISOString(),content:[u]};return{...e,messages:[...e.messages,f],toolIndex:{...e.toolIndex,[i]:l}}}if(t.type==="tool_end"){const i=t.id??t.call_id;if(!i)return e;const a=e.toolIndex[i]??`tool-${i}`,l={type:"tool_end",toolCallId:i,output:t.output,error:t.error},u=e.messages.find(h=>h.id===a),d={id:a,role:"tool",name:t.name??((s=e.messages.find(h=>h.id===a))==null?void 0:s.name),content:[l],createdAt:new Date().toISOString()},f=u?Ac(e.messages,a,[l]):[...e.messages,d];return{...e,messages:f,toolIndex:{...e.toolIndex,[i]:a}}}if(t.type==="checkpoint"){const i=t.checkpointNs??e.lastCheckpointNs??null,a=xx(e.messages,t.checkpointId,i);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:i,messages:a}}if(t.type==="branch"){const i=t.checkpointId??e.lastCheckpointId,a=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:i??null,lastCheckpointNs:a??null}}if(t.type==="error"){const i={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,i]}}if(t.type==="interrupt"){const i=e.assemblingId??Ei(e.messages),a={type:"interrupt",value:t.value,id:t.id};if(i)return{...e,assemblingId:null,messages:Ac(e.messages,i,[a]),pendingInterrupt:{id:t.id,value:t.value}};const l=`interrupt-${t.id}`;if(e.messages.findIndex(f=>f.id===l)!==-1)return{...e,assemblingId:null,messages:Nc(e.messages,l,f=>({...f,content:_c(f.content??[],[a])})),pendingInterrupt:{id:t.id,value:t.value}};const d={id:l,role:"system",createdAt:new Date().toISOString(),content:[a]};return{...e,messages:[...e.messages,d],pendingInterrupt:{id:t.id,value:t.value}}}return e}function ki(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 Ic(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Ei(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function Nc(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 Ac(e,t,n){return Nc(e,t,r=>({...r,content:_c(r.content,n)}))}function _c(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1],s=r.text??"";if(!s)continue;if((o==null?void 0:o.type)==="text"){let i=function(p){return p.replace(/\s+/g," ").trim()};const a=o,l=a.text??"";if(console.debug("[MessageReducer] mergeParts",{incomingLength:s.length,previousLength:l.length,incomingSnippet:s.slice(0,100),previousSnippet:l.slice(-100)}),!l){a.text=s;continue}const u=i(s),d=i(l);if(u.startsWith(d)||s.startsWith(l)){console.debug("[MessageReducer] incoming startsWith previous (norm/raw) - replacing",{incomingLength:s.length,previousLength:l.length}),a.text=s;continue}if(u.includes(d)){console.debug("[MessageReducer] incoming includes previous (normalized) - replacing",{incomingLength:s.length,previousLength:l.length}),a.text=s;continue}if(d.includes(u)&&u.length<=3){console.debug("[MessageReducer] previous includes incoming (normalized) - skipping trivial incoming",{incomingLength:s.length,previousLength:l.length});continue}const h=Pc(l,s);h?(console.debug("[MessageReducer] suffix computed",{suffixLength:h.length}),a.text=l+h):(console.debug("[MessageReducer] no overlap detected - appending incoming",{incomingLength:s.length}),a.text=l+s)}else n.push({type:"text",text:s})}else n.push(r);return n}function jc(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function gx(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(f=>f.type==="text").map(f=>f.text??"").join(""),i=t.filter(f=>f.type!=="text"),a=o.lastText??jc(e);let l="",u=e.slice();if(s){const f=Pc(a,s);if(f===""?l="":f===s?l=s:l=f,l){const h=u[u.length-1];if((h==null?void 0:h.type)==="text"){const p=h.text??"",v={...h,text:p+l};u=[...u.slice(0,u.length-1),v]}else u=[...u,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(u=[...u,...i]);const d=!!(l||i.length);return{newParts:u,newMeta:o,changed:d}}function Rc(e){return e.replace(/\s+/g," ").trim()}function Pc(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let i=n;i>0;i--)if(e.slice(-i)===t.slice(0,i))return t.slice(i);const r=Rc(e),o=Rc(t);if(r===o)return"";const s=Math.min(r.length,o.length);for(let i=s;i>0;i--)if(r.slice(-i)===o.slice(0,i))return t;return t}function xx(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 Ic(e,r,s)}return e}function yx(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Oc(e={}){const t=w.useMemo(()=>En(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=w.useState(e.token??null),s=w.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=w.useState(!1),[u,d]=w.useState(null),[f,h]=w.useState(""),[p,v]=w.useState(null),[x,g]=w.useState(0),[y,b]=w.useState(!1),S=w.useRef(null),k=w.useRef(!0),C=w.useRef(0),T=w.useCallback(P=>{o(P)},[]),I=w.useCallback(()=>{var P;(P=S.current)==null||P.abort(),S.current=null,l(!1),b(!1),C.current=0,g(0)},[]),A=w.useCallback(()=>{h(""),v(null),d(null)},[]),j=w.useCallback((P,D,L)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h("");const B=new AbortController;return S.current=B,(async()=>{var X,W,V,z,$,pe,F,Z;const M=he=>{var ve;try{const be=JSON.parse(JSON.stringify(he));return(ve=be==null?void 0:be.payload)!=null&&ve.files_info&&Array.isArray(be.payload.files_info)&&(be.payload.files_info=be.payload.files_info.map(Te=>({...Te,data:Te!=null&&Te.data?`<base64 ${String(Te.data).length} chars>`:Te==null?void 0:Te.data}))),be}catch{return he}};try{let he={};try{if(r)he={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const He=window.__AUTH_TOKEN__,ht=((X=window.localStorage)==null?void 0:X.getItem("authToken"))||null;let nt=null;try{const bt=(W=window.localStorage)==null?void 0:W.getItem("chat-settings");bt&&(nt=((V=JSON.parse(bt))==null?void 0:V.apiKey)||null)}catch{}const Me=He||ht||nt||null;Me&&(he={Authorization:`Bearer ${Me}`})}}catch{}console.debug("[use-chat] POST",t+n,M(P));const ve=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...he,...s.current},body:JSON.stringify(P),signal:B.signal,credentials:i});if(!ve.ok||!ve.body){const Oe=await ve.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",ve.status,Oe==null?void 0:Oe.slice(0,500)),new Error(`stream ${ve.status}${Oe?": "+Oe:""}`)}b(!0);const be=ve.body.getReader(),Te=new TextDecoder;let K="",O=[];C.current=0,g(0);let J=0,te=null;const de=()=>{if(O.length){const Oe=O.join("");O=[],k.current&&h(He=>He+Oe)}te=null},le=()=>{typeof window<"u"&&te==null&&(te=requestAnimationFrame(de))};let ie=Date.now();const tt=setInterval(()=>{var Oe;if(Date.now()-ie>6e4){const He="Stream idle timeout";d(He),B.abort(),(Oe=L==null?void 0:L.onError)==null||Oe.call(L,He)}},5e3),et=1024*1024;try{const Oe=ve.headers.get("X-Thread-Id")||ve.headers.get("x-thread-id"),He=ve.headers.get("X-Thread-Created")||ve.headers.get("x-thread-created"),ht=Oe??null,nt=String(He??"").toLowerCase()==="true";for((z=L==null?void 0:L.onOpen)==null||z.call(L,{threadId:ht,created:nt});;){const{value:Me,done:bt}=await be.read();if(bt)break;K+=Te.decode(Me,{stream:!0}),K.length>et&&(K="",console.warn("Stream buffer reset: exceeded 1MB"));let ne;for(;(ne=K.indexOf(`
34
+ `):" "+oc(i[0]):"as no adapter specified";throw new De("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:vi};function bi(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Ir(null,e)}function ic(e){return bi(e),e.headers=zt.from(e.headers),e.data=yi.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),sc.getAdapter(e.adapter||Jr.adapter,e)(e).then(function(r){return bi(e),r.data=yi.call(e,e.transformResponse,r),r.headers=zt.from(r.headers),r},function(r){return Vl(r)||(bi(e),r&&r.response&&(r.response.data=yi.call(e,e.transformResponse,r.response),r.response.headers=zt.from(r.response.headers))),Promise.reject(r)})}const ac="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 lc={};Fo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+ac+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new De(o(i," has been removed"+(n?" in "+n:"")),De.ERR_DEPRECATED);return n&&!lc[i]&&(lc[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 qg(e,t,n){if(typeof e!="object")throw new De("options must be an object",De.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 De("option "+s+" must be "+l,De.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new De("Unknown option "+s,De.ERR_BAD_OPTION)}}const zo={assertOptions:qg,validators:Fo},hn=zo.validators;let ir=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Bl,response:new Bl}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
35
+ `+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=sr(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&zo.assertOptions(r,{silentJSONParsing:hn.transitional(hn.boolean),forcedJSONParsing:hn.transitional(hn.boolean),clarifyTimeoutError:hn.transitional(hn.boolean)},!1),o!=null&&(R.isFunction(o)?n.paramsSerializer={serialize:o}:zo.assertOptions(o,{encode:hn.function,serialize:hn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),zo.assertOptions(n,{baseUrl:hn.spelling("baseURL"),withXsrfToken:hn.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"],v=>{delete s[v]}),n.headers=zt.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(x){typeof x.runWhen=="function"&&x.runWhen(n)===!1||(l=l&&x.synchronous,a.unshift(x.fulfilled,x.rejected))});const u=[];this.interceptors.response.forEach(function(x){u.push(x.fulfilled,x.rejected)});let d,f=0,h;if(!l){const v=[ic.bind(this),void 0];for(v.unshift(...a),v.push(...u),h=v.length,d=Promise.resolve(n);f<h;)d=d.then(v[f++],v[f++]);return d}h=a.length;let p=n;for(;f<h;){const v=a[f++],x=a[f++];try{p=v(p)}catch(g){x.call(this,g);break}}try{d=ic.call(this,p)}catch(v){return Promise.reject(v)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=sr(this.defaults,t);const n=Yl(t.baseURL,t.url,t.allowAbsoluteUrls);return zl(n,t.params,t.paramsSerializer)}};R.forEach(["delete","get","head","options"],function(t){ir.prototype[t]=function(n,r){return this.request(sr(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(sr(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}ir.prototype[t]=n(),ir.prototype[t+"Form"]=n(!0)});let Gg=class Tm{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 Ir(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 Tm(function(o){t=o}),cancel:t}}};function Yg(e){return function(n){return e.apply(null,n)}}function Xg(e){return R.isObject(e)&&e.isAxiosError===!0}const wi={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(wi).forEach(([e,t])=>{wi[t]=e});function cc(e){const t=new ir(e),n=kl(ir.prototype.request,t);return R.extend(n,ir.prototype,t,{allOwnKeys:!0}),R.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return cc(sr(e,o))},n}const mt=cc(Jr);mt.Axios=ir,mt.CanceledError=Ir,mt.CancelToken=Gg,mt.isCancel=Vl,mt.VERSION=ac,mt.toFormData=Mo,mt.AxiosError=De,mt.Cancel=mt.CanceledError,mt.all=function(t){return Promise.all(t)},mt.spread=Yg,mt.isAxiosError=Xg,mt.mergeConfig=sr,mt.AxiosHeaders=zt,mt.formToJSON=e=>Ul(R.isHTMLForm(e)?new FormData(e):e),mt.getAdapter=sc.getAdapter,mt.HttpStatusCode=wi,mt.default=mt;const{Axios:BT,AxiosError:HT,CanceledError:UT,isCancel:WT,CancelToken:VT,VERSION:KT,all:qT,Cancel:GT,isAxiosError:YT,spread:XT,toFormData:JT,AxiosHeaders:ZT,HttpStatusCode:QT,formToJSON:ek,getAdapter:tk,mergeConfig:nk}=mt,uc=typeof window<"u"?window.__API_BASE_URL__:void 0,dc=uc?_n(uc):void 0;function _n(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Bo=null;const Si=new Set;function fc(){return Bo}function Ci(e){Bo=e,Si.forEach(t=>t(e))}function hc(e){return Si.add(e),()=>Si.delete(e)}const Xt=mt.create({...dc?{baseURL:dc}:{},timeout:3e4,withCredentials:!0});Xt.interceptors.request.use(e=>(Bo&&(e.headers.Authorization=`Bearer ${Bo}`),e)),Xt.interceptors.response.use(e=>e,e=>Promise.reject(e));async function pn(e,t){return Xt.defaults.baseURL?(await Xt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function pc(e,t,n){return Xt.defaults.baseURL?(await Xt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function mc(e,t,n){return Xt.defaults.baseURL?(await Xt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function gc(e,t){return Xt.defaults.baseURL?(await Xt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function jn(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class xc{get baseUrl(){const t=Xt.defaults.baseURL;return t?_n(String(t)):""}updateConfig(t){t.baseUrl&&(Xt.defaults.baseURL=_n(String(t.baseUrl))),t.authToken!==void 0&&Ci(t.authToken)}getAuthToken(){return fc()}setAuthToken(t){Ci(t)}onTokenChange(t){return hc(t)}async listThreads(){const t=await pn("/threads"),n=jn(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await pc("/threads",t?{title:t}:void 0);return jn(r)}async updateThread(t,n){const r=await mc(`/threads/${t}`,{title:n});return jn(r)}async deleteThread(t){const n=await gc(`/threads/${t}`);return jn(n)}async threadInfo(t){const n=await pn(`/threads/${t}/info`);return jn(n)}async listAgents(){const t=await pn("/agents"),n=jn(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await pn(`/agents/${t}`);return jn(n)}async getAgentSchema(t){const n=await pn(`/agents/${t}/schema`);return jn(n)}async getStateHistory(t){const n=await pn(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return jn(n)}}const Fn=new xc,yc=w.createContext(null);function Jg({children:e,apiConfig:t}){const n=Fn;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(yc.Provider,{value:r,children:e})}function Ti(){const e=w.useContext(yc);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function Zg(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let l=0;l<a;l++)i+=String.fromCharCode(s[l]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function Qg(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const u=await Zg(l);a.push({filename:l.name,data:u,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const ex={human:"user",user:"user",ai:"assistant",assistant:"assistant",tool:"tool",function:"tool",system:"system"};function ki(e){if(!e||typeof e!="object")return!1;const t=e;return"values"in t&&"config"in t&&typeof t.values=="object"&&t.values!==null&&typeof t.config=="object"&&t.config!==null}function Ho(e,t){return`${e??""}::${t??""}`}function vc(e){const t=Array.isArray(e==null?void 0:e.checkpoints)?(e==null?void 0:e.checkpoints)??[]:e!=null&&e.checkpoints?Object.values(e.checkpoints):[],n=(e==null?void 0:e.threadId)??"",r=t[0];if(!ki(r))return{threadId:n,latest:null,checkpoints:[],interrupt:null,snapshots:{}};const{orderedSnapshots:o,snapshotMap:s}=nx(t),i=bc(r,0);return{threadId:n,latest:i,checkpoints:o,interrupt:(i==null?void 0:i.interrupt)??null,snapshots:s}}function bc(e,t){var C,T;if(!ki(e))return null;const n=e.values??{},r=Array.isArray(n==null?void 0:n.messages)?n.messages:[],o=e.tasks,s=r.map((I,A)=>ax(I,A)).filter(I=>!!I),i=Ut((C=e.config)==null?void 0:C.configurable),a=ft(i,["checkpoint_id","checkpointId"]),l=ft(i,["checkpoint_ns","checkpointNs"]),u=Ut((T=e.parentConfig)==null?void 0:T.configurable),d=ft(u,["checkpoint_id","checkpointId"])??null,f=ft(u,["checkpoint_ns","checkpointNs"])??null,h=e==null?void 0:e.createdAt,p=typeof h=="string"&&h.trim()?h:new Date(Date.now()-t).toISOString(),v=rx(s),x=s[s.length-1]??null,g=Ut(e==null?void 0:e.metadata),y=ft(g,["branch_label","branchLabel"]),b=Ut(e==null?void 0:e.parentConfig),S=Ut(b==null?void 0:b.configurable),k=ft(S,["checkpoint_id","checkpointId"]);return{messages:s,checkpointId:a??null,checkpointNs:l??null,nextCursor:d,nextCursorNs:f,interrupt:tx(o,s,t),createdAt:p,preview:v??null,role:(x==null?void 0:x.role)??null,parentId:k??null,branchLabel:y??null,lastMessageId:(x==null?void 0:x.id)??null,hasMessages:s.length>0,messagesLen:s.length}}function tx(e,t,n){const r=sx(e,n);return r||ox(t,n)}function nx(e){const t=new Map;e.forEach((o,s)=>{if(!ki(o))return;const i=bc(o,s);if(!(i!=null&&i.checkpointId))return;const a=Ho(i.checkpointId,i.checkpointNs??null);t.has(a)||t.set(a,i)});const n=Array.from(t.values());n.sort((o,s)=>Sc(s.createdAt??"")-Sc(o.createdAt??""));const r={};for(const[o,s]of t.entries())r[o]=s;return{orderedSnapshots:n,snapshotMap:r}}function rx(e){var t;for(let n=e.length-1;n>=0;n--){const r=((t=e[n])==null?void 0:t.content)??[];for(let o=0;o<r.length;o++){const s=r[o];if(s&&s.type==="text"&&typeof s.text=="string"){const i=s.text.trim();if(i)return i}}}return null}function ox(e,t){var n;for(let r=e.length-1;r>=0;r--){const o=((n=e[r])==null?void 0:n.content)??[];for(let s=o.length-1;s>=0;s--){const i=o[s];if((i==null?void 0:i.type)==="interrupt"){const a=i;return{id:typeof a.id=="string"&&a.id.trim()?a.id:`interrupt-${t}-${r}-${s}`,value:a.value}}}}return null}function sx(e,t){if(!Array.isArray(e)||!e.length)return null;for(let n=e.length-1;n>=0;n--){const r=ix(e[n],`task-${t}-${n}`);if(!r)continue;const o=r.id||`task-${t}-${n}`;if(Array.isArray(r.interrupts)&&r.interrupts.length)for(let s=r.interrupts.length-1;s>=0;s--){const i=Qr(r.interrupts[s],`${o}-interrupt-${s}`);if(i)return i}if(r.state!==void 0&&r.state!==null){const s=Qr(r.state,`${o}-state`);if(s)return s}}return null}function ix(e,t){if(!e)return null;if(Array.isArray(e)){const[a,l,u,,d,,f,...h]=e,p=typeof a=="string"&&a.trim()?a:t,v=typeof l=="string"&&l.trim()?l:Array.isArray(u)&&typeof u[0]=="string"?String(u[0]):"task",x=Array.isArray(d)?d:void 0,g=h.length?h[h.length-1]:void 0;return{id:p,name:v,interrupts:x,state:g!==void 0?g:f}}const n=Ut(e);if(!n)return null;const r=ft(n,["id","task_id","taskId"])??t,o=ft(n,["name"])??"task",s=Array.isArray(n.interrupts)?n.interrupts:void 0,i=Object.prototype.hasOwnProperty.call(n,"state")?n.state:void 0;return{id:r,name:o,interrupts:s,state:i}}function Qr(e,t,n=0,r=new Set){if(n>6||e==null)return null;if(typeof e=="object"){if(r.has(e))return null;r.add(e)}const o=wc(e,t);if(o)return o;if(Array.isArray(e)){for(let s=e.length-1;s>=0;s--){const i=Qr(e[s],t,n+1,r);if(i)return i}return null}if(typeof e=="object"){const s=e,i=["interrupt","pending_interrupt","pendingInterrupt","value","data","payload","result","response"];for(const a of i)if(a in s){const l=Qr(s[a],t,n+1,r);if(l)return l}for(const[a,l]of Object.entries(s)){if(i.includes(a)||a==="messages"||a==="results")continue;const u=Qr(l,t,n+1,r);if(u)return u}}return null}function wc(e,t){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){const n=e,r=ft(n,["type","event","kind"]),o=ft(n,["id","interrupt_id","interruptId","value_id"])??(r&&r.toLowerCase().includes("interrupt")?t:void 0);if(!(Object.prototype.hasOwnProperty.call(n,"value")||Object.prototype.hasOwnProperty.call(n,"data")||Object.prototype.hasOwnProperty.call(n,"payload"))&&!(r&&r.toLowerCase().includes("interrupt")))return null;const i=Object.prototype.hasOwnProperty.call(n,"value")?n.value:Object.prototype.hasOwnProperty.call(n,"data")?n.data:Object.prototype.hasOwnProperty.call(n,"payload")?n.payload:n,a=o&&o.trim()?o:t;return a?{id:a,value:i}:null}if(Array.isArray(e)){for(let n=e.length-1;n>=0;n--){const r=wc(e[n],t);if(r)return r}return e.length>=2&&typeof e[0]=="string"&&e[0].trim()?{id:e[0],value:e[1]}:null}if(typeof e=="string"){const n=e.trim();return n?{id:t||n,value:n}:null}return null}function Sc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function ax(e,t){if(!e||typeof e!="object")return null;const n=e,r=Ut(e)??{},o=Ut(n.data)??r,s=String(n.type??o.type??o.role??"").toLowerCase(),i=ex[s];if(!i)return null;const a=o.id??o.message_id??o.run_id??null,l=typeof a=="string"&&a.trim()?a:`history-${i}-${t}`,u=Ut(o.additional_kwargs)??Ut(o.additionalKwargs),d=Ut(o.response_metadata)??Ut(o.responseMetadata),f=ft(u,["createdAt","created_at"])??ft(o,["created_at","createdAt"]),h=ft(u,["checkpointId","checkpoint_id"]),p=ft(u,["checkpointNs","checkpoint_ns"]),v=lx(o.content),x={id:l,role:i,content:v};f&&(x.createdAt=f),typeof o.name=="string"&&o.name.trim()&&(x.name=o.name),typeof(d==null?void 0:d.model_name)=="string"&&(x.model=String(d.model_name)),!x.model&&typeof o.model=="string"&&(x.model=o.model),h&&(x.checkpointId=h),p&&(x.checkpointNs=p);const g=hx(u,["createdAt","created_at","checkpointId","checkpoint_id","checkpointNs","checkpoint_ns","tool_calls"]),y=d?{...d}:void 0;g&&Object.keys(g).length&&(x.additionalKwargs=g),y&&Object.keys(y).length&&(x.responseMetadata=y);const b=cx((u==null?void 0:u.tool_calls)??o.tool_calls);if(b.length&&(x.content=[...x.content,...b]),i==="tool"){const S=dx(o,x.content);S&&(x.content=S)}return x}function lx(e){if(!e)return[];if(Array.isArray(e))return e.map(t=>Cc(t)).filter(t=>!!t);if(typeof e=="string")return e.trim()?[{type:"text",text:e.trim()}]:[];if(typeof e=="object"){const t=Cc(e);return t?[t]:[]}return[]}function Cc(e){if(!e||typeof e!="object")return typeof e=="string"&&e.trim()?{type:"text",text:e}:null;const t=e,n=String(t.type??"").toLowerCase();if(!n||n==="text"){const o=typeof t.text=="string"?t.text:typeof t.value=="string"?t.value:"";return o.trim()?{type:"text",text:o}:null}if(n==="image"||n==="image_url"){const o=ft(t,["url","src"]);if(!o)return null;const s={type:"image_url",url:o};return typeof t.mimeType=="string"&&(s.mimeType=t.mimeType),typeof t.alt=="string"&&(s.alt=t.alt),s}if(n==="file"){const o=ft(t,["url"]);if(!o)return null;const s={type:"file",url:o};return typeof t.mimeType=="string"&&(s.mimeType=t.mimeType),typeof t.name=="string"&&(s.name=t.name),typeof t.size=="number"&&(s.size=t.size),typeof t.sourceType=="string"&&(s.sourceType=t.sourceType),s}if(n==="tool_call")return ux(t)??null;if(n==="tool_end"){const o=ft(t,["tool_call_id","toolCallId","id"]);if(!o)return null;const s={type:"tool_end",toolCallId:o,output:"output"in t?t.output:t.content};return typeof t.error=="string"&&(s.error=t.error),s}if(n==="interrupt")return{type:"interrupt",value:t.value,...t};if(n==="tool"){const o=ft(t,["text","content"]);if(o)return{type:"text",text:o}}const r=typeof t.content=="string"?t.content:typeof t.value=="string"?t.value:JSON.stringify(t);return r?{type:"text",text:r}:null}function cx(e){return Array.isArray(e)?e.map((t,n)=>{if(!t||typeof t!="object")return null;const r=t,o=ft(r,["id","call_id"]),s=Ut(r.function),i=ft(s,["name"])??"tool",a=s==null?void 0:s.arguments,l=Tc(a);return{type:"tool_call",id:o??`tool_call_${n}`,name:i,args:l}}).filter(t=>!!t):[]}function ux(e){const t=ft(e,["id","call_id"]),n=ft(e,["name"]);if(!t||!n)return null;const r=Tc(e.args??e.arguments);return{type:"tool_call",id:t,name:n,args:r}}function dx(e,t){const n=ft(e,["tool_call_id","toolCallId","id"]);if(!n)return t;const r=e.content??e.output,o=typeof r=="string"?fx(r):r,s={type:"tool_end",toolCallId:n,output:o};return typeof e.error=="string"&&(s.error=e.error),[s]}function Tc(e){if(!e)return{};if(typeof e=="string")try{const t=JSON.parse(e);return typeof t=="object"&&t!==null?t:{raw:e}}catch{return{raw:e}}return typeof e=="object"&&!Array.isArray(e)?{...e}:{}}function fx(e){try{return JSON.parse(e)}catch{return e}}function Ut(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function ft(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r}}function hx(e,t){if(!e)return;const n={};let r=!1;for(const[o,s]of Object.entries(e)){if(t.includes(o)){r=!0;continue}s!==void 0&&(n[o]=s)}return r?Object.keys(n).length?n:void 0:e}function px(e){return e.type!=="thread_info"&&e.type!=="token"}const mx={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,messagesStreamMeta:{},pendingInterrupt:null};function gx(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:Ei(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,pendingInterrupt:null};return console.log("[MessageReducer] 📊 After reset - messages count:",r.messages.length),r}case"seed":{const r=Ei(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),console.log("[MessageReducer] seed action (REPLACE mode):",{incomingCount:t.payload.messages.length,sanitizedCount:r.length,previousCount:e.messages.length,checkpointId:o.lastCheckpointId}),o}case"prepend":{const r=Ei(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 Ec(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Ec(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 kc(e=[]){const[t,n]=w.useReducer(gx,{...mx,messages:e}),r=w.useRef([]),o=w.useRef(null),s=w.useRef(null),i=w.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=w.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=w.useCallback(d=>{r.current.push(d),a()},[a]);w.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const u=w.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:d=>n({type:"user_message",payload:{message:d}}),onEvent:l}),[l]);return{state:t,dispatch:n,...u}}function Ec(e,t){var n,r,o,s;if(t.type==="message_start"&&t.role==="assistant"){const i=t.id,a=vx(t.model);if(e.messages.some(d=>d.id===i)){const d=e.messagesStreamMeta??{},f={...d,[i]:d[i]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:i,messagesStreamMeta:f}}const u={id:i,role:"assistant",name:a||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:i,messages:[...e.messages,u]}}if(t.type==="message_delta"){const i=e.assemblingId??Ii(e.messages);if(!i)return e;const a=e.messages,l=a.findIndex(S=>S.id===i&&S.role==="assistant");if(l===-1)return e;const u=a[l],d=e.messagesStreamMeta??{},f=d[i]??{lastSeq:null,lastText:jc(u.content)},h=t.seq??null;if(h!==null&&typeof h=="number"&&typeof f.lastSeq=="number"&&h<=f.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:h,lastSeq:f.lastSeq}),e;const{newParts:p,newMeta:v,changed:x}=xx(u.content,t.delta,f,h);if(!x)return e;const g={...u,content:p},y=Ic(a,l,g),b={...d,[i]:v};return{...e,messages:y,messagesStreamMeta:b}}if(t.type==="message_end"){const i=e.assemblingId??Ii(e.messages);if(!i)return{...e,assemblingId:null};const a=e.messages,l=a.findIndex(u=>u.id===i&&u.role==="assistant");if(l>=0){const u=a[l];if(!((n=u.content)==null?void 0:n.some(f=>{var h;return(f==null?void 0:f.type)==="text"&&((h=f.text)==null?void 0:h.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:u.id,contentTypes:(r=u.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=u.content)==null?void 0:o.map(h=>(h==null?void 0:h.type)==="text"?String(h.text).slice(0,100):h==null?void 0:h.type)});const f=[...a.slice(0,l),...a.slice(l+1)];return{...e,assemblingId:null,messages:f}}}return e}if(t.type==="tool_start"){const i=t.id??t.call_id,a=t.name??t.tool??"tool";if(!i)return e;const l=`tool-${i}`,u={type:"tool_call",id:i,name:a,args:t.args};if(e.messages.find(h=>h.id===l))return{...e,toolIndex:{...e.toolIndex,[i]:l}};const f={id:l,role:"tool",name:a,createdAt:new Date().toISOString(),content:[u]};return{...e,messages:[...e.messages,f],toolIndex:{...e.toolIndex,[i]:l}}}if(t.type==="tool_end"){const i=t.id??t.call_id;if(!i)return e;const a=e.toolIndex[i]??`tool-${i}`,l={type:"tool_end",toolCallId:i,output:t.output,error:t.error},u=e.messages.find(h=>h.id===a),d={id:a,role:"tool",name:t.name??((s=e.messages.find(h=>h.id===a))==null?void 0:s.name),content:[l],createdAt:new Date().toISOString()},f=u?Ac(e.messages,a,[l]):[...e.messages,d];return{...e,messages:f,toolIndex:{...e.toolIndex,[i]:a}}}if(t.type==="checkpoint"){const i=t.checkpointNs??e.lastCheckpointNs??null,a=yx(e.messages,t.checkpointId,i);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:i,messages:a}}if(t.type==="branch"){const i=t.checkpointId??e.lastCheckpointId,a=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:i??null,lastCheckpointNs:a??null}}if(t.type==="error"){const i={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,i]}}if(t.type==="interrupt"){const i=e.assemblingId??Ii(e.messages),a={type:"interrupt",value:t.value,id:t.id};if(i)return{...e,assemblingId:null,messages:Ac(e.messages,i,[a]),pendingInterrupt:{id:t.id,value:t.value}};const l=`interrupt-${t.id}`;if(e.messages.findIndex(f=>f.id===l)!==-1)return{...e,assemblingId:null,messages:Nc(e.messages,l,f=>({...f,content:_c(f.content??[],[a])})),pendingInterrupt:{id:t.id,value:t.value}};const d={id:l,role:"system",createdAt:new Date().toISOString(),content:[a]};return{...e,messages:[...e.messages,d],pendingInterrupt:{id:t.id,value:t.value}}}return e}function Ei(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 Ic(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Ii(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function Nc(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 Ac(e,t,n){return Nc(e,t,r=>({...r,content:_c(r.content,n)}))}function _c(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1],s=r.text??"";if(!s)continue;if((o==null?void 0:o.type)==="text"){let i=function(p){return p.replace(/\s+/g," ").trim()};const a=o,l=a.text??"";if(console.debug("[MessageReducer] mergeParts",{incomingLength:s.length,previousLength:l.length,incomingSnippet:s.slice(0,100),previousSnippet:l.slice(-100)}),!l){a.text=s;continue}const u=i(s),d=i(l);if(u.startsWith(d)||s.startsWith(l)){console.debug("[MessageReducer] incoming startsWith previous (norm/raw) - replacing",{incomingLength:s.length,previousLength:l.length}),a.text=s;continue}if(u.includes(d)){console.debug("[MessageReducer] incoming includes previous (normalized) - replacing",{incomingLength:s.length,previousLength:l.length}),a.text=s;continue}if(d.includes(u)&&u.length<=3){console.debug("[MessageReducer] previous includes incoming (normalized) - skipping trivial incoming",{incomingLength:s.length,previousLength:l.length});continue}const h=Pc(l,s);h?(console.debug("[MessageReducer] suffix computed",{suffixLength:h.length}),a.text=l+h):(console.debug("[MessageReducer] no overlap detected - appending incoming",{incomingLength:s.length}),a.text=l+s)}else n.push({type:"text",text:s})}else n.push(r);return n}function jc(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function xx(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(f=>f.type==="text").map(f=>f.text??"").join(""),i=t.filter(f=>f.type!=="text"),a=o.lastText??jc(e);let l="",u=e.slice();if(s){const f=Pc(a,s);if(f===""?l="":f===s?l=s:l=f,l){const h=u[u.length-1];if((h==null?void 0:h.type)==="text"){const p=h.text??"",v={...h,text:p+l};u=[...u.slice(0,u.length-1),v]}else u=[...u,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(u=[...u,...i]);const d=!!(l||i.length);return{newParts:u,newMeta:o,changed:d}}function Rc(e){return e.replace(/\s+/g," ").trim()}function Pc(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let i=n;i>0;i--)if(e.slice(-i)===t.slice(0,i))return t.slice(i);const r=Rc(e),o=Rc(t);if(r===o)return"";const s=Math.min(r.length,o.length);for(let i=s;i>0;i--)if(r.slice(-i)===o.slice(0,i))return t;return t}function yx(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 Ic(e,r,s)}return e}function vx(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Oc(e={}){const t=w.useMemo(()=>_n(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=w.useState(e.token??null),s=w.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=w.useState(!1),[u,d]=w.useState(null),[f,h]=w.useState(""),[p,v]=w.useState(null),[x,g]=w.useState(0),[y,b]=w.useState(!1),S=w.useRef(null),k=w.useRef(!0),C=w.useRef(0),T=w.useCallback(P=>{o(P)},[]),I=w.useCallback(()=>{var P;(P=S.current)==null||P.abort(),S.current=null,l(!1),b(!1),C.current=0,g(0)},[]),A=w.useCallback(()=>{h(""),v(null),d(null)},[]),j=w.useCallback((P,D,L)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h("");const B=new AbortController;return S.current=B,(async()=>{var X,W,V,z,$,pe,F,Q;const M=he=>{var ve;try{const be=JSON.parse(JSON.stringify(he));return(ve=be==null?void 0:be.payload)!=null&&ve.files_info&&Array.isArray(be.payload.files_info)&&(be.payload.files_info=be.payload.files_info.map(Te=>({...Te,data:Te!=null&&Te.data?`<base64 ${String(Te.data).length} chars>`:Te==null?void 0:Te.data}))),be}catch{return he}};try{let he={};try{if(r)he={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Be=window.__AUTH_TOKEN__,ht=((X=window.localStorage)==null?void 0:X.getItem("authToken"))||null;let tt=null;try{const bt=(W=window.localStorage)==null?void 0:W.getItem("chat-settings");bt&&(tt=((V=JSON.parse(bt))==null?void 0:V.apiKey)||null)}catch{}const Me=Be||ht||tt||null;Me&&(he={Authorization:`Bearer ${Me}`})}}catch{}console.debug("[use-chat] POST",t+n,M(P));const ve=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...he,...s.current},body:JSON.stringify(P),signal:B.signal,credentials:i});if(!ve.ok||!ve.body){const Oe=await ve.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",ve.status,Oe==null?void 0:Oe.slice(0,500)),new Error(`stream ${ve.status}${Oe?": "+Oe:""}`)}b(!0);const be=ve.body.getReader(),Te=new TextDecoder;let q="",O=[];C.current=0,g(0);let J=0,te=null;const de=()=>{if(O.length){const Oe=O.join("");O=[],k.current&&h(Be=>Be+Oe)}te=null},le=()=>{typeof window<"u"&&te==null&&(te=requestAnimationFrame(de))};let ie=Date.now();const et=setInterval(()=>{var Oe;if(Date.now()-ie>6e4){const Be="Stream idle timeout";d(Be),B.abort(),(Oe=L==null?void 0:L.onError)==null||Oe.call(L,Be)}},5e3),Qe=1024*1024;try{const Oe=ve.headers.get("X-Thread-Id")||ve.headers.get("x-thread-id"),Be=ve.headers.get("X-Thread-Created")||ve.headers.get("x-thread-created"),ht=Oe??null,tt=String(Be??"").toLowerCase()==="true";for((z=L==null?void 0:L.onOpen)==null||z.call(L,{threadId:ht,created:tt});;){const{value:Me,done:bt}=await be.read();if(bt)break;q+=Te.decode(Me,{stream:!0}),q.length>Qe&&(q="",console.warn("Stream buffer reset: exceeded 1MB"));let ne;for(;(ne=q.indexOf(`
36
36
 
37
- `))>=0;){const se=K.slice(0,ne);K=K.slice(ne+2);const ge=bx(se);if(!ge)continue;let we;try{we=JSON.parse(ge)}catch{console.debug("[use-chat] malformed SSE:",ge.slice(0,200));continue}const xe=vx(we)?we.data:we;ie=Date.now();const ze=xe.seq;if(ze!==void 0){if(ze<=J){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:ze,lastProcessedSeq:J,type:xe.type});continue}J>0&&ze>J+1&&(($=L==null?void 0:L.onGap)==null||$.call(L,{from:J,to:ze})),J=ze,C.current=ze,g(ze)}if(console.debug("[use-chat] received event",{seq:xe.seq,type:xe.type,preview:(()=>{var st;try{return xe.type==="message_delta"?{deltaTypes:(st=xe.delta)==null?void 0:st.map(Fe=>Fe.type),textLen:(xe.delta||[]).filter(Fe=>Fe.type==="text").map(Fe=>String(Fe.text||"").length)}:xe.content||xe.delta?{hasContent:!0}:{}}catch(Fe){return{err:String(Fe)}}})()}),D==null||D(xe),xe.type==="token"&&e.autoAppendAssistant!==!1)O.push(xe.content),le();else if(xe.type==="message_delta"){const st=xe.delta.filter(Fe=>Fe.type==="text").map(Fe=>Fe.text).join("");st&&e.autoAppendAssistant!==!1&&(O.push(st),le())}else xe.type==="heartbeat"?console.debug("[use-chat] heartbeat received"):(te!==null&&cancelAnimationFrame(te),de(),xe.type==="checkpoint"?v(xe.checkpointId):xe.type==="error"&&d(xe.message))}}de()}catch(Oe){if(Oe.name!=="AbortError"){const He=Oe.message||String(Oe);d(He),(pe=L==null?void 0:L.onError)==null||pe.call(L,He)}}finally{try{await be.cancel()}catch{}finally{(F=be.releaseLock)==null||F.call(be)}te!==null&&typeof window<"u"&&window.cancelAnimationFrame(te),clearInterval(tt),l(!1),b(!1),S.current=null,C.current=0,g(0)}}catch(he){if(he.name!=="AbortError"){const ve=he.message||String(he);d(ve),(Z=L==null?void 0:L.onError)==null||Z.call(L,ve)}}finally{l(!1),b(!1),S.current=null,C.current=0,g(0)}})(),{close:()=>B.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var P;k.current=!1,(P=S.current)==null||P.abort()},[]),{isStreaming:a,error:u,assistantText:f,lastCheckpointId:p,lastSeq:x,connected:y,stream:j,stop:I,clear:A,setToken:T}}function vx(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function bx(e){const t=e.split(/\r?\n/),n=[];for(const r of t)if(r&&!r.startsWith(":")&&r.startsWith("data:")){const o=r.slice(5);n.push(o.startsWith(" ")?o.slice(1):o)}return n.length===0?null:n.join(`
38
- `)}function wx({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onUnhandledEvent:r,onSequenceGap:o}){const s=w.useRef(null),i=w.useCallback(p=>{const v=p.seq??null;if(v!==null){const x=s.current;if(x!==null){if(v<=x)return;v>x+1&&(o==null||o({from:x,to:v}))}s.current=v}if(p.type==="thread_info"){console.log("[useChatStreamingService] 🎯 Received thread_info event:",p),t(p);return}if(hx(p)){n(p);return}r==null||r(p)},[n,o,t,r]),{stream:a,stop:l,isStreaming:u,error:d,setToken:f}=Oc({baseUrl:e,token:null}),h=w.useCallback((p,v)=>{s.current=null,a(p,i,{onOpen:v==null?void 0:v.onOpen,onError:x=>{var g;(g=v==null?void 0:v.onError)==null||g.call(v,x)},onGap:(v==null?void 0:v.onGap)??o})},[i,o,a]);return w.useMemo(()=>({startStream:h,stop:l,isStreaming:u,error:d,setAuthToken:f}),[h,l,u,d,f])}function Yt(e,t={}){const n=t.cloneMessages??!1,r=Array.isArray(e==null?void 0:e.messages)?e.messages:[];return{checkpointId:(e==null?void 0:e.checkpointId)??null,checkpointNs:(e==null?void 0:e.checkpointNs)??null,createdAt:(e==null?void 0:e.createdAt)??null,preview:(e==null?void 0:e.preview)??null,role:(e==null?void 0:e.role)??null,parentId:(e==null?void 0:e.parentId)??null,branchLabel:(e==null?void 0:e.branchLabel)??null,lastMessageId:(e==null?void 0:e.lastMessageId)??null,messagesLen:typeof(e==null?void 0:e.messagesLen)=="number"?e.messagesLen:r.length,hasMessages:typeof(e==null?void 0:e.hasMessages)=="boolean"?e.hasMessages:r.length>0,messages:n?r.slice():r,nextCursor:(e==null?void 0:e.nextCursor)??null,nextCursorNs:(e==null?void 0:e.nextCursorNs)??null,interrupt:(e==null?void 0:e.interrupt)??null}}function Sx(e){var t;for(let n=e.length-1;n>=0;n--){const r=((t=e[n])==null?void 0:t.content)??[];for(let o=r.length-1;o>=0;o--){const s=r[o];if((s==null?void 0:s.type)==="interrupt"){const i=s.id;return{id:(typeof i=="string"?i:null)??`interrupt-${e[n].id??o}`,value:s.value}}}}return null}function Mc(e,t){if(!e&&!t)return!0;if(!e||!t||e.id!==t.id)return!1;try{return JSON.stringify(e.value)===JSON.stringify(t.value)}catch{return e.value===t.value}}const Bo=300;function Dc(e,t=Bo){if(typeof window<"u"&&"requestIdleCallback"in window)try{window.requestIdleCallback(e,{timeout:t});return}catch{}window.setTimeout(e,t)}function Ir(){return typeof window<"u"&&typeof window.localStorage<"u"}function Ii(e){if(!Ir())return null;try{return window.localStorage.getItem(e)}catch{return null}}function Lc(e,t){if(Ir())try{window.localStorage.setItem(e,t)}catch{}}function Ni(e){if(Ir())try{window.localStorage.removeItem(e)}catch{}}const Cx="cachedThreads",Tx="v1",Ai=200;function kx(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 _i(e,t){return`cachedThreads:v1:${e}:${kx(t||"anon")}`}function Ex(){const e=Ii(Cx);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 Ix(e){const t=Ii(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 ji(e,t){try{Lc(e,JSON.stringify(t))}catch{}}function Ri(e){const t=Ix(e);if(t.length>0)return t;const n=Ex();if(n.length>0)try{ji(e,n.slice(0,Ai))}catch{}return n}function Ho(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 Pi(e){return e.order.map(t=>e.byId[t]).filter(Boolean)}function Oi(e,t){return`${e}${t}`}function Nx(e,t){const n=Ii(Oi(e,t));if(!n)return null;try{const r=JSON.parse(n);return typeof(r==null?void 0:r.threadId)!="string"?null:{threadId:r.threadId,snapshot:Yt(r.snapshot,{cloneMessages:!0})}}catch{return null}}function Ax(e,t,n=100){const r=Yt(t.snapshot,{cloneMessages:!0}),o={threadId:t.threadId,snapshot:{...r,messages:r.messages.slice(-n)}};try{Lc(Oi(e,t.threadId),JSON.stringify(o))}catch{}}function _x(e,t){Ni(Oi(e,t))}function jx(e){if(Ir())try{for(let t=0;t<window.localStorage.length;t++){const n=window.localStorage.key(t);n&&n.startsWith(e)&&window.localStorage.removeItem(n)}}catch{}}const $c=w.createContext(null),Fc=w.createContext(null),zc=w.createContext(null),Rx=w.createContext(!1),Bc=50;function Px(e,t,n){return`${e}__${t??""}__${n??""}`}function Ox({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}=Ci(),d=w.useMemo(()=>En(u),[u]),f=w.useMemo(()=>{try{return new URL(u).host}catch{return"unknown"}},[u]),h=w.useMemo(()=>`threadPayload:${Tx}:${f}:`,[f]),p=w.useCallback(N=>Nx(h,N),[h]),v=w.useCallback((N,_=100)=>{Ax(h,N,_)},[h]),x=w.useCallback(N=>{_x(h,N)},[h]),g=w.useCallback(()=>{jx(h)},[h]),[y,b]=w.useState(()=>{var N;return _i(f,(N=l.getAuthToken)==null?void 0:N.call(l))}),[S,k]=w.useState(()=>{var _;const N=Ri(_i(f,(_=l.getAuthToken)==null?void 0:_.call(l)));return Ho(N)}),C=w.useMemo(()=>Pi(S),[S]),[T,I]=w.useState(t),[A,j]=w.useState(!1),[P,D]=w.useState(!1),[L,B]=w.useState(null),[M,X]=w.useState(null),[W,V]=w.useState(null),[z,$]=w.useState([]),pe=w.useCallback(()=>{const N=Ri(y);w.startTransition(()=>{k(Ho(N))})},[y]),[F,Z]=w.useState(!1),[he,ve]=w.useState(!1),[be,Te]=w.useState(null),[K,O]=w.useState(void 0),[J,te]=w.useState(void 0),[de,le]=w.useState(void 0),{state:ie,dispatch:tt,seed:et,prepend:Oe,pushUser:He,onEvent:ht,reset:nt}=kc(),Me=w.useRef(T);w.useEffect(()=>{Me.current=T},[T]);const bt=w.useRef(!1),ne=w.useRef([]),se=w.useRef(null),ge=w.useRef(null),we=w.useRef(new Map),xe=w.useRef(T),ze=w.useRef(!1),st=w.useRef(null),Fe=w.useRef(new Map),ut=w.useRef(new Map),xt=w.useRef(new Map),Ot=w.useRef(new Map),tn=w.useCallback(N=>{if(!N){$([]);return}const _=Fe.current.get(N);if(!_||!_.length){$([]);return}$(_.map(q=>Yt(q,{cloneMessages:!0})))},[]);w.useEffect(()=>{tn(T)},[T,tn]);const Hr=w.useCallback(()=>{var Q;const N=Ot.current;if(N.size<=Bc)return;const _=Array.from(N.entries()).sort((re,G)=>re[1].timestamp-G[1].timestamp),q=N.size-Bc;for(let re=0;re<q;re++){const G=(Q=_[re])==null?void 0:Q[0];G&&N.delete(G)}},[]),Yn=w.useCallback((N,_,q)=>{if(!N)return;const Q=q==="replace"?[]:Fe.current.get(N)??[],re=q==="replace"?_:[..._,...Q];if(!re.length){q==="replace"&&Fe.current.set(N,[]);return}const G=new Map;for(const Ye of re){if(!(Ye!=null&&Ye.checkpointId))continue;const De=`${Ye.checkpointId}::${Ye.checkpointNs??""}`;G.has(De)||G.set(De,Yt(Ye,{cloneMessages:!0}))}const Ke=Array.from(G.values()).sort((Ye,De)=>{const Je=Number.isFinite(Date.parse(Ye.createdAt??""))?Date.parse(Ye.createdAt??""):0;return(Number.isFinite(Date.parse(De.createdAt??""))?Date.parse(De.createdAt??""):0)-Je});Fe.current.set(N,Ke),N===Me.current&&tn(N)},[tn]),Tn=w.useCallback((N,_,q)=>{if(!N)return;const Q=ut.current.get(N),re=q==="replace"||!Q?new Map:new Map(Q);if(_&&typeof _=="object")for(const[G,Ke]of Object.entries(_)){if(!(Ke!=null&&Ke.checkpointId))continue;const Ye=G||zo(Ke.checkpointId,Ke.checkpointNs??null);re.set(Ye,Yt(Ke,{cloneMessages:!0}))}ut.current.set(N,re)},[]),Xn=w.useCallback((N,_)=>{const{threadId:q,checkpointId:Q=null,checkpointNs:re=null}=N,G=Px(q,Q,re);if(_!=null&&_.force)xt.current.delete(G),Ot.current.delete(G);else{if(_!=null&&_.preferCache){const Je=Ot.current.get(G);if(Je)return Promise.resolve(Je.payload)}const De=xt.current.get(G);if(De)return De}const Ye=l.getStateHistory({threadId:q,checkpointId:Q??void 0,checkpointNs:re??void 0}).then(De=>(Ot.current.set(G,{payload:De,timestamp:Date.now()}),Hr(),De)).finally(()=>{xt.current.get(G)===Ye&&xt.current.delete(G)});return xt.current.set(G,Ye),Ye},[l,Hr]),nn=w.useCallback((N,_)=>new Promise((q,Q)=>{const re=async()=>{bt.current=!0;try{await N(),q()}catch(G){Q(G)}finally{bt.current=!1;const G=ne.current.shift();G&&G().catch(()=>{})}};bt.current?ne.current.push(re):re().catch(G=>{Q(G)})}),[]),br=w.useRef(C.length),[jn,wr]=w.useState(!1),Rn=w.useRef(!1);w.useEffect(()=>{br.current=C.length},[C.length]),w.useEffect(()=>{const N=ie.pendingInterrupt??Sx(ie.messages);Mc(W,N)||V(N??null)},[W,ie.messages,ie.pendingInterrupt]);const _t=w.useCallback(async()=>{const N=br.current>0;N||j(!0);try{const _=await l.listThreads();w.startTransition(()=>{k(q=>{const Q=Ke=>Ke.map(Ye=>`${Ye.threadId}:${Ye.updatedAt??""}:${Ye.messageCount??""}`).join("|"),re=Pi(q);return Q(re)===Q(_)||_.length===0&&re.length>0&&!Rn.current?q:Ho(_)})}),B(null),Rn.current||(Rn.current=!0,wr(!0))}catch(_){i==null||i(String(_)),console.error("[ChatSessionProvider] Failed to refresh threads:",_),B(String(_))}finally{N||j(!1)}},[l,i]),me=w.useRef(!1),Ee=w.useRef(null),Pe=w.useRef(null),it=w.useRef(""),Ft=w.useCallback((N,_)=>{if(!Ir())return;Pe.current!==null&&(window.clearTimeout(Pe.current),Pe.current=null);const q=N.map(re=>`${re.threadId}:${re.updatedAt??""}:${re.messageCount??""}`).join("|");if(N.length===0){try{Ni(y)}catch{}it.current="";return}if(q===it.current)return;const Q=()=>{try{const re=N.slice(0,Ai);ji(y,re),it.current=q}catch{}finally{Pe.current=null}};if(_!=null&&_.immediate){Q();return}Pe.current=window.setTimeout(()=>{Dc(Q)},Bo)},[y]),Jn=w.useCallback(()=>{Ft(C,{immediate:!0})},[Ft,C]),kn=w.useCallback((N,_,q,Q)=>{var bl;const re=q??Me.current;if(!re)return;const G=Yt(N),Ke=re===Me.current,Ye=(Q==null?void 0:Q.persist)!==!1;if(_==="replace"){if(Ye){const Ct={threadId:re,snapshot:Yt(N,{cloneMessages:!0})};we.current.set(re,Ct),xe.current=re}if(!Ke)return;et(G.messages,{checkpointId:G.checkpointId??null,checkpointNs:G.checkpointNs??null,pendingInterrupt:G.interrupt??null}),V(G.interrupt??null),Te(G.nextCursor??null),Z(!!G.nextCursor),O(G.checkpointId??void 0),te(G.checkpointNs??void 0),le(G.nextCursorNs??void 0);return}const De=we.current.get(re),Je=(De==null?void 0:De.snapshot)??null,qt=Array.isArray(Je==null?void 0:Je.messages)?Je.messages:[],jt=Yt(Je),Mn=Array.isArray(N==null?void 0:N.messages)?N.messages:[],Eo=new Set,Sr=[...Mn,...qt].filter(Ct=>{const wl=Ct==null?void 0:Ct.id;return wl?Eo.has(wl)?!1:(Eo.add(wl),!0):!0}),vl={checkpointId:jt.checkpointId??G.checkpointId??null,checkpointNs:jt.checkpointNs??G.checkpointNs??null,createdAt:G.createdAt??jt.createdAt??null,preview:G.preview??jt.preview??null,role:G.role??jt.role??null,parentId:G.parentId??jt.parentId??null,branchLabel:G.branchLabel??jt.branchLabel??null,lastMessageId:((bl=Sr[Sr.length-1])==null?void 0:bl.id)??null,messagesLen:Sr.length,hasMessages:Sr.length>0,messages:Sr,nextCursor:G.nextCursor??jt.nextCursor??null,nextCursorNs:G.nextCursorNs??jt.nextCursorNs??null,interrupt:jt.interrupt??G.interrupt??null};if(we.current.set(re,{threadId:re,snapshot:Yt(vl,{cloneMessages:!0})}),!Ke)return;Mn.length&&Oe(Mn);const ai=N&&Object.prototype.hasOwnProperty.call(N,"checkpointId")?N.checkpointId:void 0,Qn=N&&Object.prototype.hasOwnProperty.call(N,"checkpointNs")?N.checkpointNs:void 0,Cr=N&&Object.prototype.hasOwnProperty.call(N,"nextCursor")?N.nextCursor:void 0,er=N&&Object.prototype.hasOwnProperty.call(N,"nextCursorNs")?N.nextCursorNs:void 0;Te(Ct=>Cr!==void 0?Cr??Ct??null:Ct??null),Z(Ct=>Cr!==void 0?!!Cr:Ct),O(Ct=>ai!==void 0?ai??Ct??void 0:Ct??void 0),te(Ct=>Qn!==void 0?Qn??Ct??void 0:Ct??void 0),le(Ct=>er!==void 0?er??void 0:Ct)},[Oe,et,V]),Ur=w.useCallback(N=>{if(N.threadId!=null&&N.threadId!==Me.current)return;const _=Yt(N.snapshot,{cloneMessages:!0});et(_.messages,{checkpointId:_.checkpointId??null,checkpointNs:_.checkpointNs??null,pendingInterrupt:_.interrupt??null}),V(_.interrupt??null),Te(_.nextCursor??null),Z(!!_.nextCursor),O(_.checkpointId??void 0),te(_.checkpointNs??void 0),le(_.nextCursorNs??void 0),xe.current=N.threadId,tn(N.threadId??Me.current??null)},[et,V,tn]),Pn=w.useCallback(N=>{if(!N)return;we.current.delete(N),x(N),Fe.current.delete(N),ut.current.delete(N),N===Me.current&&$([]);const _=`${N}__`;for(const q of xt.current.keys())q.startsWith(_)&&xt.current.delete(q);for(const q of Ot.current.keys())q.startsWith(_)&&Ot.current.delete(q);xe.current===N&&(xe.current=null)},[x]),Zn=w.useCallback(()=>{const N=Me.current;N&&Pn(N),nt([]),Z(!1),ve(!1),Te(null),O(void 0),te(void 0),le(void 0)},[Pn,nt]),To=w.useCallback(({from:N,to:_})=>{const q=Me.current;q&&console.warn(`[ChatSessionProvider] Stream sequence gap detected (${N} -> ${_}) for thread ${q}`)},[]),gl=w.useCallback(N=>{const _=N.threadId;console.log("[ChatSessionProvider] 📥 Handling thread_info event:",{threadId:_,title:N.title,created:N.created,currentThreads:C.length});const q={threadId:_,title:N.title||`Thread ${_.slice(0,8)}`,createdAt:N.createdAt||new Date().toISOString(),updatedAt:N.updatedAt||new Date().toISOString(),messageCount:N.messageCount||0};Me.current!==_&&(!Me.current&&ie.messages.length<=1&&(ge.current=_),I(_)),w.startTransition(()=>{k(Q=>{const re=Q.byId[_];return re?re.title===q.title&&re.updatedAt===q.updatedAt&&re.messageCount===q.messageCount?Q:{byId:{...Q.byId,[_]:q},order:Q.order}:{byId:{...Q.byId,[_]:q},order:[_,...Q.order]}})})},[ie.messages.length]),{startStream:ii,stop:E,isStreaming:H,error:oe,setAuthToken:ke}=wx({baseUrl:d,onThreadInfo:gl,onMessageEvent:ht,onUnhandledEvent:N=>{console.warn(`[ChatSessionProvider] Unhandled stream event: ${N.type}`,N)},onSequenceGap:To});w.useEffect(()=>{me.current=H},[H]),w.useEffect(()=>{if(!Ir())return;Pe.current!==null&&(window.clearTimeout(Pe.current),Pe.current=null);const N=C.map(q=>`${q.threadId}:${q.updatedAt??""}:${q.messageCount??""}`).join("|");if(C.length===0){try{Ni(y)}catch{}it.current="";return}if(N===it.current)return;const _=()=>{try{const q=C.slice(0,Ai);ji(y,q),it.current=N}catch{}finally{Pe.current=null}};return Pe.current=window.setTimeout(()=>{Dc(_),Pe.current=null},Bo),()=>{Pe.current!==null&&(window.clearTimeout(Pe.current),Pe.current=null)}},[C,Ft]),w.useEffect(()=>{var Q;const N=l.getAuthToken();ke(N);const _=re=>{const G=_i(f,re);st.current!==G&&(st.current=G,ze.current=!1),b(G);const Ke=Ri(G);w.startTransition(()=>{k(Ho(Ke))}),ze.current||(ze.current=!0,_t().catch(()=>{}))};_(N);const q=(Q=l.onTokenChange)==null?void 0:Q.call(l,re=>{ke(re),g(),xt.current.clear(),Ot.current.clear(),_(re)});return()=>{q==null||q()}},[l,f,ke,g,_t]);const Ge=w.useCallback(async N=>{var Q;const _=`Thread ${(Q=crypto.randomUUID)==null?void 0:Q.call(crypto)}`,q={threadId:_,title:N||"New Chat",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messageCount:0};k(re=>({byId:{...re.byId,[_]:q},order:[_,...re.order]})),I(_);try{const re=await l.createThread(N),G=typeof re=="string"?re:re.threadId;return k(Ke=>{const Ye=Ke.byId[_];if(!Ye)return Ke;const De={...Ke.byId};delete De[_],De[G]={...Ye,threadId:G};const Je=Ke.order.map(qt=>qt===_?G:qt);return{byId:De,order:Je}}),I(G),setTimeout(()=>_t(),10),B(null),G}catch(re){throw k(G=>{if(!G.byId[_])return G;const Ke={...G.byId};delete Ke[_];const Ye=G.order.filter(De=>De!==_);return{byId:Ke,order:Ye}}),I(null),B(String(re)),re}},[l,_t]),Qe=w.useCallback(async N=>{try{await l.deleteThread(N);let _=null;k(q=>{if(!q.byId[N])return q;const Q={...q.byId};delete Q[N];const re=q.order.filter(Ke=>Ke!==N),G={byId:Q,order:re};return _=Pi(G),G}),_&&Ft(_,{immediate:!0}),Pn(N),Me.current===N&&(ge.current=N,I(null),Me.current=null,xe.current=null,Zn()),await _t(),B(null)}catch(_){throw B(String(_)),_}},[l,Zn,Pn,_t,Ft]),Ue=w.useCallback(async(N,_)=>{try{await l.updateThread(N,_),k(q=>{const Q=q.byId[N];return Q?{byId:{...q.byId,[N]:{...Q,title:_}},order:q.order}:q}),B(null)}catch(q){throw await _t(),B(String(q)),q}},[l,_t]),je=w.useCallback(async(N,_,q,Q=!1)=>{await nn(async()=>{if(ge.current===N&&!Q){ge.current=null;return}if(se.current===N&&!Q)return;I(De=>De===N?De:N),Me.current=N;const re=!Q&&!_&&!q;let G=!1;if(re){const De=we.current.get(N);if(De)Ur(De),G=!0;else{const Je=p(N);Je&&(we.current.set(N,Je),Ur(Je),G=!0)}}const Ke=Q||!G||!!_||!!q,Ye=async De=>{De&&D(!0),se.current=N;try{const Je=await Xn({threadId:N,checkpointId:_,checkpointNs:q},{force:Q}),{latest:qt,checkpoints:jt,snapshots:Mn}=vc(Je);kn(qt,"replace",N),Yn(N,jt,"replace"),Tn(N,Mn,"replace"),X(null)}catch(Je){throw(!G||Q||De)&&(i==null||i(String(Je))),X(String(Je)),Je}finally{se.current=null,De&&D(!1)}};Ke?await Ye(!0):re&&G&&Ye(!1).catch(De=>{console.warn("[ChatSessionProvider] Background refresh failed:",De)})},`loadThread-${N}`)},[Ur,kn,nn,Xn,i,Yn,Tn]),St=w.useCallback(async()=>{await nn(async()=>{const N=Me.current;N&&Pn(N),ge.current=null,I(null),Me.current=null,xe.current=null,Zn(),O(void 0),te(void 0),le(void 0),$([]);try{localStorage.removeItem("lastThreadId")}catch(_){console.warn("[ChatSessionProvider] Failed to clear lastThreadId:",_)}},"clearCurrentThread")},[Zn,Pn,nn]),dt=w.useCallback(async(N,_)=>{var G;const q=Me.current;if(!q)throw new Error("No active thread");const Q=zo(N,_??null),re=(G=ut.current.get(q))==null?void 0:G.get(Q);if(re){await nn(async()=>{kn(re,"replace",q,{persist:!1})},`navigateToCheckpoint-${q}-${Q}`);return}await je(q,N,_??void 0,!0)},[kn,nn,je]),pt=w.useCallback(async()=>{if(!Me.current)throw new Error("No active thread");await je(Me.current,void 0,void 0,!0)},[je]),Mt=w.useCallback(async()=>{if(!Me.current)throw new Error("No active thread");if(he||!F)return;const N=be;if(N){ve(!0);try{const _=Me.current,q=await Xn({threadId:_,checkpointId:N??K??null,checkpointNs:de??J??null}),{latest:Q,checkpoints:re,snapshots:G}=vc(q);kn(Q,"prepend",_??void 0),_&&(Yn(_,re,"prepend"),Tn(_,G,"prepend")),X(null)}catch(_){throw X(String(_)),_}finally{ve(!1)}}},[kn,Xn,F,K,J,de,be,he,Yn,Tn]),On=w.useCallback(N=>{if(N!=null&&N.threadId){if(N.checkpointId){const _=zo(N.checkpointId,N.checkpointNs??null),q=Yt({...N,interrupt:N.interrupt??null},{cloneMessages:!0});Tn(N.threadId,{[_]:q},"prepend")}kn(N,"replace",N.threadId)}},[kn,Tn]),Kt=w.useCallback(async(N,_)=>{var Cr;const q=Me.current,Q=(N==null?void 0:N.text)??"",re=(N==null?void 0:N.attachments)??[],G=re.length?re:(_==null?void 0:_.attachments)??[],Ke={...(_==null?void 0:_.payloadExtras)??{},...(N==null?void 0:N.payload)??{}};if(!q&&!Object.keys(Ke).length&&G.length===0&&!Q.trim()){console.warn("[ChatSessionProvider] Nothing to submit - skipping");return}!q&&!Ke.messages&&console.warn("[ChatSessionProvider] No thread ID - message will create new thread");const{contentParts:Ye,filesInfo:De}=await Zg(l,G),Je=[...Ye];Q&&Q.trim()&&Je.push({type:"text",text:Q.trim()});const qt=!!q,jt=qt?(_==null?void 0:_.checkpointId)??ie.lastCheckpointId??void 0:void 0,Mn=qt?(_==null?void 0:_.checkpointNs)??ie.lastCheckpointNs??void 0:void 0,Eo={id:((Cr=crypto.randomUUID)==null?void 0:Cr.call(crypto))||`user-${Date.now()}`,role:"user",content:Je,createdAt:new Date().toISOString(),...jt!=null?{checkpointId:jt}:{},...Mn!=null?{checkpointNs:Mn}:{}};Je.length>0&&He(Eo);const Sr={...Eo,content:Je},vl=G.length>0,ai={messages:Je.length>0?[Sr]:[],files_info:De,...o&&vl&&s?{active_agent:s}:{},...Ke},Qn={threadId:q??null,payload:ai,checkpointId:jt??null,checkpointNs:Mn??null,nodeFilter:(_==null?void 0:_.nodeFilter)??null,config:_==null?void 0:_.config,command:(_==null?void 0:_.command)??null};Qn.threadId||delete Qn.threadId,Qn.command||delete Qn.command,ii(Qn,{onError:er=>{console.warn("[ChatSessionProvider] Stream error:",er)},onOpen:({threadId:er})=>{!Me.current&&er&&(ie.messages.length<=1&&(ge.current=er),I(er))},onGap:To})},[l,o,s,To,ie.lastCheckpointId,ie.lastCheckpointNs,ie.messages.length,He,ii]),kt=w.useCallback(async(N,_,q)=>{if(!Me.current)throw new Error("No active thread to handle interrupt");const re=_?q??!0:!1;try{try{tt({type:"interrupt_response",payload:{interruptId:N}})}catch(G){console.warn("[ChatSessionProvider] optimistic interrupt_response dispatch failed:",G)}await Kt({payload:{}},{checkpointId:ie.lastCheckpointId??void 0,checkpointNs:ie.lastCheckpointNs??void 0,command:{kind:"resume",value:re}}),V(null)}catch(G){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${N}:`,G),G}},[tt,ie.lastCheckpointId,ie.lastCheckpointNs,Kt]);w.useEffect(()=>{if(a==null||a(T),T)try{localStorage.setItem("lastThreadId",T)}catch(N){console.warn("[ChatSessionProvider] Failed to persist lastThreadId:",N)}},[T,a]),w.useEffect(()=>((async()=>{try{if(_t().catch(_=>{console.error("[ChatSessionProvider] Failed to refresh threads (background):",_),i==null||i(String(_))}),!r&&!t)try{const _=localStorage.getItem("lastThreadId");_&&(I(_),n&&await je(_))}catch(_){console.warn("[ChatSessionProvider] Failed to restore last thread:",_)}else t&&n&&await je(t)}catch(_){console.error("[ChatSessionProvider] Initialization failed:",_),i==null||i(String(_))}})(),()=>{}),[]),w.useEffect(()=>{const N=Me.current;if(!N||xe.current!==N)return;ie.messages.length&&ie.messages[ie.messages.length-1];const _=Yt({checkpointId:ie.lastCheckpointId??null,checkpointNs:ie.lastCheckpointNs??null,messages:ie.messages.slice(),nextCursor:be??null,nextCursorNs:de??null,interrupt:ie.pendingInterrupt??W??null}),q=we.current.get(N),Q=q==null?void 0:q.snapshot,re=!Q||Q.messages.length!==_.messages.length||Q.messages.some((De,Je)=>{var qt;return(De==null?void 0:De.id)!==((qt=_.messages[Je])==null?void 0:qt.id)}),G=((Q==null?void 0:Q.checkpointId)??null)!==_.checkpointId||((Q==null?void 0:Q.checkpointNs)??null)!==_.checkpointNs,Ke=((Q==null?void 0:Q.nextCursor)??null)!==_.nextCursor||((Q==null?void 0:Q.nextCursorNs)??null)!==_.nextCursorNs,Ye=!Mc((Q==null?void 0:Q.interrupt)??null,_.interrupt??null);if(re||G||Ke||Ye){const De={threadId:N,snapshot:_};we.current.set(N,De),Ee.current&&window.clearTimeout(Ee.current),Ee.current=window.setTimeout(()=>{try{v(De,100)}catch(Je){console.warn("[ChatSessionProvider] Failed to persist thread payload:",Je)}},Bo)}},[be,de,ie.lastCheckpointId,ie.lastCheckpointNs,ie.messages,ie.pendingInterrupt,W,v]);const ko=w.useMemo(()=>({threads:C,currentThreadId:T,setCurrentThreadId:I,isLoading:A,error:L,actions:{createThread:Ge,deleteThread:Qe,renameThread:Ue,refreshThreads:()=>_t()},persistThreadsCache:Jn,hydrateFromCache:pe}),[C,T,A,L,Ge,Qe,Ue,_t,Jn,pe,I]),xl=w.useMemo(()=>{const N=ie.lastBranch??null,_=ie.assemblingId??null,q=N||_?{branchLabel:(N==null?void 0:N.branchLabel)??null,lastBranch:N,assemblingMessageId:_}:null;return{threadId:T,messages:ie.messages,interrupt:W,checkpoint:{id:ie.lastCheckpointId??null,namespace:ie.lastCheckpointNs??null},checkpoints:z,metadata:q,isLoading:P,isHistoryLoading:he,error:M,hasMore:F,loadOlder:Mt,seedFromSnapshot:On,clearState:Zn,navigateToCheckpoint:dt,returnToLatest:pt,loadThread:je,clearThread:St,respondToInterrupt:kt}},[St,Zn,T,W,F,he,P,Mt,je,ie.assemblingId,ie.lastBranch,ie.lastCheckpointId,ie.lastCheckpointNs,ie.messages,dt,kt,pt,On,M,z]),yl=w.useMemo(()=>({isStreaming:H,error:oe,submit:Kt,send:Kt,stop:E,setAuthToken:ke}),[H,oe,Kt,E,ke]);return c.jsx(Rx.Provider,{value:!0,children:c.jsx(zc.Provider,{value:yl,children:c.jsx($c.Provider,{value:ko,children:c.jsx(Fc.Provider,{value:xl,children:e})})})})}function Uo(){const e=w.useContext($c);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Wo(){const e=w.useContext(Fc);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function Hc(){const e=w.useContext(zc);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function Vo({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(Xg,{apiConfig:t,children:c.jsx(Ox,{initialThreadId:n,autoLoadInitial:r,disableAutoRestore:o,enableFileAgentRouting:s,fileAgentId:i,onError:a,onThreadChange:l,children:e})})}function ee(...e){return km.twMerge(Tm.clsx(e))}const Mx=Io.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),qe=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?tr.Slot:"button";return c.jsx(i,{className:ee(Mx({variant:t,size:n,className:e})),ref:s,...o})});qe.displayName="Button";const Uc=m.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:ee("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}));Uc.displayName="Textarea";function Dx({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,onSend:i,onCancelEdit:a,onStop:l,className:u="",textareaClassName:d="",allowEmptySend:f=!1}){const[h,p]=w.useState(e),[v,x]=w.useTransition(),g=w.useRef(null);w.useEffect(()=>{p(e??""),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const y=w.useCallback(()=>{const A=g.current;A&&(A.style.height="auto",A.style.height=`${A.scrollHeight}px`)},[]);w.useEffect(()=>{y()},[y]);const b=w.useCallback(async A=>{A&&A.preventDefault();const j=(h??"").trim();!j&&!f||x(()=>{try{const P=i(j);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=w.useCallback(A=>{p(A.target.value),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),k=w.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(Uc,{ref:g,value:h,onChange:S,onKeyDown:k,placeholder:t?"Edit your message...":n,className:I,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),c.jsx("div",{children:r?c.jsx(qe,{type:"button",onClick:()=>{l==null||l()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!l,children:c.jsx(ae.Square,{size:16})}):c.jsx(qe,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||v,children:c.jsx(ae.Send,{size:16})})})]})})}const Lx=w.memo(Dx),Ko=0,Ln=1,Nr=2,Wc=4;function Vc(e){return()=>e}function $x(e){e()}function Kc(e,t){return n=>e(t(n))}function qc(e,t){return()=>e(t)}function Fx(e,t){return n=>e(t,n)}function Mi(e){return e!==void 0}function zx(...e){return()=>{e.map($x)}}function Ar(){}function qo(e,t){return t(e),e}function Bx(e,t){return t(e)}function at(...e){return e}function Ze(e,t){return e(Ln,t)}function $e(e,t){e(Ko,t)}function Di(e){e(Nr)}function gt(e){return e(Wc)}function ye(e,t){return Ze(e,Fx(t,Ko))}function on(e,t){const n=e(Ln,r=>{n(),t(r)});return n}function Gc(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Yc(e,t){return e===t}function lt(e=Yc){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ne(e){return t=>n=>{e(n)&&t(n)}}function ce(e){return t=>Kc(t,e)}function hn(e){return t=>()=>{t(e)}}function U(e,...t){const n=Hx(...t);return(r,o)=>{switch(r){case Nr:Di(e);return;case Ln:return Ze(e,n(o))}}}function pn(e,t){return n=>r=>{n(t=e(t,r))}}function sr(e){return t=>n=>{e>0?e--:t(n)}}function Nn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Be(...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);Ze(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 Hx(...e){return t=>e.reduceRight(Bx,t)}function Ux(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Ln:return s?n===s?void 0:(r(),n=s,t=Ze(e,s),t):(r(),Ar);case Nr:r(),n=null;return}}}function Y(e){let t=e;const n=Ve();return(r,o)=>{switch(r){case Ko:t=o;break;case Ln:{o(t);break}case Wc:return t}return n(r,o)}}function It(e,t){return qo(Y(t),n=>ye(e,n))}function Ve(){const e=[];return(t,n)=>{switch(t){case Ko:e.slice().forEach(r=>{r(n)});return;case Nr:e.splice(0,e.length);return;case Ln:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Bt(e){return qo(Ve(),t=>ye(e,t))}function Xe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Wx(),singleton:n}}const Wx=()=>Symbol();function Vx(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function yt(...e){const t=Ve(),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);Ze(s,l=>{n[i]=l,r=r|a,r===o&&$e(t,n)})}),function(s,i){switch(s){case Nr:{Di(t);return}case Ln:return r===o&&i(n),Ze(t,i)}}}function Ie(e,t=Yc){return U(e,lt(t))}function Li(...e){return function(t,n){switch(t){case Nr:return;case Ln:return zx(...e.map(r=>Ze(r,n)))}}}var $t=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))($t||{});const Kx={0:"debug",3:"error",1:"log",2:"warn"},qx=()=>typeof globalThis>"u"?window:globalThis,$n=Xe(()=>{const e=Y(3);return{log:Y((t,n,r=1)=>{var o;const s=(o=qx().VIRTUOSO_LOG_LEVEL)!=null?o:gt(e);r>=s&&console[Kx[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function ir(e,t,n){return $i(e,t,n).callbackRef}function $i(e,t,n){const r=w.useRef(null);let o=i=>{};const s=w.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function Gx(e,t,n,r,o,s,i,a,l){const u=w.useCallback(d=>{const f=Yx(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const p=h.lastElementChild.dataset.viewportType==="window";let v;p&&(v=h.ownerDocument.defaultView);const x=i?a?i.scrollLeft:i.scrollTop:p?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:p?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:p?a?v.innerWidth:v.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(x,0),viewportHeight:y}),s==null||s(a?Xc("column-gap",getComputedStyle(d).columnGap,o):Xc("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return $i(u,n,l)}function Yx(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},$t.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 Xc(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,$t.WARN),t==="normal"?0:parseInt(t??"0",10)}function Jc(e,t,n){const r=w.useRef(null),o=w.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const u=l.getBoundingClientRect(),d=u.width;let f,h;if(t){const p=t.getBoundingClientRect(),v=u.top-p.top;h=p.height-Math.max(0,v),f=v+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;h=p.innerHeight-Math.max(0,u.top),f=u.top+p.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=$i(o,!0,n),a=w.useCallback(()=>{o(i.current)},[o,i]);return w.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const u=new ResizeObserver(()=>{requestAnimationFrame(a)});return u.observe(t),()=>{t.removeEventListener("scroll",a),u.unobserve(t)}}else{const u=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return u==null||u.addEventListener("scroll",a),u==null||u.addEventListener("resize",a),()=>{u==null||u.removeEventListener("scroll",a),u==null||u.removeEventListener("resize",a)}}},[a,t,i]),s}const Rt=Xe(()=>{const e=Ve(),t=Ve(),n=Y(0),r=Ve(),o=Y(0),s=Ve(),i=Ve(),a=Y(0),l=Y(0),u=Y(0),d=Y(0),f=Ve(),h=Ve(),p=Y(!1),v=Y(!1),x=Y(!1);return ye(U(e,ce(({scrollTop:g})=>g)),t),ye(U(e,ce(({scrollHeight:g})=>g)),i),ye(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:x,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Zr={lvl:0};function Zc(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function rt(e){return e===Zr}function Qr(e,t){if(!rt(e))return t===e.k?e.v:t<e.k?Qr(e.l,t):Qr(e.r,t)}function sn(e,t,n="k"){if(rt(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=sn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return sn(e.l,t,n)}function Ht(e,t,n){return rt(e)?tu(t,n,1):t===e.k?vt(e,{k:t,v:n}):t<e.k?nu(vt(e,{l:Ht(e.l,t,n)})):nu(vt(e,{r:Ht(e.r,t,n)}))}function _r(){return Zr}function Go(e,t,n){if(rt(e))return[];const r=sn(e,t)[0];return Xx(zi(e,r,n))}function Fi(e,t){if(rt(e))return Zr;const{k:n,l:r,r:o}=e;if(t===n){if(rt(r))return o;if(rt(o))return r;{const[s,i]=eu(r);return Yo(vt(e,{k:s,l:Qc(r),v:i}))}}else return t<n?Yo(vt(e,{l:Fi(r,t)})):Yo(vt(e,{r:Fi(o,t)}))}function ar(e){return rt(e)?[]:[...ar(e.l),{k:e.k,v:e.v},...ar(e.r)]}function zi(e,t,n){if(rt(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(zi(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(zi(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(Bi(t))return ru(vt(e,{lvl:n-1}));if(!rt(t)&&!rt(t.r))return vt(t.r,{l:vt(t,{r:t.r.l}),lvl:n,r:vt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Bi(e))return Hi(vt(e,{lvl:n-1}));if(!rt(r)&&!rt(r.l)){const o=r.l,s=Bi(o)?r.lvl-1:r.lvl;return vt(o,{l:vt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Hi(vt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function vt(e,t){return tu(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 Qc(e){return rt(e.r)?e.l:Yo(vt(e,{r:Qc(e.r)}))}function Bi(e){return rt(e)||e.lvl>e.r.lvl}function eu(e){return rt(e.r)?[e.k,e.v]:eu(e.r)}function tu(e,t,n,r=Zr,o=Zr){return{k:e,l:r,lvl:n,r:o,v:t}}function nu(e){return Hi(ru(e))}function ru(e){const{l:t}=e;return!rt(t)&&t.lvl===e.lvl?vt(t,{r:vt(e,{l:t.r})}):e}function Hi(e){const{lvl:t,r:n}=e;return!rt(n)&&!rt(n.r)&&n.lvl===t&&n.r.lvl===t?vt(n,{l:vt(e,{r:n.l}),lvl:t+1}):e}function Xx(e){return Zc(e,({k:t,v:n})=>({index:t,value:n}))}function ou(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function eo(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ui=Xe(()=>({recalcInProgress:Y(!1)}),[],{singleton:!0});function su(e,t,n){return e[Xo(e,t,n)]}function Xo(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 Jx(e,t,n,r){const o=Xo(e,t,r),s=Xo(e,n,r,o);return e.slice(o,s+1)}function Fn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Jo(e){return!rt(e.groupOffsetTree)}function Wi({index:e},t){return t===e?0:t<e?-1:1}function Zx(){return{groupIndices:[],groupOffsetTree:_r(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:_r()}}function Qx(e,t){let n=rt(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),rt(e)){e=Ht(e,0,s);continue}const a=Go(e,i-1,o+1);if(a.some(iy(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=Fi(e,f)):(u=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=Ht(e,o+1,h));u&&(e=Ht(e,i,s))}return[e,n]}function ey(e){return typeof e.groupIndex<"u"}function ty({offset:e},t){return t===e?0:t<e?-1:1}function to(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=su(t,e,Wi),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function iu(e,t){if(!Jo(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function au(e,t,n){if(ey(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=iu(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function ny(e,t,n,r=0){return r>0&&(t=Math.max(t,su(e,r,Wi).offset)),Zc(Jx(e,t,n,ty),sy)}function ry(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,$t.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&rt(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((v,x)=>Ht(Ht(v,x,h),x+1,p),i)}else[i,a]=Qx(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=Vi(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>Ht(h,p,to(p,f,o)),_r()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function oy(e){return ar(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 lu(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 Vi(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=Xo(o,t-1,Wi),a=o[l].offset;const u=sn(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===sn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:u,value:d}of Go(n,t,1/0)){const f=u-s,h=f*i+a+f*r;o.push({index:u,offset:h,size:d}),s=u,a=h,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function sy(e){return{index:e.index,value:e}}function iy(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 ay={offsetHeight:"height",offsetWidth:"width"},mn=Xe(([{log:e},{recalcInProgress:t}])=>{const n=Ve(),r=Ve(),o=It(r,0),s=Ve(),i=Ve(),a=Y(0),l=Y([]),u=Y(void 0),d=Y(void 0),f=Y((C,T)=>Fn(C,ay[T])),h=Y(void 0),p=Y(0),v=Zx(),x=It(U(n,Be(l,e,p),pn(ry,v),lt()),v),g=It(U(l,lt(),pn((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),ce(({prev:C})=>C)),[]);ye(U(l,Ne(C=>C.length>0),Be(x,p),ce(([C,T,I])=>{const A=C.reduce((j,P,D)=>Ht(j,P,to(P,T.offsetTree,I)||D),_r());return{...T,groupIndices:C,groupOffsetTree:A}})),x),ye(U(r,Be(x),Ne(([C,{lastIndex:T}])=>C<T),ce(([C,{lastIndex:T,lastSize:I}])=>[{endIndex:T,size:I,startIndex:C}])),n),ye(u,d);const y=It(U(u,ce(C=>C===void 0)),!0);ye(U(d,Ne(C=>C!==void 0&&rt(gt(x).sizeTree)),ce(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=Bt(U(n,Be(x),pn(({sizes:C},[T,I])=>({changed:I!==C,sizes:I}),{changed:!1,sizes:v}),ce(C=>C.changed)));Ze(U(a,pn((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),ce(C=>C.diff)),C=>{const{groupIndices:T}=gt(x);if(C>0)$e(t,!0),$e(s,C+lu(C,T));else if(C<0){const I=gt(g);I.length>0&&(C-=lu(-C,I)),$e(i,C)}}),Ze(U(a,Be(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},$t.ERROR)});const S=Bt(s);ye(U(s,Be(x),ce(([C,T])=>{const I=T.groupIndices.length>0,A=[],j=T.lastSize;if(I){const P=Qr(T.sizeTree,0);let D=0,L=0;for(;D<C;){const M=T.groupIndices[L],X=T.groupIndices.length===L+1?1/0:T.groupIndices[L+1]-M-1;A.push({endIndex:M,size:P,startIndex:M}),A.push({endIndex:M+1+X-1,size:j,startIndex:M+1}),L++,D+=X+1}const B=ar(T.sizeTree);return D!==C&&B.shift(),B.reduce((M,{k:X,v:W})=>{let V=M.ranges;return M.prevSize!==0&&(V=[...M.ranges,{endIndex:X+C-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:X+C,prevSize:W,ranges:V}},{prevIndex:C,prevSize:0,ranges:A}).ranges}return ar(T.sizeTree).reduce((P,{k:D,v:L})=>({prevIndex:D+C,prevSize:L,ranges:[...P.ranges,{endIndex:D+C-1,size:P.prevSize,startIndex:P.prevIndex}]}),{prevIndex:0,prevSize:j,ranges:[]}).ranges})),n);const k=Bt(U(i,Be(x,p),ce(([C,{offsetTree:T},I])=>{const A=-C;return to(A,T,I)})));return ye(U(i,Be(x,p),ce(([C,T,I])=>{if(T.groupIndices.length>0){if(rt(T.sizeTree))return T;let A=_r();const j=gt(g);let P=0,D=0,L=0;for(;P<-C;){L=j[D];const B=j[D+1]-L-1;D++,P+=B+1}if(A=ar(T.sizeTree).reduce((B,{k:M,v:X})=>Ht(B,Math.max(0,M+C),X),A),P!==-C){const B=Qr(T.sizeTree,L);A=Ht(A,0,B);const M=sn(T.sizeTree,-C+1)[1];A=Ht(A,1,M)}return{...T,sizeTree:A,...Vi(T.offsetTree,0,A,I)}}else{const A=ar(T.sizeTree).reduce((j,{k:P,v:D})=>Ht(j,Math.max(0,P+C),D),_r());return{...T,sizeTree:A,...Vi(T.offsetTree,0,A,I)}}})),x),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:x,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},at($n,Ui),{singleton:!0});function ly(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const cu=Xe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Ve(),i=Ve(),a=Bt(U(s,ce(ly)));return ye(U(a,ce(l=>l.totalCount)),n),ye(U(a,ce(l=>l.groupIndices)),e),ye(U(yt(o,t,r),Ne(([l,u])=>Jo(u)),ce(([l,u,d])=>sn(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),lt(),ce(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},at(mn,Rt)),zn=Xe(([{log:e}])=>{const t=Y(!1),n=Bt(U(t,Ne(r=>r),lt()));return Ze(t,r=>{r&&gt(e)("props updated",{},$t.DEBUG)}),{didMount:n,propsReady:t}},at($n),{singleton:!0}),cy=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function uu(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!cy)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const no=Xe(([{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=Ve(),v=Ve(),x=Y(0);let g=null,y=null,b=null;function S(){g&&(g(),g=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),$e(l,!1)}return ye(U(p,Be(n,f,r,x,a,i,h),Be(e,s,o),ce(([[k,C,T,I,A,j,P,D],L,B,M])=>{const X=uu(k),{align:W,behavior:V,offset:z}=X,$=I-1,pe=au(X,C,$);let F=to(pe,C.offsetTree,L)+j;W==="end"?(F+=B+sn(C.sizeTree,pe)[1]-T+M,pe===$&&(F+=P)):W==="center"?F+=(B+sn(C.sizeTree,pe)[1]-T+M)/2:F-=A,z&&(F+=z);const Z=he=>{S(),he?(D("retrying to scroll to",{location:k},$t.DEBUG),$e(p,k)):($e(v,!0),D("list did not change, scroll successful",{},$t.DEBUG))};if(S(),V==="smooth"){let he=!1;b=Ze(t,ve=>{he=he||ve}),g=on(d,()=>{Z(he)})}else g=on(U(t,uy(150)),Z);return y=setTimeout(()=>{S()},1200),$e(l,!0),D("scrolling from index to",{behavior:V,index:pe,top:F},$t.DEBUG),{behavior:V,top:F}})),u),{scrollTargetReached:v,scrollToIndex:p,topListHeight:x}},at(mn,Rt,$n),{singleton:!0});function uy(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Ki(e,t){e==0?t():requestAnimationFrame(()=>{Ki(e-1,t)})}function qi(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const ro=Xe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=Y(!0),l=Y(0),u=Y(!0);return ye(U(i,Be(l),Ne(([d,f])=>!!f),hn(!1)),a),ye(U(i,Be(l),Ne(([d,f])=>!!f),hn(!1)),u),Ze(U(yt(t,i),Be(a,n,e,u),Ne(([[,d],f,{sizeTree:h},p,v])=>d&&(!rt(h)||Mi(p))&&!f&&!v),Be(l)),([,d])=>{on(o,()=>{$e(u,!0)}),Ki(4,()=>{on(r,()=>{$e(a,!0)}),$e(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},at(mn,Rt,no,zn),{singleton:!0});function du(e,t){return Math.abs(e-t)<1.01}const oo="up",so="down",dy="none",fy={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},hy=0,io=Xe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=Y(!1),a=Y(!0),l=Ve(),u=Ve(),d=Y(4),f=Y(hy),h=It(U(Li(U(Ie(o),sr(1),hn(!0)),U(Ie(o),sr(1),hn(!1),Gc(100))),lt()),!1),p=It(U(Li(U(n,hn(!0)),U(n,hn(!1),Gc(200))),lt()),!1);ye(U(yt(Ie(o),Ie(f)),ce(([b,S])=>b<=S),lt()),a),ye(U(a,Nn(50)),u);const v=Bt(U(yt(r,Ie(s),Ie(t),Ie(e),Ie(d)),pn((b,[{scrollHeight:S,scrollTop:k},C,T,I,A])=>{const j=k+C-S>-A,P={scrollHeight:S,scrollTop:k,viewportHeight:C};if(j){let L,B;return k>b.state.scrollTop?(L="SCROLLED_DOWN",B=b.state.scrollTop-k):(L="SIZE_DECREASED",B=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:L,scrollTopDelta:B,state:P}}let D;return P.scrollHeight>b.state.scrollHeight?D="SIZE_INCREASED":C<b.state.viewportHeight?D="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?D="SCROLLING_UPWARDS":D="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:D,state:P}},fy),lt((b,S)=>b&&b.atBottom===S.atBottom))),x=It(U(r,pn((b,{scrollHeight:S,scrollTop:k,viewportHeight:C})=>{if(du(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const T=S-(k+C)<1;return b.scrollTop!==k&&T?{changed:!0,jump:b.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ne(b=>b.changed),ce(b=>b.jump)),0);ye(U(v,ce(b=>b.atBottom)),i),ye(U(i,Nn(50)),l);const g=Y(so);ye(U(r,ce(({scrollTop:b})=>b),lt(),pn((b,S)=>gt(p)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?oo:so,prevScrollTop:S},{direction:so,prevScrollTop:0}),ce(b=>b.direction)),g),ye(U(r,Nn(50),hn(dy)),g);const y=Y(0);return ye(U(h,Ne(b=>!b),hn(0)),y),ye(U(o,Nn(100),Be(h),Ne(([b,S])=>!!S),pn(([b,S],[k])=>[S,k],[0,0]),ce(([b,S])=>S-b)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:x,scrollDirection:g,scrollVelocity:y}},at(Rt)),Zo="top",Qo="bottom",fu="none";function hu(e,t,n){return typeof e=="number"?n===oo&&t===Zo||n===so&&t===Qo?e:0:n===oo?t===Zo?e.main:e.reverse:t===Qo?e.main:e.reverse}function pu(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Gi=Xe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Ve(),i=Y(0),a=Y(0),l=Y(0),u=It(U(yt(Ie(r),Ie(o),Ie(n),Ie(s,eo),Ie(l),Ie(i),Ie(t),Ie(e),Ie(a)),ce(([d,f,h,[p,v],x,g,y,b,S])=>{const k=d-b,C=g+y,T=Math.max(h-k,0);let I=fu;const A=pu(S,Zo),j=pu(S,Qo);return p-=b,p+=h+y,v+=h+y,v-=b,p>d+C-A&&(I=oo),v<d-T+f+j&&(I=so),I!==fu?[Math.max(k-h-hu(x,Zo,I)-A,0),k-T-y+f+hu(x,Qo,I)+j]:null}),Ne(d=>d!=null),lt(eo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},at(Rt),{singleton:!0});function py(e,t,n){if(Jo(t)){const r=iu(e,t);return[{index:sn(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 Yi={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function es(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const x=e[e.length-1];d=x.offset+x.size}const f=n-i,h=a+f*l+(f-1)*r,p=u,v=h-d;return{bottom:d,firstItemIndex:s,items:gu(e,o,s),offsetBottom:v,offsetTop:u,top:p,topItems:gu(t,o,s),topListHeight:t.reduce((x,g)=>g.size+x,0),totalCount:n}}function mu(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=qi(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return es(u,[],a,o,n,r)}function gu(e,t,n){if(e.length===0)return[];if(!Jo(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=Go(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 lr=Xe(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:p},{recalcInProgress:v}])=>{const x=Y([]),g=Y(0),y=Ve();ye(s.topItemsIndexes,x);const b=It(U(yt(p,v,Ie(l,eo),Ie(o),Ie(r),Ie(u),d,Ie(x),Ie(t),Ie(n),e),Ne(([T,I,,A,,,,,,,j])=>{const P=j&&j.length!==A;return T&&!I&&!P}),ce(([,,[T,I],A,j,P,D,L,B,M,X])=>{const W=j,{offsetTree:V,sizeTree:z}=W,$=gt(g);if(A===0)return{...Yi,totalCount:A};if(T===0&&I===0)return $===0?{...Yi,totalCount:A}:mu($,P,j,B,M,X||[]);if(rt(z))return $>0?null:es(py(qi(P,A),W,X),[],A,M,W,B);const pe=[];if(L.length>0){const be=L[0],Te=L[L.length-1];let K=0;for(const O of Go(z,be,Te)){const J=O.value,te=Math.max(O.start,be),de=Math.min(O.end,Te);for(let le=te;le<=de;le++)pe.push({data:X==null?void 0:X[le],index:le,offset:K,size:J}),K+=J}}if(!D)return es([],pe,A,M,W,B);const F=L.length>0?L[L.length-1]+1:0,Z=ny(V,T,I,F);if(Z.length===0)return null;const he=A-1,ve=qo([],be=>{for(const Te of Z){const K=Te.value;let O=K.offset,J=Te.start;const te=K.size;if(K.offset<T){J+=Math.floor((T-K.offset+M)/(te+M));const le=J-Te.start;O+=le*te+le*M}J<F&&(O+=(F-J)*te,J=F);const de=Math.min(Te.end,he);for(let le=J;le<=de&&!(O>=I);le++)be.push({data:X==null?void 0:X[le],index:le,offset:O,size:te}),O+=te+M}});return es(ve,pe,A,M,W,B)}),Ne(T=>T!==null),lt()),Yi);ye(U(e,Ne(Mi),ce(T=>T==null?void 0:T.length)),o),ye(U(b,ce(T=>T.topListHeight)),f),ye(f,a),ye(U(b,ce(T=>[T.top,T.bottom])),i),ye(U(b,ce(T=>T.items)),y);const S=Bt(U(b,Ne(({items:T})=>T.length>0),Be(o,e),Ne(([{items:T},I])=>T[T.length-1].originalIndex===I-1),ce(([,T,I])=>[T-1,I]),lt(eo),ce(([T])=>T))),k=Bt(U(b,Nn(200),Ne(({items:T,topItems:I})=>T.length>0&&T[0].originalIndex===I.length),ce(({items:T})=>T[0].index),lt())),C=Bt(U(b,Ne(({items:T})=>T.length>0),ce(({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}}),lt(ou)));return{endReached:S,initialItemCount:g,itemsRendered:y,listState:b,rangeChanged:C,startReached:k,topItemsIndexes:x,...h}},at(mn,cu,Gi,ro,no,io,zn,Ui),{singleton:!0}),xu=Xe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Ve(),i=It(U(yt(n,e,r,t,o),ce(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return ye(Ie(i),s),{totalListHeight:i,totalListHeightChanged:s}},at(Rt,lr),{singleton:!0}),my=Xe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=Y(!1),r=It(U(yt(n,e,t),Ne(([o])=>o),ce(([,o,s])=>Math.max(0,o-s)),Nn(0),lt()),0);return{alignToBottom:n,paddingTopAddition:r}},at(Rt,xu),{singleton:!0}),yu=Xe(()=>({context:Y(null)})),gy=({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,vu=Xe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:u}])=>{const d=Ve();return ye(U(d,Be(t,l,n,s,o,r,a),Be(e),ce(([[f,h,p,v,x,g,y,b],S])=>{const{align:k,behavior:C,calculateViewLocation:T=gy,done:I,...A}=f,j=au(f,h,v-1),P=to(j,h.offsetTree,S)+x+g,D=P+sn(h.sizeTree,j)[1],L=b+g,B=b+p-y,M=T({itemBottom:D,itemTop:P,locationParams:{align:k,behavior:C,...A},viewportBottom:B,viewportTop:L});return M?I&&on(U(i,Ne(X=>!X),sr(gt(i)?1:2)),I):I&&I(),M}),Ne(f=>f!==null)),u),{scrollIntoView:d}},at(mn,Rt,no,lr,$n),{singleton:!0});function bu(e){return e?e==="smooth"?"smooth":"auto":!1}const xy=(e,t)=>typeof e=="function"?bu(e(t)):t&&bu(e),yy=Xe(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:u},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:p}])=>{const v=Y(!1),x=Ve();let g=null;function y(C){$e(i,{align:"end",behavior:C,index:"LAST"})}Ze(U(yt(U(Ie(t),sr(1)),l),Be(Ie(v),s,a,f),ce(([[C,T],I,A,j,P])=>{let D=T&&j,L="auto";return D&&(L=xy(I,A||P),D=D&&!!L),{followOutputBehavior:L,shouldFollow:D,totalCount:C}}),Ne(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{g&&(g(),g=null),gt(n)?requestAnimationFrame(()=>{gt(d)("following output to ",{totalCount:T},$t.DEBUG),y(C)}):g=on(e,()=>{gt(d)("following output to ",{totalCount:T},$t.DEBUG),y(C),g=null})});function b(C){const T=on(o,I=>{C&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(gt(d)("scrolling to bottom due to increased size",{},$t.DEBUG),y("auto"))});setTimeout(T,100)}Ze(U(yt(Ie(v),t,u),Ne(([C,,T])=>C&&T),pn(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),Ne(({refreshed:C})=>C),Be(v,t)),([,C])=>{gt(a)&&b(C!==!1)}),Ze(x,()=>{b(gt(v)!==!1)}),Ze(yt(Ie(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=Y(null),k=Ve();return ye(Li(U(Ie(r),ce(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),U(Ie(t))),k),Ze(U(yt(U(k,sr(1)),l),Be(Ie(S),a,f,h),ce(([[C,T],I,A,j,P])=>T&&A&&(I==null?void 0:I({context:P,totalCount:C,scrollingInProgress:j}))),Ne(C=>!!C),Nn(0)),C=>{g&&(g(),g=null),gt(n)?requestAnimationFrame(()=>{gt(d)("scrolling into view",{}),$e(p,C)}):g=on(e,()=>{gt(d)("scrolling into view",{}),$e(p,C),g=null})}),{autoscrollToBottom:x,followOutput:v,scrollIntoViewOnChange:S}},at(mn,io,no,ro,zn,$n,Rt,yu,vu)),vy=Xe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ye(U(a,Be(s),Ne(([,l])=>l!==0),Be(o,r,t,n,e),ce(([[,l],u,d,f,h,p=[]])=>mu(l,u,d,f,h,p))),i),{}),at(mn,ro,lr,zn),{singleton:!0}),by=Xe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=Y(0);return Ze(U(e,Be(r),Ne(([,o])=>o!==0),ce(([,o])=>({top:o}))),o=>{on(U(n,sr(1),Ne(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{$e(t,o)})})}),{initialScrollTop:r}},at(zn,Rt,lr),{singleton:!0}),wu=Xe(([{scrollVelocity:e}])=>{const t=Y(!1),n=Ve(),r=Y(!1);return ye(U(e,Be(r,t,n),Ne(([o,s])=>!!s),ce(([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}),lt()),t),Ze(U(yt(t,e,n),Be(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},at(io),{singleton:!0}),Xi=Xe(([{scrollContainerState:e,scrollTo:t}])=>{const n=Ve(),r=Ve(),o=Ve(),s=Y(!1),i=Y(void 0);return ye(U(yt(n,r),ce(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),ye(U(t,Be(r),ce(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},at(Rt)),wy=Xe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=Ve(),d=Y(void 0),f=Y(null),h=Y(null);return ye(a,f),ye(l,h),Ze(U(u,Be(t,r,i,f,h,n)),([p,v,x,g,y,b,S])=>{const k=oy(v.sizeTree);g&&y!==null&&b!==null&&(x=y.scrollTop-b.offsetTop),x-=S,p({ranges:k,scrollTop:x})}),ye(U(d,Ne(Mi),ce(Sy)),o),ye(U(s,Be(d),Ne(([,p])=>p!==void 0),lt(),ce(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},at(mn,Rt,ro,zn,Xi));function Sy(e){return{align:"start",index:0,offset:e.scrollTop}}const Cy=Xe(([{topItemsIndexes:e}])=>{const t=Y(0);return ye(U(t,Ne(n=>n>=0),ce(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},at(lr));function Su(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const Ty=Su(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),ky=Xe(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:h},{log:p},{recalcInProgress:v}])=>{const x=Bt(U(l,Be(i),pn(([,y,b,S],[{bottom:k,items:C,offsetBottom:T,totalCount:I},A])=>{const j=k+T;let P=0;return b===I&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(P=j-S,P!==0&&(P+=A))),[P,C,I,j]},[0,[],0,0]),Ne(([y])=>y!==0),Be(r,a,n,o,p,v),Ne(([,y,b,S,,,k])=>!k&&!S&&y!==0&&b===oo),ce(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},$t.DEBUG),y))));function g(y){y>0?($e(t,{behavior:"auto",top:-y}),$e(e,0)):($e(e,0),$e(t,{behavior:"auto",top:-y}))}return Ze(U(x,Be(e,s)),([y,b,S])=>{S&&Ty()?$e(e,b-y):g(-y)}),Ze(U(yt(It(s,!1),e,v),Ne(([y,b,S])=>!y&&!S&&b!==0),ce(([y,b])=>b),Nn(1)),g),ye(U(f,ce(y=>({top:-y}))),t),Ze(U(u,Be(h,d),ce(([y,{groupIndices:b,lastSize:S,sizeTree:k},C])=>{function T(I){return I*(S+C)}if(b.length===0)return T(y);{let I=0;const A=Qr(k,0);let j=0,P=0;for(;j<y;){j++,I+=A;let D=b.length===P+1?1/0:b[P+1]-b[P]-1;j+D>y&&(I-=A,D=y-j+1),j+=D,I+=T(D),P++}return I}})),y=>{$e(e,y),requestAnimationFrame(()=>{$e(t,{top:y}),requestAnimationFrame(()=>{$e(e,0),$e(v,!1)})})}),{deviation:e}},at(Rt,io,lr,mn,$n,Ui)),Ey=Xe(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),at(Gi,vy,zn,wu,xu,by,my,Xi,vu,$n,yu)),Cu=Xe(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:v},x,g,y,{listState:b,topItemsIndexes:S,...k},{scrollToIndex:C},T,{topItemCount:I},{groupCounts:A},j])=>(ye(k.rangeChanged,j.scrollSeekRangeChanged),ye(U(j.windowViewportRect,ce(P=>P.visibleHeight)),x.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:v,sizeRanges:a,topItemCount:I,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...k,...j,...x,sizes:l,...g}),at(mn,ro,Rt,wy,yy,lr,no,ky,Cy,cu,Ey));function Iy(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 ts=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Tu(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=w.createContext({});function l(g,y){g.propsReady&&$e(g.propsReady,!1);for(const b of r){const S=g[t.required[b]];$e(S,y[b])}for(const b of o)if(b in y){const S=g[t.optional[b]];$e(S,y[b])}g.propsReady&&$e(g.propsReady,!0)}function u(g){return s.reduce((y,b)=>(y[b]=S=>{const k=g[t.methods[b]];$e(k,S)},y),{})}function d(g){return i.reduce((y,b)=>(y[b]=Ux(g[t.events[b]]),y),{})}const f=w.forwardRef((g,y)=>{const{children:b,...S}=g,[k]=w.useState(()=>qo(Vx(e),I=>{l(I,S)})),[C]=w.useState(qc(d,k));ts(()=>{for(const I of i)I in S&&Ze(C[I],S[I]);return()=>{Object.values(C).map(Di)}},[S,C,k]),ts(()=>{l(k,S)}),w.useImperativeHandle(y,Vc(u(k)));const T=n;return c.jsx(a.Provider,{value:k,children:n?c.jsx(T,{...Iy([...r,...o,...i],S),children:b}):b})}),h=g=>{const y=w.useContext(a);return w.useCallback(b=>{$e(y[g],b)},[y,g])},p=g=>{const y=w.useContext(a)[g],b=w.useCallback(S=>Ze(y,S),[y]);return w.useSyncExternalStore(b,()=>gt(y),()=>gt(y))},v=g=>{const y=w.useContext(a)[g],[b,S]=w.useState(qc(gt,y));return ts(()=>Ze(y,k=>{k!==b&&S(Vc(k))}),[y,b]),b},x=w.version.startsWith("18")?p:v;return{Component:f,useEmitter:(g,y)=>{const b=w.useContext(a)[g];ts(()=>Ze(b,y),[y,b])},useEmitterValue:x,usePublisher:h}}const ku=w.createContext(void 0),Eu=w.createContext(void 0),Iu=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Ji(e){return"self"in e}function Ny(e){return"body"in e}function Nu(e,t,n,r=Ar,o,s){const i=w.useRef(null),a=w.useRef(null),l=w.useRef(null),u=w.useCallback(h=>{let p,v,x;const g=h.target;if(Ny(g)||Ji(g)){const b=Ji(g)?g:g.defaultView;x=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,v=s?b.innerWidth:b.innerHeight}else x=s?g.scrollLeft:g.scrollTop,p=s?g.scrollWidth:g.scrollHeight,v=s?g.offsetWidth:g.offsetHeight;const y=()=>{e({scrollHeight:p,scrollTop:Math.max(x,0),viewportHeight:v})};h.suppressFlushSync?y():li.flushSync(y),a.current!==null&&(x===a.current||x<=0||x===p-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);w.useEffect(()=>{const h=o||i.current;return r(o||i.current),u({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",u,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",u)}},[i,u,n,r,o]);function d(h){const p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const v=h.behavior==="smooth";let x,g,y;Ji(p)?(g=Math.max(Fn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),x=s?p.innerWidth:p.innerHeight,y=s?window.scrollX:window.scrollY):(g=p[s?"scrollWidth":"scrollHeight"],x=Fn(p,s?"width":"height"),y=p[s?"scrollLeft":"scrollTop"]);const b=g-x;if(h.top=Math.ceil(Math.max(Math.min(b,h.top),0)),du(x,g)||h.top===y){e({scrollHeight:g,scrollTop:y,viewportHeight:x}),v&&t(!0);return}v?(a.current=h.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(h={behavior:h.behavior,left:h.top}),p.scrollTo(h)}function f(h){s&&(h={behavior:h.behavior,left:h.top}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const Zi="-webkit-sticky",Au="sticky",Qi=Su(()=>{if(typeof document>"u")return Au;const e=document.createElement("div");return e.style.position=Zi,e.style.position===Zi?Zi:Au});function ea(e){return e}const Ay=Xe(()=>{const e=Y(a=>`Item ${a}`),t=Y(a=>`Group ${a}`),n=Y({}),r=Y(ea),o=Y("div"),s=Y(Ar),i=(a,l=null)=>It(U(n,ce(u=>u[a]),lt()),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")}}),_y=Xe(([e,t])=>({...e,...t}),at(Cu,Ay)),jy=({height:e})=>c.jsx("div",{style:{height:e}}),Ry={overflowAnchor:"none",position:Qi(),zIndex:1},_u={overflowAnchor:"none"},Py={..._u,display:"inline-block",height:"100%"},ju=w.memo(function({showTopList:e=!1}){const t=Re("listState"),n=Xt("sizeRanges"),r=Re("useWindowScroll"),o=Re("customScrollParent"),s=Xt("windowScrollContainerState"),i=Xt("scrollContainerState"),a=o||r?s:i,l=Re("itemContent"),u=Re("context"),d=Re("groupContent"),f=Re("trackItemSizes"),h=Re("itemSize"),p=Re("log"),v=Xt("gap"),x=Re("horizontalDirection"),{callbackRef:g}=Gx(n,h,f,e?Ar:a,p,v,o,x,Re("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);ta("deviation",M=>{y!==M&&b(M)});const S=Re("EmptyPlaceholder"),k=Re("ScrollSeekPlaceholder")||jy,C=Re("ListComponent"),T=Re("ItemComponent"),I=Re("GroupComponent"),A=Re("computeItemKey"),j=Re("isSeeking"),P=Re("groupIndices").length>0,D=Re("alignToBottom"),L=Re("initialItemFinalLocationReached"),B=e?{}:{boxSizing:"border-box",...x?{display:"inline-block",height:"100%",marginLeft:y!==0?y:D?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:D?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...L?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?c.jsx(S,{...Nt(S,u)}):c.jsx(C,{...Nt(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:B,children:(e?t.topItems:t.items).map(M=>{const X=M.originalIndex,W=A(X+t.firstItemIndex,M.data,u);return j?w.createElement(k,{...Nt(k,u),height:M.size,index:M.index,key:W,type:M.type||"item",...M.type==="group"?{}:{groupIndex:M.groupIndex}}):M.type==="group"?w.createElement(I,{...Nt(I,u),"data-index":X,"data-item-index":M.index,"data-known-size":M.size,key:W,style:Ry},d(M.index,u)):w.createElement(T,{...Nt(T,u),...Ly(T,M.data),"data-index":X,"data-item-group-index":M.groupIndex,"data-item-index":M.index,"data-known-size":M.size,key:W,style:x?Py:_u},P?l(M.index,M.groupIndex,M.data,u):l(M.index,M.data,u))})})}),Oy={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},My={outline:"none",overflowX:"auto",position:"relative"},ns=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Dy={position:Qi(),top:0,width:"100%",zIndex:1};function Nt(e,t){if(typeof e!="string")return{context:t}}function Ly(e,t){return{item:typeof e=="string"?void 0:t}}const $y=w.memo(function(){const e=Re("HeaderComponent"),t=Xt("headerHeight"),n=Re("HeaderFooterTag"),r=ir(w.useMemo(()=>s=>{t(Fn(s,"height"))},[t]),!0,Re("skipAnimationFrameInResizeObserver")),o=Re("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Nt(e,o)})}):null}),Fy=w.memo(function(){const e=Re("FooterComponent"),t=Xt("footerHeight"),n=Re("HeaderFooterTag"),r=ir(w.useMemo(()=>s=>{t(Fn(s,"height"))},[t]),!0,Re("skipAnimationFrameInResizeObserver")),o=Re("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Nt(e,o)})}):null});function Ru({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:v}=Nu(a,u,l,d,void 0,f);return e("scrollTo",v),e("scrollBy",h),c.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?My:Oy,...o},tabIndex:0,...i,...Nt(l,s),children:r})})}function Pu({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=w.useRef(null),v=t("scrollerRef"),{scrollByCallback:x,scrollerRef:g,scrollToCallback:y}=Nu(a,u,l,v,h);return Iu(()=>{var b;return g.current=h||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",y),e("scrollBy",x),c.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Nt(l,s),children:r})})}const zy=({children:e})=>{const t=w.useContext(ku),n=Xt("viewportHeight"),r=Xt("fixedItemHeight"),o=Re("alignToBottom"),s=Re("horizontalDirection"),i=w.useMemo(()=>Kc(n,l=>Fn(l,s?"width":"height")),[n,s]),a=ir(i,!0,Re("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),c.jsx("div",{"data-viewport-type":"element",ref:a,style:ns(o),children:e})},By=({children:e})=>{const t=w.useContext(ku),n=Xt("windowViewportRect"),r=Xt("fixedItemHeight"),o=Re("customScrollParent"),s=Jc(n,o,Re("skipAnimationFrameInResizeObserver")),i=Re("alignToBottom");return w.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),c.jsx("div",{"data-viewport-type":"window",ref:s,style:ns(i),children:e})},Hy=({children:e})=>{const t=Re("TopItemListComponent")||"div",n=Re("headerHeight"),r={...Dy,marginTop:`${n}px`},o=Re("context");return c.jsx(t,{style:r,...Nt(t,o),children:e})},Uy=w.memo(function(e){const t=Re("useWindowScroll"),n=Re("topItemsIndexes").length>0,r=Re("customScrollParent"),o=Re("context");return c.jsxs(r||t?Ky:Vy,{...e,context:o,children:[n&&c.jsx(Hy,{children:c.jsx(ju,{showTopList:!0})}),c.jsxs(r||t?By:zy,{children:[c.jsx($y,{}),c.jsx(ju,{}),c.jsx(Fy,{})]})]})}),{Component:Wy,useEmitter:ta,useEmitterValue:Re,usePublisher:Xt}=Tu(_y,{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"}},Uy),Vy=Ru({useEmitter:ta,useEmitterValue:Re,usePublisher:Xt}),Ky=Pu({useEmitter:ta,useEmitterValue:Re,usePublisher:Xt}),qy=Wy;at(Cu,Xe(()=>{const e=Y(u=>c.jsxs("td",{children:["Item $",u]})),t=Y(null),n=Y(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=Y(null),o=Y(null),s=Y({}),i=Y(ea),a=Y(Ar),l=(u,d=null)=>It(U(s,ce(f=>f[u]),lt()),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")}})),Qi();const Ou={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Gy={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Mu,floor:rs,max:ao,min:na,round:Du}=Math;function Lu(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function Yy(e){return{...Gy,items:e}}function os(e,t){return e&&e.width===t.width&&e.height===t.height}function Xy(e,t){return e&&e.column===t.column&&e.row===t.row}const Jy=Xe(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},h,p,{didMount:v,propsReady:x},{customScrollParent:g,useWindowScroll:y,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k},C])=>{const T=Y(0),I=Y(0),A=Y(Ou),j=Y({height:0,width:0}),P=Y({height:0,width:0}),D=Ve(),L=Ve(),B=Y(0),M=Y(null),X=Y({column:0,row:0}),W=Ve(),V=Ve(),z=Y(!1),$=Y(0),pe=Y(!0),F=Y(!1),Z=Y(!1);Ze(U(v,Be($),Ne(([O,J])=>!!J)),()=>{$e(pe,!1)}),Ze(U(yt(v,pe,P,j,$,F),Ne(([O,J,te,de,,le])=>O&&!J&&te.height!==0&&de.height!==0&&!le)),([,,,,O])=>{$e(F,!0),Ki(1,()=>{$e(D,O)}),on(U(u),()=>{$e(t,[0,0]),$e(pe,!0)})}),ye(U(V,Ne(O=>O!=null&&O.scrollTop>0),hn(0)),I),Ze(U(v,Be(V),Ne(([,O])=>O!=null)),([,O])=>{O&&($e(j,O.viewport),$e(P,O.item),$e(X,O.gap),O.scrollTop>0&&($e(z,!0),on(U(u,sr(1)),J=>{$e(z,!1)}),$e(l,{top:O.scrollTop})))}),ye(U(j,ce(({height:O})=>O)),f),ye(U(yt(Ie(j,os),Ie(P,os),Ie(X,(O,J)=>O&&O.column===J.column&&O.row===J.row),Ie(u)),ce(([O,J,te,de])=>({gap:te,item:J,scrollTop:de,viewport:O}))),W),ye(U(yt(Ie(T),r,Ie(X,Xy),Ie(P,os),Ie(j,os),Ie(M),Ie(I),Ie(z),Ie(pe),Ie($)),Ne(([,,,,,,,O])=>!O),ce(([O,[J,te],de,le,ie,tt,et,,Oe,He])=>{const{column:ht,row:nt}=de,{height:Me,width:bt}=le,{width:ne}=ie;if(et===0&&(O===0||ne===0))return Ou;if(bt===0){const xt=qi(He,O),Ot=xt+Math.max(et-1,0);return Yy(Lu(xt,Ot,tt))}const se=$u(ne,bt,ht);let ge,we;Oe?J===0&&te===0&&et>0?(ge=0,we=et-1):(ge=se*rs((J+nt)/(Me+nt)),we=se*Mu((te+nt)/(Me+nt))-1,we=na(O-1,ao(we,se-1)),ge=na(we,ao(0,ge))):(ge=0,we=-1);const xe=Lu(ge,we,tt),{bottom:ze,top:st}=Fu(ie,de,le,xe),Fe=Mu(O/se),ut=Fe*Me+(Fe-1)*nt-ze;return{bottom:ze,itemHeight:Me,items:xe,itemWidth:bt,offsetBottom:ut,offsetTop:st,top:st}})),A),ye(U(M,Ne(O=>O!==null),ce(O=>O.length)),T),ye(U(yt(j,P,A,X),Ne(([O,J,{items:te}])=>te.length>0&&J.height!==0&&O.height!==0),ce(([O,J,{items:te},de])=>{const{bottom:le,top:ie}=Fu(O,de,J,te);return[ie,le]}),lt(eo)),t);const he=Y(!1);ye(U(u,Be(he),ce(([O,J])=>J||O!==0)),he);const ve=Bt(U(yt(A,T),Ne(([{items:O}])=>O.length>0),Be(he),Ne(([[O,J],te])=>{const de=O.items[O.items.length-1].index===J-1;return(te||O.bottom>0&&O.itemHeight>0&&O.offsetBottom===0&&O.items.length===J)&&de}),ce(([[,O]])=>O-1),lt())),be=Bt(U(Ie(A),Ne(({items:O})=>O.length>0&&O[0].index===0),hn(0),lt())),Te=Bt(U(Ie(A),Be(z),Ne(([{items:O},J])=>O.length>0&&!J),ce(([{items:O}])=>({endIndex:O[O.length-1].index,startIndex:O[0].index})),lt(ou),Nn(0)));ye(Te,p.scrollSeekRangeChanged),ye(U(D,Be(j,P,T,X),ce(([O,J,te,de,le])=>{const ie=uu(O),{align:tt,behavior:et,offset:Oe}=ie;let He=ie.index;He==="LAST"&&(He=de-1),He=ao(0,He,na(de-1,He));let ht=ra(J,le,te,He);return tt==="end"?ht=Du(ht-J.height+te.height):tt==="center"&&(ht=Du(ht-J.height/2+te.height/2)),Oe&&(ht+=Oe),{behavior:et,top:ht}})),l);const K=It(U(A,ce(O=>O.offsetBottom+O.bottom)),0);return ye(U(k,ce(O=>({height:O.visibleHeight,width:O.visibleWidth}))),j),{customScrollParent:g,data:M,deviation:B,footerHeight:o,gap:X,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:P,overscan:n,restoreStateFrom:V,scrollBy:i,scrollContainerState:a,scrollHeight:L,scrollTo:l,scrollToIndex:D,scrollTop:u,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:j,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k,...p,gridState:A,horizontalDirection:Z,initialTopMostItemIndex:$,totalListHeight:K,...h,endReached:ve,propsReady:x,rangeChanged:Te,startReached:be,stateChanged:W,stateRestoreInProgress:z,...C}},at(Gi,Rt,io,wu,zn,Xi,$n));function $u(e,t,n){return ao(1,rs((e+n)/(rs(t)+n)))}function Fu(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=ra(e,t,n,r[0].index);return{bottom:ra(e,t,n,r[r.length-1].index)+o,top:s}}function ra(e,t,n,r){const o=$u(e.width,n.width,t.column),s=rs(r/o),i=s*n.height+ao(0,s-1)*t.row;return i>0?i+t.row:i}const Zy=Xe(()=>{const e=Y(f=>`Item ${f}`),t=Y({}),n=Y(null),r=Y("virtuoso-grid-item"),o=Y("virtuoso-grid-list"),s=Y(ea),i=Y("div"),a=Y(Ar),l=(f,h=null)=>It(U(t,ce(p=>p[f]),lt()),h),u=Y(!1),d=Y(!1);return ye(Ie(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")}}),Qy=Xe(([e,t])=>({...e,...t}),at(Jy,Zy)),ev=w.memo(function(){const e=ct("gridState"),t=ct("listClassName"),n=ct("itemClassName"),r=ct("itemContent"),o=ct("computeItemKey"),s=ct("isSeeking"),i=Jt("scrollHeight"),a=ct("ItemComponent"),l=ct("ListComponent"),u=ct("ScrollSeekPlaceholder"),d=ct("context"),f=Jt("itemDimensions"),h=Jt("gap"),p=ct("log"),v=ct("stateRestoreInProgress"),x=Jt("reportReadyState"),g=ir(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);const S=y.firstChild;if(S){const{height:k,width:C}=S.getBoundingClientRect();f({height:k,width:C})}h({column:Bu("column-gap",getComputedStyle(y).columnGap,p),row:Bu("row-gap",getComputedStyle(y).rowGap,p)})},[i,f,h,p]),!0,!1);return Iu(()=>{e.itemHeight>0&&e.itemWidth>0&&x(!0)},[e]),v?null:c.jsx(l,{className:t,ref:g,...Nt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const b=o(y.index,y.data,d);return s?c.jsx(u,{...Nt(u,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{...Nt(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),tv=w.memo(function(){const e=ct("HeaderComponent"),t=Jt("headerHeight"),n=ct("headerFooterTag"),r=ir(w.useMemo(()=>s=>{t(Fn(s,"height"))},[t]),!0,!1),o=ct("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Nt(e,o)})}):null}),nv=w.memo(function(){const e=ct("FooterComponent"),t=Jt("footerHeight"),n=ct("headerFooterTag"),r=ir(w.useMemo(()=>s=>{t(Fn(s,"height"))},[t]),!0,!1),o=ct("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Nt(e,o)})}):null}),rv=({children:e})=>{const t=w.useContext(Eu),n=Jt("itemDimensions"),r=Jt("viewportDimensions"),o=ir(w.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return w.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),c.jsx("div",{ref:o,style:ns(!1),children:e})},ov=({children:e})=>{const t=w.useContext(Eu),n=Jt("windowViewportRect"),r=Jt("itemDimensions"),o=ct("customScrollParent"),s=Jc(n,o,!1);return w.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),c.jsx("div",{ref:s,style:ns(!1),children:e})},sv=w.memo(function({...e}){const t=ct("useWindowScroll"),n=ct("customScrollParent"),r=n||t?av:iv,o=n||t?ov:rv,s=ct("context");return c.jsx(r,{...e,...Nt(r,s),children:c.jsxs(o,{children:[c.jsx(tv,{}),c.jsx(ev,{}),c.jsx(nv,{})]})})}),{useEmitter:zu,useEmitterValue:ct,usePublisher:Jt}=Tu(Qy,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},sv),iv=Ru({useEmitter:zu,useEmitterValue:ct,usePublisher:Jt}),av=Pu({useEmitter:zu,useEmitterValue:ct,usePublisher:Jt});function Bu(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,$t.WARN),t==="normal"?0:parseInt(t??"0",10)}const lv=Io.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 oa({className:e,variant:t,...n}){return c.jsx("div",{className:ee(lv({variant:t}),e),...n})}function fe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function cv(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 gn(e,t=[]){let n=[];function r(s,i){const a=m.createContext(i),l=n.length;n=[...n,i];const u=f=>{var y;const{scope:h,children:p,...v}=f,x=((y=h==null?void 0:h[e])==null?void 0:y[l])||a,g=m.useMemo(()=>v,Object.values(v));return c.jsx(x.Provider,{value:g,children:p})};u.displayName=s+"Provider";function d(f,h){var x;const p=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,v=m.useContext(p);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>m.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,uv(o,...t)]}function uv(...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 wt=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},dv=m[" useInsertionEffect ".trim().toString()]||wt;function cr({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=fv({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=hv(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 fv({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return dv(()=>{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 hv(e){return typeof e=="function"}function Hu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function sa(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Hu(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():Hu(e[o],null)}}}}function We(...e){return m.useCallback(sa(...e),e)}var pv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ae=pv.reduce((e,t)=>{const n=tr.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 Uu(e,t){e&&No.flushSync(()=>e.dispatchEvent(t))}function mv(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Ut=e=>{const{present:t,children:n}=e,r=gv(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=We(r.ref,xv(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};Ut.displayName="Presence";function gv(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=mv(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=ss(r.current);s.current=a==="mounted"?u:"none"},[a]),wt(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,p=ss(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]),wt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const x=ss(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&x&&(l("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},h=p=>{p.target===t&&(s.current=ss(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 ss(e){return(e==null?void 0:e.animationName)||"none"}function xv(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 yv=m[" useId ".trim().toString()]||(()=>{}),vv=0;function xn(e){const[t,n]=m.useState(yv());return wt(()=>{n(r=>r??String(vv++))},[e]),e||(t?`radix-${t}`:"")}var is="Collapsible",[bv,rk]=gn(is),[wv,ia]=bv(is),Wu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,u]=cr({prop:r,defaultProp:o??!1,onChange:i,caller:is});return c.jsx(wv,{scope:n,disabled:s,contentId:xn(),open:l,onOpenToggle:m.useCallback(()=>u(d=>!d),[u]),children:c.jsx(Ae.div,{"data-state":la(l),"data-disabled":s?"":void 0,...a,ref:t})})});Wu.displayName=is;var Vu="CollapsibleTrigger",Ku=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=ia(Vu,n);return c.jsx(Ae.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":la(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:fe(e.onClick,o.onOpenToggle)})});Ku.displayName=Vu;var aa="CollapsibleContent",Sv=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=ia(aa,e.__scopeCollapsible);return c.jsx(Ut,{present:n||o.open,children:({present:s})=>c.jsx(Cv,{...r,ref:t,present:s})})});Sv.displayName=aa;var Cv=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=ia(aa,n),[a,l]=m.useState(r),u=m.useRef(null),d=We(t,u),f=m.useRef(0),h=f.current,p=m.useRef(0),v=p.current,x=i.open||a,g=m.useRef(x),y=m.useRef(void 0);return m.useEffect(()=>{const b=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(b)},[]),wt(()=>{const b=u.current;if(b){y.current=y.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const S=b.getBoundingClientRect();f.current=S.height,p.current=S.width,g.current||(b.style.transitionDuration=y.current.transitionDuration,b.style.animationName=y.current.animationName),l(r)}},[i.open,r]),c.jsx(Ae.div,{"data-state":la(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!x,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style},children:x&&o})});function la(e){return e?"open":"closed"}var Tv=Wu;const qu=Tv,Gu=Ku,lo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ee("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));lo.displayName="Card";const co=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ee("flex flex-col space-y-1.5 p-6",e),...t}));co.displayName="CardHeader";const uo=m.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:ee("text-2xl font-semibold leading-none tracking-tight",e),...t}));uo.displayName="CardTitle";const Yu=m.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:ee("text-sm text-muted-foreground",e),...t}));Yu.displayName="CardDescription";const as=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ee("p-6 pt-0",e),...t}));as.displayName="CardContent";const Xu=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ee("flex items-center p-6 pt-0",e),...t}));Xu.displayName="CardFooter";function Ju(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let ur=Ju();function kv(e){ur=e}const Zu=/[&<>"']/,Ev=new RegExp(Zu.source,"g"),Qu=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Iv=new RegExp(Qu.source,"g"),Nv={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ed=e=>Nv[e];function At(e,t){if(t){if(Zu.test(e))return e.replace(Ev,ed)}else if(Qu.test(e))return e.replace(Iv,ed);return e}const Av=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function td(e){return e.replace(Av,(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 _v=/(^|[^\[])\^/g;function ot(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(_v,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const jv=/[^\w:]/g,Rv=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function nd(e,t,n){if(e){let r;try{r=decodeURIComponent(td(n)).replace(jv,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!Rv.test(n)&&(n=Dv(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const ls={},Pv=/^[^:]+:\/*[^/]*$/,Ov=/^([^:]+:)[\s\S]*$/,Mv=/^([^:]+:\/*[^/]*)[\s\S]*$/;function Dv(e,t){ls[" "+e]||(Pv.test(e)?ls[" "+e]=e+"/":ls[" "+e]=us(e,"/",!0)),e=ls[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(Ov,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(Mv,"$1")+t:e+t}const cs={exec:function(){}};function rd(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,u=i;for(;--u>=0&&a[u]==="\\";)l=!l;return l?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function us(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 Lv(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 $v(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function od(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function sd(e,t,n,r){const o=t.href,s=t.title?At(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:At(i)}}function Fv(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
37
+ `))>=0;){const oe=q.slice(0,ne);q=q.slice(ne+2);const ge=wx(oe);if(!ge)continue;let we;try{we=JSON.parse(ge)}catch{console.debug("[use-chat] malformed SSE:",ge.slice(0,200));continue}const xe=bx(we)?we.data:we;ie=Date.now();const Fe=xe.seq;if(Fe!==void 0){if(Fe<=J){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:Fe,lastProcessedSeq:J,type:xe.type});continue}J>0&&Fe>J+1&&(($=L==null?void 0:L.onGap)==null||$.call(L,{from:J,to:Fe})),J=Fe,C.current=Fe,g(Fe)}if(console.debug("[use-chat] received event",{seq:xe.seq,type:xe.type,preview:(()=>{var ot;try{return xe.type==="message_delta"?{deltaTypes:(ot=xe.delta)==null?void 0:ot.map($e=>$e.type),textLen:(xe.delta||[]).filter($e=>$e.type==="text").map($e=>String($e.text||"").length)}:xe.content||xe.delta?{hasContent:!0}:{}}catch($e){return{err:String($e)}}})()}),D==null||D(xe),xe.type==="token"&&e.autoAppendAssistant!==!1)O.push(xe.content),le();else if(xe.type==="message_delta"){const ot=xe.delta.filter($e=>$e.type==="text").map($e=>$e.text).join("");ot&&e.autoAppendAssistant!==!1&&(O.push(ot),le())}else xe.type==="heartbeat"?console.debug("[use-chat] heartbeat received"):(te!==null&&cancelAnimationFrame(te),de(),xe.type==="checkpoint"?v(xe.checkpointId):xe.type==="error"&&d(xe.message))}}de()}catch(Oe){if(Oe.name!=="AbortError"){const Be=Oe.message||String(Oe);d(Be),(pe=L==null?void 0:L.onError)==null||pe.call(L,Be)}}finally{try{await be.cancel()}catch{}finally{(F=be.releaseLock)==null||F.call(be)}te!==null&&typeof window<"u"&&window.cancelAnimationFrame(te),clearInterval(et),l(!1),b(!1),S.current=null,C.current=0,g(0)}}catch(he){if(he.name!=="AbortError"){const ve=he.message||String(he);d(ve),(Q=L==null?void 0:L.onError)==null||Q.call(L,ve)}}finally{l(!1),b(!1),S.current=null,C.current=0,g(0)}})(),{close:()=>B.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var P;k.current=!1,(P=S.current)==null||P.abort()},[]),{isStreaming:a,error:u,assistantText:f,lastCheckpointId:p,lastSeq:x,connected:y,stream:j,stop:I,clear:A,setToken:T}}function bx(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function wx(e){const t=e.split(/\r?\n/),n=[];for(const r of t)if(r&&!r.startsWith(":")&&r.startsWith("data:")){const o=r.slice(5);n.push(o.startsWith(" ")?o.slice(1):o)}return n.length===0?null:n.join(`
38
+ `)}function Sx({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onUnhandledEvent:r,onSequenceGap:o}){const s=w.useRef(null),i=w.useCallback(p=>{const v=p.seq??null;if(v!==null){const x=s.current;if(x!==null){if(v<=x)return;v>x+1&&(o==null||o({from:x,to:v}))}s.current=v}if(p.type==="thread_info"){console.log("[useChatStreamingService] 🎯 Received thread_info event:",p),t(p);return}if(px(p)){n(p);return}r==null||r(p)},[n,o,t,r]),{stream:a,stop:l,isStreaming:u,error:d,setToken:f}=Oc({baseUrl:e,token:null}),h=w.useCallback((p,v)=>{s.current=null,a(p,i,{onOpen:v==null?void 0:v.onOpen,onError:x=>{var g;(g=v==null?void 0:v.onError)==null||g.call(v,x)},onGap:(v==null?void 0:v.onGap)??o})},[i,o,a]);return w.useMemo(()=>({startStream:h,stop:l,isStreaming:u,error:d,setAuthToken:f}),[h,l,u,d,f])}function Jt(e,t={}){const n=t.cloneMessages??!1,r=Array.isArray(e==null?void 0:e.messages)?e.messages:[];return{checkpointId:(e==null?void 0:e.checkpointId)??null,checkpointNs:(e==null?void 0:e.checkpointNs)??null,createdAt:(e==null?void 0:e.createdAt)??null,preview:(e==null?void 0:e.preview)??null,role:(e==null?void 0:e.role)??null,parentId:(e==null?void 0:e.parentId)??null,branchLabel:(e==null?void 0:e.branchLabel)??null,lastMessageId:(e==null?void 0:e.lastMessageId)??null,messagesLen:typeof(e==null?void 0:e.messagesLen)=="number"?e.messagesLen:r.length,hasMessages:typeof(e==null?void 0:e.hasMessages)=="boolean"?e.hasMessages:r.length>0,messages:n?r.slice():r,nextCursor:(e==null?void 0:e.nextCursor)??null,nextCursorNs:(e==null?void 0:e.nextCursorNs)??null,interrupt:(e==null?void 0:e.interrupt)??null}}function Cx(e){var t;for(let n=e.length-1;n>=0;n--){const r=((t=e[n])==null?void 0:t.content)??[];for(let o=r.length-1;o>=0;o--){const s=r[o];if((s==null?void 0:s.type)==="interrupt"){const i=s.id;return{id:(typeof i=="string"?i:null)??`interrupt-${e[n].id??o}`,value:s.value}}}}return null}function Mc(e,t){if(!e&&!t)return!0;if(!e||!t||e.id!==t.id)return!1;try{return JSON.stringify(e.value)===JSON.stringify(t.value)}catch{return e.value===t.value}}const Uo=300;function Dc(e,t=Uo){if(typeof window<"u"&&"requestIdleCallback"in window)try{window.requestIdleCallback(e,{timeout:t});return}catch{}window.setTimeout(e,t)}function Nr(){return typeof window<"u"&&typeof window.localStorage<"u"}function Ni(e){if(!Nr())return null;try{return window.localStorage.getItem(e)}catch{return null}}function Lc(e,t){if(Nr())try{window.localStorage.setItem(e,t)}catch{}}function Ai(e){if(Nr())try{window.localStorage.removeItem(e)}catch{}}const Tx="cachedThreads",kx="v1",_i=200;function Ex(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 ji(e,t){return`cachedThreads:v1:${e}:${Ex(t||"anon")}`}function Ix(){const e=Ni(Tx);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 Nx(e){const t=Ni(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 Ri(e,t){try{Lc(e,JSON.stringify(t))}catch{}}function Pi(e){const t=Nx(e);if(t.length>0)return t;const n=Ix();if(n.length>0)try{Ri(e,n.slice(0,_i))}catch{}return n}function Wo(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 Oi(e){return e.order.map(t=>e.byId[t]).filter(Boolean)}function Mi(e,t){return`${e}${t}`}function Ax(e,t){const n=Ni(Mi(e,t));if(!n)return null;try{const r=JSON.parse(n);return typeof(r==null?void 0:r.threadId)!="string"?null:{threadId:r.threadId,snapshot:Jt(r.snapshot,{cloneMessages:!0})}}catch{return null}}function _x(e,t,n=100){const r=Jt(t.snapshot,{cloneMessages:!0}),o={threadId:t.threadId,snapshot:{...r,messages:r.messages.slice(-n)}};try{Lc(Mi(e,t.threadId),JSON.stringify(o))}catch{}}function jx(e,t){Ai(Mi(e,t))}function Rx(e){if(Nr())try{for(let t=0;t<window.localStorage.length;t++){const n=window.localStorage.key(t);n&&n.startsWith(e)&&window.localStorage.removeItem(n)}}catch{}}const $c=w.createContext(null),Fc=w.createContext(null),zc=w.createContext(null),Px=w.createContext(!1),Bc=50,Ox=750;function Hc(e,t,n){return`${e}__${t??""}__${n??""}`}function Mx({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}=Ti(),d=w.useMemo(()=>_n(u),[u]),f=w.useMemo(()=>{try{return new URL(u).host}catch{return"unknown"}},[u]),h=w.useMemo(()=>`threadPayload:${kx}:${f}:`,[f]),p=w.useCallback(N=>Ax(h,N),[h]),v=w.useCallback((N,_=100)=>{_x(h,N,_)},[h]),x=w.useCallback(N=>{jx(h,N)},[h]),g=w.useCallback(()=>{Rx(h)},[h]),[y,b]=w.useState(()=>{var N;return ji(f,(N=l.getAuthToken)==null?void 0:N.call(l))}),[S,k]=w.useState(()=>{var _;const N=Pi(ji(f,(_=l.getAuthToken)==null?void 0:_.call(l)));return Wo(N)}),C=w.useMemo(()=>Oi(S),[S]),[T,I]=w.useState(t),[A,j]=w.useState(!1),[P,D]=w.useState(!1),[L,B]=w.useState(null),[M,X]=w.useState(null),[W,V]=w.useState(null),[z,$]=w.useState([]),pe=w.useCallback(()=>{const N=Pi(y);w.startTransition(()=>{k(Wo(N))})},[y]),[F,Q]=w.useState(!1),[he,ve]=w.useState(!1),[be,Te]=w.useState(null),[q,O]=w.useState(void 0),[J,te]=w.useState(void 0),[de,le]=w.useState(void 0),{state:ie,dispatch:et,seed:Qe,prepend:Oe,pushUser:Be,onEvent:ht,reset:tt}=kc(),Me=w.useRef(T);w.useEffect(()=>{Me.current=T},[T]);const bt=w.useRef(!1),ne=w.useRef([]),oe=w.useRef(null),ge=w.useRef(null),we=w.useRef(new Map),xe=w.useRef(T),Fe=w.useRef(!1),ot=w.useRef(null),$e=w.useRef(new Map),ut=w.useRef(new Map),xt=w.useRef(new Map),Pt=w.useRef(new Map),rn=w.useCallback(N=>{if(!N){$([]);return}const _=$e.current.get(N);if(!_||!_.length){$([]);return}$(_.map(K=>Jt(K,{cloneMessages:!0})))},[]);w.useEffect(()=>{rn(T)},[T,rn]);const Ur=w.useCallback(()=>{var Z;const N=Pt.current;if(N.size<=Bc)return;const _=Array.from(N.entries()).sort((se,Y)=>se[1].timestamp-Y[1].timestamp),K=N.size-Bc;for(let se=0;se<K;se++){const Y=(Z=_[se])==null?void 0:Z[0];Y&&N.delete(Y)}},[]),Zn=w.useCallback((N,_,K)=>{if(!N)return;const Z=K==="replace"?[]:$e.current.get(N)??[],se=K==="replace"?_:[..._,...Z];if(!se.length){K==="replace"&&$e.current.set(N,[]);return}const Y=new Map;for(const Ge of se){if(!(Ge!=null&&Ge.checkpointId))continue;const Ye=`${Ge.checkpointId}::${Ge.checkpointNs??""}`;Y.has(Ye)||Y.set(Ye,Jt(Ge,{cloneMessages:!0}))}const Ve=Array.from(Y.values()).sort((Ge,Ye)=>{const lt=Number.isFinite(Date.parse(Ge.createdAt??""))?Date.parse(Ge.createdAt??""):0;return(Number.isFinite(Date.parse(Ye.createdAt??""))?Date.parse(Ye.createdAt??""):0)-lt});$e.current.set(N,Ve),N===Me.current&&rn(N)},[rn]),En=w.useCallback((N,_,K)=>{if(!N)return;const Z=ut.current.get(N),se=K==="replace"||!Z?new Map:new Map(Z);if(_&&typeof _=="object")for(const[Y,Ve]of Object.entries(_)){if(!(Ve!=null&&Ve.checkpointId))continue;const Ge=Y||Ho(Ve.checkpointId,Ve.checkpointNs??null);se.set(Ge,Jt(Ve,{cloneMessages:!0}))}ut.current.set(N,se)},[]),Qn=w.useCallback((N,_)=>{const{threadId:K,checkpointId:Z=null,checkpointNs:se=null}=N,Y=Hc(K,Z,se);if(_!=null&&_.force)xt.current.delete(Y),Pt.current.delete(Y);else{if(_!=null&&_.preferCache){const lt=Pt.current.get(Y);if(lt)return Promise.resolve(lt.payload)}const Ye=xt.current.get(Y);if(Ye)return Ye}const Ge=l.getStateHistory({threadId:K,checkpointId:Z??void 0,checkpointNs:se??void 0}).then(Ye=>(Pt.current.set(Y,{payload:Ye,timestamp:Date.now()}),Ur(),Ye)).finally(()=>{xt.current.get(Y)===Ge&&xt.current.delete(Y)});return xt.current.set(Y,Ge),Ge},[l,Ur]),on=w.useCallback((N,_)=>new Promise((K,Z)=>{const se=async()=>{bt.current=!0;try{await N(),K()}catch(Y){Z(Y)}finally{bt.current=!1;const Y=ne.current.shift();Y&&Y().catch(()=>{})}};bt.current?ne.current.push(se):se().catch(Y=>{Z(Y)})}),[]),Sr=w.useRef(C.length),[Mn,Cr]=w.useState(!1),Dn=w.useRef(!1);w.useEffect(()=>{Sr.current=C.length},[C.length]),w.useEffect(()=>{const N=ie.pendingInterrupt??Cx(ie.messages);Mc(W,N)||V(N??null)},[W,ie.messages,ie.pendingInterrupt]);const Ot=w.useCallback(async()=>{const N=Sr.current>0;N||j(!0);try{const _=await l.listThreads();w.startTransition(()=>{k(K=>{const Z=Ve=>Ve.map(Ge=>`${Ge.threadId}:${Ge.updatedAt??""}:${Ge.messageCount??""}`).join("|"),se=Oi(K);return Z(se)===Z(_)||_.length===0&&se.length>0&&!Dn.current?K:Wo(_)})}),B(null),Dn.current||(Dn.current=!0,Cr(!0))}catch(_){i==null||i(String(_)),console.error("[ChatSessionProvider] Failed to refresh threads:",_),B(String(_))}finally{N||j(!1)}},[l,i]),me=w.useRef(!1),Ee=w.useRef(null),Pe=w.useRef(null),st=w.useRef(""),Ht=w.useCallback((N,_)=>{if(!Nr())return;Pe.current!==null&&(window.clearTimeout(Pe.current),Pe.current=null);const K=N.map(se=>`${se.threadId}:${se.updatedAt??""}:${se.messageCount??""}`).join("|");if(N.length===0){try{Ai(y)}catch{}st.current="";return}if(K===st.current)return;const Z=()=>{try{const se=N.slice(0,_i);Ri(y,se),st.current=K}catch{}finally{Pe.current=null}};if(_!=null&&_.immediate){Z();return}Pe.current=window.setTimeout(()=>{Dc(Z)},Uo)},[y]),er=w.useCallback(()=>{Ht(C,{immediate:!0})},[Ht,C]),In=w.useCallback((N,_,K,Z)=>{var bl;const se=K??Me.current;if(!se)return;const Y=Jt(N),Ve=se===Me.current,Ge=(Z==null?void 0:Z.persist)!==!1;if(_==="replace"){if(Ge){const Ct={threadId:se,snapshot:Jt(N,{cloneMessages:!0})};we.current.set(se,Ct),xe.current=se}if(!Ve)return;Qe(Y.messages,{checkpointId:Y.checkpointId??null,checkpointNs:Y.checkpointNs??null,pendingInterrupt:Y.interrupt??null}),V(Y.interrupt??null),Te(Y.nextCursor??null),Q(!!Y.nextCursor),O(Y.checkpointId??void 0),te(Y.checkpointNs??void 0),le(Y.nextCursorNs??void 0);return}const Ye=we.current.get(se),lt=(Ye==null?void 0:Ye.snapshot)??null,Et=Array.isArray(lt==null?void 0:lt.messages)?lt.messages:[],Mt=Jt(lt),Nn=Array.isArray(N==null?void 0:N.messages)?N.messages:[],It=new Set,Nt=[...Nn,...Et].filter(Ct=>{const wl=Ct==null?void 0:Ct.id;return wl?It.has(wl)?!1:(It.add(wl),!0):!0}),No={checkpointId:Mt.checkpointId??Y.checkpointId??null,checkpointNs:Mt.checkpointNs??Y.checkpointNs??null,createdAt:Y.createdAt??Mt.createdAt??null,preview:Y.preview??Mt.preview??null,role:Y.role??Mt.role??null,parentId:Y.parentId??Mt.parentId??null,branchLabel:Y.branchLabel??Mt.branchLabel??null,lastMessageId:((bl=Nt[Nt.length-1])==null?void 0:bl.id)??null,messagesLen:Nt.length,hasMessages:Nt.length>0,messages:Nt,nextCursor:Y.nextCursor??Mt.nextCursor??null,nextCursorNs:Y.nextCursorNs??Mt.nextCursorNs??null,interrupt:Mt.interrupt??Y.interrupt??null};if(we.current.set(se,{threadId:se,snapshot:Jt(No,{cloneMessages:!0})}),!Ve)return;Nn.length&&Oe(Nn);const Vr=N&&Object.prototype.hasOwnProperty.call(N,"checkpointId")?N.checkpointId:void 0,An=N&&Object.prototype.hasOwnProperty.call(N,"checkpointNs")?N.checkpointNs:void 0,Tr=N&&Object.prototype.hasOwnProperty.call(N,"nextCursor")?N.nextCursor:void 0,nr=N&&Object.prototype.hasOwnProperty.call(N,"nextCursorNs")?N.nextCursorNs:void 0;Te(Ct=>Tr!==void 0?Tr??Ct??null:Ct??null),Q(Ct=>Tr!==void 0?!!Tr:Ct),O(Ct=>Vr!==void 0?Vr??Ct??void 0:Ct??void 0),te(Ct=>An!==void 0?An??Ct??void 0:Ct??void 0),le(Ct=>nr!==void 0?nr??void 0:Ct)},[Oe,Qe,V]),Wr=w.useCallback(N=>{if(N.threadId!=null&&N.threadId!==Me.current)return;const _=Jt(N.snapshot,{cloneMessages:!0});Qe(_.messages,{checkpointId:_.checkpointId??null,checkpointNs:_.checkpointNs??null,pendingInterrupt:_.interrupt??null}),V(_.interrupt??null),Te(_.nextCursor??null),Q(!!_.nextCursor),O(_.checkpointId??void 0),te(_.checkpointNs??void 0),le(_.nextCursorNs??void 0),xe.current=N.threadId,rn(N.threadId??Me.current??null)},[Qe,V,rn]),Ln=w.useCallback(N=>{if(!N)return;we.current.delete(N),x(N),$e.current.delete(N),ut.current.delete(N),N===Me.current&&$([]);const _=`${N}__`;for(const K of xt.current.keys())K.startsWith(_)&&xt.current.delete(K);for(const K of Pt.current.keys())K.startsWith(_)&&Pt.current.delete(K);xe.current===N&&(xe.current=null)},[x]),tr=w.useCallback(()=>{const N=Me.current;N&&Ln(N),tt([]),Q(!1),ve(!1),Te(null),O(void 0),te(void 0),le(void 0)},[Ln,tt]),Eo=w.useCallback(({from:N,to:_})=>{const K=Me.current;K&&console.warn(`[ChatSessionProvider] Stream sequence gap detected (${N} -> ${_}) for thread ${K}`)},[]),xl=w.useCallback(N=>{const _=N.threadId;console.log("[ChatSessionProvider] 📥 Handling thread_info event:",{threadId:_,title:N.title,created:N.created,currentThreads:C.length});const K={threadId:_,title:N.title||`Thread ${_.slice(0,8)}`,createdAt:N.createdAt||new Date().toISOString(),updatedAt:N.updatedAt||new Date().toISOString(),messageCount:N.messageCount||0};Me.current!==_&&(!Me.current&&ie.messages.length<=1&&(ge.current=_),I(_)),w.startTransition(()=>{k(Z=>{const se=Z.byId[_];return se?se.title===K.title&&se.updatedAt===K.updatedAt&&se.messageCount===K.messageCount?Z:{byId:{...Z.byId,[_]:K},order:Z.order}:{byId:{...Z.byId,[_]:K},order:[_,...Z.order]}})})},[ie.messages.length]),{startStream:li,stop:E,isStreaming:H,error:re,setAuthToken:ke}=Sx({baseUrl:d,onThreadInfo:xl,onMessageEvent:ht,onUnhandledEvent:N=>{console.warn(`[ChatSessionProvider] Unhandled stream event: ${N.type}`,N)},onSequenceGap:Eo});w.useEffect(()=>{me.current=H},[H]),w.useEffect(()=>{if(!Nr())return;Pe.current!==null&&(window.clearTimeout(Pe.current),Pe.current=null);const N=C.map(K=>`${K.threadId}:${K.updatedAt??""}:${K.messageCount??""}`).join("|");if(C.length===0){try{Ai(y)}catch{}st.current="";return}if(N===st.current)return;const _=()=>{try{const K=C.slice(0,_i);Ri(y,K),st.current=N}catch{}finally{Pe.current=null}};return Pe.current=window.setTimeout(()=>{Dc(_),Pe.current=null},Uo),()=>{Pe.current!==null&&(window.clearTimeout(Pe.current),Pe.current=null)}},[C,Ht]),w.useEffect(()=>{var Z;const N=l.getAuthToken();ke(N);const _=se=>{const Y=ji(f,se);ot.current!==Y&&(ot.current=Y,Fe.current=!1),b(Y);const Ve=Pi(Y);w.startTransition(()=>{k(Wo(Ve))}),Fe.current||(Fe.current=!0,Ot().catch(()=>{}))};_(N);const K=(Z=l.onTokenChange)==null?void 0:Z.call(l,se=>{ke(se),g(),xt.current.clear(),Pt.current.clear(),_(se)});return()=>{K==null||K()}},[l,f,ke,g,Ot]);const qe=w.useCallback(async N=>{var Z;const _=`Thread ${(Z=crypto.randomUUID)==null?void 0:Z.call(crypto)}`,K={threadId:_,title:N||"New Chat",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messageCount:0};k(se=>({byId:{...se.byId,[_]:K},order:[_,...se.order]})),I(_);try{const se=await l.createThread(N),Y=typeof se=="string"?se:se.threadId;return k(Ve=>{const Ge=Ve.byId[_];if(!Ge)return Ve;const Ye={...Ve.byId};delete Ye[_],Ye[Y]={...Ge,threadId:Y};const lt=Ve.order.map(Et=>Et===_?Y:Et);return{byId:Ye,order:lt}}),I(Y),setTimeout(()=>Ot(),10),B(null),Y}catch(se){throw k(Y=>{if(!Y.byId[_])return Y;const Ve={...Y.byId};delete Ve[_];const Ge=Y.order.filter(Ye=>Ye!==_);return{byId:Ve,order:Ge}}),I(null),B(String(se)),se}},[l,Ot]),Ze=w.useCallback(async N=>{try{await l.deleteThread(N);let _=null;k(K=>{if(!K.byId[N])return K;const Z={...K.byId};delete Z[N];const se=K.order.filter(Ve=>Ve!==N),Y={byId:Z,order:se};return _=Oi(Y),Y}),_&&Ht(_,{immediate:!0}),Ln(N),Me.current===N&&(ge.current=N,I(null),Me.current=null,xe.current=null,tr()),await Ot(),B(null)}catch(_){throw B(String(_)),_}},[l,tr,Ln,Ot,Ht]),He=w.useCallback(async(N,_)=>{try{await l.updateThread(N,_),k(K=>{const Z=K.byId[N];return Z?{byId:{...K.byId,[N]:{...Z,title:_}},order:K.order}:K}),B(null)}catch(K){throw await Ot(),B(String(K)),K}},[l,Ot]),je=w.useCallback(async(N,_,K,Z=!1)=>{await on(async()=>{if(ge.current===N&&!Z){ge.current=null;return}if(oe.current===N&&!Z)return;I(It=>It===N?It:N),Me.current=N;const Ve=Hc(N,_??null,K??null),Ge=Pt.current.get(Ve),Ye=!Z&&!_&&!K&&Ge&&Date.now()-Ge.timestamp<Ox,lt=!Z&&!_&&!K;let Et=!1;if(lt){const It=we.current.get(N);if(It)Wr(It),Et=!0;else{const Nt=p(N);Nt&&(we.current.set(N,Nt),Wr(Nt),Et=!0)}}const Mt=Z||!Et||!!_||!!K,Nn=async It=>{It&&D(!0),oe.current=N;try{const Nt=await Qn({threadId:N,checkpointId:_,checkpointNs:K},{force:Z}),{latest:No,checkpoints:Vr,snapshots:An}=vc(Nt);In(No,"replace",N),Zn(N,Vr,"replace"),En(N,An,"replace"),X(null)}catch(Nt){throw(!Et||Z||It)&&(i==null||i(String(Nt))),X(String(Nt)),Nt}finally{oe.current=null,It&&D(!1)}};Mt?await Nn(!0):lt&&Et&&!Ye&&Nn(!1).catch(It=>{console.warn("[ChatSessionProvider] Background refresh failed:",It)})},`loadThread-${N}`)},[Wr,In,on,Qn,i,Zn,En]),St=w.useCallback(async()=>{await on(async()=>{const N=Me.current;N&&Ln(N),ge.current=null,I(null),Me.current=null,xe.current=null,tr(),O(void 0),te(void 0),le(void 0),$([]);try{localStorage.removeItem("lastThreadId")}catch(_){console.warn("[ChatSessionProvider] Failed to clear lastThreadId:",_)}},"clearCurrentThread")},[tr,Ln,on]),dt=w.useCallback(async(N,_)=>{var Y;const K=Me.current;if(!K)throw new Error("No active thread");const Z=Ho(N,_??null),se=(Y=ut.current.get(K))==null?void 0:Y.get(Z);if(se){await on(async()=>{In(se,"replace",K,{persist:!1})},`navigateToCheckpoint-${K}-${Z}`);return}await je(K,N,_??void 0,!0)},[In,on,je]),pt=w.useCallback(async()=>{if(!Me.current)throw new Error("No active thread");await je(Me.current,void 0,void 0,!0)},[je]),$t=w.useCallback(async()=>{if(!Me.current)throw new Error("No active thread");if(he||!F)return;const N=be;if(N){ve(!0);try{const _=Me.current,K=await Qn({threadId:_,checkpointId:N??q??null,checkpointNs:de??J??null}),{latest:Z,checkpoints:se,snapshots:Y}=vc(K);In(Z,"prepend",_??void 0),_&&(Zn(_,se,"prepend"),En(_,Y,"prepend")),X(null)}catch(_){throw X(String(_)),_}finally{ve(!1)}}},[In,Qn,F,q,J,de,be,he,Zn,En]),$n=w.useCallback(N=>{if(N!=null&&N.threadId){if(N.checkpointId){const _=Ho(N.checkpointId,N.checkpointNs??null),K=Jt({...N,interrupt:N.interrupt??null},{cloneMessages:!0});En(N.threadId,{[_]:K},"prepend")}In(N,"replace",N.threadId)}},[In,En]),Yt=w.useCallback(async(N,_)=>{var Tr;const K=Me.current,Z=(N==null?void 0:N.text)??"",se=(N==null?void 0:N.attachments)??[],Y=se.length?se:(_==null?void 0:_.attachments)??[],Ve={...(_==null?void 0:_.payloadExtras)??{},...(N==null?void 0:N.payload)??{}};if(!K&&!Object.keys(Ve).length&&Y.length===0&&!Z.trim()){console.warn("[ChatSessionProvider] Nothing to submit - skipping");return}!K&&!Ve.messages&&console.warn("[ChatSessionProvider] No thread ID - message will create new thread");const{contentParts:Ge,filesInfo:Ye}=await Qg(l,Y),lt=[...Ge];Z&&Z.trim()&&lt.push({type:"text",text:Z.trim()});const Et=!!K,Mt=Et?(_==null?void 0:_.checkpointId)??ie.lastCheckpointId??void 0:void 0,Nn=Et?(_==null?void 0:_.checkpointNs)??ie.lastCheckpointNs??void 0:void 0,It={id:((Tr=crypto.randomUUID)==null?void 0:Tr.call(crypto))||`user-${Date.now()}`,role:"user",content:lt,createdAt:new Date().toISOString(),...Mt!=null?{checkpointId:Mt}:{},...Nn!=null?{checkpointNs:Nn}:{}};lt.length>0&&Be(It);const Nt={...It,content:lt},No=Y.length>0,Vr={messages:lt.length>0?[Nt]:[],files_info:Ye,...o&&No&&s?{active_agent:s}:{},...Ve},An={threadId:K??null,payload:Vr,checkpointId:Mt??null,checkpointNs:Nn??null,nodeFilter:(_==null?void 0:_.nodeFilter)??null,config:_==null?void 0:_.config,command:(_==null?void 0:_.command)??null};An.threadId||delete An.threadId,An.command||delete An.command,li(An,{onError:nr=>{console.warn("[ChatSessionProvider] Stream error:",nr)},onOpen:({threadId:nr})=>{!Me.current&&nr&&(ie.messages.length<=1&&(ge.current=nr),I(nr))},onGap:Eo})},[l,o,s,Eo,ie.lastCheckpointId,ie.lastCheckpointNs,ie.messages.length,Be,li]),kt=w.useCallback(async(N,_,K)=>{if(!Me.current)throw new Error("No active thread to handle interrupt");const se=_?K??!0:!1;try{try{et({type:"interrupt_response",payload:{interruptId:N}})}catch(Y){console.warn("[ChatSessionProvider] optimistic interrupt_response dispatch failed:",Y)}await Yt({payload:{}},{checkpointId:ie.lastCheckpointId??void 0,checkpointNs:ie.lastCheckpointNs??void 0,command:{kind:"resume",value:se}}),V(null)}catch(Y){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${N}:`,Y),Y}},[et,ie.lastCheckpointId,ie.lastCheckpointNs,Yt]);w.useEffect(()=>{if(a==null||a(T),T)try{localStorage.setItem("lastThreadId",T)}catch(N){console.warn("[ChatSessionProvider] Failed to persist lastThreadId:",N)}},[T,a]),w.useEffect(()=>((async()=>{try{if(Ot().catch(_=>{console.error("[ChatSessionProvider] Failed to refresh threads (background):",_),i==null||i(String(_))}),!r&&!t)try{const _=localStorage.getItem("lastThreadId");_&&(I(_),n&&await je(_))}catch(_){console.warn("[ChatSessionProvider] Failed to restore last thread:",_)}else t&&n&&await je(t)}catch(_){console.error("[ChatSessionProvider] Initialization failed:",_),i==null||i(String(_))}})(),()=>{}),[]),w.useEffect(()=>{const N=Me.current;if(!N||xe.current!==N)return;ie.messages.length&&ie.messages[ie.messages.length-1];const _=Jt({checkpointId:ie.lastCheckpointId??null,checkpointNs:ie.lastCheckpointNs??null,messages:ie.messages.slice(),nextCursor:be??null,nextCursorNs:de??null,interrupt:ie.pendingInterrupt??W??null}),K=we.current.get(N),Z=K==null?void 0:K.snapshot,se=!Z||Z.messages.length!==_.messages.length||Z.messages.some((Ye,lt)=>{var Et;return(Ye==null?void 0:Ye.id)!==((Et=_.messages[lt])==null?void 0:Et.id)}),Y=((Z==null?void 0:Z.checkpointId)??null)!==_.checkpointId||((Z==null?void 0:Z.checkpointNs)??null)!==_.checkpointNs,Ve=((Z==null?void 0:Z.nextCursor)??null)!==_.nextCursor||((Z==null?void 0:Z.nextCursorNs)??null)!==_.nextCursorNs,Ge=!Mc((Z==null?void 0:Z.interrupt)??null,_.interrupt??null);if(se||Y||Ve||Ge){const Ye={threadId:N,snapshot:_};we.current.set(N,Ye),Ee.current&&window.clearTimeout(Ee.current),Ee.current=window.setTimeout(()=>{try{v(Ye,100)}catch(lt){console.warn("[ChatSessionProvider] Failed to persist thread payload:",lt)}},Uo)}},[be,de,ie.lastCheckpointId,ie.lastCheckpointNs,ie.messages,ie.pendingInterrupt,W,v]);const Io=w.useMemo(()=>({threads:C,currentThreadId:T,setCurrentThreadId:I,isLoading:A,error:L,actions:{createThread:qe,deleteThread:Ze,renameThread:He,refreshThreads:()=>Ot()},persistThreadsCache:er,hydrateFromCache:pe}),[C,T,A,L,qe,Ze,He,Ot,er,pe,I]),yl=w.useMemo(()=>{const N=ie.lastBranch??null,_=ie.assemblingId??null,K=N||_?{branchLabel:(N==null?void 0:N.branchLabel)??null,lastBranch:N,assemblingMessageId:_}:null;return{threadId:T,messages:ie.messages,interrupt:W,checkpoint:{id:ie.lastCheckpointId??null,namespace:ie.lastCheckpointNs??null},checkpoints:z,metadata:K,isLoading:P,isHistoryLoading:he,error:M,hasMore:F,loadOlder:$t,seedFromSnapshot:$n,clearState:tr,navigateToCheckpoint:dt,returnToLatest:pt,loadThread:je,clearThread:St,respondToInterrupt:kt}},[St,tr,T,W,F,he,P,$t,je,ie.assemblingId,ie.lastBranch,ie.lastCheckpointId,ie.lastCheckpointNs,ie.messages,dt,kt,pt,$n,M,z]),vl=w.useMemo(()=>({isStreaming:H,error:re,submit:Yt,send:Yt,stop:E,setAuthToken:ke}),[H,re,Yt,E,ke]);return c.jsx(Px.Provider,{value:!0,children:c.jsx(zc.Provider,{value:vl,children:c.jsx($c.Provider,{value:Io,children:c.jsx(Fc.Provider,{value:yl,children:e})})})})}function Vo(){const e=w.useContext($c);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Ko(){const e=w.useContext(Fc);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function Uc(){const e=w.useContext(zc);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function qo({children:e,apiConfig:t,initialThreadId:n=null,autoLoadInitial:r=!0,disableAutoRestore:o=!1,enableFileAgentRouting:s=!1,fileAgentId:i="invoice_reader",onError:a,onThreadChange:l}){return c.jsx(Jg,{apiConfig:t,children:c.jsx(Mx,{initialThreadId:n,autoLoadInitial:r,disableAutoRestore:o,enableFileAgentRouting:s,fileAgentId:i,onError:a,onThreadChange:l,children:e})})}function ee(...e){return Em.twMerge(km.clsx(e))}const Dx=Ao.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"}}),Ke=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?rr.Slot:"button";return c.jsx(i,{className:ee(Dx({variant:t,size:n,className:e})),ref:s,...o})});Ke.displayName="Button";const Wc=m.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:ee("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Wc.displayName="Textarea";function Lx({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,onSend:i,onCancelEdit:a,onStop:l,className:u="",textareaClassName:d="",allowEmptySend:f=!1}){const[h,p]=w.useState(e),[v,x]=w.useTransition(),g=w.useRef(null);w.useEffect(()=>{p(e??""),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const y=w.useCallback(()=>{const A=g.current;A&&(A.style.height="auto",A.style.height=`${A.scrollHeight}px`)},[]);w.useEffect(()=>{y()},[y]);const b=w.useCallback(async A=>{A&&A.preventDefault();const j=(h??"").trim();!j&&!f||x(()=>{try{const P=i(j);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=w.useCallback(A=>{p(A.target.value),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),k=w.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(Wc,{ref:g,value:h,onChange:S,onKeyDown:k,placeholder:t?"Edit your message...":n,className:I,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),c.jsx("div",{children:r?c.jsx(Ke,{type:"button",onClick:()=>{l==null||l()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!l,children:c.jsx(ae.Square,{size:16})}):c.jsx(Ke,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||v,children:c.jsx(ae.Send,{size:16})})})]})})}const $x=w.memo(Lx),Go=0,zn=1,Ar=2,Vc=4;function Kc(e){return()=>e}function Fx(e){e()}function qc(e,t){return n=>e(t(n))}function Gc(e,t){return()=>e(t)}function zx(e,t){return n=>e(t,n)}function Di(e){return e!==void 0}function Bx(...e){return()=>{e.map(Fx)}}function _r(){}function Yo(e,t){return t(e),e}function Hx(e,t){return t(e)}function it(...e){return e}function Je(e,t){return e(zn,t)}function Le(e,t){e(Go,t)}function Li(e){e(Ar)}function gt(e){return e(Vc)}function ye(e,t){return Je(e,zx(t,Go))}function an(e,t){const n=e(zn,r=>{n(),t(r)});return n}function Yc(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Xc(e,t){return e===t}function at(e=Xc){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ne(e){return t=>n=>{e(n)&&t(n)}}function ce(e){return t=>qc(t,e)}function mn(e){return t=>()=>{t(e)}}function U(e,...t){const n=Ux(...t);return(r,o)=>{switch(r){case Ar:Li(e);return;case zn:return Je(e,n(o))}}}function gn(e,t){return n=>r=>{n(t=e(t,r))}}function ar(e){return t=>n=>{e>0?e--:t(n)}}function Rn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function ze(...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);Je(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 Ux(...e){return t=>e.reduceRight(Hx,t)}function Wx(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case zn:return s?n===s?void 0:(r(),n=s,t=Je(e,s),t):(r(),_r);case Ar:r(),n=null;return}}}function G(e){let t=e;const n=We();return(r,o)=>{switch(r){case Go:t=o;break;case zn:{o(t);break}case Vc:return t}return n(r,o)}}function _t(e,t){return Yo(G(t),n=>ye(e,n))}function We(){const e=[];return(t,n)=>{switch(t){case Go:e.slice().forEach(r=>{r(n)});return;case Ar:e.splice(0,e.length);return;case zn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Wt(e){return Yo(We(),t=>ye(e,t))}function Xe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Vx(),singleton:n}}const Vx=()=>Symbol();function Kx(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function yt(...e){const t=We(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Je(s,l=>{n[i]=l,r=r|a,r===o&&Le(t,n)})}),function(s,i){switch(s){case Ar:{Li(t);return}case zn:return r===o&&i(n),Je(t,i)}}}function Ie(e,t=Xc){return U(e,at(t))}function $i(...e){return function(t,n){switch(t){case Ar:return;case zn:return Bx(...e.map(r=>Je(r,n)))}}}var Bt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Bt||{});const qx={0:"debug",3:"error",1:"log",2:"warn"},Gx=()=>typeof globalThis>"u"?window:globalThis,Bn=Xe(()=>{const e=G(3);return{log:G((t,n,r=1)=>{var o;const s=(o=Gx().VIRTUOSO_LOG_LEVEL)!=null?o:gt(e);r>=s&&console[qx[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function lr(e,t,n){return Fi(e,t,n).callbackRef}function Fi(e,t,n){const r=w.useRef(null);let o=i=>{};const s=w.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function Yx(e,t,n,r,o,s,i,a,l){const u=w.useCallback(d=>{const f=Xx(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const p=h.lastElementChild.dataset.viewportType==="window";let v;p&&(v=h.ownerDocument.defaultView);const x=i?a?i.scrollLeft:i.scrollTop:p?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:p?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:p?a?v.innerWidth:v.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(x,0),viewportHeight:y}),s==null||s(a?Jc("column-gap",getComputedStyle(d).columnGap,o):Jc("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return Fi(u,n,l)}function Xx(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},Bt.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Jc(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Bt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Zc(e,t,n){const r=w.useRef(null),o=w.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const u=l.getBoundingClientRect(),d=u.width;let f,h;if(t){const p=t.getBoundingClientRect(),v=u.top-p.top;h=p.height-Math.max(0,v),f=v+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;h=p.innerHeight-Math.max(0,u.top),f=u.top+p.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Fi(o,!0,n),a=w.useCallback(()=>{o(i.current)},[o,i]);return w.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const u=new ResizeObserver(()=>{requestAnimationFrame(a)});return u.observe(t),()=>{t.removeEventListener("scroll",a),u.unobserve(t)}}else{const u=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return u==null||u.addEventListener("scroll",a),u==null||u.addEventListener("resize",a),()=>{u==null||u.removeEventListener("scroll",a),u==null||u.removeEventListener("resize",a)}}},[a,t,i]),s}const Dt=Xe(()=>{const e=We(),t=We(),n=G(0),r=We(),o=G(0),s=We(),i=We(),a=G(0),l=G(0),u=G(0),d=G(0),f=We(),h=We(),p=G(!1),v=G(!1),x=G(!1);return ye(U(e,ce(({scrollTop:g})=>g)),t),ye(U(e,ce(({scrollHeight:g})=>g)),i),ye(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:x,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),eo={lvl:0};function Qc(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function nt(e){return e===eo}function to(e,t){if(!nt(e))return t===e.k?e.v:t<e.k?to(e.l,t):to(e.r,t)}function ln(e,t,n="k"){if(nt(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=ln(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return ln(e.l,t,n)}function Vt(e,t,n){return nt(e)?nu(t,n,1):t===e.k?vt(e,{k:t,v:n}):t<e.k?ru(vt(e,{l:Vt(e.l,t,n)})):ru(vt(e,{r:Vt(e.r,t,n)}))}function jr(){return eo}function Xo(e,t,n){if(nt(e))return[];const r=ln(e,t)[0];return Jx(Bi(e,r,n))}function zi(e,t){if(nt(e))return eo;const{k:n,l:r,r:o}=e;if(t===n){if(nt(r))return o;if(nt(o))return r;{const[s,i]=tu(r);return Jo(vt(e,{k:s,l:eu(r),v:i}))}}else return t<n?Jo(vt(e,{l:zi(r,t)})):Jo(vt(e,{r:zi(o,t)}))}function cr(e){return nt(e)?[]:[...cr(e.l),{k:e.k,v:e.v},...cr(e.r)]}function Bi(e,t,n){if(nt(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Bi(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Bi(s,t,n))),a}function Jo(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(Hi(t))return ou(vt(e,{lvl:n-1}));if(!nt(t)&&!nt(t.r))return vt(t.r,{l:vt(t,{r:t.r.l}),lvl:n,r:vt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Hi(e))return Ui(vt(e,{lvl:n-1}));if(!nt(r)&&!nt(r.l)){const o=r.l,s=Hi(o)?r.lvl-1:r.lvl;return vt(o,{l:vt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Ui(vt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function vt(e,t){return nu(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function eu(e){return nt(e.r)?e.l:Jo(vt(e,{r:eu(e.r)}))}function Hi(e){return nt(e)||e.lvl>e.r.lvl}function tu(e){return nt(e.r)?[e.k,e.v]:tu(e.r)}function nu(e,t,n,r=eo,o=eo){return{k:e,l:r,lvl:n,r:o,v:t}}function ru(e){return Ui(ou(e))}function ou(e){const{l:t}=e;return!nt(t)&&t.lvl===e.lvl?vt(t,{r:vt(e,{l:t.r})}):e}function Ui(e){const{lvl:t,r:n}=e;return!nt(n)&&!nt(n.r)&&n.lvl===t&&n.r.lvl===t?vt(n,{l:vt(e,{r:n.l}),lvl:t+1}):e}function Jx(e){return Qc(e,({k:t,v:n})=>({index:t,value:n}))}function su(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function no(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Wi=Xe(()=>({recalcInProgress:G(!1)}),[],{singleton:!0});function iu(e,t,n){return e[Zo(e,t,n)]}function Zo(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 Zx(e,t,n,r){const o=Zo(e,t,r),s=Zo(e,n,r,o);return e.slice(o,s+1)}function Hn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Qo(e){return!nt(e.groupOffsetTree)}function Vi({index:e},t){return t===e?0:t<e?-1:1}function Qx(){return{groupIndices:[],groupOffsetTree:jr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:jr()}}function ey(e,t){let n=nt(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),nt(e)){e=Vt(e,0,s);continue}const a=Xo(e,i-1,o+1);if(a.some(ay(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=zi(e,f)):(u=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=Vt(e,o+1,h));u&&(e=Vt(e,i,s))}return[e,n]}function ty(e){return typeof e.groupIndex<"u"}function ny({offset:e},t){return t===e?0:t<e?-1:1}function ro(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=iu(t,e,Vi),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function au(e,t){if(!Qo(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function lu(e,t,n){if(ty(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=au(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function ry(e,t,n,r=0){return r>0&&(t=Math.max(t,iu(e,r,Vi).offset)),Qc(Zx(e,t,n,ny),iy)}function oy(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Bt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&nt(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((v,x)=>Vt(Vt(v,x,h),x+1,p),i)}else[i,a]=ey(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=Ki(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>Vt(h,p,ro(p,f,o)),jr()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function sy(e){return cr(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function cu(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function Ki(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=Zo(o,t-1,Vi),a=o[l].offset;const u=ln(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===ln(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:u,value:d}of Xo(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 iy(e){return{index:e.index,value:e}}function ay(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 ly={offsetHeight:"height",offsetWidth:"width"},xn=Xe(([{log:e},{recalcInProgress:t}])=>{const n=We(),r=We(),o=_t(r,0),s=We(),i=We(),a=G(0),l=G([]),u=G(void 0),d=G(void 0),f=G((C,T)=>Hn(C,ly[T])),h=G(void 0),p=G(0),v=Qx(),x=_t(U(n,ze(l,e,p),gn(oy,v),at()),v),g=_t(U(l,at(),gn((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),ce(({prev:C})=>C)),[]);ye(U(l,Ne(C=>C.length>0),ze(x,p),ce(([C,T,I])=>{const A=C.reduce((j,P,D)=>Vt(j,P,ro(P,T.offsetTree,I)||D),jr());return{...T,groupIndices:C,groupOffsetTree:A}})),x),ye(U(r,ze(x),Ne(([C,{lastIndex:T}])=>C<T),ce(([C,{lastIndex:T,lastSize:I}])=>[{endIndex:T,size:I,startIndex:C}])),n),ye(u,d);const y=_t(U(u,ce(C=>C===void 0)),!0);ye(U(d,Ne(C=>C!==void 0&&nt(gt(x).sizeTree)),ce(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=Wt(U(n,ze(x),gn(({sizes:C},[T,I])=>({changed:I!==C,sizes:I}),{changed:!1,sizes:v}),ce(C=>C.changed)));Je(U(a,gn((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),ce(C=>C.diff)),C=>{const{groupIndices:T}=gt(x);if(C>0)Le(t,!0),Le(s,C+cu(C,T));else if(C<0){const I=gt(g);I.length>0&&(C-=cu(-C,I)),Le(i,C)}}),Je(U(a,ze(e)),([C,T])=>{C<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Bt.ERROR)});const S=Wt(s);ye(U(s,ze(x),ce(([C,T])=>{const I=T.groupIndices.length>0,A=[],j=T.lastSize;if(I){const P=to(T.sizeTree,0);let D=0,L=0;for(;D<C;){const M=T.groupIndices[L],X=T.groupIndices.length===L+1?1/0:T.groupIndices[L+1]-M-1;A.push({endIndex:M,size:P,startIndex:M}),A.push({endIndex:M+1+X-1,size:j,startIndex:M+1}),L++,D+=X+1}const B=cr(T.sizeTree);return D!==C&&B.shift(),B.reduce((M,{k:X,v:W})=>{let V=M.ranges;return M.prevSize!==0&&(V=[...M.ranges,{endIndex:X+C-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:X+C,prevSize:W,ranges:V}},{prevIndex:C,prevSize:0,ranges:A}).ranges}return cr(T.sizeTree).reduce((P,{k:D,v:L})=>({prevIndex:D+C,prevSize:L,ranges:[...P.ranges,{endIndex:D+C-1,size:P.prevSize,startIndex:P.prevIndex}]}),{prevIndex:0,prevSize:j,ranges:[]}).ranges})),n);const k=Wt(U(i,ze(x,p),ce(([C,{offsetTree:T},I])=>{const A=-C;return ro(A,T,I)})));return ye(U(i,ze(x,p),ce(([C,T,I])=>{if(T.groupIndices.length>0){if(nt(T.sizeTree))return T;let A=jr();const j=gt(g);let P=0,D=0,L=0;for(;P<-C;){L=j[D];const B=j[D+1]-L-1;D++,P+=B+1}if(A=cr(T.sizeTree).reduce((B,{k:M,v:X})=>Vt(B,Math.max(0,M+C),X),A),P!==-C){const B=to(T.sizeTree,L);A=Vt(A,0,B);const M=ln(T.sizeTree,-C+1)[1];A=Vt(A,1,M)}return{...T,sizeTree:A,...Ki(T.offsetTree,0,A,I)}}else{const A=cr(T.sizeTree).reduce((j,{k:P,v:D})=>Vt(j,Math.max(0,P+C),D),jr());return{...T,sizeTree:A,...Ki(T.offsetTree,0,A,I)}}})),x),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:x,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},it(Bn,Wi),{singleton:!0});function cy(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const uu=Xe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=We(),i=We(),a=Wt(U(s,ce(cy)));return ye(U(a,ce(l=>l.totalCount)),n),ye(U(a,ce(l=>l.groupIndices)),e),ye(U(yt(o,t,r),Ne(([l,u])=>Qo(u)),ce(([l,u,d])=>ln(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),at(),ce(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},it(xn,Dt)),Un=Xe(([{log:e}])=>{const t=G(!1),n=Wt(U(t,Ne(r=>r),at()));return Je(t,r=>{r&&gt(e)("props updated",{},Bt.DEBUG)}),{didMount:n,propsReady:t}},it(Bn),{singleton:!0}),uy=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function du(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!uy)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const oo=Xe(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const p=We(),v=We(),x=G(0);let g=null,y=null,b=null;function S(){g&&(g(),g=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),Le(l,!1)}return ye(U(p,ze(n,f,r,x,a,i,h),ze(e,s,o),ce(([[k,C,T,I,A,j,P,D],L,B,M])=>{const X=du(k),{align:W,behavior:V,offset:z}=X,$=I-1,pe=lu(X,C,$);let F=ro(pe,C.offsetTree,L)+j;W==="end"?(F+=B+ln(C.sizeTree,pe)[1]-T+M,pe===$&&(F+=P)):W==="center"?F+=(B+ln(C.sizeTree,pe)[1]-T+M)/2:F-=A,z&&(F+=z);const Q=he=>{S(),he?(D("retrying to scroll to",{location:k},Bt.DEBUG),Le(p,k)):(Le(v,!0),D("list did not change, scroll successful",{},Bt.DEBUG))};if(S(),V==="smooth"){let he=!1;b=Je(t,ve=>{he=he||ve}),g=an(d,()=>{Q(he)})}else g=an(U(t,dy(150)),Q);return y=setTimeout(()=>{S()},1200),Le(l,!0),D("scrolling from index to",{behavior:V,index:pe,top:F},Bt.DEBUG),{behavior:V,top:F}})),u),{scrollTargetReached:v,scrollToIndex:p,topListHeight:x}},it(xn,Dt,Bn),{singleton:!0});function dy(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function qi(e,t){e==0?t():requestAnimationFrame(()=>{qi(e-1,t)})}function Gi(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const so=Xe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=G(!0),l=G(0),u=G(!0);return ye(U(i,ze(l),Ne(([d,f])=>!!f),mn(!1)),a),ye(U(i,ze(l),Ne(([d,f])=>!!f),mn(!1)),u),Je(U(yt(t,i),ze(a,n,e,u),Ne(([[,d],f,{sizeTree:h},p,v])=>d&&(!nt(h)||Di(p))&&!f&&!v),ze(l)),([,d])=>{an(o,()=>{Le(u,!0)}),qi(4,()=>{an(r,()=>{Le(a,!0)}),Le(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},it(xn,Dt,oo,Un),{singleton:!0});function fu(e,t){return Math.abs(e-t)<1.01}const io="up",ao="down",fy="none",hy={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},py=0,lo=Xe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=G(!1),a=G(!0),l=We(),u=We(),d=G(4),f=G(py),h=_t(U($i(U(Ie(o),ar(1),mn(!0)),U(Ie(o),ar(1),mn(!1),Yc(100))),at()),!1),p=_t(U($i(U(n,mn(!0)),U(n,mn(!1),Yc(200))),at()),!1);ye(U(yt(Ie(o),Ie(f)),ce(([b,S])=>b<=S),at()),a),ye(U(a,Rn(50)),u);const v=Wt(U(yt(r,Ie(s),Ie(t),Ie(e),Ie(d)),gn((b,[{scrollHeight:S,scrollTop:k},C,T,I,A])=>{const j=k+C-S>-A,P={scrollHeight:S,scrollTop:k,viewportHeight:C};if(j){let L,B;return k>b.state.scrollTop?(L="SCROLLED_DOWN",B=b.state.scrollTop-k):(L="SIZE_DECREASED",B=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:L,scrollTopDelta:B,state:P}}let D;return P.scrollHeight>b.state.scrollHeight?D="SIZE_INCREASED":C<b.state.viewportHeight?D="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?D="SCROLLING_UPWARDS":D="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:D,state:P}},hy),at((b,S)=>b&&b.atBottom===S.atBottom))),x=_t(U(r,gn((b,{scrollHeight:S,scrollTop:k,viewportHeight:C})=>{if(fu(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const T=S-(k+C)<1;return b.scrollTop!==k&&T?{changed:!0,jump:b.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ne(b=>b.changed),ce(b=>b.jump)),0);ye(U(v,ce(b=>b.atBottom)),i),ye(U(i,Rn(50)),l);const g=G(ao);ye(U(r,ce(({scrollTop:b})=>b),at(),gn((b,S)=>gt(p)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?io:ao,prevScrollTop:S},{direction:ao,prevScrollTop:0}),ce(b=>b.direction)),g),ye(U(r,Rn(50),mn(fy)),g);const y=G(0);return ye(U(h,Ne(b=>!b),mn(0)),y),ye(U(o,Rn(100),ze(h),Ne(([b,S])=>!!S),gn(([b,S],[k])=>[S,k],[0,0]),ce(([b,S])=>S-b)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:x,scrollDirection:g,scrollVelocity:y}},it(Dt)),es="top",ts="bottom",hu="none";function pu(e,t,n){return typeof e=="number"?n===io&&t===es||n===ao&&t===ts?e:0:n===io?t===es?e.main:e.reverse:t===ts?e.main:e.reverse}function mu(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Yi=Xe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=We(),i=G(0),a=G(0),l=G(0),u=_t(U(yt(Ie(r),Ie(o),Ie(n),Ie(s,no),Ie(l),Ie(i),Ie(t),Ie(e),Ie(a)),ce(([d,f,h,[p,v],x,g,y,b,S])=>{const k=d-b,C=g+y,T=Math.max(h-k,0);let I=hu;const A=mu(S,es),j=mu(S,ts);return p-=b,p+=h+y,v+=h+y,v-=b,p>d+C-A&&(I=io),v<d-T+f+j&&(I=ao),I!==hu?[Math.max(k-h-pu(x,es,I)-A,0),k-T-y+f+pu(x,ts,I)+j]:null}),Ne(d=>d!=null),at(no)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},it(Dt),{singleton:!0});function my(e,t,n){if(Qo(t)){const r=au(e,t);return[{index:ln(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 ns(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const x=e[e.length-1];d=x.offset+x.size}const f=n-i,h=a+f*l+(f-1)*r,p=u,v=h-d;return{bottom:d,firstItemIndex:s,items:xu(e,o,s),offsetBottom:v,offsetTop:u,top:p,topItems:xu(t,o,s),topListHeight:t.reduce((x,g)=>g.size+x,0),totalCount:n}}function gu(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,l=Gi(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return ns(u,[],a,o,n,r)}function xu(e,t,n){if(e.length===0)return[];if(!Qo(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=Xo(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 ur=Xe(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:p},{recalcInProgress:v}])=>{const x=G([]),g=G(0),y=We();ye(s.topItemsIndexes,x);const b=_t(U(yt(p,v,Ie(l,no),Ie(o),Ie(r),Ie(u),d,Ie(x),Ie(t),Ie(n),e),Ne(([T,I,,A,,,,,,,j])=>{const P=j&&j.length!==A;return T&&!I&&!P}),ce(([,,[T,I],A,j,P,D,L,B,M,X])=>{const W=j,{offsetTree:V,sizeTree:z}=W,$=gt(g);if(A===0)return{...Xi,totalCount:A};if(T===0&&I===0)return $===0?{...Xi,totalCount:A}:gu($,P,j,B,M,X||[]);if(nt(z))return $>0?null:ns(my(Gi(P,A),W,X),[],A,M,W,B);const pe=[];if(L.length>0){const be=L[0],Te=L[L.length-1];let q=0;for(const O of Xo(z,be,Te)){const J=O.value,te=Math.max(O.start,be),de=Math.min(O.end,Te);for(let le=te;le<=de;le++)pe.push({data:X==null?void 0:X[le],index:le,offset:q,size:J}),q+=J}}if(!D)return ns([],pe,A,M,W,B);const F=L.length>0?L[L.length-1]+1:0,Q=ry(V,T,I,F);if(Q.length===0)return null;const he=A-1,ve=Yo([],be=>{for(const Te of Q){const q=Te.value;let O=q.offset,J=Te.start;const te=q.size;if(q.offset<T){J+=Math.floor((T-q.offset+M)/(te+M));const le=J-Te.start;O+=le*te+le*M}J<F&&(O+=(F-J)*te,J=F);const de=Math.min(Te.end,he);for(let le=J;le<=de&&!(O>=I);le++)be.push({data:X==null?void 0:X[le],index:le,offset:O,size:te}),O+=te+M}});return ns(ve,pe,A,M,W,B)}),Ne(T=>T!==null),at()),Xi);ye(U(e,Ne(Di),ce(T=>T==null?void 0:T.length)),o),ye(U(b,ce(T=>T.topListHeight)),f),ye(f,a),ye(U(b,ce(T=>[T.top,T.bottom])),i),ye(U(b,ce(T=>T.items)),y);const S=Wt(U(b,Ne(({items:T})=>T.length>0),ze(o,e),Ne(([{items:T},I])=>T[T.length-1].originalIndex===I-1),ce(([,T,I])=>[T-1,I]),at(no),ce(([T])=>T))),k=Wt(U(b,Rn(200),Ne(({items:T,topItems:I})=>T.length>0&&T[0].originalIndex===I.length),ce(({items:T})=>T[0].index),at())),C=Wt(U(b,Ne(({items:T})=>T.length>0),ce(({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}}),at(su)));return{endReached:S,initialItemCount:g,itemsRendered:y,listState:b,rangeChanged:C,startReached:k,topItemsIndexes:x,...h}},it(xn,uu,Yi,so,oo,lo,Un,Wi),{singleton:!0}),yu=Xe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=We(),i=_t(U(yt(n,e,r,t,o),ce(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return ye(Ie(i),s),{totalListHeight:i,totalListHeightChanged:s}},it(Dt,ur),{singleton:!0}),gy=Xe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=G(!1),r=_t(U(yt(n,e,t),Ne(([o])=>o),ce(([,o,s])=>Math.max(0,o-s)),Rn(0),at()),0);return{alignToBottom:n,paddingTopAddition:r}},it(Dt,yu),{singleton:!0}),vu=Xe(()=>({context:G(null)})),xy=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...o},viewportBottom:s,viewportTop:i})=>t<i?{...o,align:n??"start",behavior:r}:e>s?{...o,align:n??"end",behavior:r}:null,bu=Xe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:u}])=>{const d=We();return ye(U(d,ze(t,l,n,s,o,r,a),ze(e),ce(([[f,h,p,v,x,g,y,b],S])=>{const{align:k,behavior:C,calculateViewLocation:T=xy,done:I,...A}=f,j=lu(f,h,v-1),P=ro(j,h.offsetTree,S)+x+g,D=P+ln(h.sizeTree,j)[1],L=b+g,B=b+p-y,M=T({itemBottom:D,itemTop:P,locationParams:{align:k,behavior:C,...A},viewportBottom:B,viewportTop:L});return M?I&&an(U(i,Ne(X=>!X),ar(gt(i)?1:2)),I):I&&I(),M}),Ne(f=>f!==null)),u),{scrollIntoView:d}},it(xn,Dt,oo,ur,Bn),{singleton:!0});function wu(e){return e?e==="smooth"?"smooth":"auto":!1}const yy=(e,t)=>typeof e=="function"?wu(e(t)):t&&wu(e),vy=Xe(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:u},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:p}])=>{const v=G(!1),x=We();let g=null;function y(C){Le(i,{align:"end",behavior:C,index:"LAST"})}Je(U(yt(U(Ie(t),ar(1)),l),ze(Ie(v),s,a,f),ce(([[C,T],I,A,j,P])=>{let D=T&&j,L="auto";return D&&(L=yy(I,A||P),D=D&&!!L),{followOutputBehavior:L,shouldFollow:D,totalCount:C}}),Ne(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{g&&(g(),g=null),gt(n)?requestAnimationFrame(()=>{gt(d)("following output to ",{totalCount:T},Bt.DEBUG),y(C)}):g=an(e,()=>{gt(d)("following output to ",{totalCount:T},Bt.DEBUG),y(C),g=null})});function b(C){const T=an(o,I=>{C&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(gt(d)("scrolling to bottom due to increased size",{},Bt.DEBUG),y("auto"))});setTimeout(T,100)}Je(U(yt(Ie(v),t,u),Ne(([C,,T])=>C&&T),gn(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),Ne(({refreshed:C})=>C),ze(v,t)),([,C])=>{gt(a)&&b(C!==!1)}),Je(x,()=>{b(gt(v)!==!1)}),Je(yt(Ie(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=G(null),k=We();return ye($i(U(Ie(r),ce(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),U(Ie(t))),k),Je(U(yt(U(k,ar(1)),l),ze(Ie(S),a,f,h),ce(([[C,T],I,A,j,P])=>T&&A&&(I==null?void 0:I({context:P,totalCount:C,scrollingInProgress:j}))),Ne(C=>!!C),Rn(0)),C=>{g&&(g(),g=null),gt(n)?requestAnimationFrame(()=>{gt(d)("scrolling into view",{}),Le(p,C)}):g=an(e,()=>{gt(d)("scrolling into view",{}),Le(p,C),g=null})}),{autoscrollToBottom:x,followOutput:v,scrollIntoViewOnChange:S}},it(xn,lo,oo,so,Un,Bn,Dt,vu,bu)),by=Xe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ye(U(a,ze(s),Ne(([,l])=>l!==0),ze(o,r,t,n,e),ce(([[,l],u,d,f,h,p=[]])=>gu(l,u,d,f,h,p))),i),{}),it(xn,so,ur,Un),{singleton:!0}),wy=Xe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=G(0);return Je(U(e,ze(r),Ne(([,o])=>o!==0),ce(([,o])=>({top:o}))),o=>{an(U(n,ar(1),Ne(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Le(t,o)})})}),{initialScrollTop:r}},it(Un,Dt,ur),{singleton:!0}),Su=Xe(([{scrollVelocity:e}])=>{const t=G(!1),n=We(),r=G(!1);return ye(U(e,ze(r,t,n),Ne(([o,s])=>!!s),ce(([o,s,i,a])=>{const{enter:l,exit:u}=s;if(i){if(u(o,a))return!1}else if(l(o,a))return!0;return i}),at()),t),Je(U(yt(t,e,n),ze(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},it(lo),{singleton:!0}),Ji=Xe(([{scrollContainerState:e,scrollTo:t}])=>{const n=We(),r=We(),o=We(),s=G(!1),i=G(void 0);return ye(U(yt(n,r),ce(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),ye(U(t,ze(r),ce(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},it(Dt)),Sy=Xe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=We(),d=G(void 0),f=G(null),h=G(null);return ye(a,f),ye(l,h),Je(U(u,ze(t,r,i,f,h,n)),([p,v,x,g,y,b,S])=>{const k=sy(v.sizeTree);g&&y!==null&&b!==null&&(x=y.scrollTop-b.offsetTop),x-=S,p({ranges:k,scrollTop:x})}),ye(U(d,Ne(Di),ce(Cy)),o),ye(U(s,ze(d),Ne(([,p])=>p!==void 0),at(),ce(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},it(xn,Dt,so,Un,Ji));function Cy(e){return{align:"start",index:0,offset:e.scrollTop}}const Ty=Xe(([{topItemsIndexes:e}])=>{const t=G(0);return ye(U(t,Ne(n=>n>=0),ce(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},it(ur));function Cu(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const ky=Cu(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Ey=Xe(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:h},{log:p},{recalcInProgress:v}])=>{const x=Wt(U(l,ze(i),gn(([,y,b,S],[{bottom:k,items:C,offsetBottom:T,totalCount:I},A])=>{const j=k+T;let P=0;return b===I&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(P=j-S,P!==0&&(P+=A))),[P,C,I,j]},[0,[],0,0]),Ne(([y])=>y!==0),ze(r,a,n,o,p,v),Ne(([,y,b,S,,,k])=>!k&&!S&&y!==0&&b===io),ce(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},Bt.DEBUG),y))));function g(y){y>0?(Le(t,{behavior:"auto",top:-y}),Le(e,0)):(Le(e,0),Le(t,{behavior:"auto",top:-y}))}return Je(U(x,ze(e,s)),([y,b,S])=>{S&&ky()?Le(e,b-y):g(-y)}),Je(U(yt(_t(s,!1),e,v),Ne(([y,b,S])=>!y&&!S&&b!==0),ce(([y,b])=>b),Rn(1)),g),ye(U(f,ce(y=>({top:-y}))),t),Je(U(u,ze(h,d),ce(([y,{groupIndices:b,lastSize:S,sizeTree:k},C])=>{function T(I){return I*(S+C)}if(b.length===0)return T(y);{let I=0;const A=to(k,0);let j=0,P=0;for(;j<y;){j++,I+=A;let D=b.length===P+1?1/0:b[P+1]-b[P]-1;j+D>y&&(I-=A,D=y-j+1),j+=D,I+=T(D),P++}return I}})),y=>{Le(e,y),requestAnimationFrame(()=>{Le(t,{top:y}),requestAnimationFrame(()=>{Le(e,0),Le(v,!1)})})}),{deviation:e}},it(Dt,lo,ur,xn,Bn,Wi)),Iy=Xe(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),it(Yi,by,Un,Su,yu,wy,gy,Ji,bu,Bn,vu)),Tu=Xe(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:v},x,g,y,{listState:b,topItemsIndexes:S,...k},{scrollToIndex:C},T,{topItemCount:I},{groupCounts:A},j])=>(ye(k.rangeChanged,j.scrollSeekRangeChanged),ye(U(j.windowViewportRect,ce(P=>P.visibleHeight)),x.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:v,sizeRanges:a,topItemCount:I,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...k,...j,...x,sizes:l,...g}),it(xn,so,Dt,Sy,vy,ur,oo,Ey,Ty,uu,Iy));function Ny(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 rs=typeof document<"u"?w.useLayoutEffect:w.useEffect;function ku(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=w.createContext({});function l(g,y){g.propsReady&&Le(g.propsReady,!1);for(const b of r){const S=g[t.required[b]];Le(S,y[b])}for(const b of o)if(b in y){const S=g[t.optional[b]];Le(S,y[b])}g.propsReady&&Le(g.propsReady,!0)}function u(g){return s.reduce((y,b)=>(y[b]=S=>{const k=g[t.methods[b]];Le(k,S)},y),{})}function d(g){return i.reduce((y,b)=>(y[b]=Wx(g[t.events[b]]),y),{})}const f=w.forwardRef((g,y)=>{const{children:b,...S}=g,[k]=w.useState(()=>Yo(Kx(e),I=>{l(I,S)})),[C]=w.useState(Gc(d,k));rs(()=>{for(const I of i)I in S&&Je(C[I],S[I]);return()=>{Object.values(C).map(Li)}},[S,C,k]),rs(()=>{l(k,S)}),w.useImperativeHandle(y,Kc(u(k)));const T=n;return c.jsx(a.Provider,{value:k,children:n?c.jsx(T,{...Ny([...r,...o,...i],S),children:b}):b})}),h=g=>{const y=w.useContext(a);return w.useCallback(b=>{Le(y[g],b)},[y,g])},p=g=>{const y=w.useContext(a)[g],b=w.useCallback(S=>Je(y,S),[y]);return w.useSyncExternalStore(b,()=>gt(y),()=>gt(y))},v=g=>{const y=w.useContext(a)[g],[b,S]=w.useState(Gc(gt,y));return rs(()=>Je(y,k=>{k!==b&&S(Kc(k))}),[y,b]),b},x=w.version.startsWith("18")?p:v;return{Component:f,useEmitter:(g,y)=>{const b=w.useContext(a)[g];rs(()=>Je(b,y),[y,b])},useEmitterValue:x,usePublisher:h}}const Eu=w.createContext(void 0),Iu=w.createContext(void 0),Nu=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Zi(e){return"self"in e}function Ay(e){return"body"in e}function Au(e,t,n,r=_r,o,s){const i=w.useRef(null),a=w.useRef(null),l=w.useRef(null),u=w.useCallback(h=>{let p,v,x;const g=h.target;if(Ay(g)||Zi(g)){const b=Zi(g)?g:g.defaultView;x=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,v=s?b.innerWidth:b.innerHeight}else x=s?g.scrollLeft:g.scrollTop,p=s?g.scrollWidth:g.scrollHeight,v=s?g.offsetWidth:g.offsetHeight;const y=()=>{e({scrollHeight:p,scrollTop:Math.max(x,0),viewportHeight:v})};h.suppressFlushSync?y():ci.flushSync(y),a.current!==null&&(x===a.current||x<=0||x===p-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);w.useEffect(()=>{const h=o||i.current;return r(o||i.current),u({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",u,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",u)}},[i,u,n,r,o]);function d(h){const p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const v=h.behavior==="smooth";let x,g,y;Zi(p)?(g=Math.max(Hn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),x=s?p.innerWidth:p.innerHeight,y=s?window.scrollX:window.scrollY):(g=p[s?"scrollWidth":"scrollHeight"],x=Hn(p,s?"width":"height"),y=p[s?"scrollLeft":"scrollTop"]);const b=g-x;if(h.top=Math.ceil(Math.max(Math.min(b,h.top),0)),fu(x,g)||h.top===y){e({scrollHeight:g,scrollTop:y,viewportHeight:x}),v&&t(!0);return}v?(a.current=h.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(h={behavior:h.behavior,left:h.top}),p.scrollTo(h)}function f(h){s&&(h={behavior:h.behavior,left:h.top}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const Qi="-webkit-sticky",_u="sticky",ea=Cu(()=>{if(typeof document>"u")return _u;const e=document.createElement("div");return e.style.position=Qi,e.style.position===Qi?Qi:_u});function ta(e){return e}const _y=Xe(()=>{const e=G(a=>`Item ${a}`),t=G(a=>`Group ${a}`),n=G({}),r=G(ta),o=G("div"),s=G(_r),i=(a,l=null)=>_t(U(n,ce(u=>u[a]),at()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),jy=Xe(([e,t])=>({...e,...t}),it(Tu,_y)),Ry=({height:e})=>c.jsx("div",{style:{height:e}}),Py={overflowAnchor:"none",position:ea(),zIndex:1},ju={overflowAnchor:"none"},Oy={...ju,display:"inline-block",height:"100%"},Ru=w.memo(function({showTopList:e=!1}){const t=Re("listState"),n=Zt("sizeRanges"),r=Re("useWindowScroll"),o=Re("customScrollParent"),s=Zt("windowScrollContainerState"),i=Zt("scrollContainerState"),a=o||r?s:i,l=Re("itemContent"),u=Re("context"),d=Re("groupContent"),f=Re("trackItemSizes"),h=Re("itemSize"),p=Re("log"),v=Zt("gap"),x=Re("horizontalDirection"),{callbackRef:g}=Yx(n,h,f,e?_r:a,p,v,o,x,Re("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);na("deviation",M=>{y!==M&&b(M)});const S=Re("EmptyPlaceholder"),k=Re("ScrollSeekPlaceholder")||Ry,C=Re("ListComponent"),T=Re("ItemComponent"),I=Re("GroupComponent"),A=Re("computeItemKey"),j=Re("isSeeking"),P=Re("groupIndices").length>0,D=Re("alignToBottom"),L=Re("initialItemFinalLocationReached"),B=e?{}:{boxSizing:"border-box",...x?{display:"inline-block",height:"100%",marginLeft:y!==0?y:D?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:D?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...L?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?c.jsx(S,{...jt(S,u)}):c.jsx(C,{...jt(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:B,children:(e?t.topItems:t.items).map(M=>{const X=M.originalIndex,W=A(X+t.firstItemIndex,M.data,u);return j?w.createElement(k,{...jt(k,u),height:M.size,index:M.index,key:W,type:M.type||"item",...M.type==="group"?{}:{groupIndex:M.groupIndex}}):M.type==="group"?w.createElement(I,{...jt(I,u),"data-index":X,"data-item-index":M.index,"data-known-size":M.size,key:W,style:Py},d(M.index,u)):w.createElement(T,{...jt(T,u),...$y(T,M.data),"data-index":X,"data-item-group-index":M.groupIndex,"data-item-index":M.index,"data-known-size":M.size,key:W,style:x?Oy:ju},P?l(M.index,M.groupIndex,M.data,u):l(M.index,M.data,u))})})}),My={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Dy={outline:"none",overflowX:"auto",position:"relative"},os=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Ly={position:ea(),top:0,width:"100%",zIndex:1};function jt(e,t){if(typeof e!="string")return{context:t}}function $y(e,t){return{item:typeof e=="string"?void 0:t}}const Fy=w.memo(function(){const e=Re("HeaderComponent"),t=Zt("headerHeight"),n=Re("HeaderFooterTag"),r=lr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Re("skipAnimationFrameInResizeObserver")),o=Re("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...jt(e,o)})}):null}),zy=w.memo(function(){const e=Re("FooterComponent"),t=Zt("footerHeight"),n=Re("HeaderFooterTag"),r=lr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Re("skipAnimationFrameInResizeObserver")),o=Re("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...jt(e,o)})}):null});function Pu({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:v}=Au(a,u,l,d,void 0,f);return e("scrollTo",v),e("scrollBy",h),c.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?Dy:My,...o},tabIndex:0,...i,...jt(l,s),children:r})})}function Ou({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=w.useRef(null),v=t("scrollerRef"),{scrollByCallback:x,scrollerRef:g,scrollToCallback:y}=Au(a,u,l,v,h);return Nu(()=>{var b;return g.current=h||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",y),e("scrollBy",x),c.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...jt(l,s),children:r})})}const By=({children:e})=>{const t=w.useContext(Eu),n=Zt("viewportHeight"),r=Zt("fixedItemHeight"),o=Re("alignToBottom"),s=Re("horizontalDirection"),i=w.useMemo(()=>qc(n,l=>Hn(l,s?"width":"height")),[n,s]),a=lr(i,!0,Re("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),c.jsx("div",{"data-viewport-type":"element",ref:a,style:os(o),children:e})},Hy=({children:e})=>{const t=w.useContext(Eu),n=Zt("windowViewportRect"),r=Zt("fixedItemHeight"),o=Re("customScrollParent"),s=Zc(n,o,Re("skipAnimationFrameInResizeObserver")),i=Re("alignToBottom");return w.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),c.jsx("div",{"data-viewport-type":"window",ref:s,style:os(i),children:e})},Uy=({children:e})=>{const t=Re("TopItemListComponent")||"div",n=Re("headerHeight"),r={...Ly,marginTop:`${n}px`},o=Re("context");return c.jsx(t,{style:r,...jt(t,o),children:e})},Wy=w.memo(function(e){const t=Re("useWindowScroll"),n=Re("topItemsIndexes").length>0,r=Re("customScrollParent"),o=Re("context");return c.jsxs(r||t?qy:Ky,{...e,context:o,children:[n&&c.jsx(Uy,{children:c.jsx(Ru,{showTopList:!0})}),c.jsxs(r||t?Hy:By,{children:[c.jsx(Fy,{}),c.jsx(Ru,{}),c.jsx(zy,{})]})]})}),{Component:Vy,useEmitter:na,useEmitterValue:Re,usePublisher:Zt}=ku(jy,{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"}},Wy),Ky=Pu({useEmitter:na,useEmitterValue:Re,usePublisher:Zt}),qy=Ou({useEmitter:na,useEmitterValue:Re,usePublisher:Zt}),Gy=Vy;it(Tu,Xe(()=>{const e=G(u=>c.jsxs("td",{children:["Item $",u]})),t=G(null),n=G(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=G(null),o=G(null),s=G({}),i=G(ta),a=G(_r),l=(u,d=null)=>_t(U(s,ce(f=>f[u]),at()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),ea();const Mu={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Yy={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Du,floor:ss,max:co,min:ra,round:Lu}=Math;function $u(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function Xy(e){return{...Yy,items:e}}function is(e,t){return e&&e.width===t.width&&e.height===t.height}function Jy(e,t){return e&&e.column===t.column&&e.row===t.row}const Zy=Xe(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},h,p,{didMount:v,propsReady:x},{customScrollParent:g,useWindowScroll:y,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k},C])=>{const T=G(0),I=G(0),A=G(Mu),j=G({height:0,width:0}),P=G({height:0,width:0}),D=We(),L=We(),B=G(0),M=G(null),X=G({column:0,row:0}),W=We(),V=We(),z=G(!1),$=G(0),pe=G(!0),F=G(!1),Q=G(!1);Je(U(v,ze($),Ne(([O,J])=>!!J)),()=>{Le(pe,!1)}),Je(U(yt(v,pe,P,j,$,F),Ne(([O,J,te,de,,le])=>O&&!J&&te.height!==0&&de.height!==0&&!le)),([,,,,O])=>{Le(F,!0),qi(1,()=>{Le(D,O)}),an(U(u),()=>{Le(t,[0,0]),Le(pe,!0)})}),ye(U(V,Ne(O=>O!=null&&O.scrollTop>0),mn(0)),I),Je(U(v,ze(V),Ne(([,O])=>O!=null)),([,O])=>{O&&(Le(j,O.viewport),Le(P,O.item),Le(X,O.gap),O.scrollTop>0&&(Le(z,!0),an(U(u,ar(1)),J=>{Le(z,!1)}),Le(l,{top:O.scrollTop})))}),ye(U(j,ce(({height:O})=>O)),f),ye(U(yt(Ie(j,is),Ie(P,is),Ie(X,(O,J)=>O&&O.column===J.column&&O.row===J.row),Ie(u)),ce(([O,J,te,de])=>({gap:te,item:J,scrollTop:de,viewport:O}))),W),ye(U(yt(Ie(T),r,Ie(X,Jy),Ie(P,is),Ie(j,is),Ie(M),Ie(I),Ie(z),Ie(pe),Ie($)),Ne(([,,,,,,,O])=>!O),ce(([O,[J,te],de,le,ie,et,Qe,,Oe,Be])=>{const{column:ht,row:tt}=de,{height:Me,width:bt}=le,{width:ne}=ie;if(Qe===0&&(O===0||ne===0))return Mu;if(bt===0){const xt=Gi(Be,O),Pt=xt+Math.max(Qe-1,0);return Xy($u(xt,Pt,et))}const oe=Fu(ne,bt,ht);let ge,we;Oe?J===0&&te===0&&Qe>0?(ge=0,we=Qe-1):(ge=oe*ss((J+tt)/(Me+tt)),we=oe*Du((te+tt)/(Me+tt))-1,we=ra(O-1,co(we,oe-1)),ge=ra(we,co(0,ge))):(ge=0,we=-1);const xe=$u(ge,we,et),{bottom:Fe,top:ot}=zu(ie,de,le,xe),$e=Du(O/oe),ut=$e*Me+($e-1)*tt-Fe;return{bottom:Fe,itemHeight:Me,items:xe,itemWidth:bt,offsetBottom:ut,offsetTop:ot,top:ot}})),A),ye(U(M,Ne(O=>O!==null),ce(O=>O.length)),T),ye(U(yt(j,P,A,X),Ne(([O,J,{items:te}])=>te.length>0&&J.height!==0&&O.height!==0),ce(([O,J,{items:te},de])=>{const{bottom:le,top:ie}=zu(O,de,J,te);return[ie,le]}),at(no)),t);const he=G(!1);ye(U(u,ze(he),ce(([O,J])=>J||O!==0)),he);const ve=Wt(U(yt(A,T),Ne(([{items:O}])=>O.length>0),ze(he),Ne(([[O,J],te])=>{const de=O.items[O.items.length-1].index===J-1;return(te||O.bottom>0&&O.itemHeight>0&&O.offsetBottom===0&&O.items.length===J)&&de}),ce(([[,O]])=>O-1),at())),be=Wt(U(Ie(A),Ne(({items:O})=>O.length>0&&O[0].index===0),mn(0),at())),Te=Wt(U(Ie(A),ze(z),Ne(([{items:O},J])=>O.length>0&&!J),ce(([{items:O}])=>({endIndex:O[O.length-1].index,startIndex:O[0].index})),at(su),Rn(0)));ye(Te,p.scrollSeekRangeChanged),ye(U(D,ze(j,P,T,X),ce(([O,J,te,de,le])=>{const ie=du(O),{align:et,behavior:Qe,offset:Oe}=ie;let Be=ie.index;Be==="LAST"&&(Be=de-1),Be=co(0,Be,ra(de-1,Be));let ht=oa(J,le,te,Be);return et==="end"?ht=Lu(ht-J.height+te.height):et==="center"&&(ht=Lu(ht-J.height/2+te.height/2)),Oe&&(ht+=Oe),{behavior:Qe,top:ht}})),l);const q=_t(U(A,ce(O=>O.offsetBottom+O.bottom)),0);return ye(U(k,ce(O=>({height:O.visibleHeight,width:O.visibleWidth}))),j),{customScrollParent:g,data:M,deviation:B,footerHeight:o,gap:X,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:P,overscan:n,restoreStateFrom:V,scrollBy:i,scrollContainerState:a,scrollHeight:L,scrollTo:l,scrollToIndex:D,scrollTop:u,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:j,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k,...p,gridState:A,horizontalDirection:Q,initialTopMostItemIndex:$,totalListHeight:q,...h,endReached:ve,propsReady:x,rangeChanged:Te,startReached:be,stateChanged:W,stateRestoreInProgress:z,...C}},it(Yi,Dt,lo,Su,Un,Ji,Bn));function Fu(e,t,n){return co(1,ss((e+n)/(ss(t)+n)))}function zu(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=oa(e,t,n,r[0].index);return{bottom:oa(e,t,n,r[r.length-1].index)+o,top:s}}function oa(e,t,n,r){const o=Fu(e.width,n.width,t.column),s=ss(r/o),i=s*n.height+co(0,s-1)*t.row;return i>0?i+t.row:i}const Qy=Xe(()=>{const e=G(f=>`Item ${f}`),t=G({}),n=G(null),r=G("virtuoso-grid-item"),o=G("virtuoso-grid-list"),s=G(ta),i=G("div"),a=G(_r),l=(f,h=null)=>_t(U(t,ce(p=>p[f]),at()),h),u=G(!1),d=G(!1);return ye(Ie(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")}}),ev=Xe(([e,t])=>({...e,...t}),it(Zy,Qy)),tv=w.memo(function(){const e=ct("gridState"),t=ct("listClassName"),n=ct("itemClassName"),r=ct("itemContent"),o=ct("computeItemKey"),s=ct("isSeeking"),i=Qt("scrollHeight"),a=ct("ItemComponent"),l=ct("ListComponent"),u=ct("ScrollSeekPlaceholder"),d=ct("context"),f=Qt("itemDimensions"),h=Qt("gap"),p=ct("log"),v=ct("stateRestoreInProgress"),x=Qt("reportReadyState"),g=lr(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);const S=y.firstChild;if(S){const{height:k,width:C}=S.getBoundingClientRect();f({height:k,width:C})}h({column:Hu("column-gap",getComputedStyle(y).columnGap,p),row:Hu("row-gap",getComputedStyle(y).rowGap,p)})},[i,f,h,p]),!0,!1);return Nu(()=>{e.itemHeight>0&&e.itemWidth>0&&x(!0)},[e]),v?null:c.jsx(l,{className:t,ref:g,...jt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const b=o(y.index,y.data,d);return s?c.jsx(u,{...jt(u,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{...jt(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),nv=w.memo(function(){const e=ct("HeaderComponent"),t=Qt("headerHeight"),n=ct("headerFooterTag"),r=lr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=ct("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...jt(e,o)})}):null}),rv=w.memo(function(){const e=ct("FooterComponent"),t=Qt("footerHeight"),n=ct("headerFooterTag"),r=lr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=ct("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...jt(e,o)})}):null}),ov=({children:e})=>{const t=w.useContext(Iu),n=Qt("itemDimensions"),r=Qt("viewportDimensions"),o=lr(w.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return w.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),c.jsx("div",{ref:o,style:os(!1),children:e})},sv=({children:e})=>{const t=w.useContext(Iu),n=Qt("windowViewportRect"),r=Qt("itemDimensions"),o=ct("customScrollParent"),s=Zc(n,o,!1);return w.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),c.jsx("div",{ref:s,style:os(!1),children:e})},iv=w.memo(function({...e}){const t=ct("useWindowScroll"),n=ct("customScrollParent"),r=n||t?lv:av,o=n||t?sv:ov,s=ct("context");return c.jsx(r,{...e,...jt(r,s),children:c.jsxs(o,{children:[c.jsx(nv,{}),c.jsx(tv,{}),c.jsx(rv,{})]})})}),{useEmitter:Bu,useEmitterValue:ct,usePublisher:Qt}=ku(ev,{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"}},iv),av=Pu({useEmitter:Bu,useEmitterValue:ct,usePublisher:Qt}),lv=Ou({useEmitter:Bu,useEmitterValue:ct,usePublisher:Qt});function Hu(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Bt.WARN),t==="normal"?0:parseInt(t??"0",10)}const cv=Ao.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 sa({className:e,variant:t,...n}){return c.jsx("div",{className:ee(cv({variant:t}),e),...n})}function fe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function uv(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 yn(e,t=[]){let n=[];function r(s,i){const a=m.createContext(i),l=n.length;n=[...n,i];const u=f=>{var y;const{scope:h,children:p,...v}=f,x=((y=h==null?void 0:h[e])==null?void 0:y[l])||a,g=m.useMemo(()=>v,Object.values(v));return c.jsx(x.Provider,{value:g,children:p})};u.displayName=s+"Provider";function d(f,h){var x;const p=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,v=m.useContext(p);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>m.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,dv(o,...t)]}function dv(...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 wt=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},fv=m[" useInsertionEffect ".trim().toString()]||wt;function dr({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=hv({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=pv(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 hv({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return fv(()=>{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 pv(e){return typeof e=="function"}function Uu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function ia(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Uu(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():Uu(e[o],null)}}}}function Ue(...e){return m.useCallback(ia(...e),e)}var mv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ae=mv.reduce((e,t)=>{const n=rr.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 Wu(e,t){e&&_o.flushSync(()=>e.dispatchEvent(t))}function gv(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Kt=e=>{const{present:t,children:n}=e,r=xv(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=Ue(r.ref,yv(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};Kt.displayName="Presence";function xv(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=gv(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=as(r.current);s.current=a==="mounted"?u:"none"},[a]),wt(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,p=as(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]),wt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const x=as(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&x&&(l("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},h=p=>{p.target===t&&(s.current=as(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 as(e){return(e==null?void 0:e.animationName)||"none"}function yv(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 vv=m[" useId ".trim().toString()]||(()=>{}),bv=0;function vn(e){const[t,n]=m.useState(vv());return wt(()=>{n(r=>r??String(bv++))},[e]),e||(t?`radix-${t}`:"")}var ls="Collapsible",[wv,ok]=yn(ls),[Sv,aa]=wv(ls),Vu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,u]=dr({prop:r,defaultProp:o??!1,onChange:i,caller:ls});return c.jsx(Sv,{scope:n,disabled:s,contentId:vn(),open:l,onOpenToggle:m.useCallback(()=>u(d=>!d),[u]),children:c.jsx(Ae.div,{"data-state":ca(l),"data-disabled":s?"":void 0,...a,ref:t})})});Vu.displayName=ls;var Ku="CollapsibleTrigger",qu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=aa(Ku,n);return c.jsx(Ae.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":ca(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:fe(e.onClick,o.onOpenToggle)})});qu.displayName=Ku;var la="CollapsibleContent",Cv=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=aa(la,e.__scopeCollapsible);return c.jsx(Kt,{present:n||o.open,children:({present:s})=>c.jsx(Tv,{...r,ref:t,present:s})})});Cv.displayName=la;var Tv=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=aa(la,n),[a,l]=m.useState(r),u=m.useRef(null),d=Ue(t,u),f=m.useRef(0),h=f.current,p=m.useRef(0),v=p.current,x=i.open||a,g=m.useRef(x),y=m.useRef(void 0);return m.useEffect(()=>{const b=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(b)},[]),wt(()=>{const b=u.current;if(b){y.current=y.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const S=b.getBoundingClientRect();f.current=S.height,p.current=S.width,g.current||(b.style.transitionDuration=y.current.transitionDuration,b.style.animationName=y.current.animationName),l(r)}},[i.open,r]),c.jsx(Ae.div,{"data-state":ca(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!x,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style},children:x&&o})});function ca(e){return e?"open":"closed"}var kv=Vu;const Gu=kv,Yu=qu,uo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ee("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));uo.displayName="Card";const fo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ee("flex flex-col space-y-1.5 p-6",e),...t}));fo.displayName="CardHeader";const ho=m.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:ee("text-2xl font-semibold leading-none tracking-tight",e),...t}));ho.displayName="CardTitle";const Xu=m.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:ee("text-sm text-muted-foreground",e),...t}));Xu.displayName="CardDescription";const cs=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ee("p-6 pt-0",e),...t}));cs.displayName="CardContent";const Ju=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ee("flex items-center p-6 pt-0",e),...t}));Ju.displayName="CardFooter";function Zu(){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 fr=Zu();function Ev(e){fr=e}const Qu=/[&<>"']/,Iv=new RegExp(Qu.source,"g"),ed=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Nv=new RegExp(ed.source,"g"),Av={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},td=e=>Av[e];function Rt(e,t){if(t){if(Qu.test(e))return e.replace(Iv,td)}else if(ed.test(e))return e.replace(Nv,td);return e}const _v=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function nd(e){return e.replace(_v,(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 jv=/(^|[^\[])\^/g;function rt(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(jv,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const Rv=/[^\w:]/g,Pv=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function rd(e,t,n){if(e){let r;try{r=decodeURIComponent(nd(n)).replace(Rv,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!Pv.test(n)&&(n=Lv(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const us={},Ov=/^[^:]+:\/*[^/]*$/,Mv=/^([^:]+:)[\s\S]*$/,Dv=/^([^:]+:\/*[^/]*)[\s\S]*$/;function Lv(e,t){us[" "+e]||(Ov.test(e)?us[" "+e]=e+"/":us[" "+e]=fs(e,"/",!0)),e=us[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(Mv,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(Dv,"$1")+t:e+t}const ds={exec:function(){}};function od(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 fs(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 $v(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 Fv(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 sd(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function id(e,t,n,r){const o=t.href,s=t.title?Rt(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:Rt(i)}}function zv(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
39
39
  `).map(o=>{const s=o.match(/^\s+/);if(s===null)return o;const[i]=s;return i.length>=r.length?o.slice(r.length):o}).join(`
40
- `)}class ca{constructor(t){this.options=t||ur}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:us(r,`
41
- `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=Fv(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=us(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,l,u,d,f,h,p,v,x=n[1].trim();const g=x.length>1,y={type:"list",raw:"",ordered:g,start:g?+x.slice(0,-1):"",loose:!1,items:[]};x=g?`\\d{1,9}\\${x.slice(-1)}`:`\\${x}`,this.options.pedantic&&(x=g?x:"[*+-]");const b=new RegExp(`^( {0,3}${x})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(v=!1,!(!(n=b.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
40
+ `)}class ua{constructor(t){this.options=t||fr}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:fs(r,`
41
+ `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=zv(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:o}}}heading(t){const n=this.rules.block.heading.exec(t);if(n){let r=n[2].trim();if(/#$/.test(r)){const o=fs(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,l,u,d,f,h,p,v,x=n[1].trim();const g=x.length>1,y={type:"list",raw:"",ordered:g,start:g?+x.slice(0,-1):"",loose:!1,items:[]};x=g?`\\d{1,9}\\${x.slice(-1)}`:`\\${x}`,this.options.pedantic&&(x=g?x:"[*+-]");const b=new RegExp(`^( {0,3}${x})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(v=!1,!(!(n=b.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
42
42
  `,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),f=t.split(`
43
43
  `,1)[0],this.options.pedantic?(i=2,p=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,p=d.slice(i),i+=n[1].length),l=!1,!d&&/^ *$/.test(f)&&(r+=f+`
44
44
  `,t=t.substring(f.length+1),v=!0),!v){const k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),C=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),I=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(h=t.split(`
45
45
  `,1)[0],f=h,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(T.test(f)||I.test(f)||k.test(f)||C.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())p+=`
46
46
  `+f.slice(i);else{if(l||d.search(/[^ ]/)>=4||T.test(d)||I.test(d)||C.test(d))break;p+=`
47
47
  `+f}!l&&!f.trim()&&(l=!0),r+=h+`
48
- `,t=t.substring(h.length+1),d=f.slice(i)}}y.loose||(u?y.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),y.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),y.raw+=r}y.items[y.items.length-1].raw=r.trimRight(),y.items[y.items.length-1].text=p.trimRight(),y.raw=y.raw.trimRight();const S=y.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const k=y.items[a].tokens.filter(T=>T.type==="space"),C=k.length>0&&k.some(T=>/\n.*\n/.test(T.raw));y.loose=C}if(y.loose)for(a=0;a<S;a++)y.items[a].loose=!0;return y}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):At(n[0]);r.type="paragraph",r.text=o,r.tokens=this.lexer.inline(o)}return r}}def(t){const n=this.rules.block.def.exec(t);if(n){const r=n[1].toLowerCase().replace(/\s+/g," "),o=n[2]?n[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline._escapes,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:o,title:s}}}table(t){const n=this.rules.block.table.exec(t);if(n){const r={type:"table",header:rd(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
49
- `):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,l;for(s=0;s<o;s++)/^ *-+: *$/.test(r.align[s])?r.align[s]="right":/^ *:-+: *$/.test(r.align[s])?r.align[s]="center":/^ *:-+ *$/.test(r.align[s])?r.align[s]="left":r.align[s]=null;for(o=r.rows.length,s=0;s<o;s++)r.rows[s]=rd(r.rows[s],r.header.length).map(u=>({text:u}));for(o=r.header.length,i=0;i<o;i++)r.header[i].tokens=this.lexer.inline(r.header[i].text);for(o=r.rows.length,i=0;i<o;i++)for(l=r.rows[i],a=0;a<l.length;a++)l[a].tokens=this.lexer.inline(l[a].text);return r}}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const r=n[1].charAt(n[1].length-1)===`
50
- `?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:r,tokens:this.lexer.inline(r)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:At(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]):At(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=us(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=Lv(n[2],"()");if(i>-1){const l=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,l).trim(),n[3]=""}}let o=n[2],s="";if(this.options.pedantic){const i=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(o);i&&(o=i[1],s=i[3])}else s=n[3]?n[3].slice(1,-1):"";return o=o.trim(),/^</.test(o)&&(this.options.pedantic&&!/>$/.test(r)?o=o.slice(1):o=o.slice(1,-1)),sd(n,{href:o&&o.replace(this.rules.inline._escapes,"$1"),title:s&&s.replace(this.rules.inline._escapes,"$1")},n[0],this.lexer)}}reflink(t,n){let r;if((r=this.rules.inline.reflink.exec(t))||(r=this.rules.inline.nolink.exec(t))){let o=(r[2]||r[1]).replace(/\s+/g," ");if(o=n[o.toLowerCase()],!o){const s=r[0].charAt(0);return{type:"text",raw:s,text:s}}return sd(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,l,u=i,d=0;const f=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*t.length+i);(o=f.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(l=a.length,o[3]||o[4]){u+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(u-=l,u>0)continue;l=Math.min(l,l+u+d);const h=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const v=h.slice(1,-1);return{type:"em",raw:h,text:v,tokens:this.lexer.inlineTokens(v)}}const p=h.slice(2,-2);return{type:"strong",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=At(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=At(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=At(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=At(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=At(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]):At(r[0]):r[0]:o=At(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const Se={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:cs,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Se._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Se._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,Se.def=ot(Se.def).replace("label",Se._label).replace("title",Se._title).getRegex(),Se.bullet=/(?:[*+-]|\d{1,9}[.)])/,Se.listItemStart=ot(/^( *)(bull) */).replace("bull",Se.bullet).getRegex(),Se.list=ot(Se.list).replace(/bull/g,Se.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Se.def.source+")").getRegex(),Se._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",Se._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,Se.html=ot(Se.html,"i").replace("comment",Se._comment).replace("tag",Se._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Se.paragraph=ot(Se._paragraph).replace("hr",Se.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",Se._tag).getRegex(),Se.blockquote=ot(Se.blockquote).replace("paragraph",Se.paragraph).getRegex(),Se.normal={...Se},Se.gfm={...Se.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},Se.gfm.table=ot(Se.gfm.table).replace("hr",Se.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",Se._tag).getRegex(),Se.gfm.paragraph=ot(Se._paragraph).replace("hr",Se.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Se.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",Se._tag).getRegex(),Se.pedantic={...Se.normal,html:ot(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Se._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:cs,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ot(Se.normal._paragraph).replace("hr",Se.hr).replace("heading",` *#{1,6} *[^
51
- ]`).replace("lheading",Se.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ue={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:cs,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:cs,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};ue._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",ue.punctuation=ot(ue.punctuation).replace(/punctuation/g,ue._punctuation).getRegex(),ue.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,ue.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,ue._comment=ot(Se._comment).replace("(?:-->|$)","-->").getRegex(),ue.emStrong.lDelim=ot(ue.emStrong.lDelim).replace(/punct/g,ue._punctuation).getRegex(),ue.emStrong.rDelimAst=ot(ue.emStrong.rDelimAst,"g").replace(/punct/g,ue._punctuation).getRegex(),ue.emStrong.rDelimUnd=ot(ue.emStrong.rDelimUnd,"g").replace(/punct/g,ue._punctuation).getRegex(),ue._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,ue._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,ue._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])?)+(?![-_])/,ue.autolink=ot(ue.autolink).replace("scheme",ue._scheme).replace("email",ue._email).getRegex(),ue._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,ue.tag=ot(ue.tag).replace("comment",ue._comment).replace("attribute",ue._attribute).getRegex(),ue._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ue._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,ue._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ue.link=ot(ue.link).replace("label",ue._label).replace("href",ue._href).replace("title",ue._title).getRegex(),ue.reflink=ot(ue.reflink).replace("label",ue._label).replace("ref",Se._label).getRegex(),ue.nolink=ot(ue.nolink).replace("ref",Se._label).getRegex(),ue.reflinkSearch=ot(ue.reflinkSearch,"g").replace("reflink",ue.reflink).replace("nolink",ue.nolink).getRegex(),ue.normal={...ue},ue.pedantic={...ue.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:ot(/^!?\[(label)\]\((.*?)\)/).replace("label",ue._label).getRegex(),reflink:ot(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ue._label).getRegex()},ue.gfm={...ue.normal,escape:ot(ue.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},ue.gfm.url=ot(ue.gfm.url,"i").replace("email",ue.gfm._extended_email).getRegex(),ue.breaks={...ue.gfm,br:ot(ue.br).replace("{2,}","*").getRegex(),text:ot(ue.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function zv(e){return e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")}function id(e){let t="",n,r;const o=e.length;for(n=0;n<o;n++)r=e.charCodeAt(n),Math.random()>.5&&(r="x"+r.toString(16)),t+="&#"+r+";";return t}class Bn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||ur,this.options.tokenizer=this.options.tokenizer||new ca,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:Se.normal,inline:ue.normal};this.options.pedantic?(n.block=Se.pedantic,n.inline=ue.pedantic):this.options.gfm&&(n.block=Se.gfm,this.options.breaks?n.inline=ue.breaks:n.inline=ue.gfm),this.tokenizer.rules=n}static get rules(){return{block:Se,inline:ue}}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,`
48
+ `,t=t.substring(h.length+1),d=f.slice(i)}}y.loose||(u?y.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),y.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),y.raw+=r}y.items[y.items.length-1].raw=r.trimRight(),y.items[y.items.length-1].text=p.trimRight(),y.raw=y.raw.trimRight();const S=y.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const k=y.items[a].tokens.filter(T=>T.type==="space"),C=k.length>0&&k.some(T=>/\n.*\n/.test(T.raw));y.loose=C}if(y.loose)for(a=0;a<S;a++)y.items[a].loose=!0;return y}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):Rt(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:od(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
49
+ `):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,l;for(s=0;s<o;s++)/^ *-+: *$/.test(r.align[s])?r.align[s]="right":/^ *:-+: *$/.test(r.align[s])?r.align[s]="center":/^ *:-+ *$/.test(r.align[s])?r.align[s]="left":r.align[s]=null;for(o=r.rows.length,s=0;s<o;s++)r.rows[s]=od(r.rows[s],r.header.length).map(u=>({text:u}));for(o=r.header.length,i=0;i<o;i++)r.header[i].tokens=this.lexer.inline(r.header[i].text);for(o=r.rows.length,i=0;i<o;i++)for(l=r.rows[i],a=0;a<l.length;a++)l[a].tokens=this.lexer.inline(l[a].text);return r}}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const r=n[1].charAt(n[1].length-1)===`
50
+ `?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:r,tokens:this.lexer.inline(r)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:Rt(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]):Rt(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=fs(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=$v(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)),id(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 id(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,l,u=i,d=0;const f=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*t.length+i);(o=f.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(l=a.length,o[3]||o[4]){u+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(u-=l,u>0)continue;l=Math.min(l,l+u+d);const h=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const v=h.slice(1,-1);return{type:"em",raw:h,text:v,tokens:this.lexer.inlineTokens(v)}}const p=h.slice(2,-2);return{type:"strong",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=Rt(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=Rt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Rt(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=Rt(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=Rt(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]):Rt(r[0]):r[0]:o=Rt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const Se={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:ds,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Se._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Se._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,Se.def=rt(Se.def).replace("label",Se._label).replace("title",Se._title).getRegex(),Se.bullet=/(?:[*+-]|\d{1,9}[.)])/,Se.listItemStart=rt(/^( *)(bull) */).replace("bull",Se.bullet).getRegex(),Se.list=rt(Se.list).replace(/bull/g,Se.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Se.def.source+")").getRegex(),Se._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",Se._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,Se.html=rt(Se.html,"i").replace("comment",Se._comment).replace("tag",Se._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Se.paragraph=rt(Se._paragraph).replace("hr",Se.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",Se._tag).getRegex(),Se.blockquote=rt(Se.blockquote).replace("paragraph",Se.paragraph).getRegex(),Se.normal={...Se},Se.gfm={...Se.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},Se.gfm.table=rt(Se.gfm.table).replace("hr",Se.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",Se._tag).getRegex(),Se.gfm.paragraph=rt(Se._paragraph).replace("hr",Se.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Se.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",Se._tag).getRegex(),Se.pedantic={...Se.normal,html:rt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Se._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:ds,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:rt(Se.normal._paragraph).replace("hr",Se.hr).replace("heading",` *#{1,6} *[^
51
+ ]`).replace("lheading",Se.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ue={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:ds,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:ds,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};ue._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",ue.punctuation=rt(ue.punctuation).replace(/punctuation/g,ue._punctuation).getRegex(),ue.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,ue.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,ue._comment=rt(Se._comment).replace("(?:-->|$)","-->").getRegex(),ue.emStrong.lDelim=rt(ue.emStrong.lDelim).replace(/punct/g,ue._punctuation).getRegex(),ue.emStrong.rDelimAst=rt(ue.emStrong.rDelimAst,"g").replace(/punct/g,ue._punctuation).getRegex(),ue.emStrong.rDelimUnd=rt(ue.emStrong.rDelimUnd,"g").replace(/punct/g,ue._punctuation).getRegex(),ue._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,ue._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,ue._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])?)+(?![-_])/,ue.autolink=rt(ue.autolink).replace("scheme",ue._scheme).replace("email",ue._email).getRegex(),ue._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,ue.tag=rt(ue.tag).replace("comment",ue._comment).replace("attribute",ue._attribute).getRegex(),ue._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ue._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,ue._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ue.link=rt(ue.link).replace("label",ue._label).replace("href",ue._href).replace("title",ue._title).getRegex(),ue.reflink=rt(ue.reflink).replace("label",ue._label).replace("ref",Se._label).getRegex(),ue.nolink=rt(ue.nolink).replace("ref",Se._label).getRegex(),ue.reflinkSearch=rt(ue.reflinkSearch,"g").replace("reflink",ue.reflink).replace("nolink",ue.nolink).getRegex(),ue.normal={...ue},ue.pedantic={...ue.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:rt(/^!?\[(label)\]\((.*?)\)/).replace("label",ue._label).getRegex(),reflink:rt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ue._label).getRegex()},ue.gfm={...ue.normal,escape:rt(ue.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},ue.gfm.url=rt(ue.gfm.url,"i").replace("email",ue.gfm._extended_email).getRegex(),ue.breaks={...ue.gfm,br:rt(ue.br).replace("{2,}","*").getRegex(),text:rt(ue.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function Bv(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 ad(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 Wn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||fr,this.options.tokenizer=this.options.tokenizer||new ua,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:Se.normal,inline:ue.normal};this.options.pedantic?(n.block=Se.pedantic,n.inline=ue.pedantic):this.options.gfm&&(n.block=Se.gfm,this.options.breaks?n.inline=ue.breaks:n.inline=ue.gfm),this.tokenizer.rules=n}static get rules(){return{block:Se,inline:ue}}static lex(t,n){return new Wn(n).lex(t)}static lexInline(t,n){return new Wn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
52
52
  `),this.blockTokens(t,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(t,n=[]){this.options.pedantic?t=t.replace(/\t/g," ").replace(/^ +$/gm,""):t=t.replace(/^( *)(\t+)/gm,(a,l,u)=>l+" ".repeat(u.length));let r,o,s,i;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(r=a.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=`
53
53
  `:n.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&(o.type==="paragraph"||o.type==="text")?(o.raw+=`
54
54
  `+r.raw,o.text+=`
@@ -58,9 +58,9 @@ React keys must be passed directly to JSX without using spread:
58
58
  `+r.raw,o.text+=`
59
59
  `+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r),i=s.length!==t.length,t=t.substring(r.raw.length);continue}if(r=this.tokenizer.text(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&o.type==="text"?(o.raw+=`
60
60
  `+r.raw,o.text+=`
61
- `+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,l,u;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+od("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)i=i.slice(0,a.index)+"["+od("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.escapedEmSt.exec(i))!=null;)i=i.slice(0,a.index+a[0].length-2)+"++"+i.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;t;)if(l||(u=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(t,i,u)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(t,id)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,id))){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const f=t.slice(1);let h;this.options.extensions.startInline.forEach(function(p){h=p.call({lexer:this},f),typeof h=="number"&&h>=0&&(d=Math.min(d,h))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,zv)){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 ua{constructor(t){this.options=t||ur}code(t,n,r){const o=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(t,o);s!=null&&s!==t&&(r=!0,t=s)}return t=t.replace(/\n$/,"")+`
62
- `,o?'<pre><code class="'+this.options.langPrefix+At(o)+'">'+(r?t:At(t,!0))+`</code></pre>
63
- `:"<pre><code>"+(r?t:At(t,!0))+`</code></pre>
61
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,l,u;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+sd("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)+"["+sd("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,ad)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,ad))){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,Bv)){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 da{constructor(t){this.options=t||fr}code(t,n,r){const o=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(t,o);s!=null&&s!==t&&(r=!0,t=s)}return t=t.replace(/\n$/,"")+`
62
+ `,o?'<pre><code class="'+this.options.langPrefix+Rt(o)+'">'+(r?t:Rt(t,!0))+`</code></pre>
63
+ `:"<pre><code>"+(r?t:Rt(t,!0))+`</code></pre>
64
64
  `}blockquote(t){return`<blockquote>
65
65
  ${t}</blockquote>
66
66
  `}html(t){return t}heading(t,n,r,o){if(this.options.headerIds){const s=this.options.headerPrefix+o.slug(r);return`<h${n} id="${s}">${t}</h${n}>
@@ -78,14 +78,14 @@ ${t}</blockquote>
78
78
  `}tablerow(t){return`<tr>
79
79
  ${t}</tr>
80
80
  `}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
81
- `}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=nd(this.options.sanitize,this.options.baseUrl,t),t===null)return r;let o='<a href="'+t+'"';return n&&(o+=' title="'+n+'"'),o+=">"+r+"</a>",o}image(t,n,r){if(t=nd(this.options.sanitize,this.options.baseUrl,t),t===null)return r;let o=`<img src="${t}" alt="${r}"`;return n&&(o+=` title="${n}"`),o+=this.options.xhtml?"/>":">",o}text(t){return t}}class ad{strong(t){return t}em(t){return t}codespan(t){return t}del(t){return t}html(t){return t}text(t){return t}link(t,n,r){return""+r}image(t,n,r){return""+r}br(){return""}}class ld{constructor(){this.seen={}}serialize(t){return t.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(t,n){let r=t,o=0;if(this.seen.hasOwnProperty(r)){o=this.seen[t];do o++,r=t+"-"+o;while(this.seen.hasOwnProperty(r))}return n||(this.seen[t]=o,this.seen[r]=0),r}slug(t,n={}){const r=this.serialize(t);return this.getNextSafeSlug(r,n.dryrun)}}class Hn{constructor(t){this.options=t||ur,this.options.renderer=this.options.renderer||new ua,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new ad,this.slugger=new ld}static parse(t,n){return new Hn(n).parse(t)}static parseInline(t,n){return new Hn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,u,d,f,h,p,v,x,g,y,b,S,k,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,td(this.parseInline(p.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(p.text,p.lang,p.escaped);continue}case"table":{for(f="",d="",a=p.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(p.header[s].tokens),{header:!0,align:p.align[s]});for(f+=this.renderer.tablerow(d),h="",a=p.rows.length,s=0;s<a;s++){for(u=p.rows[s],d="",l=u.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(u[i].tokens),{header:!1,align:p.align[i]});h+=this.renderer.tablerow(d)}r+=this.renderer.table(f,h);continue}case"blockquote":{h=this.parse(p.tokens),r+=this.renderer.blockquote(h);continue}case"list":{for(v=p.ordered,x=p.start,g=p.loose,a=p.items.length,h="",s=0;s<a;s++)b=p.items[s],S=b.checked,k=b.task,y="",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}):y+=C),y+=this.parse(b.tokens,g),h+=this.renderer.listitem(y,k,S);r+=this.renderer.list(h,v,x);continue}case"html":{r+=this.renderer.html(p.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(p.tokens));continue}case"text":{for(h=p.tokens?this.parseInline(p.tokens):p.text;o+1<I&&t[o+1].type==="text";)p=t[++o],h+=`
82
- `+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const 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 ds{constructor(t){this.options=t||ur}preprocess(t){return t}postprocess(t){return t}}Sm(ds,"passThroughHooks",new Set(["preprocess","postprocess"]));function Bv(e,t,n){return r=>{if(r.message+=`
83
- Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+At(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function cd(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...Ce.defaults,...s};const i=Bv(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($v(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&&Ce.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;Ce.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(Ce.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&&Ce.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function Ce(e,t,n){return cd(Bn.lex,Hn.parse)(e,t,n)}Ce.options=Ce.setOptions=function(e){return Ce.defaults={...Ce.defaults,...e},kv(Ce.defaults),Ce},Ce.getDefaults=Ju,Ce.defaults=ur,Ce.use=function(...e){const t=Ce.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=Ce.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=Ce.defaults.renderer||new ua;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=Ce.defaults.tokenizer||new ca;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=Ce.defaults.hooks||new ds;for(const s in n.hooks){const i=o[s];ds.passThroughHooks.has(s)?o[s]=a=>{if(Ce.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=Ce.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}}Ce.setOptions(r)})},Ce.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(Ce,r)),r.type){case"table":{for(const o of r.header)n=n.concat(Ce.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(Ce.walkTokens(s.tokens,t));break}case"list":{n=n.concat(Ce.walkTokens(r.items,t));break}default:Ce.defaults.extensions&&Ce.defaults.extensions.childTokens&&Ce.defaults.extensions.childTokens[r.type]?Ce.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(Ce.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(Ce.walkTokens(r.tokens,t)))}return n},Ce.parseInline=cd(Bn.lexInline,Hn.parseInline),Ce.Parser=Hn,Ce.parser=Hn.parse,Ce.Renderer=ua,Ce.TextRenderer=ad,Ce.Lexer=Bn,Ce.lexer=Bn.lex,Ce.Tokenizer=ca,Ce.Slugger=ld,Ce.Hooks=ds,Ce.parse=Ce,Ce.options,Ce.setOptions,Ce.use,Ce.walkTokens,Ce.parseInline,Hn.parse,Bn.lex;function da({content:e,className:t="",allowHtml:n=!1,style:r}){const o=w.useMemo(()=>{try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return Ce.parse(i)}return Ce.parse(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre>Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=w.useMemo(()=>{if(r&&r.color){const i=r.color;return{...r,"--tw-prose-body":i,"--tw-prose-headings":i,"--tw-prose-links":i,"--tw-prose-bold":i,"--tw-prose-counters":i,"--tw-prose-bullets":i,"--tw-prose-hr":i,"--tw-prose-quotes":i,"--tw-prose-quote-borders":i,"--tw-prose-captions":i,"--tw-prose-code":i,"--tw-prose-pre-code":i,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":i,"--tw-prose-td-borders":i}}return r},[r]);return c.jsx("div",{className:ee("markdown prose max-w-none break-words dark:prose-invert",t),style:s,dangerouslySetInnerHTML:{__html:o}})}async function ud(e,t){return await fn(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function dd(e,t){return await(await ud(`/files/${e}/view`,t)).text()}async function Hv(e,t){const n=await ud(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await fn(`/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 Uv(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await fn("/files",{params:r})}const Wv=1,Vv=1e6;let fa=0;function Kv(){return fa=(fa+1)%Number.MAX_SAFE_INTEGER,fa.toString()}const ha=new Map,fd=e=>{if(ha.has(e))return;const t=setTimeout(()=>{ha.delete(e),fo({type:"REMOVE_TOAST",toastId:e})},Vv);ha.set(e,t)},qv=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Wv)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?fd(n):e.toasts.forEach(r=>{fd(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},fs=[];let hs={toasts:[]};function fo(e){hs=qv(hs,e),fs.forEach(t=>{t(hs)})}function Gv({...e}){const t=Kv(),n=o=>fo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>fo({type:"DISMISS_TOAST",toastId:t});return fo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function pa(){const[e,t]=m.useState(hs);return m.useEffect(()=>(fs.push(t),()=>{const n=fs.indexOf(t);n>-1&&fs.splice(n,1)}),[e]),{...e,toast:Gv,dismiss:n=>fo({type:"DISMISS_TOAST",toastId:n})}}function Tt(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 Yv(e,t=globalThis==null?void 0:globalThis.document){const n=Tt(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 Xv="DismissableLayer",ma="dismissableLayer.update",Jv="dismissableLayer.pointerDownOutside",Zv="dismissableLayer.focusOutside",hd,pd=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ps=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=m.useContext(pd),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),v=We(t,I=>f(I)),x=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=x.indexOf(g),b=d?x.indexOf(d):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,k=b>=y,C=tb(I=>{const A=I.target,j=[...u.branches].some(P=>P.contains(A));!k||j||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},h),T=nb(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 Yv(I=>{b===u.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},h),m.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(hd=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),md(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=hd)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),md())},[d,u]),m.useEffect(()=>{const I=()=>p({});return document.addEventListener(ma,I),()=>document.removeEventListener(ma,I)},[]),c.jsx(Ae.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:fe(e.onFocusCapture,T.onFocusCapture),onBlurCapture:fe(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:fe(e.onPointerDownCapture,C.onPointerDownCapture)})});ps.displayName=Xv;var Qv="DismissableLayerBranch",eb=m.forwardRef((e,t)=>{const n=m.useContext(pd),r=m.useRef(null),o=We(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(Ae.div,{...e,ref:o})});eb.displayName=Qv;function tb(e,t=globalThis==null?void 0:globalThis.document){const n=Tt(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){gd(Jv,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 nb(e,t=globalThis==null?void 0:globalThis.document){const n=Tt(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&gd(Zv,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function md(){const e=new CustomEvent(ma);document.dispatchEvent(e)}function gd(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Uu(o,s):o.dispatchEvent(s)}var ga="focusScope.autoFocusOnMount",xa="focusScope.autoFocusOnUnmount",xd={bubbles:!1,cancelable:!0},rb="FocusScope",ms=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=m.useState(null),u=Tt(o),d=Tt(s),f=m.useRef(null),h=We(t,x=>l(x)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let x=function(S){if(p.paused||!a)return;const k=S.target;a.contains(k)?f.current=k:Un(f.current,{select:!0})},g=function(S){if(p.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||Un(f.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Un(a)};document.addEventListener("focusin",x),document.addEventListener("focusout",g);const b=new MutationObserver(y);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",g),b.disconnect()}}},[r,a,p.paused]),m.useEffect(()=>{if(a){bd.add(p);const x=document.activeElement;if(!a.contains(x)){const y=new CustomEvent(ga,xd);a.addEventListener(ga,u),a.dispatchEvent(y),y.defaultPrevented||(ob(cb(yd(a)),{select:!0}),document.activeElement===x&&Un(a))}return()=>{a.removeEventListener(ga,u),setTimeout(()=>{const y=new CustomEvent(xa,xd);a.addEventListener(xa,d),a.dispatchEvent(y),y.defaultPrevented||Un(x??document.body,{select:!0}),a.removeEventListener(xa,d),bd.remove(p)},0)}}},[a,u,d,p]);const v=m.useCallback(x=>{if(!n&&!r||p.paused)return;const g=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,y=document.activeElement;if(g&&y){const b=x.currentTarget,[S,k]=sb(b);S&&k?!x.shiftKey&&y===k?(x.preventDefault(),n&&Un(S,{select:!0})):x.shiftKey&&y===S&&(x.preventDefault(),n&&Un(k,{select:!0})):y===b&&x.preventDefault()}},[n,r,p.paused]);return c.jsx(Ae.div,{tabIndex:-1,...i,ref:h,onKeyDown:v})});ms.displayName=rb;function ob(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Un(r,{select:t}),document.activeElement!==n)return}function sb(e){const t=yd(e),n=vd(t,e),r=vd(t.reverse(),e);return[n,r]}function yd(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function vd(e,t){for(const n of e)if(!ib(n,{upTo:t}))return n}function ib(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 ab(e){return e instanceof HTMLInputElement&&"select"in e}function Un(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&ab(e)&&t&&e.select()}}var bd=lb();function lb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=wd(e,t),e.unshift(t)},remove(t){var n;e=wd(e,t),(n=e[0])==null||n.resume()}}}function wd(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function cb(e){return e.filter(t=>t.tagName!=="A")}var ub="Portal",gs=m.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=m.useState(!1);wt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?li.createPortal(c.jsx(Ae.div,{...r,ref:t}),i):null});gs.displayName=ub;var ya=0;function va(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Sd()),document.body.insertAdjacentElement("beforeend",e[1]??Sd()),ya++,()=>{ya===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),ya--}},[])}function Sd(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var yn=function(){return yn=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},yn.apply(this,arguments)};function Cd(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function db(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 xs="right-scroll-bar-position",ys="width-before-scroll-bar",fb="with-scroll-bars-hidden",hb="--removed-body-scroll-bar-size";function ba(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function pb(e,t){var n=w.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var mb=typeof window<"u"?m.useLayoutEffect:m.useEffect,Td=new WeakMap;function gb(e,t){var n=pb(null,function(r){return e.forEach(function(o){return ba(o,r)})});return mb(function(){var r=Td.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||ba(a,null)}),s.forEach(function(a){o.has(a)||ba(a,i)})}Td.set(n,e)},[e]),n}function xb(e){return e}function yb(e,t){t===void 0&&(t=xb);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 vb(e){e===void 0&&(e={});var t=yb(null);return t.options=yn({async:!0,ssr:!1},e),t}var kd=function(e){var t=e.sideCar,n=Cd(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return m.createElement(r,yn({},n))};kd.isSideCarExport=!0;function bb(e,t){return e.useMedium(t),kd}var Ed=vb(),wa=function(){},vs=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:wa,onWheelCapture:wa,onTouchMoveCapture:wa}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,p=e.noRelative,v=e.noIsolation,x=e.inert,g=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,S=e.gapMode,k=Cd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,T=gb([n,t]),I=yn(yn({},k),o);return m.createElement(m.Fragment,null,d&&m.createElement(C,{sideCar:Ed,removeScrollBar:u,shards:f,noRelative:p,noIsolation:v,inert:x,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:S}),i?m.cloneElement(m.Children.only(a),yn(yn({},I),{ref:T})):m.createElement(b,yn({},I,{className:l,ref:T}),a))});vs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},vs.classNames={fullWidth:ys,zeroRight:xs};var wb=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Sb(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=wb();return t&&e.setAttribute("nonce",t),e}function Cb(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Tb(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var kb=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Sb())&&(Cb(t,n),Tb(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Eb=function(){var e=kb();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Id=function(){var e=Eb(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Ib={left:0,top:0,right:0,gap:0},Sa=function(e){return parseInt(e||"",10)||0},Nb=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[Sa(n),Sa(r),Sa(o)]},Ab=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Ib;var t=Nb(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])}},_b=Id(),jr="data-scroll-locked",jb=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
84
- .`.concat(fb,` {
81
+ `}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=rd(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=rd(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 ld{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 cd{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 Vn{constructor(t){this.options=t||fr,this.options.renderer=this.options.renderer||new da,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new ld,this.slugger=new cd}static parse(t,n){return new Vn(n).parse(t)}static parseInline(t,n){return new Vn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,u,d,f,h,p,v,x,g,y,b,S,k,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,nd(this.parseInline(p.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(p.text,p.lang,p.escaped);continue}case"table":{for(f="",d="",a=p.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(p.header[s].tokens),{header:!0,align:p.align[s]});for(f+=this.renderer.tablerow(d),h="",a=p.rows.length,s=0;s<a;s++){for(u=p.rows[s],d="",l=u.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(u[i].tokens),{header:!1,align:p.align[i]});h+=this.renderer.tablerow(d)}r+=this.renderer.table(f,h);continue}case"blockquote":{h=this.parse(p.tokens),r+=this.renderer.blockquote(h);continue}case"list":{for(v=p.ordered,x=p.start,g=p.loose,a=p.items.length,h="",s=0;s<a;s++)b=p.items[s],S=b.checked,k=b.task,y="",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}):y+=C),y+=this.parse(b.tokens,g),h+=this.renderer.listitem(y,k,S);r+=this.renderer.list(h,v,x);continue}case"html":{r+=this.renderer.html(p.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(p.tokens));continue}case"text":{for(h=p.tokens?this.parseInline(p.tokens):p.text;o+1<I&&t[o+1].type==="text";)p=t[++o],h+=`
82
+ `+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const 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 hs{constructor(t){this.options=t||fr}preprocess(t){return t}postprocess(t){return t}}Cm(hs,"passThroughHooks",new Set(["preprocess","postprocess"]));function Hv(e,t,n){return r=>{if(r.message+=`
83
+ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Rt(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 ud(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...Ce.defaults,...s};const i=Hv(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(Fv(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&&Ce.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;Ce.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(Ce.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&&Ce.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function Ce(e,t,n){return ud(Wn.lex,Vn.parse)(e,t,n)}Ce.options=Ce.setOptions=function(e){return Ce.defaults={...Ce.defaults,...e},Ev(Ce.defaults),Ce},Ce.getDefaults=Zu,Ce.defaults=fr,Ce.use=function(...e){const t=Ce.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=Ce.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=Ce.defaults.renderer||new da;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=Ce.defaults.tokenizer||new ua;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=Ce.defaults.hooks||new hs;for(const s in n.hooks){const i=o[s];hs.passThroughHooks.has(s)?o[s]=a=>{if(Ce.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=Ce.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}}Ce.setOptions(r)})},Ce.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(Ce,r)),r.type){case"table":{for(const o of r.header)n=n.concat(Ce.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(Ce.walkTokens(s.tokens,t));break}case"list":{n=n.concat(Ce.walkTokens(r.items,t));break}default:Ce.defaults.extensions&&Ce.defaults.extensions.childTokens&&Ce.defaults.extensions.childTokens[r.type]?Ce.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(Ce.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(Ce.walkTokens(r.tokens,t)))}return n},Ce.parseInline=ud(Wn.lexInline,Vn.parseInline),Ce.Parser=Vn,Ce.parser=Vn.parse,Ce.Renderer=da,Ce.TextRenderer=ld,Ce.Lexer=Wn,Ce.lexer=Wn.lex,Ce.Tokenizer=ua,Ce.Slugger=cd,Ce.Hooks=hs,Ce.parse=Ce,Ce.options,Ce.setOptions,Ce.use,Ce.walkTokens,Ce.parseInline,Vn.parse,Wn.lex;function fa({content:e,className:t="",allowHtml:n=!1,style:r}){const o=w.useMemo(()=>{try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return Ce.parse(i)}return Ce.parse(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre>Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=w.useMemo(()=>{if(r&&r.color){const i=r.color;return{...r,"--tw-prose-body":i,"--tw-prose-headings":i,"--tw-prose-links":i,"--tw-prose-bold":i,"--tw-prose-counters":i,"--tw-prose-bullets":i,"--tw-prose-hr":i,"--tw-prose-quotes":i,"--tw-prose-quote-borders":i,"--tw-prose-captions":i,"--tw-prose-code":i,"--tw-prose-pre-code":i,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":i,"--tw-prose-td-borders":i}}return r},[r]);return c.jsx("div",{className:ee("markdown prose max-w-none break-words dark:prose-invert",t),style:s,dangerouslySetInnerHTML:{__html:o}})}async function dd(e,t){return await pn(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function fd(e,t){return await(await dd(`/files/${e}/view`,t)).text()}async function Uv(e,t){const n=await dd(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await pn(`/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 Wv(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await pn("/files",{params:r})}const Vv=1,Kv=1e6;let ha=0;function qv(){return ha=(ha+1)%Number.MAX_SAFE_INTEGER,ha.toString()}const pa=new Map,hd=e=>{if(pa.has(e))return;const t=setTimeout(()=>{pa.delete(e),po({type:"REMOVE_TOAST",toastId:e})},Kv);pa.set(e,t)},Gv=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Vv)};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?hd(n):e.toasts.forEach(r=>{hd(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)}}},ps=[];let ms={toasts:[]};function po(e){ms=Gv(ms,e),ps.forEach(t=>{t(ms)})}function Yv({...e}){const t=qv(),n=o=>po({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>po({type:"DISMISS_TOAST",toastId:t});return po({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function ma(){const[e,t]=m.useState(ms);return m.useEffect(()=>(ps.push(t),()=>{const n=ps.indexOf(t);n>-1&&ps.splice(n,1)}),[e]),{...e,toast:Yv,dismiss:n=>po({type:"DISMISS_TOAST",toastId:n})}}function Tt(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 Xv(e,t=globalThis==null?void 0:globalThis.document){const n=Tt(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 Jv="DismissableLayer",ga="dismissableLayer.update",Zv="dismissableLayer.pointerDownOutside",Qv="dismissableLayer.focusOutside",pd,md=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),gs=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=m.useContext(md),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),v=Ue(t,I=>f(I)),x=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=x.indexOf(g),b=d?x.indexOf(d):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,k=b>=y,C=nb(I=>{const A=I.target,j=[...u.branches].some(P=>P.contains(A));!k||j||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},h),T=rb(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 Xv(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&&(pd=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),gd(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=pd)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),gd())},[d,u]),m.useEffect(()=>{const I=()=>p({});return document.addEventListener(ga,I),()=>document.removeEventListener(ga,I)},[]),c.jsx(Ae.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:fe(e.onFocusCapture,T.onFocusCapture),onBlurCapture:fe(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:fe(e.onPointerDownCapture,C.onPointerDownCapture)})});gs.displayName=Jv;var eb="DismissableLayerBranch",tb=m.forwardRef((e,t)=>{const n=m.useContext(md),r=m.useRef(null),o=Ue(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(Ae.div,{...e,ref:o})});tb.displayName=eb;function nb(e,t=globalThis==null?void 0:globalThis.document){const n=Tt(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){xd(Zv,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 rb(e,t=globalThis==null?void 0:globalThis.document){const n=Tt(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&xd(Qv,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 gd(){const e=new CustomEvent(ga);document.dispatchEvent(e)}function xd(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?Wu(o,s):o.dispatchEvent(s)}var xa="focusScope.autoFocusOnMount",ya="focusScope.autoFocusOnUnmount",yd={bubbles:!1,cancelable:!0},ob="FocusScope",xs=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=m.useState(null),u=Tt(o),d=Tt(s),f=m.useRef(null),h=Ue(t,x=>l(x)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let x=function(S){if(p.paused||!a)return;const k=S.target;a.contains(k)?f.current=k:Kn(f.current,{select:!0})},g=function(S){if(p.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||Kn(f.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Kn(a)};document.addEventListener("focusin",x),document.addEventListener("focusout",g);const b=new MutationObserver(y);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",g),b.disconnect()}}},[r,a,p.paused]),m.useEffect(()=>{if(a){wd.add(p);const x=document.activeElement;if(!a.contains(x)){const y=new CustomEvent(xa,yd);a.addEventListener(xa,u),a.dispatchEvent(y),y.defaultPrevented||(sb(ub(vd(a)),{select:!0}),document.activeElement===x&&Kn(a))}return()=>{a.removeEventListener(xa,u),setTimeout(()=>{const y=new CustomEvent(ya,yd);a.addEventListener(ya,d),a.dispatchEvent(y),y.defaultPrevented||Kn(x??document.body,{select:!0}),a.removeEventListener(ya,d),wd.remove(p)},0)}}},[a,u,d,p]);const v=m.useCallback(x=>{if(!n&&!r||p.paused)return;const g=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,y=document.activeElement;if(g&&y){const b=x.currentTarget,[S,k]=ib(b);S&&k?!x.shiftKey&&y===k?(x.preventDefault(),n&&Kn(S,{select:!0})):x.shiftKey&&y===S&&(x.preventDefault(),n&&Kn(k,{select:!0})):y===b&&x.preventDefault()}},[n,r,p.paused]);return c.jsx(Ae.div,{tabIndex:-1,...i,ref:h,onKeyDown:v})});xs.displayName=ob;function sb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Kn(r,{select:t}),document.activeElement!==n)return}function ib(e){const t=vd(e),n=bd(t,e),r=bd(t.reverse(),e);return[n,r]}function vd(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 bd(e,t){for(const n of e)if(!ab(n,{upTo:t}))return n}function ab(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 lb(e){return e instanceof HTMLInputElement&&"select"in e}function Kn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&lb(e)&&t&&e.select()}}var wd=cb();function cb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Sd(e,t),e.unshift(t)},remove(t){var n;e=Sd(e,t),(n=e[0])==null||n.resume()}}}function Sd(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ub(e){return e.filter(t=>t.tagName!=="A")}var db="Portal",ys=m.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=m.useState(!1);wt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?ci.createPortal(c.jsx(Ae.div,{...r,ref:t}),i):null});ys.displayName=db;var va=0;function ba(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Cd()),document.body.insertAdjacentElement("beforeend",e[1]??Cd()),va++,()=>{va===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),va--}},[])}function Cd(){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 bn=function(){return bn=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},bn.apply(this,arguments)};function Td(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 fb(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 vs="right-scroll-bar-position",bs="width-before-scroll-bar",hb="with-scroll-bars-hidden",pb="--removed-body-scroll-bar-size";function wa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function mb(e,t){var n=w.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var gb=typeof window<"u"?m.useLayoutEffect:m.useEffect,kd=new WeakMap;function xb(e,t){var n=mb(null,function(r){return e.forEach(function(o){return wa(o,r)})});return gb(function(){var r=kd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||wa(a,null)}),s.forEach(function(a){o.has(a)||wa(a,i)})}kd.set(n,e)},[e]),n}function yb(e){return e}function vb(e,t){t===void 0&&(t=yb);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 bb(e){e===void 0&&(e={});var t=vb(null);return t.options=bn({async:!0,ssr:!1},e),t}var Ed=function(e){var t=e.sideCar,n=Td(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,bn({},n))};Ed.isSideCarExport=!0;function wb(e,t){return e.useMedium(t),Ed}var Id=bb(),Sa=function(){},ws=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:Sa,onWheelCapture:Sa,onTouchMoveCapture:Sa}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,p=e.noRelative,v=e.noIsolation,x=e.inert,g=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,S=e.gapMode,k=Td(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,T=xb([n,t]),I=bn(bn({},k),o);return m.createElement(m.Fragment,null,d&&m.createElement(C,{sideCar:Id,removeScrollBar:u,shards:f,noRelative:p,noIsolation:v,inert:x,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:S}),i?m.cloneElement(m.Children.only(a),bn(bn({},I),{ref:T})):m.createElement(b,bn({},I,{className:l,ref:T}),a))});ws.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ws.classNames={fullWidth:bs,zeroRight:vs};var Sb=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Cb(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Sb();return t&&e.setAttribute("nonce",t),e}function Tb(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function kb(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Eb=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Cb())&&(Tb(t,n),kb(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Ib=function(){var e=Eb();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Nd=function(){var e=Ib(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Nb={left:0,top:0,right:0,gap:0},Ca=function(e){return parseInt(e||"",10)||0},Ab=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[Ca(n),Ca(r),Ca(o)]},_b=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Nb;var t=Ab(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])}},jb=Nd(),Rr="data-scroll-locked",Rb=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
84
+ .`.concat(hb,` {
85
85
  overflow: hidden `).concat(r,`;
86
86
  padding-right: `).concat(a,"px ").concat(r,`;
87
87
  }
88
- body[`).concat(jr,`] {
88
+ body[`).concat(Rr,`] {
89
89
  overflow: hidden `).concat(r,`;
90
90
  overscroll-behavior: contain;
91
91
  `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
@@ -98,37 +98,37 @@ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An err
98
98
  `),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
99
99
  }
100
100
 
101
- .`).concat(xs,` {
101
+ .`).concat(vs,` {
102
102
  right: `).concat(a,"px ").concat(r,`;
103
103
  }
104
104
 
105
- .`).concat(ys,` {
105
+ .`).concat(bs,` {
106
106
  margin-right: `).concat(a,"px ").concat(r,`;
107
107
  }
108
108
 
109
- .`).concat(xs," .").concat(xs,` {
109
+ .`).concat(vs," .").concat(vs,` {
110
110
  right: 0 `).concat(r,`;
111
111
  }
112
112
 
113
- .`).concat(ys," .").concat(ys,` {
113
+ .`).concat(bs," .").concat(bs,` {
114
114
  margin-right: 0 `).concat(r,`;
115
115
  }
116
116
 
117
- body[`).concat(jr,`] {
118
- `).concat(hb,": ").concat(a,`px;
117
+ body[`).concat(Rr,`] {
118
+ `).concat(pb,": ").concat(a,`px;
119
119
  }
120
- `)},Nd=function(){var e=parseInt(document.body.getAttribute(jr)||"0",10);return isFinite(e)?e:0},Rb=function(){m.useEffect(function(){return document.body.setAttribute(jr,(Nd()+1).toString()),function(){var e=Nd()-1;e<=0?document.body.removeAttribute(jr):document.body.setAttribute(jr,e.toString())}},[])},Pb=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Rb();var s=m.useMemo(function(){return Ab(o)},[o]);return m.createElement(_b,{styles:jb(s,!t,o,n?"":"!important")})},Ca=!1;if(typeof window<"u")try{var bs=Object.defineProperty({},"passive",{get:function(){return Ca=!0,!0}});window.addEventListener("test",bs,bs),window.removeEventListener("test",bs,bs)}catch{Ca=!1}var Rr=Ca?{passive:!1}:!1,Ob=function(e){return e.tagName==="TEXTAREA"},Ad=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Ob(e)&&n[t]==="visible")},Mb=function(e){return Ad(e,"overflowY")},Db=function(e){return Ad(e,"overflowX")},_d=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=jd(e,r);if(o){var s=Rd(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Lb=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},$b=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},jd=function(e,t){return e==="v"?Mb(t):Db(t)},Rd=function(e,t){return e==="v"?Lb(t):$b(t)},Fb=function(e,t){return e==="h"&&t==="rtl"?-1:1},zb=function(e,t,n,r,o){var s=Fb(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),u=!1,d=i>0,f=0,h=0;do{if(!a)break;var p=Rd(e,a),v=p[0],x=p[1],g=p[2],y=x-g-s*v;(v||y)&&jd(e,a)&&(f+=y,h+=v);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},ws=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Pd=function(e){return[e.deltaX,e.deltaY]},Od=function(e){return e&&"current"in e?e.current:e},Bb=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Hb=function(e){return`
120
+ `)},Ad=function(){var e=parseInt(document.body.getAttribute(Rr)||"0",10);return isFinite(e)?e:0},Pb=function(){m.useEffect(function(){return document.body.setAttribute(Rr,(Ad()+1).toString()),function(){var e=Ad()-1;e<=0?document.body.removeAttribute(Rr):document.body.setAttribute(Rr,e.toString())}},[])},Ob=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Pb();var s=m.useMemo(function(){return _b(o)},[o]);return m.createElement(jb,{styles:Rb(s,!t,o,n?"":"!important")})},Ta=!1;if(typeof window<"u")try{var Ss=Object.defineProperty({},"passive",{get:function(){return Ta=!0,!0}});window.addEventListener("test",Ss,Ss),window.removeEventListener("test",Ss,Ss)}catch{Ta=!1}var Pr=Ta?{passive:!1}:!1,Mb=function(e){return e.tagName==="TEXTAREA"},_d=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Mb(e)&&n[t]==="visible")},Db=function(e){return _d(e,"overflowY")},Lb=function(e){return _d(e,"overflowX")},jd=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Rd(e,r);if(o){var s=Pd(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},$b=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Fb=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Rd=function(e,t){return e==="v"?Db(t):Lb(t)},Pd=function(e,t){return e==="v"?$b(t):Fb(t)},zb=function(e,t){return e==="h"&&t==="rtl"?-1:1},Bb=function(e,t,n,r,o){var s=zb(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=Pd(e,a),v=p[0],x=p[1],g=p[2],y=x-g-s*v;(v||y)&&Rd(e,a)&&(f+=y,h+=v);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},Cs=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Od=function(e){return[e.deltaX,e.deltaY]},Md=function(e){return e&&"current"in e?e.current:e},Hb=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Ub=function(e){return`
121
121
  .block-interactivity-`.concat(e,` {pointer-events: none;}
122
122
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
123
- `)},Ub=0,Pr=[];function Wb(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(Ub++)[0],s=m.useState(Id)[0],i=m.useRef(e);m.useEffect(function(){i.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var x=db([e.lockRef.current],(e.shards||[]).map(Od),!0).filter(Boolean);return x.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),x.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=m.useCallback(function(x,g){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var y=ws(x),b=n.current,S="deltaX"in x?x.deltaX:b[0]-y[0],k="deltaY"in x?x.deltaY:b[1]-y[1],C,T=x.target,I=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in x&&I==="h"&&T.type==="range")return!1;var A=_d(I,T);if(!A)return!0;if(A?C=I:(C=I==="v"?"h":"v",A=_d(I,T)),!A)return!1;if(!r.current&&"changedTouches"in x&&(S||k)&&(r.current=C),!C)return!0;var j=r.current||C;return zb(j,g,x,j==="h"?S:k)},[]),l=m.useCallback(function(x){var g=x;if(!(!Pr.length||Pr[Pr.length-1]!==s)){var y="deltaY"in g?Pd(g):ws(g),b=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&Bb(C.delta,y)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Od).filter(Boolean).filter(function(C){return C.contains(g.target)}),k=S.length>0?a(g,S[0]):!i.current.noIsolation;k&&g.cancelable&&g.preventDefault()}}},[]),u=m.useCallback(function(x,g,y,b){var S={name:x,delta:g,target:y,should:b,shadowParent:Vb(y)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=m.useCallback(function(x){n.current=ws(x),r.current=void 0},[]),f=m.useCallback(function(x){u(x.type,Pd(x),x.target,a(x,e.lockRef.current))},[]),h=m.useCallback(function(x){u(x.type,ws(x),x.target,a(x,e.lockRef.current))},[]);m.useEffect(function(){return Pr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,Rr),document.addEventListener("touchmove",l,Rr),document.addEventListener("touchstart",d,Rr),function(){Pr=Pr.filter(function(x){return x!==s}),document.removeEventListener("wheel",l,Rr),document.removeEventListener("touchmove",l,Rr),document.removeEventListener("touchstart",d,Rr)}},[]);var p=e.removeScrollBar,v=e.inert;return m.createElement(m.Fragment,null,v?m.createElement(s,{styles:Hb(o)}):null,p?m.createElement(Pb,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Vb(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Kb=bb(Ed,Wb);var Ss=m.forwardRef(function(e,t){return m.createElement(vs,yn({},e,{ref:t,sideCar:Kb}))});Ss.classNames=vs.classNames;var qb=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Or=new WeakMap,Cs=new WeakMap,Ts={},Ta=0,Md=function(e){return e&&(e.host||Md(e.parentNode))},Gb=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Md(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Yb=function(e,t,n,r){var o=Gb(t,Array.isArray(e)?e:[e]);Ts[n]||(Ts[n]=new WeakMap);var s=Ts[n],i=[],a=new Set,l=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var d=function(f){!f||l.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))d(h);else try{var p=h.getAttribute(r),v=p!==null&&p!=="false",x=(Or.get(h)||0)+1,g=(s.get(h)||0)+1;Or.set(h,x),s.set(h,g),i.push(h),x===1&&v&&Cs.set(h,!0),g===1&&h.setAttribute(n,"true"),v||h.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",h,y)}})};return d(t),a.clear(),Ta++,function(){i.forEach(function(f){var h=Or.get(f)-1,p=s.get(f)-1;Or.set(f,h),s.set(f,p),h||(Cs.has(f)||f.removeAttribute(r),Cs.delete(f)),p||f.removeAttribute(n)}),Ta--,Ta||(Or=new WeakMap,Or=new WeakMap,Cs=new WeakMap,Ts={})}},ka=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=qb(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Yb(r,o,n,"aria-hidden")):function(){return null}},ks="Dialog",[Dd,ok]=gn(ks),[Xb,an]=Dd(ks),Ld=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=m.useRef(null),l=m.useRef(null),[u,d]=cr({prop:r,defaultProp:o??!1,onChange:s,caller:ks});return c.jsx(Xb,{scope:t,triggerRef:a,contentRef:l,contentId:xn(),titleId:xn(),descriptionId:xn(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Ld.displayName=ks;var $d="DialogTrigger",Fd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an($d,n),s=We(t,o.triggerRef);return c.jsx(Ae.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Na(o.open),...r,ref:s,onClick:fe(e.onClick,o.onOpenToggle)})});Fd.displayName=$d;var Ea="DialogPortal",[Jb,zd]=Dd(Ea,{forceMount:void 0}),Bd=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=an(Ea,t);return c.jsx(Jb,{scope:t,forceMount:n,children:m.Children.map(r,i=>c.jsx(Ut,{present:n||s.open,children:c.jsx(gs,{asChild:!0,container:o,children:i})}))})};Bd.displayName=Ea;var Es="DialogOverlay",Hd=m.forwardRef((e,t)=>{const n=zd(Es,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=an(Es,e.__scopeDialog);return s.modal?c.jsx(Ut,{present:r||s.open,children:c.jsx(Qb,{...o,ref:t})}):null});Hd.displayName=Es;var Zb=tr.createSlot("DialogOverlay.RemoveScroll"),Qb=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(Es,n);return c.jsx(Ss,{as:Zb,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(Ae.div,{"data-state":Na(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),dr="DialogContent",Ud=m.forwardRef((e,t)=>{const n=zd(dr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=an(dr,e.__scopeDialog);return c.jsx(Ut,{present:r||s.open,children:s.modal?c.jsx(ew,{...o,ref:t}):c.jsx(tw,{...o,ref:t})})});Ud.displayName=dr;var ew=m.forwardRef((e,t)=>{const n=an(dr,e.__scopeDialog),r=m.useRef(null),o=We(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return ka(s)},[]),c.jsx(Wd,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:fe(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:fe(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:fe(e.onFocusOutside,s=>s.preventDefault())})}),tw=m.forwardRef((e,t)=>{const n=an(dr,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return c.jsx(Wd,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var l,u;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((u=n.triggerRef.current)==null?void 0:u.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Wd=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=an(dr,n),l=m.useRef(null),u=We(t,l);return va(),c.jsxs(c.Fragment,{children:[c.jsx(ms,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(ps,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Na(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(nw,{titleId:a.titleId}),c.jsx(ow,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ia="DialogTitle",Vd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(Ia,n);return c.jsx(Ae.h2,{id:o.titleId,...r,ref:t})});Vd.displayName=Ia;var Kd="DialogDescription",qd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(Kd,n);return c.jsx(Ae.p,{id:o.descriptionId,...r,ref:t})});qd.displayName=Kd;var Gd="DialogClose",Yd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(Gd,n);return c.jsx(Ae.button,{type:"button",...r,ref:t,onClick:fe(e.onClick,()=>o.onOpenChange(!1))})});Yd.displayName=Gd;function Na(e){return e?"open":"closed"}var Xd="DialogTitleWarning",[sk,Jd]=cv(Xd,{contentName:dr,titleName:Ia,docsSlug:"dialog"}),nw=({titleId:e})=>{const t=Jd(Xd),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
123
+ `)},Wb=0,Or=[];function Vb(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(Wb++)[0],s=m.useState(Nd)[0],i=m.useRef(e);m.useEffect(function(){i.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var x=fb([e.lockRef.current],(e.shards||[]).map(Md),!0).filter(Boolean);return x.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),x.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=m.useCallback(function(x,g){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var y=Cs(x),b=n.current,S="deltaX"in x?x.deltaX:b[0]-y[0],k="deltaY"in x?x.deltaY:b[1]-y[1],C,T=x.target,I=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in x&&I==="h"&&T.type==="range")return!1;var A=jd(I,T);if(!A)return!0;if(A?C=I:(C=I==="v"?"h":"v",A=jd(I,T)),!A)return!1;if(!r.current&&"changedTouches"in x&&(S||k)&&(r.current=C),!C)return!0;var j=r.current||C;return Bb(j,g,x,j==="h"?S:k)},[]),l=m.useCallback(function(x){var g=x;if(!(!Or.length||Or[Or.length-1]!==s)){var y="deltaY"in g?Od(g):Cs(g),b=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&Hb(C.delta,y)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Md).filter(Boolean).filter(function(C){return C.contains(g.target)}),k=S.length>0?a(g,S[0]):!i.current.noIsolation;k&&g.cancelable&&g.preventDefault()}}},[]),u=m.useCallback(function(x,g,y,b){var S={name:x,delta:g,target:y,should:b,shadowParent:Kb(y)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=m.useCallback(function(x){n.current=Cs(x),r.current=void 0},[]),f=m.useCallback(function(x){u(x.type,Od(x),x.target,a(x,e.lockRef.current))},[]),h=m.useCallback(function(x){u(x.type,Cs(x),x.target,a(x,e.lockRef.current))},[]);m.useEffect(function(){return Or.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,Pr),document.addEventListener("touchmove",l,Pr),document.addEventListener("touchstart",d,Pr),function(){Or=Or.filter(function(x){return x!==s}),document.removeEventListener("wheel",l,Pr),document.removeEventListener("touchmove",l,Pr),document.removeEventListener("touchstart",d,Pr)}},[]);var p=e.removeScrollBar,v=e.inert;return m.createElement(m.Fragment,null,v?m.createElement(s,{styles:Ub(o)}):null,p?m.createElement(Ob,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Kb(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const qb=wb(Id,Vb);var Ts=m.forwardRef(function(e,t){return m.createElement(ws,bn({},e,{ref:t,sideCar:qb}))});Ts.classNames=ws.classNames;var Gb=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Mr=new WeakMap,ks=new WeakMap,Es={},ka=0,Dd=function(e){return e&&(e.host||Dd(e.parentNode))},Yb=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Dd(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})},Xb=function(e,t,n,r){var o=Yb(t,Array.isArray(e)?e:[e]);Es[n]||(Es[n]=new WeakMap);var s=Es[n],i=[],a=new Set,l=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var d=function(f){!f||l.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))d(h);else try{var p=h.getAttribute(r),v=p!==null&&p!=="false",x=(Mr.get(h)||0)+1,g=(s.get(h)||0)+1;Mr.set(h,x),s.set(h,g),i.push(h),x===1&&v&&ks.set(h,!0),g===1&&h.setAttribute(n,"true"),v||h.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",h,y)}})};return d(t),a.clear(),ka++,function(){i.forEach(function(f){var h=Mr.get(f)-1,p=s.get(f)-1;Mr.set(f,h),s.set(f,p),h||(ks.has(f)||f.removeAttribute(r),ks.delete(f)),p||f.removeAttribute(n)}),ka--,ka||(Mr=new WeakMap,Mr=new WeakMap,ks=new WeakMap,Es={})}},Ea=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Gb(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Xb(r,o,n,"aria-hidden")):function(){return null}},Is="Dialog",[Ld,sk]=yn(Is),[Jb,cn]=Ld(Is),$d=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]=dr({prop:r,defaultProp:o??!1,onChange:s,caller:Is});return c.jsx(Jb,{scope:t,triggerRef:a,contentRef:l,contentId:vn(),titleId:vn(),descriptionId:vn(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};$d.displayName=Is;var Fd="DialogTrigger",zd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=cn(Fd,n),s=Ue(t,o.triggerRef);return c.jsx(Ae.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Aa(o.open),...r,ref:s,onClick:fe(e.onClick,o.onOpenToggle)})});zd.displayName=Fd;var Ia="DialogPortal",[Zb,Bd]=Ld(Ia,{forceMount:void 0}),Hd=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=cn(Ia,t);return c.jsx(Zb,{scope:t,forceMount:n,children:m.Children.map(r,i=>c.jsx(Kt,{present:n||s.open,children:c.jsx(ys,{asChild:!0,container:o,children:i})}))})};Hd.displayName=Ia;var Ns="DialogOverlay",Ud=m.forwardRef((e,t)=>{const n=Bd(Ns,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=cn(Ns,e.__scopeDialog);return s.modal?c.jsx(Kt,{present:r||s.open,children:c.jsx(ew,{...o,ref:t})}):null});Ud.displayName=Ns;var Qb=rr.createSlot("DialogOverlay.RemoveScroll"),ew=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=cn(Ns,n);return c.jsx(Ts,{as:Qb,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(Ae.div,{"data-state":Aa(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),hr="DialogContent",Wd=m.forwardRef((e,t)=>{const n=Bd(hr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=cn(hr,e.__scopeDialog);return c.jsx(Kt,{present:r||s.open,children:s.modal?c.jsx(tw,{...o,ref:t}):c.jsx(nw,{...o,ref:t})})});Wd.displayName=hr;var tw=m.forwardRef((e,t)=>{const n=cn(hr,e.__scopeDialog),r=m.useRef(null),o=Ue(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return Ea(s)},[]),c.jsx(Vd,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:fe(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:fe(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:fe(e.onFocusOutside,s=>s.preventDefault())})}),nw=m.forwardRef((e,t)=>{const n=cn(hr,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return c.jsx(Vd,{...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()}})}),Vd=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=cn(hr,n),l=m.useRef(null),u=Ue(t,l);return ba(),c.jsxs(c.Fragment,{children:[c.jsx(xs,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(gs,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Aa(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(rw,{titleId:a.titleId}),c.jsx(sw,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Na="DialogTitle",Kd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=cn(Na,n);return c.jsx(Ae.h2,{id:o.titleId,...r,ref:t})});Kd.displayName=Na;var qd="DialogDescription",Gd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=cn(qd,n);return c.jsx(Ae.p,{id:o.descriptionId,...r,ref:t})});Gd.displayName=qd;var Yd="DialogClose",Xd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=cn(Yd,n);return c.jsx(Ae.button,{type:"button",...r,ref:t,onClick:fe(e.onClick,()=>o.onOpenChange(!1))})});Xd.displayName=Yd;function Aa(e){return e?"open":"closed"}var Jd="DialogTitleWarning",[ik,Zd]=uv(Jd,{contentName:hr,titleName:Na,docsSlug:"dialog"}),rw=({titleId:e})=>{const t=Zd(Jd),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
124
124
 
125
125
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
126
126
 
127
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},rw="DialogDescriptionWarning",ow=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Jd(rw).contentName}}.`;return m.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Zd=Ld,sw=Fd,Qd=Bd,Is=Hd,Ns=Ud,fr=Vd,As=qd,ef=Yd;const iw=Zd,aw=Qd,tf=m.forwardRef(({className:e,...t},n)=>c.jsx(Is,{ref:n,className:ee("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));tf.displayName=Is.displayName;const nf=m.forwardRef(({className:e,children:t,...n},r)=>{const o=m.useMemo(()=>{let s=!1;function i(a){m.Children.forEach(a,l=>{if(s||!m.isValidElement(l))return;const u=l.type;if(u===fr||(u==null?void 0:u.displayName)===fr.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(aw,{children:[c.jsx(tf,{}),c.jsxs(Ns,{ref:r,className:ee("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(fr,{className:"sr-only",children:"Dialog"}),t,c.jsxs(ef,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[c.jsx(ae.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});nf.displayName=Ns.displayName;const rf=({className:e,...t})=>c.jsx("div",{className:ee("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});rf.displayName="DialogHeader";const of=m.forwardRef(({className:e,...t},n)=>c.jsx(fr,{ref:n,className:ee("text-lg font-semibold leading-none tracking-tight",e),...t}));of.displayName=fr.displayName;const lw=m.forwardRef(({className:e,...t},n)=>c.jsx(As,{ref:n,className:ee("text-sm text-muted-foreground",e),...t}));lw.displayName=As.displayName;function cw({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=w.useState(!1),[a,l]=w.useState(null),[u,d]=w.useState(null),{toast:f}=pa(),h=w.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await dd(n);l(y)}catch(y){console.error("Failed to load file:",y),d(y instanceof Error?y.message:"Failed to load file")}finally{i(!1)}}},[n]);w.useEffect(()=>{e&&n&&h()},[e,n,h]);const p=async()=>{if(n)try{await Hv(n),f({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),f({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await dd(n),b=new Blob([y],{type:o}),S=URL.createObjectURL(b);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(y){console.error("Failed to open file externally:",y),f({title:"Failed to open file",description:String(y),variant:"destructive"})}},x=()=>s?c.jsxs("div",{className:"flex items-center justify-center py-12",children:[c.jsx(ae.Loader,{className:"h-8 w-8 animate-spin mr-3"}),c.jsx("span",{children:"Loading file..."})]}):u?c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),c.jsx("p",{className:"text-red-600 mb-4",children:u}),c.jsx(qe,{onClick:h,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?c.jsx("div",{className:"flex justify-center",children:c.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?c.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:c.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?c.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:c.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx(ae.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(ae.Image,{className:"h-5 w-5"}):c.jsx(ae.FileText,{className:"h-5 w-5"});return c.jsx(iw,{open:e,onOpenChange:t,children:c.jsxs(nf,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[c.jsx(rf,{children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[g(),c.jsxs("div",{children:[c.jsx(of,{className:"text-left",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(qe,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[c.jsx(ae.ExternalLink,{className:"h-4 w-4"}),"External"]}),c.jsxs(qe,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[c.jsx(ae.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),c.jsx("div",{className:"flex-1 overflow-hidden",children:x()})]})})}function sf(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function af(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function ho(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(ho).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(af(e)){try{console.debug("[message-utils] sanitizeForDisplay - dropping file-like object",{sampleFilename:e&&(e.filename||e.name)?e.filename||e.name:void 0,keys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - dropped file-like (unable to inspect)",{err:String(n)})}return}const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=ho(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function Aa(e){if(typeof e=="string")return e;if(af(e))return"";try{const t=ho(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function lf(e){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){if(e.desirability||e.feasibility||e.viability||e.other)return{desirability:Array.isArray(e.desirability)?e.desirability:[],feasibility:Array.isArray(e.feasibility)?e.feasibility:[],viability:Array.isArray(e.viability)?e.viability:[],other:Array.isArray(e.other)?e.other:[]};if(e.output&&typeof e.output!="object")e=e.output;else if(e.output&&typeof e.output=="object")return lf(e.output)}const t=String(e),n={desirability:[],feasibility:[],viability:[],other:[]};let r=t;const o=Math.min(...["desirability=","feasibility=","viability=","other="].map(i=>{const a=r.toLowerCase().indexOf(i);return a===-1?Number.MAX_SAFE_INTEGER:a}));o!==Number.MAX_SAFE_INTEGER&&(r=r.slice(o));for(const i of Object.keys(n)){const l=new RegExp(i+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(r);if(!l)continue;const u=l[1],d=/Issue\(([\s\S]*?)\)(?:,|$)/g;let f=null;for(;(f=d.exec(u))!==null;){const h=f[1],p=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(h),v=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(h),x=p?p[2].trim():"",g=v?v[2].trim():"";n[i].push({title:x,description:g})}}return Object.values(n).some(i=>i.length>0)?n:null}const _s="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",hr=1e5;function uw(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function dw(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 fw(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 hw(e){const t=(r,o=hr)=>{try{const s=ho(r),i=typeof s=="string"?s:JSON.stringify(s??"");return i.length<=o?i:i.slice(0,o)+`
128
- … [truncated ${i.length-o} chars]`}catch{return""}},n=e.filter(r=>r.type==="tool_end");if(n.length)try{return n.length===1?t(n[0].output):t(n.map(r=>({toolCallId:r.toolCallId,output:r.output})))}catch{}return t(e)}function pw(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 mw(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function cf(e){const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(r=>{switch(r.type){case"text":return`t:${r.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"tool_end":return"end";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function gw({className:e}){const[t,n]=w.useState(0);return w.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),c.jsxs("span",{"aria-live":"polite",className:ee("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const uf=w.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateToolMessages:u=!0,toolMessagePreviewLength:d=200,truncateUserMessages:f=!0,userMessagePreviewLength:h=200,customStyles:p={},onEdit:v,onRegenerate:x,onCancelEdit:g,onCopy:y}){const[b,S]=w.useState(!1),[k,C]=w.useState("collapsed"),[T,I]=w.useState(!1),{currentThreadId:A}=Uo(),{respondToInterrupt:j}=Wo(),{toast:P}=pa(),[D,L]=w.useState({}),[B,M]=w.useState(!1),[X,W]=w.useState(null),V=l==="phone"||l==="half-screen",z=t.role,$=z==="tool",pe=!(r&&z!=="user"),F=w.useMemo(()=>{switch(z){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))]"}},[z]),Z=w.useMemo(()=>uw(t.content),[t.content]),he=w.useMemo(()=>dw(t.content),[t.content]),ve=w.useMemo(()=>t.content.filter(ne=>ne.type==="image_url"),[t.content]),be=w.useMemo(()=>t.content.filter(ne=>ne.type==="file"),[t.content]),Te=w.useMemo(()=>t.content.filter(ne=>ne.type==="interrupt"),[t.content]),K=w.useMemo(()=>hw(t.content),[t.content]);w.useMemo(()=>pw(t.content),[t.content]);const O=w.useMemo(()=>K.length<=hr?K:`${K.slice(0,hr)}
129
- … [truncated ${K.length-hr} chars]`,[K]),J=w.useCallback(async(ne="all")=>{const ge=ne==="visible"&&$?O:$?K:Z;async function we(xe){try{await navigator.clipboard.writeText(xe)}catch{try{const ze=document.createElement("textarea");ze.value=xe,ze.setAttribute("readonly",""),ze.style.position="absolute",ze.style.left="-9999px",document.body.appendChild(ze),ze.select(),document.execCommand("copy"),document.body.removeChild(ze)}catch(ze){throw console.error("Failed to copy:",ze),ze}}}try{await we(ge),S(!0),setTimeout(()=>S(!1),2e3),y==null||y(ge)}catch(xe){console.error("Failed to copy:",xe)}},[$,K,Z,O,y]),te=w.useCallback(()=>{if(!v)return;const ne=$?K:Z;v(t.id,ne)},[v,t.id,$,K,Z]),de=w.useCallback(()=>{x==null||x(n)},[x,n]),le=w.useCallback(async(ne,se,ge)=>{if(!pe){ne.preventDefault();return}if(D[ge]){ne.preventDefault();return}try{const we=String(se.url??""),xe=we.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(xe){ne.preventDefault();const ze=xe[1],st=se.name||`file_${ze}`,Fe=se.mimeType||"application/octet-stream";W({id:ze,name:st,mimeType:Fe}),M(!0);return}if(we.startsWith("data:")){ne.preventDefault(),L(Fe=>({...Fe,[ge]:!0}));const ze=`${se.name}_${se.size}_${Date.now()}`,st=P({title:"Fetching file...",description:"",open:!0});try{const Fe=await Uv(A??void 0);if(!Fe||!Array.isArray(Fe))throw new Error("Invalid file list response");const ut=Fe.find(xt=>!xt||typeof xt!="object"||!((xt.filename??"")===(se.name??""))?!1:typeof se.size=="number"&&typeof xt.size=="number"?xt.size===se.size:!0);if(!(ut!=null&&ut.id))throw new Error(`File "${se.name}" is not yet available on the server`);if(!ut.id||!ut.filename)throw new Error("Invalid file data received from server");W({id:ut.id,name:se.name||ut.filename||`file_${ut.id}`,mimeType:se.mimeType||ut.mime_type||"application/octet-stream"}),M(!0),st.update({id:st.id,title:"Success",description:`Opened ${se.name}`,open:!0})}catch(Fe){console.error("Failed to fetch server file:",Fe);const ut=Fe instanceof Error?Fe.message:"Unknown error occurred";st.update({id:st.id,title:"Failed",description:ut}),P({title:"Failed to fetch file",description:ut,open:!0})}finally{L(Fe=>({...Fe,[ge]:!1}))}}}catch(we){console.error("File click error:",we),L(xe=>({...xe,[ge]:!1}))}},[pe,D,P,A]),ie=w.useCallback(()=>{const se=ee(V?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",F);switch(z){case"user":return c.jsx(ae.User,{className:se});case"assistant":return c.jsx(ae.Bot,{className:se});case"tool":return c.jsx(ae.Wrench,{className:se});default:return c.jsx(ae.Bot,{className:se})}},[V,F,z]),tt=w.useCallback(()=>{const ne="group relative mb-4 flex w-full";switch(z){case"user":return ee(ne,"justify-end");case"assistant":case"tool":case"system":return ee(ne,"justify-start");default:return ne}},[z]),et=w.useCallback(()=>{const ne=ee("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",V&&"px-3 py-2 text-sm");switch(z){case"user":return ee(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 ee(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 ee(ne,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ee(ne,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ee(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")}},[V,z]),Oe=w.useCallback(async ne=>{try{const se=(ne==null?void 0:ne.id)||(ne==null?void 0:ne.interrupt_id);if(!se){console.warn("Interrupt part missing id",ne);return}await j(se,!0)}catch(se){console.error("Failed to approve interrupt:",se)}},[j]),He=w.useCallback(async ne=>{try{const se=(ne==null?void 0:ne.id)||(ne==null?void 0:ne.interrupt_id);if(!se){console.warn("Interrupt part missing id",ne);return}await j(se,!1)}catch(se){console.error("Failed to reject interrupt:",se)}},[j]),ht=w.useCallback(({part:ne,i:se})=>{if(ne.type==="text"){const ge=ne.text??"",we=ge.trim(),xe=sf(we);return xe&&z!=="tool"?c.jsx(xw,{data:xe},se):z==="user"&&f&&we.length>h?c.jsxs(qu,{open:T,onOpenChange:I,children:[c.jsx("div",{className:ee("text-sm text-[hsl(var(--chat-bubble-user-text))]",V&&"text-xs"),children:T?c.jsx(da,{content:we,allowHtml:!1}):c.jsxs("pre",{className:ee("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",V&&"text-xs"),children:[we.substring(0,h),"..."]})}),c.jsx(Gu,{asChild:!0,children:c.jsx(qe,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:T?c.jsxs(c.Fragment,{children:[c.jsx(ae.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ae.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",we.length-h," chars)"]})})})]},se):c.jsx(da,{content:ge,allowHtml:!1},se)}if(ne.type==="image_url"){const ge=ne;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"})},se)}if(ne.type==="file"){const ge=ne,we=ge.name||"file";return c.jsxs("a",{href:ge.url,onClick:xe=>le(xe,ge,se),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
130
- dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[D[se]?c.jsx(ae.Loader,{className:"h-4 w-4 animate-spin"}):null,c.jsxs("span",{className:"truncate max-w-[180px]",children:[we,D[se]?" (processing)":""]})]},se)}return ne.type==="interrupt"?c.jsx(vw,{interruptPart:ne,onApprove:Oe,onReject:He},se):null},[le,D,Oe,He,z,f,h,T,V]),nt=w.useCallback(()=>c.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[c.jsx(ae.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),Me=w.useCallback(()=>{const ne=Z.trim().length>0||ve.length>0||be.length>0||Te.length>0;if(!$&&!ne&&!r)return nt();if(t.model==="reflection"){const se=Z.trim(),ge=sf(se);if(ge&&typeof ge=="object")return c.jsx(bw,{data:ge})}if($&&he.name==="get_issues"){const se=t.content.find(xe=>xe.type==="tool_end"),ge=(se==null?void 0:se.output)??K,we=lf(ge);if(we)return c.jsx(ww,{issues:we})}if($){const se=fw(t.content);if(se.length>0)return c.jsx("div",{className:"space-y-2",children:se.map((ge,we)=>{const xe=typeof ge.output=="string"?ge.output:Aa(ge.output),ze=xe.length>hr?`${xe.slice(0,hr)}
131
- … [truncated ${xe.length-hr} chars]`:xe,st=k==="expanded";return c.jsxs(qu,{open:st,onOpenChange:Fe=>C(Fe?"expanded":"preview"),children:[c.jsx("div",{className:"flex items-center gap-2 text-xs",children:c.jsx(oa,{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:st?ze:ze.slice(0,d)+(ze.length>d?"...":"")})}),c.jsx(Gu,{asChild:!0,children:c.jsx(qe,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:st?c.jsxs(c.Fragment,{children:[" ",c.jsx(ae.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ae.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},ge.toolCallId??we)})})}if(!$){const se=c.jsx("div",{className:"space-y-2",children:t.content.map((ge,we)=>c.jsx(ht,{part:ge,i:we},we))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[se,c.jsx(gw,{className:F})]}):se}},[Z,ve.length,be.length,Te.length,r,t.model,$,he.name,K,k,u,nt,F]),bt=w.useMemo(()=>mw(t),[t]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:ee(tt(),p.container),children:c.jsxs("div",{className:ee(et(),p.content),children:[(i||a||$)&&c.jsxs("div",{className:ee("flex items-center justify-between mb-2 pb-2 border-b border-current/10",V&&"mb-1 pb-1",F,p.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[ie(),a&&bt&&c.jsx("span",{className:ee("font-medium",V?"text-xs":"text-sm"),children:bt}),$&&he.name&&c.jsxs(oa,{variant:"outline",className:ee("text-xs flex items-center gap-1 cursor-pointer",F,"border border-current/40",V&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":k!=="collapsed",onKeyDown:ne=>{(ne.key==="Enter"||ne.key===" ")&&(ne.preventDefault(),C(se=>se==="collapsed"?"preview":"collapsed"))},onClick:()=>C(ne=>ne==="collapsed"?"preview":"collapsed"),children:[c.jsx("span",{children:he.name}),c.jsx("span",{className:"inline-flex items-center",children:k!=="collapsed"?c.jsx(ae.ChevronUp,{className:"h-3 w-3"}):c.jsx(ae.ChevronDown,{className:"h-3 w-3"})})]}),$&&!he.name&&c.jsx(qe,{variant:"ghost",size:"sm",className:ee("h-6 px-1",F,"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 ",k!=="collapsed"?c.jsx(ae.ChevronUp,{className:"h-3 w-3"}):c.jsx(ae.ChevronDown,{className:"h-3 w-3"})]})})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.createdAt&&c.jsx("time",{className:ee("text-xs opacity-60",F,V&&"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:ee("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsxs("div",{className:"relative",children:[c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>J($?"visible":"all"),className:ee("h-6 w-6 p-0 hover:bg-foreground/10",F,V&&"h-5 w-5"),"aria-label":$?"Copy visible":"Copy message",title:$?"Copy visible portion":"Copy message",children:c.jsx(ae.Copy,{className:ee(b?"text-success":F,V?"h-3 w-3":"h-4 w-4")})}),$&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>J("all"),className:ee("h-6 px-1 text-xs hover:bg-foreground/10",F),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),z==="user"&&v&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:te,className:ee("h-6 w-6 p-0 hover:bg-foreground/10",F,V&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(ae.Edit,{className:ee(F,V?"h-3 w-3":"h-4 w-4")})}),z==="assistant"&&x&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:de,className:ee("h-6 w-6 p-0 hover:bg-foreground/10",F,V&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(ae.RotateCcw,{className:ee(F,V?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsx("div",{className:"relative",children:Me()}),$&&k==="expanded"&&(he.toolCallId||he.name)&&c.jsxs("div",{className:ee("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",V&&"text-xs"),children:[he.name&&c.jsxs("div",{children:["Function: ",he.name]}),he.toolCallId&&c.jsxs("div",{children:["Call ID: ",he.toolCallId]})]}),!(i||a||$)&&s&&!o&&c.jsxs("div",{className:ee("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>J(),className:ee("h-6 w-6 p-0 hover:bg-background/50 text-current",V&&"h-5 w-5"),children:c.jsx(ae.Copy,{className:ee(b?"text-success":"text-current",V?"h-3 w-3":"h-4 w-4")})}),z==="user"&&v&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:te,className:ee("h-6 w-6 p-0 hover:bg-background/50 text-current",V&&"h-5 w-5"),children:c.jsx(ae.Edit,{className:ee("text-current",V?"h-3 w-3":"h-4 w-4")})}),z==="assistant"&&x&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:de,className:ee("h-6 w-6 p-0 hover:bg-background/50 text-current",V&&"h-5 w-5"),children:c.jsx(ae.RotateCcw,{className:ee("text-current",V?"h-3 w-3":"h-4 w-4")})})]})]})}),X&&c.jsx(cw,{isOpen:B,onClose:()=>{M(!1),W(null)},fileId:X.id,fileName:X.name,mimeType:X.mimeType})]})},(e,t)=>{var i,a,l,u,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&cf(e.message)===cf(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(v=>e[v]===t[v]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((l=e.customStyles)==null?void 0:l.content)===((u=t.customStyles)==null?void 0:u.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((h=e.customStyles)==null?void 0:h.header)===((p=t.customStyles)==null?void 0:p.header);return o&&s});function xw({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?c.jsx("div",{className:_s,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:Aa(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:_s,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:_s,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:yw(i)})]},s))})})}return c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Aa(e)})}function yw(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(ho(e))})}catch{return String(e)}}function vw({interruptPart:e,onApprove:t,onReject:n}){const r=e.title??"Approve the result?";return c.jsxs(lo,{className:"border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10",children:[c.jsxs(co,{className:"pb-3",children:[c.jsx(uo,{className:"text-blue-900 dark:text-blue-100 text-base",children:r}),c.jsx(Yu,{className:"text-blue-700 dark:text-blue-300",children:"Please approve or reject this action to continue."})]}),c.jsx(Xu,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(qe,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",children:"Reject"}),c.jsx(qe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",children:"Approve"})]})})]})}function bw({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 ww({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:_s,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:c.jsxs("div",{className:"mb-4",children:[c.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),c.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>c.jsxs("li",{children:[c.jsx("div",{className:"font-medium",children:o.title}),c.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const df=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,_a=w.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:v=!0,isNavigatingCheckpoint:x=!1,onScrollAway:g,onAtBottom:y},b)=>{const S=w.useRef(null),k=w.useRef(null),C=w.useRef(!1),[T,I]=w.useState(!0),A=w.useCallback(D=>{I(D),g&&g(!D),y&&y(D)},[g,y]),j=w.useMemo(()=>{if(a)return async()=>{if(!C.current){C.current=!0;try{await a()}finally{C.current=!1}}}},[a]),P=w.useMemo(()=>!v||x?!1:T?"auto":!1,[T,v,x]);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(qy,{ref:D=>{S.current=D},scrollerRef:D=>{k.current=D instanceof HTMLDivElement?D:null},data:e,followOutput:P,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{j&&j()},atBottomStateChange:A,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(D,L)=>df(L,D),itemContent:(D,L)=>{const B=df(L,D);return c.jsx("div",{className:"mb-4 last:mb-0","data-message-id":B,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(uf,{message:L,messageIndex:D,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(D),onCancelEdit:d})})}})})});_a.displayName="MessageList";const js=1e4;function Sw(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
127
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},ow="DialogDescriptionWarning",sw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Zd(ow).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},Qd=$d,iw=zd,ef=Hd,As=Ud,_s=Wd,pr=Kd,js=Gd,tf=Xd;const aw=Qd,lw=ef,nf=m.forwardRef(({className:e,...t},n)=>c.jsx(As,{ref:n,className:ee("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}));nf.displayName=As.displayName;const rf=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===pr||(u==null?void 0:u.displayName)===pr.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(lw,{children:[c.jsx(nf,{}),c.jsxs(_s,{ref:r,className:ee("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(pr,{className:"sr-only",children:"Dialog"}),t,c.jsxs(tf,{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(ae.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});rf.displayName=_s.displayName;const of=({className:e,...t})=>c.jsx("div",{className:ee("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});of.displayName="DialogHeader";const sf=m.forwardRef(({className:e,...t},n)=>c.jsx(pr,{ref:n,className:ee("text-lg font-semibold leading-none tracking-tight",e),...t}));sf.displayName=pr.displayName;const cw=m.forwardRef(({className:e,...t},n)=>c.jsx(js,{ref:n,className:ee("text-sm text-muted-foreground",e),...t}));cw.displayName=js.displayName;function uw({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=w.useState(!1),[a,l]=w.useState(null),[u,d]=w.useState(null),{toast:f}=ma(),h=w.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await fd(n);l(y)}catch(y){console.error("Failed to load file:",y),d(y instanceof Error?y.message:"Failed to load file")}finally{i(!1)}}},[n]);w.useEffect(()=>{e&&n&&h()},[e,n,h]);const p=async()=>{if(n)try{await Uv(n),f({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),f({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await fd(n),b=new Blob([y],{type:o}),S=URL.createObjectURL(b);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(y){console.error("Failed to open file externally:",y),f({title:"Failed to open file",description:String(y),variant:"destructive"})}},x=()=>s?c.jsxs("div",{className:"flex items-center justify-center py-12",children:[c.jsx(ae.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(Ke,{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(ae.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(ae.Image,{className:"h-5 w-5"}):c.jsx(ae.FileText,{className:"h-5 w-5"});return c.jsx(aw,{open:e,onOpenChange:t,children:c.jsxs(rf,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[c.jsx(of,{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(sf,{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(Ke,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[c.jsx(ae.ExternalLink,{className:"h-4 w-4"}),"External"]}),c.jsxs(Ke,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[c.jsx(ae.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),c.jsx("div",{className:"flex-1 overflow-hidden",children:x()})]})})}function af(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 lf(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function mo(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(mo).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(lf(e)){try{console.debug("[message-utils] sanitizeForDisplay - dropping file-like object",{sampleFilename:e&&(e.filename||e.name)?e.filename||e.name:void 0,keys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - dropped file-like (unable to inspect)",{err:String(n)})}return}const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=mo(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function _a(e){if(typeof e=="string")return e;if(lf(e))return"";try{const t=mo(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function cf(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 cf(e.output)}const t=String(e),n={desirability:[],feasibility:[],viability:[],other:[]};let r=t;const o=Math.min(...["desirability=","feasibility=","viability=","other="].map(i=>{const a=r.toLowerCase().indexOf(i);return a===-1?Number.MAX_SAFE_INTEGER:a}));o!==Number.MAX_SAFE_INTEGER&&(r=r.slice(o));for(const i of Object.keys(n)){const l=new RegExp(i+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(r);if(!l)continue;const u=l[1],d=/Issue\(([\s\S]*?)\)(?:,|$)/g;let f=null;for(;(f=d.exec(u))!==null;){const h=f[1],p=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(h),v=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(h),x=p?p[2].trim():"",g=v?v[2].trim():"";n[i].push({title:x,description:g})}}return Object.values(n).some(i=>i.length>0)?n:null}const Rs="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",mr=1e5;function dw(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function fw(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 hw(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 pw(e){const t=(r,o=mr)=>{try{const s=mo(r),i=typeof s=="string"?s:JSON.stringify(s??"");return i.length<=o?i:i.slice(0,o)+`
128
+ … [truncated ${i.length-o} chars]`}catch{return""}},n=e.filter(r=>r.type==="tool_end");if(n.length)try{return n.length===1?t(n[0].output):t(n.map(r=>({toolCallId:r.toolCallId,output:r.output})))}catch{}return t(e)}function mw(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 gw(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function uf(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 xw({className:e}){const[t,n]=w.useState(0);return w.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),c.jsxs("span",{"aria-live":"polite",className:ee("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const df=w.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateToolMessages:u=!0,toolMessagePreviewLength:d=200,truncateUserMessages:f=!0,userMessagePreviewLength:h=200,customStyles:p={},onEdit:v,onRegenerate:x,onCancelEdit:g,onCopy:y}){const[b,S]=w.useState(!1),[k,C]=w.useState("collapsed"),[T,I]=w.useState(!1),{currentThreadId:A}=Vo(),{respondToInterrupt:j}=Ko(),{toast:P}=ma(),[D,L]=w.useState({}),[B,M]=w.useState(!1),[X,W]=w.useState(null),V=l==="phone"||l==="half-screen",z=t.role,$=z==="tool",pe=!(r&&z!=="user"),F=w.useMemo(()=>{switch(z){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))]"}},[z]),Q=w.useMemo(()=>dw(t.content),[t.content]),he=w.useMemo(()=>fw(t.content),[t.content]),ve=w.useMemo(()=>t.content.filter(ne=>ne.type==="image_url"),[t.content]),be=w.useMemo(()=>t.content.filter(ne=>ne.type==="file"),[t.content]),Te=w.useMemo(()=>t.content.filter(ne=>ne.type==="interrupt"),[t.content]),q=w.useMemo(()=>pw(t.content),[t.content]);w.useMemo(()=>mw(t.content),[t.content]);const O=w.useMemo(()=>q.length<=mr?q:`${q.slice(0,mr)}
129
+ … [truncated ${q.length-mr} chars]`,[q]),J=w.useCallback(async(ne="all")=>{const ge=ne==="visible"&&$?O:$?q:Q;async function we(xe){try{await navigator.clipboard.writeText(xe)}catch{try{const Fe=document.createElement("textarea");Fe.value=xe,Fe.setAttribute("readonly",""),Fe.style.position="absolute",Fe.style.left="-9999px",document.body.appendChild(Fe),Fe.select(),document.execCommand("copy"),document.body.removeChild(Fe)}catch(Fe){throw console.error("Failed to copy:",Fe),Fe}}}try{await we(ge),S(!0),setTimeout(()=>S(!1),2e3),y==null||y(ge)}catch(xe){console.error("Failed to copy:",xe)}},[$,q,Q,O,y]),te=w.useCallback(()=>{if(!v)return;const ne=$?q:Q;v(t.id,ne)},[v,t.id,$,q,Q]),de=w.useCallback(()=>{x==null||x(n)},[x,n]),le=w.useCallback(async(ne,oe,ge)=>{if(!pe){ne.preventDefault();return}if(D[ge]){ne.preventDefault();return}try{const we=String(oe.url??""),xe=we.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(xe){ne.preventDefault();const Fe=xe[1],ot=oe.name||`file_${Fe}`,$e=oe.mimeType||"application/octet-stream";W({id:Fe,name:ot,mimeType:$e}),M(!0);return}if(we.startsWith("data:")){ne.preventDefault(),L($e=>({...$e,[ge]:!0}));const Fe=`${oe.name}_${oe.size}_${Date.now()}`,ot=P({title:"Fetching file...",description:"",open:!0});try{const $e=await Wv(A??void 0);if(!$e||!Array.isArray($e))throw new Error("Invalid file list response");const ut=$e.find(xt=>!xt||typeof xt!="object"||!((xt.filename??"")===(oe.name??""))?!1:typeof oe.size=="number"&&typeof xt.size=="number"?xt.size===oe.size:!0);if(!(ut!=null&&ut.id))throw new Error(`File "${oe.name}" is not yet available on the server`);if(!ut.id||!ut.filename)throw new Error("Invalid file data received from server");W({id:ut.id,name:oe.name||ut.filename||`file_${ut.id}`,mimeType:oe.mimeType||ut.mime_type||"application/octet-stream"}),M(!0),ot.update({id:ot.id,title:"Success",description:`Opened ${oe.name}`,open:!0})}catch($e){console.error("Failed to fetch server file:",$e);const ut=$e instanceof Error?$e.message:"Unknown error occurred";ot.update({id:ot.id,title:"Failed",description:ut}),P({title:"Failed to fetch file",description:ut,open:!0})}finally{L($e=>({...$e,[ge]:!1}))}}}catch(we){console.error("File click error:",we),L(xe=>({...xe,[ge]:!1}))}},[pe,D,P,A]),ie=w.useCallback(()=>{const oe=ee(V?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",F);switch(z){case"user":return c.jsx(ae.User,{className:oe});case"assistant":return c.jsx(ae.Bot,{className:oe});case"tool":return c.jsx(ae.Wrench,{className:oe});default:return c.jsx(ae.Bot,{className:oe})}},[V,F,z]),et=w.useCallback(()=>{const ne="group relative mb-4 flex w-full";switch(z){case"user":return ee(ne,"justify-end");case"assistant":case"tool":case"system":return ee(ne,"justify-start");default:return ne}},[z]),Qe=w.useCallback(()=>{const ne=ee("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",V&&"px-3 py-2 text-sm");switch(z){case"user":return ee(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 ee(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 ee(ne,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ee(ne,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ee(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")}},[V,z]),Oe=w.useCallback(async ne=>{try{const oe=(ne==null?void 0:ne.id)||(ne==null?void 0:ne.interrupt_id);if(!oe){console.warn("Interrupt part missing id",ne);return}await j(oe,!0)}catch(oe){console.error("Failed to approve interrupt:",oe)}},[j]),Be=w.useCallback(async ne=>{try{const oe=(ne==null?void 0:ne.id)||(ne==null?void 0:ne.interrupt_id);if(!oe){console.warn("Interrupt part missing id",ne);return}await j(oe,!1)}catch(oe){console.error("Failed to reject interrupt:",oe)}},[j]),ht=w.useCallback(({part:ne,i:oe})=>{if(ne.type==="text"){const ge=ne.text??"",we=ge.trim(),xe=af(we);return xe&&z!=="tool"?c.jsx(yw,{data:xe},oe):z==="user"&&f&&we.length>h?c.jsxs(Gu,{open:T,onOpenChange:I,children:[c.jsx("div",{className:ee("text-sm text-[hsl(var(--chat-bubble-user-text))]",V&&"text-xs"),children:T?c.jsx(fa,{content:we,allowHtml:!1}):c.jsxs("pre",{className:ee("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",V&&"text-xs"),children:[we.substring(0,h),"..."]})}),c.jsx(Yu,{asChild:!0,children:c.jsx(Ke,{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(ae.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ae.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",we.length-h," chars)"]})})})]},oe):c.jsx(fa,{content:ge,allowHtml:!1},oe)}if(ne.type==="image_url"){const ge=ne;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"})},oe)}if(ne.type==="file"){const ge=ne,we=ge.name||"file";return c.jsxs("a",{href:ge.url,onClick:xe=>le(xe,ge,oe),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
130
+ dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[D[oe]?c.jsx(ae.Loader,{className:"h-4 w-4 animate-spin"}):null,c.jsxs("span",{className:"truncate max-w-[180px]",children:[we,D[oe]?" (processing)":""]})]},oe)}return ne.type==="interrupt"?c.jsx(bw,{interruptPart:ne,onApprove:Oe,onReject:Be},oe):null},[le,D,Oe,Be,z,f,h,T,V]),tt=w.useCallback(()=>c.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[c.jsx(ae.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),Me=w.useCallback(()=>{const ne=Q.trim().length>0||ve.length>0||be.length>0||Te.length>0;if(!$&&!ne&&!r)return tt();if(t.model==="reflection"){const oe=Q.trim(),ge=af(oe);if(ge&&typeof ge=="object")return c.jsx(ww,{data:ge})}if($&&he.name==="get_issues"){const oe=t.content.find(xe=>xe.type==="tool_end"),ge=(oe==null?void 0:oe.output)??q,we=cf(ge);if(we)return c.jsx(Sw,{issues:we})}if($){const oe=hw(t.content);if(oe.length>0)return c.jsx("div",{className:"space-y-2",children:oe.map((ge,we)=>{const xe=typeof ge.output=="string"?ge.output:_a(ge.output),Fe=xe.length>mr?`${xe.slice(0,mr)}
131
+ … [truncated ${xe.length-mr} chars]`:xe,ot=k==="expanded";return c.jsxs(Gu,{open:ot,onOpenChange:$e=>C($e?"expanded":"preview"),children:[c.jsx("div",{className:"flex items-center gap-2 text-xs",children:c.jsx(sa,{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:ot?Fe:Fe.slice(0,d)+(Fe.length>d?"...":"")})}),c.jsx(Yu,{asChild:!0,children:c.jsx(Ke,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:ot?c.jsxs(c.Fragment,{children:[" ",c.jsx(ae.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ae.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},ge.toolCallId??we)})})}if(!$){const oe=c.jsx("div",{className:"space-y-2",children:t.content.map((ge,we)=>c.jsx(ht,{part:ge,i:we},we))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[oe,c.jsx(xw,{className:F})]}):oe}},[Q,ve.length,be.length,Te.length,r,t.model,$,he.name,q,k,u,tt,F]),bt=w.useMemo(()=>gw(t),[t]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:ee(et(),p.container),children:c.jsxs("div",{className:ee(Qe(),p.content),children:[(i||a||$)&&c.jsxs("div",{className:ee("flex items-center justify-between mb-2 pb-2 border-b border-current/10",V&&"mb-1 pb-1",F,p.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[ie(),a&&bt&&c.jsx("span",{className:ee("font-medium",V?"text-xs":"text-sm"),children:bt}),$&&he.name&&c.jsxs(sa,{variant:"outline",className:ee("text-xs flex items-center gap-1 cursor-pointer",F,"border border-current/40",V&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":k!=="collapsed",onKeyDown:ne=>{(ne.key==="Enter"||ne.key===" ")&&(ne.preventDefault(),C(oe=>oe==="collapsed"?"preview":"collapsed"))},onClick:()=>C(ne=>ne==="collapsed"?"preview":"collapsed"),children:[c.jsx("span",{children:he.name}),c.jsx("span",{className:"inline-flex items-center",children:k!=="collapsed"?c.jsx(ae.ChevronUp,{className:"h-3 w-3"}):c.jsx(ae.ChevronDown,{className:"h-3 w-3"})})]}),$&&!he.name&&c.jsx(Ke,{variant:"ghost",size:"sm",className:ee("h-6 px-1",F,"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 ",k!=="collapsed"?c.jsx(ae.ChevronUp,{className:"h-3 w-3"}):c.jsx(ae.ChevronDown,{className:"h-3 w-3"})]})})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.createdAt&&c.jsx("time",{className:ee("text-xs opacity-60",F,V&&"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:ee("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsxs("div",{className:"relative",children:[c.jsx(Ke,{variant:"ghost",size:"sm",onClick:()=>J($?"visible":"all"),className:ee("h-6 w-6 p-0 hover:bg-foreground/10",F,V&&"h-5 w-5"),"aria-label":$?"Copy visible":"Copy message",title:$?"Copy visible portion":"Copy message",children:c.jsx(ae.Copy,{className:ee(b?"text-success":F,V?"h-3 w-3":"h-4 w-4")})}),$&&c.jsx(Ke,{variant:"ghost",size:"sm",onClick:()=>J("all"),className:ee("h-6 px-1 text-xs hover:bg-foreground/10",F),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),z==="user"&&v&&c.jsx(Ke,{variant:"ghost",size:"sm",onClick:te,className:ee("h-6 w-6 p-0 hover:bg-foreground/10",F,V&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(ae.Edit,{className:ee(F,V?"h-3 w-3":"h-4 w-4")})}),z==="assistant"&&x&&c.jsx(Ke,{variant:"ghost",size:"sm",onClick:de,className:ee("h-6 w-6 p-0 hover:bg-foreground/10",F,V&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(ae.RotateCcw,{className:ee(F,V?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsx("div",{className:"relative",children:Me()}),$&&k==="expanded"&&(he.toolCallId||he.name)&&c.jsxs("div",{className:ee("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",V&&"text-xs"),children:[he.name&&c.jsxs("div",{children:["Function: ",he.name]}),he.toolCallId&&c.jsxs("div",{children:["Call ID: ",he.toolCallId]})]}),!(i||a||$)&&s&&!o&&c.jsxs("div",{className:ee("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsx(Ke,{variant:"ghost",size:"sm",onClick:()=>J(),className:ee("h-6 w-6 p-0 hover:bg-background/50 text-current",V&&"h-5 w-5"),children:c.jsx(ae.Copy,{className:ee(b?"text-success":"text-current",V?"h-3 w-3":"h-4 w-4")})}),z==="user"&&v&&c.jsx(Ke,{variant:"ghost",size:"sm",onClick:te,className:ee("h-6 w-6 p-0 hover:bg-background/50 text-current",V&&"h-5 w-5"),children:c.jsx(ae.Edit,{className:ee("text-current",V?"h-3 w-3":"h-4 w-4")})}),z==="assistant"&&x&&c.jsx(Ke,{variant:"ghost",size:"sm",onClick:de,className:ee("h-6 w-6 p-0 hover:bg-background/50 text-current",V&&"h-5 w-5"),children:c.jsx(ae.RotateCcw,{className:ee("text-current",V?"h-3 w-3":"h-4 w-4")})})]})]})}),X&&c.jsx(uw,{isOpen:B,onClose:()=>{M(!1),W(null)},fileId:X.id,fileName:X.name,mimeType:X.mimeType})]})},(e,t)=>{var i,a,l,u,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&uf(e.message)===uf(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(v=>e[v]===t[v]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((l=e.customStyles)==null?void 0:l.content)===((u=t.customStyles)==null?void 0:u.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((h=e.customStyles)==null?void 0:h.header)===((p=t.customStyles)==null?void 0:p.header);return o&&s});function yw({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?c.jsx("div",{className:Rs,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:_a(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:Rs,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:Rs,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:vw(i)})]},s))})})}return c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:_a(e)})}function vw(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(mo(e))})}catch{return String(e)}}function bw({interruptPart:e,onApprove:t,onReject:n}){const r=e.title??"Approve the result?";return c.jsxs(uo,{className:"border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10",children:[c.jsxs(fo,{className:"pb-3",children:[c.jsx(ho,{className:"text-blue-900 dark:text-blue-100 text-base",children:r}),c.jsx(Xu,{className:"text-blue-700 dark:text-blue-300",children:"Please approve or reject this action to continue."})]}),c.jsx(Ju,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(Ke,{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(Ke,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",children:"Approve"})]})})]})}function ww({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 Sw({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:Rs,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 ff=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,ja=w.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:v=!0,isNavigatingCheckpoint:x=!1,onScrollAway:g,onAtBottom:y},b)=>{const S=w.useRef(null),k=w.useRef(null),C=w.useRef(!1),[T,I]=w.useState(!0),A=w.useCallback(D=>{I(D),g&&g(!D),y&&y(D)},[g,y]),j=w.useMemo(()=>{if(a)return async()=>{if(!C.current){C.current=!0;try{await a()}finally{C.current=!1}}}},[a]),P=w.useMemo(()=>!v||x?!1:T?"auto":!1,[T,v,x]);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(Gy,{ref:D=>{S.current=D},scrollerRef:D=>{k.current=D instanceof HTMLDivElement?D:null},data:e,followOutput:P,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{j&&j()},atBottomStateChange:A,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(D,L)=>ff(L,D),itemContent:(D,L)=>{const B=ff(L,D);return c.jsx("div",{className:"mb-4 last:mb-0","data-message-id":B,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(df,{message:L,messageIndex:D,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(D),onCancelEdit:d})})}})})});ja.displayName="MessageList";const Ps=1e4;function Cw(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
132
132
  `).replace(/<p>(.*?)<\/p>/gi,`$1
133
133
 
134
134
  `).replace(/<h([1-6])>(.*?)<\/h[1-6]>/gi,(o,s,i)=>`${"#".repeat(parseInt(s))} ${i}
@@ -136,4 +136,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
136
136
  `).replace(/<ul>/gi,"").replace(/<\/ul>/gi,`
137
137
  `).replace(/<ol>/gi,"").replace(/<\/ol>/gi,`
138
138
  `).replace(/<li>(.*?)<\/li>/gi,`- $1
139
- `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function Cw(e,t=js){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 Tw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),Cw(t),Sw(t)}function ja(e){const t=e+"CollectionProvider",[n,r]=gn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=x=>{const{scope:g,children:y}=x,b=w.useRef(null),S=w.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:S,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=tr.createSlot(a),u=w.forwardRef((x,g)=>{const{scope:y,children:b}=x,S=s(a,y),k=We(g,S.collectionRef);return c.jsx(l,{ref:k,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=tr.createSlot(d),p=w.forwardRef((x,g)=>{const{scope:y,children:b,...S}=x,k=w.useRef(null),C=We(g,k),T=s(d,y);return w.useEffect(()=>(T.itemMap.set(k,{ref:k,...S}),()=>void T.itemMap.delete(k))),c.jsx(h,{[f]:"",ref:C,children:b})});p.displayName=d;function v(x){const g=s(e+"CollectionConsumer",x);return w.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const 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},v,r]}var kw=m.createContext(void 0);function Rs(e){const t=m.useContext(kw);return e||t||"ltr"}const Ew=["top","right","bottom","left"],Wn=Math.min,Wt=Math.max,Ps=Math.round,Os=Math.floor,vn=e=>({x:e,y:e}),Iw={left:"right",right:"left",bottom:"top",top:"bottom"},Nw={start:"end",end:"start"};function Ra(e,t,n){return Wt(e,Wn(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function _n(e){return e.split("-")[0]}function Mr(e){return e.split("-")[1]}function Pa(e){return e==="x"?"y":"x"}function Oa(e){return e==="y"?"height":"width"}const Aw=new Set(["top","bottom"]);function bn(e){return Aw.has(_n(e))?"y":"x"}function Ma(e){return Pa(bn(e))}function _w(e,t,n){n===void 0&&(n=!1);const r=Mr(e),o=Ma(e),s=Oa(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Ms(i)),[i,Ms(i)]}function jw(e){const t=Ms(e);return[Da(e),t,Da(t)]}function Da(e){return e.replace(/start|end/g,t=>Nw[t])}const ff=["left","right"],hf=["right","left"],Rw=["top","bottom"],Pw=["bottom","top"];function Ow(e,t,n){switch(e){case"top":case"bottom":return n?t?hf:ff:t?ff:hf;case"left":case"right":return t?Rw:Pw;default:return[]}}function Mw(e,t,n,r){const o=Mr(e);let s=Ow(_n(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Da)))),s}function Ms(e){return e.replace(/left|right|bottom|top/g,t=>Iw[t])}function Dw(e){return{top:0,right:0,bottom:0,left:0,...e}}function pf(e){return typeof e!="number"?Dw(e):{top:e,right:e,bottom:e,left:e}}function Ds(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function mf(e,t,n){let{reference:r,floating:o}=e;const s=bn(t),i=Ma(t),a=Oa(i),l=_n(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(Mr(t)){case"start":p[i]-=h*(n&&u?-1:1);break;case"end":p[i]+=h*(n&&u?-1:1);break}return p}const Lw=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=mf(u,r,l),h=r,p={},v=0;for(let x=0;x<a.length;x++){const{name:g,fn:y}=a[x],{x:b,y:S,data:k,reset:C}=await y({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});d=b??d,f=S??f,p={...p,[g]:{...p[g],...k}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=mf(u,h,l)),x=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function po(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}=An(t,e),v=pf(p),g=a[h?f==="floating"?"reference":"floating":f],y=Ds(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)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=Ds(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(y.top-C.top+v.top)/k.y,bottom:(C.bottom-y.bottom+v.bottom)/k.y,left:(y.left-C.left+v.left)/k.x,right:(C.right-y.right+v.right)/k.x}}const $w=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}=An(e,t)||{};if(u==null)return{};const f=pf(d),h={x:n,y:r},p=Ma(o),v=Oa(p),x=await i.getDimensions(u),g=p==="y",y=g?"top":"left",b=g?"bottom":"right",S=g?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[p]-h[p]-s.floating[v],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[v]);const A=k/2-C/2,j=I/2-x[v]/2-1,P=Wn(f[y],j),D=Wn(f[b],j),L=P,B=I-x[v]-D,M=I/2-x[v]/2+A,X=Ra(L,M,B),W=!l.arrow&&Mr(o)!=null&&M!==X&&s.reference[v]/2-(M<L?P:D)-x[v]/2<0,V=W?M<L?M-L:M-B:0;return{[p]:h[p]+V,data:{[p]:X,centerOffset:M-X-V,...W&&{alignmentOffset:V}},reset:W}}}),Fw=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:x=!0,...g}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=_n(o),b=bn(a),S=_n(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(u.floating)),C=h||(S||!x?[Ms(a)]:jw(a)),T=v!=="none";!h&&T&&C.push(...Mw(a,x,v,k));const I=[a,...C],A=await po(t,g),j=[];let P=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&j.push(A[y]),f){const M=_w(o,i,k);j.push(A[M[0]],A[M[1]])}if(P=[...P,{placement:o,overflows:j}],!j.every(M=>M<=0)){var D,L;const M=(((D=s.flip)==null?void 0:D.index)||0)+1,X=I[M];if(X&&(!(f==="alignment"?b!==bn(X):!1)||P.every(z=>bn(z.placement)===b?z.overflows[0]>0:!0)))return{data:{index:M,overflows:P},reset:{placement:X}};let W=(L=P.filter(V=>V.overflows[0]<=0).sort((V,z)=>V.overflows[1]-z.overflows[1])[0])==null?void 0:L.placement;if(!W)switch(p){case"bestFit":{var B;const V=(B=P.filter(z=>{if(T){const $=bn(z.placement);return $===b||$==="y"}return!0}).map(z=>[z.placement,z.overflows.filter($=>$>0).reduce(($,pe)=>$+pe,0)]).sort((z,$)=>z[1]-$[1])[0])==null?void 0:B[0];V&&(W=V);break}case"initialPlacement":W=a;break}if(o!==W)return{reset:{placement:W}}}return{}}}};function gf(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function xf(e){return Ew.some(t=>e[t]>=0)}const zw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=An(e,t);switch(r){case"referenceHidden":{const s=await po(t,{...o,elementContext:"reference"}),i=gf(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:xf(i)}}}case"escaped":{const s=await po(t,{...o,altBoundary:!0}),i=gf(s,n.floating);return{data:{escapedOffsets:i,escaped:xf(i)}}}default:return{}}}}},yf=new Set(["left","top"]);async function Bw(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=_n(n),a=Mr(n),l=bn(n)==="y",u=yf.has(i)?-1:1,d=s&&l?-1:1,f=An(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof v=="number"&&(p=a==="end"?v*-1:v),l?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const Hw=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 Bw(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}}}}},Uw=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x:y,y:b}=g;return{x:y,y:b}}},...l}=An(e,t),u={x:n,y:r},d=await po(t,l),f=bn(_n(o)),h=Pa(f);let p=u[h],v=u[f];if(s){const g=h==="y"?"top":"left",y=h==="y"?"bottom":"right",b=p+d[g],S=p-d[y];p=Ra(b,p,S)}if(i){const g=f==="y"?"top":"left",y=f==="y"?"bottom":"right",b=v+d[g],S=v-d[y];v=Ra(b,v,S)}const x=a.fn({...t,[h]:p,[f]:v});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[h]:s,[f]:i}}}}}},Ww=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}=An(e,t),d={x:n,y:r},f=bn(o),h=Pa(f);let p=d[h],v=d[f];const x=An(a,t),g=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(l){const S=h==="y"?"height":"width",k=s.reference[h]-s.floating[S]+g.mainAxis,C=s.reference[h]+s.reference[S]-g.mainAxis;p<k?p=k:p>C&&(p=C)}if(u){var y,b;const S=h==="y"?"width":"height",k=yf.has(_n(o)),C=s.reference[f]-s.floating[S]+(k&&((y=i.offset)==null?void 0:y[f])||0)+(k?0:g.crossAxis),T=s.reference[f]+s.reference[S]+(k?0:((b=i.offset)==null?void 0:b[f])||0)-(k?g.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[h]:p,[f]:v}}}},Vw=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}=An(e,t),d=await po(t,u),f=_n(o),h=Mr(o),p=bn(o)==="y",{width:v,height:x}=s.floating;let g,y;f==="top"||f==="bottom"?(g=f,y=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=f,g=h==="end"?"top":"bottom");const b=x-d.top-d.bottom,S=v-d.left-d.right,k=Wn(x-d[g],b),C=Wn(v-d[y],S),T=!t.middlewareData.shift;let I=k,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 P=Wt(d.left,0),D=Wt(d.right,0),L=Wt(d.top,0),B=Wt(d.bottom,0);p?A=v-2*(P!==0||D!==0?P+D:Wt(d.left,d.right)):I=x-2*(L!==0||B!==0?L+B:Wt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:I});const j=await i.getDimensions(a.floating);return v!==j.width||x!==j.height?{reset:{rects:!0}}:{}}}};function Ls(){return typeof window<"u"}function Dr(e){return vf(e)?(e.nodeName||"").toLowerCase():"#document"}function Vt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function wn(e){var t;return(t=(vf(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function vf(e){return Ls()?e instanceof Node||e instanceof Vt(e).Node:!1}function ln(e){return Ls()?e instanceof Element||e instanceof Vt(e).Element:!1}function Sn(e){return Ls()?e instanceof HTMLElement||e instanceof Vt(e).HTMLElement:!1}function bf(e){return!Ls()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Vt(e).ShadowRoot}const Kw=new Set(["inline","contents"]);function mo(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=cn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Kw.has(o)}const qw=new Set(["table","td","th"]);function Gw(e){return qw.has(Dr(e))}const Yw=[":popover-open",":modal"];function $s(e){return Yw.some(t=>{try{return e.matches(t)}catch{return!1}})}const Xw=["transform","translate","scale","rotate","perspective"],Jw=["transform","translate","scale","rotate","perspective","filter"],Zw=["paint","layout","strict","content"];function La(e){const t=$a(),n=ln(e)?cn(e):e;return Xw.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)||Jw.some(r=>(n.willChange||"").includes(r))||Zw.some(r=>(n.contain||"").includes(r))}function Qw(e){let t=Vn(e);for(;Sn(t)&&!Lr(t);){if(La(t))return t;if($s(t))return null;t=Vn(t)}return null}function $a(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const e0=new Set(["html","body","#document"]);function Lr(e){return e0.has(Dr(e))}function cn(e){return Vt(e).getComputedStyle(e)}function Fs(e){return ln(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Vn(e){if(Dr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||bf(e)&&e.host||wn(e);return bf(t)?t.host:t}function wf(e){const t=Vn(e);return Lr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Sn(t)&&mo(t)?t:wf(t)}function go(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=wf(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Vt(o);if(s){const a=Fa(i);return t.concat(i,i.visualViewport||[],mo(o)?o:[],a&&n?go(a):[])}return t.concat(o,go(o,[],n))}function Fa(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Sf(e){const t=cn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Sn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Ps(n)!==s||Ps(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function za(e){return ln(e)?e:e.contextElement}function $r(e){const t=za(e);if(!Sn(t))return vn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Sf(t);let i=(s?Ps(n.width):n.width)/r,a=(s?Ps(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const t0=vn(0);function Cf(e){const t=Vt(e);return!$a()||!t.visualViewport?t0:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function n0(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Vt(e)?!1:t}function pr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=za(e);let i=vn(1);t&&(r?ln(r)&&(i=$r(r)):i=$r(e));const a=n0(s,n,r)?Cf(s):vn(0);let l=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=Vt(s),p=r&&ln(r)?Vt(r):r;let v=h,x=Fa(v);for(;x&&r&&p!==v;){const g=$r(x),y=x.getBoundingClientRect(),b=cn(x),S=y.left+(x.clientLeft+parseFloat(b.paddingLeft))*g.x,k=y.top+(x.clientTop+parseFloat(b.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=S,u+=k,v=Vt(x),x=Fa(v)}}return Ds({width:d,height:f,x:l,y:u})}function zs(e,t){const n=Fs(e).scrollLeft;return t?t.left+n:pr(wn(e)).left+n}function Tf(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-zs(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function r0(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=wn(r),a=t?$s(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=vn(1);const d=vn(0),f=Sn(r);if((f||!f&&!s)&&((Dr(r)!=="body"||mo(i))&&(l=Fs(r)),Sn(r))){const p=pr(r);u=$r(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?Tf(i,l):vn(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 o0(e){return Array.from(e.getClientRects())}function s0(e){const t=wn(e),n=Fs(e),r=e.ownerDocument.body,o=Wt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Wt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+zs(e);const a=-n.scrollTop;return cn(r).direction==="rtl"&&(i+=Wt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const kf=25;function i0(e,t){const n=Vt(e),r=wn(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=$a();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const u=zs(r);if(u<=0){const d=r.ownerDocument,f=d.body,h=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-p);v<=kf&&(s-=v)}else u<=kf&&(s+=u);return{width:s,height:i,x:a,y:l}}const a0=new Set(["absolute","fixed"]);function l0(e,t){const n=pr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Sn(e)?$r(e):vn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,u=r*s.y;return{width:i,height:a,x:l,y:u}}function Ef(e,t,n){let r;if(t==="viewport")r=i0(e,n);else if(t==="document")r=s0(wn(e));else if(ln(t))r=l0(t,n);else{const o=Cf(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ds(r)}function If(e,t){const n=Vn(e);return n===t||!ln(n)||Lr(n)?!1:cn(n).position==="fixed"||If(n,t)}function c0(e,t){const n=t.get(e);if(n)return n;let r=go(e,[],!1).filter(a=>ln(a)&&Dr(a)!=="body"),o=null;const s=cn(e).position==="fixed";let i=s?Vn(e):e;for(;ln(i)&&!Lr(i);){const a=cn(i),l=La(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&a0.has(o.position)||mo(i)&&!l&&If(e,i))?r=r.filter(d=>d!==i):o=a,i=Vn(i)}return t.set(e,r),r}function u0(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?$s(t)?[]:c0(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=Ef(t,d,o);return u.top=Wt(f.top,u.top),u.right=Wn(f.right,u.right),u.bottom=Wn(f.bottom,u.bottom),u.left=Wt(f.left,u.left),u},Ef(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function d0(e){const{width:t,height:n}=Sf(e);return{width:t,height:n}}function f0(e,t,n){const r=Sn(t),o=wn(t),s=n==="fixed",i=pr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=vn(0);function u(){l.x=zs(o)}if(r||!r&&!s)if((Dr(t)!=="body"||mo(o))&&(a=Fs(t)),r){const p=pr(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?Tf(o,a):vn(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 Ba(e){return cn(e).position==="static"}function Nf(e,t){if(!Sn(e)||cn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return wn(e)===n&&(n=n.ownerDocument.body),n}function Af(e,t){const n=Vt(e);if($s(e))return n;if(!Sn(e)){let o=Vn(e);for(;o&&!Lr(o);){if(ln(o)&&!Ba(o))return o;o=Vn(o)}return n}let r=Nf(e,t);for(;r&&Gw(r)&&Ba(r);)r=Nf(r,t);return r&&Lr(r)&&Ba(r)&&!La(r)?n:r||Qw(e)||n}const h0=async function(e){const t=this.getOffsetParent||Af,n=this.getDimensions,r=await n(e.floating);return{reference:f0(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function p0(e){return cn(e).direction==="rtl"}const m0={convertOffsetParentRelativeRectToViewportRelativeRect:r0,getDocumentElement:wn,getClippingRect:u0,getOffsetParent:Af,getElementRects:h0,getClientRects:o0,getDimensions:d0,getScale:$r,isElement:ln,isRTL:p0};function _f(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function g0(e,t){let n=null,r;const o=wn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:p}=u;if(a||t(),!h||!p)return;const v=Os(f),x=Os(o.clientWidth-(d+h)),g=Os(o.clientHeight-(f+p)),y=Os(d),S={rootMargin:-v+"px "+-x+"px "+-g+"px "+-y+"px",threshold:Wt(0,Wn(1,l))||1};let k=!0;function C(T){const I=T[0].intersectionRatio;if(I!==l){if(!k)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!_f(u,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function x0(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=za(e),d=o||s?[...u?go(u):[],...go(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const f=u&&a?g0(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(y=>{let[b]=y;b&&b.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let v,x=l?pr(e):null;l&&g();function g(){const y=pr(e);x&&!_f(x,y)&&n(),x=y,v=requestAnimationFrame(g)}return n(),()=>{var y;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(v)}}const y0=Hw,v0=Uw,b0=Fw,w0=Vw,S0=zw,jf=$w,C0=Ww,T0=(e,t,n)=>{const r=new Map,o={platform:m0,...n},s={...o.platform,_c:r};return Lw(e,t,{...o,platform:s})};var k0=typeof document<"u",E0=function(){},Bs=k0?w.useLayoutEffect:E0;function Hs(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(!Hs(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)&&!Hs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Rf(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Pf(e,t){const n=Rf(e);return Math.round(t*n)/n}function Ha(e){const t=m.useRef(e);return Bs(()=>{t.current=e}),t}function I0(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);Hs(h,r)||p(r);const[v,x]=m.useState(null),[g,y]=m.useState(null),b=m.useCallback(z=>{z!==T.current&&(T.current=z,x(z))},[]),S=m.useCallback(z=>{z!==I.current&&(I.current=z,y(z))},[]),k=s||v,C=i||g,T=m.useRef(null),I=m.useRef(null),A=m.useRef(d),j=l!=null,P=Ha(l),D=Ha(o),L=Ha(u),B=m.useCallback(()=>{if(!T.current||!I.current)return;const z={placement:t,strategy:n,middleware:h};D.current&&(z.platform=D.current),T0(T.current,I.current,z).then($=>{const pe={...$,isPositioned:L.current!==!1};M.current&&!Hs(A.current,pe)&&(A.current=pe,No.flushSync(()=>{f(pe)}))})},[h,t,n,D,L]);Bs(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(z=>({...z,isPositioned:!1})))},[u]);const M=m.useRef(!1);Bs(()=>(M.current=!0,()=>{M.current=!1}),[]),Bs(()=>{if(k&&(T.current=k),C&&(I.current=C),k&&C){if(P.current)return P.current(k,C,B);B()}},[k,C,B,P,j]);const X=m.useMemo(()=>({reference:T,floating:I,setReference:b,setFloating:S}),[b,S]),W=m.useMemo(()=>({reference:k,floating:C}),[k,C]),V=m.useMemo(()=>{const z={position:n,left:0,top:0};if(!W.floating)return z;const $=Pf(W.floating,d.x),pe=Pf(W.floating,d.y);return a?{...z,transform:"translate("+$+"px, "+pe+"px)",...Rf(W.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:$,top:pe}},[n,a,W.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:B,refs:X,elements:W,floatingStyles:V}),[d,B,X,W,V])}const N0=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?jf({element:r.current,padding:o}).fn(n):{}:r?jf({element:r,padding:o}).fn(n):{}}}},A0=(e,t)=>({...y0(e),options:[e,t]}),_0=(e,t)=>({...v0(e),options:[e,t]}),j0=(e,t)=>({...C0(e),options:[e,t]}),R0=(e,t)=>({...b0(e),options:[e,t]}),P0=(e,t)=>({...w0(e),options:[e,t]}),O0=(e,t)=>({...S0(e),options:[e,t]}),M0=(e,t)=>({...N0(e),options:[e,t]});var D0="Arrow",Of=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(Ae.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});Of.displayName=D0;var L0=Of;function Mf(e){const[t,n]=m.useState(void 0);return wt(()=>{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 Ua="Popper",[Df,Us]=gn(Ua),[$0,Lf]=Df(Ua),$f=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx($0,{scope:t,anchor:r,onAnchorChange:o,children:n})};$f.displayName=Ua;var Ff="PopperAnchor",zf=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Lf(Ff,n),i=m.useRef(null),a=We(t,i),l=m.useRef(null);return m.useEffect(()=>{const u=l.current;l.current=(r==null?void 0:r.current)||i.current,u!==l.current&&s.onAnchorChange(l.current)}),r?null:c.jsx(Ae.div,{...o,ref:a})});zf.displayName=Ff;var Wa="PopperContent",[F0,z0]=Df(Wa),Bf=m.forwardRef((e,t)=>{var K,O,J,te,de,le;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:v,...x}=e,g=Lf(Wa,n),[y,b]=m.useState(null),S=We(t,ie=>b(ie)),[k,C]=m.useState(null),T=Mf(k),I=(T==null?void 0:T.width)??0,A=(T==null?void 0:T.height)??0,j=r+(s!=="center"?"-"+s:""),P=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},D=Array.isArray(u)?u:[u],L=D.length>0,B={padding:P,boundary:D.filter(H0),altBoundary:L},{refs:M,floatingStyles:X,placement:W,isPositioned:V,middlewareData:z}=I0({strategy:"fixed",placement:j,whileElementsMounted:(...ie)=>x0(...ie,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[A0({mainAxis:o+A,alignmentAxis:i}),l&&_0({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?j0():void 0,...B}),l&&R0({...B}),P0({...B,apply:({elements:ie,rects:tt,availableWidth:et,availableHeight:Oe})=>{const{width:He,height:ht}=tt.reference,nt=ie.floating.style;nt.setProperty("--radix-popper-available-width",`${et}px`),nt.setProperty("--radix-popper-available-height",`${Oe}px`),nt.setProperty("--radix-popper-anchor-width",`${He}px`),nt.setProperty("--radix-popper-anchor-height",`${ht}px`)}}),k&&M0({element:k,padding:a}),U0({arrowWidth:I,arrowHeight:A}),h&&O0({strategy:"referenceHidden",...B})]}),[$,pe]=Wf(W),F=Tt(v);wt(()=>{V&&(F==null||F())},[V,F]);const Z=(K=z.arrow)==null?void 0:K.x,he=(O=z.arrow)==null?void 0:O.y,ve=((J=z.arrow)==null?void 0:J.centerOffset)!==0,[be,Te]=m.useState();return wt(()=>{y&&Te(window.getComputedStyle(y).zIndex)},[y]),c.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...X,transform:V?X.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:be,"--radix-popper-transform-origin":[(te=z.transformOrigin)==null?void 0:te.x,(de=z.transformOrigin)==null?void 0:de.y].join(" "),...((le=z.hide)==null?void 0:le.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(F0,{scope:n,placedSide:$,onArrowChange:C,arrowX:Z,arrowY:he,shouldHideArrow:ve,children:c.jsx(Ae.div,{"data-side":$,"data-align":pe,...x,ref:S,style:{...x.style,animation:V?void 0:"none"}})})})});Bf.displayName=Wa;var Hf="PopperArrow",B0={top:"bottom",right:"left",bottom:"top",left:"right"},Uf=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=z0(Hf,r),i=B0[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(L0,{...o,ref:n,style:{...o.style,display:"block"}})})});Uf.displayName=Hf;function H0(e){return e!==null}var U0=e=>({name:"transformOrigin",options:e,fn(t){var g,y,b;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[u,d]=Wf(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let v="",x="";return u==="bottom"?(v=i?f:`${h}px`,x=`${-l}px`):u==="top"?(v=i?f:`${h}px`,x=`${r.floating.height+l}px`):u==="right"?(v=`${-l}px`,x=i?f:`${p}px`):u==="left"&&(v=`${r.floating.width+l}px`,x=i?f:`${p}px`),{data:{x:v,y:x}}}});function Wf(e){const[t,n="center"]=e.split("-");return[t,n]}var Vf=$f,Kf=zf,qf=Bf,Gf=Uf,Va="rovingFocusGroup.onEntryFocus",W0={bubbles:!1,cancelable:!0},xo="RovingFocusGroup",[Ka,Yf,V0]=ja(xo),[K0,Xf]=gn(xo,[V0]),[q0,G0]=K0(xo),Jf=m.forwardRef((e,t)=>c.jsx(Ka.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Ka.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Y0,{...e,ref:t})})}));Jf.displayName=xo;var Y0=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=m.useRef(null),p=We(t,h),v=Rs(s),[x,g]=cr({prop:i,defaultProp:a??null,onChange:l,caller:xo}),[y,b]=m.useState(!1),S=Tt(u),k=Yf(n),C=m.useRef(!1),[T,I]=m.useState(0);return m.useEffect(()=>{const A=h.current;if(A)return A.addEventListener(Va,S),()=>A.removeEventListener(Va,S)},[S]),c.jsx(q0,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:x,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(Ae.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:fe(e.onMouseDown,()=>{C.current=!0}),onFocus:fe(e.onFocus,A=>{const j=!C.current;if(A.target===A.currentTarget&&j&&!y){const P=new CustomEvent(Va,W0);if(A.currentTarget.dispatchEvent(P),!P.defaultPrevented){const D=k().filter(W=>W.focusable),L=D.find(W=>W.active),B=D.find(W=>W.id===x),X=[L,B,...D].filter(Boolean).map(W=>W.ref.current);eh(X,d)}}C.current=!1}),onBlur:fe(e.onBlur,()=>b(!1))})})}),Zf="RovingFocusGroupItem",Qf=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=xn(),u=s||l,d=G0(Zf,n),f=d.currentTabStopId===u,h=Yf(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:x}=d;return m.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),c.jsx(Ka.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(Ae.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:fe(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:fe(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:fe(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const y=Z0(g,d.orientation,d.dir);if(y!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let S=h().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const k=S.indexOf(g.currentTarget);S=d.loop?Q0(S,k+1):S.slice(k+1)}setTimeout(()=>eh(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:x!=null}):i})})});Qf.displayName=Zf;var X0={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function J0(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Z0(e,t,n){const r=J0(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return X0[r]}function eh(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Q0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var eS=Jf,tS=Qf,qa=["Enter"," "],nS=["ArrowDown","PageUp","Home"],th=["ArrowUp","PageDown","End"],rS=[...nS,...th],oS={ltr:[...qa,"ArrowRight"],rtl:[...qa,"ArrowLeft"]},sS={ltr:["ArrowLeft"],rtl:["ArrowRight"]},yo="Menu",[vo,iS,aS]=ja(yo),[mr,nh]=gn(yo,[aS,Us,Xf]),Ws=Us(),rh=Xf(),[lS,gr]=mr(yo),[cS,bo]=mr(yo),oh=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=Ws(t),[l,u]=m.useState(null),d=m.useRef(!1),f=Tt(s),h=Rs(o);return m.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),c.jsx(Vf,{...a,children:c.jsx(lS,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(cS,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};oh.displayName=yo;var uS="MenuAnchor",Ga=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ws(n);return c.jsx(Kf,{...o,...r,ref:t})});Ga.displayName=uS;var Ya="MenuPortal",[dS,sh]=mr(Ya,{forceMount:void 0}),ih=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=gr(Ya,t);return c.jsx(dS,{scope:t,forceMount:n,children:c.jsx(Ut,{present:n||s.open,children:c.jsx(gs,{asChild:!0,container:o,children:r})})})};ih.displayName=Ya;var Zt="MenuContent",[fS,Xa]=mr(Zt),ah=m.forwardRef((e,t)=>{const n=sh(Zt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=gr(Zt,e.__scopeMenu),i=bo(Zt,e.__scopeMenu);return c.jsx(vo.Provider,{scope:e.__scopeMenu,children:c.jsx(Ut,{present:r||s.open,children:c.jsx(vo.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(hS,{...o,ref:t}):c.jsx(pS,{...o,ref:t})})})})}),hS=m.forwardRef((e,t)=>{const n=gr(Zt,e.__scopeMenu),r=m.useRef(null),o=We(t,r);return m.useEffect(()=>{const s=r.current;if(s)return ka(s)},[]),c.jsx(Ja,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:fe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),pS=m.forwardRef((e,t)=>{const n=gr(Zt,e.__scopeMenu);return c.jsx(Ja,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),mS=tr.createSlot("MenuContent.ScrollLock"),Ja=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:v,...x}=e,g=gr(Zt,n),y=bo(Zt,n),b=Ws(n),S=rh(n),k=iS(n),[C,T]=m.useState(null),I=m.useRef(null),A=We(t,I,g.onContentChange),j=m.useRef(0),P=m.useRef(""),D=m.useRef(0),L=m.useRef(null),B=m.useRef("right"),M=m.useRef(0),X=v?Ss:m.Fragment,W=v?{as:mS,allowPinchZoom:!0}:void 0,V=$=>{var K,O;const pe=P.current+$,F=k().filter(J=>!J.disabled),Z=document.activeElement,he=(K=F.find(J=>J.ref.current===Z))==null?void 0:K.textValue,ve=F.map(J=>J.textValue),be=IS(ve,pe,he),Te=(O=F.find(J=>J.textValue===be))==null?void 0:O.ref.current;(function J(te){P.current=te,window.clearTimeout(j.current),te!==""&&(j.current=window.setTimeout(()=>J(""),1e3))})(pe),Te&&setTimeout(()=>Te.focus())};m.useEffect(()=>()=>window.clearTimeout(j.current),[]),va();const z=m.useCallback($=>{var F,Z;return B.current===((F=L.current)==null?void 0:F.side)&&AS($,(Z=L.current)==null?void 0:Z.area)},[]);return c.jsx(fS,{scope:n,searchRef:P,onItemEnter:m.useCallback($=>{z($)&&$.preventDefault()},[z]),onItemLeave:m.useCallback($=>{var pe;z($)||((pe=I.current)==null||pe.focus(),T(null))},[z]),onTriggerLeave:m.useCallback($=>{z($)&&$.preventDefault()},[z]),pointerGraceTimerRef:D,onPointerGraceIntentChange:m.useCallback($=>{L.current=$},[]),children:c.jsx(X,{...W,children:c.jsx(ms,{asChild:!0,trapped:o,onMountAutoFocus:fe(s,$=>{var pe;$.preventDefault(),(pe=I.current)==null||pe.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(ps,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:c.jsx(eS,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:fe(l,$=>{y.isUsingKeyboardRef.current||$.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(qf,{role:"menu","aria-orientation":"vertical","data-state":Th(g.open),"data-radix-menu-content":"",dir:y.dir,...b,...x,ref:A,style:{outline:"none",...x.style},onKeyDown:fe(x.onKeyDown,$=>{const F=$.target.closest("[data-radix-menu-content]")===$.currentTarget,Z=$.ctrlKey||$.altKey||$.metaKey,he=$.key.length===1;F&&($.key==="Tab"&&$.preventDefault(),!Z&&he&&V($.key));const ve=I.current;if($.target!==ve||!rS.includes($.key))return;$.preventDefault();const Te=k().filter(K=>!K.disabled).map(K=>K.ref.current);th.includes($.key)&&Te.reverse(),kS(Te)}),onBlur:fe(e.onBlur,$=>{$.currentTarget.contains($.target)||(window.clearTimeout(j.current),P.current="")}),onPointerMove:fe(e.onPointerMove,So($=>{const pe=$.target,F=M.current!==$.clientX;if($.currentTarget.contains(pe)&&F){const Z=$.clientX>M.current?"right":"left";B.current=Z,M.current=$.clientX}}))})})})})})})});ah.displayName=Zt;var gS="MenuGroup",Za=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ae.div,{role:"group",...r,ref:t})});Za.displayName=gS;var xS="MenuLabel",lh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ae.div,{...r,ref:t})});lh.displayName=xS;var Vs="MenuItem",ch="menu.itemSelect",Ks=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=bo(Vs,e.__scopeMenu),a=Xa(Vs,e.__scopeMenu),l=We(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(ch,{bubbles:!0,cancelable:!0});f.addEventListener(ch,p=>r==null?void 0:r(p),{once:!0}),Uu(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(uh,{...o,ref:l,disabled:n,onClick:fe(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:fe(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:fe(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||qa.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Ks.displayName=Vs;var uh=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Xa(Vs,n),a=rh(n),l=m.useRef(null),u=We(t,l),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const v=l.current;v&&p((v.textContent??"").trim())},[s.children]),c.jsx(vo.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(tS,{asChild:!0,...a,focusable:!r,children:c.jsx(Ae.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:fe(e.onPointerMove,So(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:fe(e.onPointerLeave,So(v=>i.onItemLeave(v))),onFocus:fe(e.onFocus,()=>f(!0)),onBlur:fe(e.onBlur,()=>f(!1))})})})}),yS="MenuCheckboxItem",dh=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(gh,{scope:e.__scopeMenu,checked:n,children:c.jsx(Ks,{role:"menuitemcheckbox","aria-checked":qs(n)?"mixed":n,...o,ref:t,"data-state":el(n),onSelect:fe(o.onSelect,()=>r==null?void 0:r(qs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});dh.displayName=yS;var fh="MenuRadioGroup",[vS,bS]=mr(fh,{value:void 0,onValueChange:()=>{}}),hh=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Tt(r);return c.jsx(vS,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(Za,{...o,ref:t})})});hh.displayName=fh;var ph="MenuRadioItem",mh=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=bS(ph,e.__scopeMenu),s=n===o.value;return c.jsx(gh,{scope:e.__scopeMenu,checked:s,children:c.jsx(Ks,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":el(s),onSelect:fe(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});mh.displayName=ph;var Qa="MenuItemIndicator",[gh,wS]=mr(Qa,{checked:!1}),xh=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=wS(Qa,n);return c.jsx(Ut,{present:r||qs(s.checked)||s.checked===!0,children:c.jsx(Ae.span,{...o,ref:t,"data-state":el(s.checked)})})});xh.displayName=Qa;var SS="MenuSeparator",yh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ae.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});yh.displayName=SS;var CS="MenuArrow",vh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ws(n);return c.jsx(Gf,{...o,...r,ref:t})});vh.displayName=CS;var TS="MenuSub",[ik,bh]=mr(TS),wo="MenuSubTrigger",wh=m.forwardRef((e,t)=>{const n=gr(wo,e.__scopeMenu),r=bo(wo,e.__scopeMenu),o=bh(wo,e.__scopeMenu),s=Xa(wo,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(uh,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Th(n.open),...e,ref:sa(t,o.onTriggerChange),onClick:f=>{var h;(h=e.onClick)==null||h.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:fe(e.onPointerMove,So(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:fe(e.onPointerLeave,So(f=>{var p,v;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const x=(v=n.content)==null?void 0:v.dataset.side,g=x==="right",y=g?-5:5,b=h[g?"left":"right"],S=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+y,y:f.clientY},{x:b,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:b,y:h.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:fe(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||oS[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});wh.displayName=wo;var Sh="MenuSubContent",Ch=m.forwardRef((e,t)=>{const n=sh(Zt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=gr(Zt,e.__scopeMenu),i=bo(Zt,e.__scopeMenu),a=bh(Sh,e.__scopeMenu),l=m.useRef(null),u=We(t,l);return c.jsx(vo.Provider,{scope:e.__scopeMenu,children:c.jsx(Ut,{present:r||s.open,children:c.jsx(vo.Slot,{scope:e.__scopeMenu,children:c.jsx(Ja,{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:fe(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:fe(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:fe(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=sS[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});Ch.displayName=Sh;function Th(e){return e?"open":"closed"}function qs(e){return e==="indeterminate"}function el(e){return qs(e)?"indeterminate":e?"checked":"unchecked"}function kS(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function ES(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function IS(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=ES(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 NS(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 AS(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return NS(n,t)}function So(e){return t=>t.pointerType==="mouse"?e(t):void 0}var _S=oh,jS=Ga,RS=ih,PS=ah,OS=Za,MS=lh,DS=Ks,LS=dh,$S=hh,FS=mh,zS=xh,BS=yh,HS=vh,US=wh,WS=Ch,Gs="DropdownMenu",[VS,ak]=gn(Gs,[nh]),Pt=nh(),[KS,kh]=VS(Gs),Eh=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Pt(t),u=m.useRef(null),[d,f]=cr({prop:o,defaultProp:s??!1,onChange:i,caller:Gs});return c.jsx(KS,{scope:t,triggerId:xn(),triggerRef:u,contentId:xn(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(_S,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Eh.displayName=Gs;var Ih="DropdownMenuTrigger",Nh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=kh(Ih,n),i=Pt(n);return c.jsx(jS,{asChild:!0,...i,children:c.jsx(Ae.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:sa(t,s.triggerRef),onPointerDown:fe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:fe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Nh.displayName=Ih;var qS="DropdownMenuPortal",Ah=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Pt(t);return c.jsx(RS,{...r,...n})};Ah.displayName=qS;var _h="DropdownMenuContent",jh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=kh(_h,n),s=Pt(n),i=m.useRef(!1);return c.jsx(PS,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:fe(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:fe(e.onInteractOutside,a=>{const l=a.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,d=l.button===2||u;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});jh.displayName=_h;var GS="DropdownMenuGroup",YS=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Pt(n);return c.jsx(OS,{...o,...r,ref:t})});YS.displayName=GS;var XS="DropdownMenuLabel",Rh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Pt(n);return c.jsx(MS,{...o,...r,ref:t})});Rh.displayName=XS;var JS="DropdownMenuItem",Ph=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Pt(n);return c.jsx(DS,{...o,...r,ref:t})});Ph.displayName=JS;var ZS="DropdownMenuCheckboxItem",Oh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Pt(n);return c.jsx(LS,{...o,...r,ref:t})});Oh.displayName=ZS;var QS="DropdownMenuRadioGroup",eC=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Pt(n);return c.jsx($S,{...o,...r,ref:t})});eC.displayName=QS;var tC="DropdownMenuRadioItem",Mh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Pt(n);return c.jsx(FS,{...o,...r,ref:t})});Mh.displayName=tC;var nC="DropdownMenuItemIndicator",Dh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Pt(n);return c.jsx(zS,{...o,...r,ref:t})});Dh.displayName=nC;var rC="DropdownMenuSeparator",Lh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Pt(n);return c.jsx(BS,{...o,...r,ref:t})});Lh.displayName=rC;var oC="DropdownMenuArrow",sC=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Pt(n);return c.jsx(HS,{...o,...r,ref:t})});sC.displayName=oC;var iC="DropdownMenuSubTrigger",$h=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Pt(n);return c.jsx(US,{...o,...r,ref:t})});$h.displayName=iC;var aC="DropdownMenuSubContent",Fh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Pt(n);return c.jsx(WS,{...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)"}})});Fh.displayName=aC;var lC=Eh,cC=Nh,uC=Ah,zh=jh,Bh=Rh,Hh=Ph,Uh=Oh,Wh=Mh,Vh=Dh,Kh=Lh,qh=$h,Gh=Fh;const dC=lC,fC=cC,hC=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(qh,{ref:o,className:ee("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(ae.ChevronRight,{className:"ml-auto h-4 w-4"})]}));hC.displayName=qh.displayName;const pC=m.forwardRef(({className:e,...t},n)=>c.jsx(Gh,{ref:n,className:ee("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}));pC.displayName=Gh.displayName;const Yh=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(uC,{children:c.jsx(zh,{ref:r,sideOffset:t,className:ee("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Yh.displayName=zh.displayName;const tl=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Hh,{ref:r,className:ee("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}));tl.displayName=Hh.displayName;const mC=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(Uh,{ref:o,className:ee("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Vh,{children:c.jsx(ae.Check,{className:"h-4 w-4"})})}),t]}));mC.displayName=Uh.displayName;const gC=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Wh,{ref:r,className:ee("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Vh,{children:c.jsx(ae.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));gC.displayName=Wh.displayName;const xC=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Bh,{ref:r,className:ee("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));xC.displayName=Bh.displayName;const yC=m.forwardRef(({className:e,...t},n)=>c.jsx(Kh,{ref:n,className:ee("-mx-1 my-1 h-px bg-muted",e),...t}));yC.displayName=Kh.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:v}=Ci(),{currentThreadId:x}=Uo(),{threadId:g,messages:y,hasMore:b,isHistoryLoading:S,isLoading:k,loadOlder:C,navigateToCheckpoint:T,returnToLatest:I,checkpoint:A,checkpoints:j,respondToInterrupt:P,metadata:D}=Wo(),{isStreaming:L,error:B,submit:M,stop:X}=Hc(),W=(A==null?void 0:A.id)??null,V=(A==null?void 0:A.namespace)??null,z=(D==null?void 0:D.assemblingMessageId)??null,[$,pe]=w.useState(null),[F,Z]=w.useState(""),[he,ve]=w.useState(null),[be,Te]=w.useState([]),[K,O]=w.useState(0),[J,te]=w.useState(0),[de,le]=w.useState(!1),[ie,tt]=w.useState(null),[et,Oe]=w.useState(null),[He,ht]=w.useState(!1),[nt,Me]=w.useState(null),[bt,ne]=w.useState(!1),se=w.useRef(null),ge=w.useRef(null),we=w.useCallback(()=>{se.current&&(se.current.value=""),ge.current&&(ge.current.value=""),O(me=>me+1),te(me=>me+1)},[]),xe=w.useRef(!1);w.useEffect(()=>{xe.current&&!L&&(Te([]),we()),xe.current=L},[L,we]);const[ze,st]=w.useState("desktop");w.useEffect(()=>{const me=()=>{const Ee=window.innerWidth;st(Ee<640?"phone":Ee<1024?"tablet":"desktop")};return me(),window.addEventListener("resize",me),()=>window.removeEventListener("resize",me)},[]);const Fe=w.useCallback(async()=>{if(!(!b||S))try{await C()}catch(me){console.warn("loadOlder failed",me)}},[b,S,C]);w.useEffect(()=>{(async()=>{if(!v.baseUrl){Me(null);return}try{const Ee=await v.getAgent("default");Me(Ee.uiDefaultMessage||null)}catch(Ee){console.warn("Failed to fetch default message:",Ee),Me(null)}})()},[v]),w.useEffect(()=>{B&&!He&&(p==null||p(B))},[B,He,p]);const ut=me=>{if(me.length>js)return`Message too long (${me.length}/${js} characters)`;try{return Tw(me),null}catch(Ee){return(Ee==null?void 0:Ee.message)||"Invalid message"}},xt=async me=>{const Ee=me.trim();if(!(!Ee&&be.length===0)){if(Ee){const Pe=ut(Ee);if(Pe){ve(Pe);return}}try{await M({text:Ee||"",attachments:be,payload:$?{edit:!0,originalMessageId:$}:void 0},{checkpointId:W??void 0,checkpointNs:V??void 0}),f==null||f(Ee),ve(null),Te([]),we(),pe(null),Z("")}catch(Pe){const it=(Pe==null?void 0:Pe.message)||"Failed to send message";ve(it),p==null||p(it)}}},Ot=w.useCallback((me,Ee)=>{u&&(pe(me),Z(Ee),ve(null))},[u]),tn=w.useCallback(()=>{pe(null),Z(""),ve(null)},[]),Hr=w.useCallback((me,Ee)=>{Ot(me,Ee)},[Ot]),Yn=w.useCallback(me=>{const Ee=Pe=>{const it=Pe.content||[],Ft=it.filter(Jn=>Jn.type==="text").map(Jn=>Jn.text).join("");if(Ft)return Ft;try{return JSON.stringify(it,null,2)}catch{return String(it)}};for(let Pe=me-1;Pe>=0;Pe--)if(y[Pe].role==="user"){const it=Ee(y[Pe]);it&&M({text:it},{checkpointId:W??void 0,checkpointNs:V??void 0});break}},[y,M,W,V]),Tn=me=>{const Ee=Array.from(me.target.files||[]);Te(Pe=>[...Pe,...Ee]),me.target.value=""},Xn=me=>{Te(Ee=>{const Pe=Ee.filter((it,Ft)=>me!==Ft);return Pe.length===0&&we(),Pe})},nn=async me=>{const Ee=(me.target.files||[])[0];if(Ee){tt(null),Oe(null),le(!0);try{await M({attachments:[Ee]},{checkpointId:W??void 0,checkpointNs:V??void 0});const Pe=`Uploaded ${Ee.name} - processing through chat stream`;Oe(Pe)}catch(Pe){const it=Pe instanceof Error?Pe.message:"Failed to upload Excel file";console.error("Excel upload failed",Pe),tt(it),p==null||p(it)}finally{le(!1),me.target.value="",we()}}},br=me=>{if(!me)return"Unknown";const Ee=Date.parse(me);return Number.isNaN(Ee)?me:new Date(Ee).toLocaleString()},jn=async me=>{if(x){ne(!0);try{if(!me){await I();return}const Ee=j.find(it=>it.checkpointId===me),Pe=(Ee==null?void 0:Ee.checkpointNs)??null;await T(me,Pe)}finally{ne(!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||""}`,Rn=`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||""}`,_t=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return c.jsxs("div",{className:wr,children:[!!B&&!He&&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:B}),c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>ht(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(ae.X,{size:16})})]}),x&&j.length>0&&c.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[c.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),c.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:W??"",onChange:me=>{const Ee=me.target.value||null;jn(Ee)},children:[c.jsx("option",{value:"",children:"Latest"}),j.map(me=>c.jsxs("option",{value:me.checkpointId,children:[br(me.createdAt),me.preview?` — ${me.preview.slice(0,40)}`:""]},me.checkpointId))]})]}),c.jsxs("div",{className:`relative ${Rn}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(_a,{className:"h-full",style:{height:"100%"},messages:y,isStreaming:L,streamingAssistantId:z,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:ze,enableMessageEditing:u,editingMessageId:$,onStartReached:()=>{Fe()},onEdit:Hr,onRegenerate:Yn,onCancelEdit:tn,emptyMessage:nt??void 0,isNavigatingCheckpoint:bt}),k&&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(ae.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:_t,children:[$&&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(ae.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(qe,{variant:"ghost",size:"sm",onClick:tn,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(ae.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:me=>Tn(me),className:"hidden"},K),be.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:be.map((me,Ee)=>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(ae.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:me.name}),c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>Xn(Ee),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 ${me.name}`,children:c.jsx(ae.X,{size:12})})]},Ee))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:ge,type:"file",accept:".xls,.xlsx,.xlsm",onChange:nn,className:"hidden"},J),de&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(ae.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),et&&!de&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:et}),ie&&!de&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:ie})]})]}),he&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:he}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(dC,{children:[c.jsx(fC,{asChild:!0,children:c.jsx(qe,{type:"button",size:"icon",variant:"outline",disabled:L,title:"More input actions",className:d.moreButton||"",children:c.jsx(ae.Plus,{size:16})})}),c.jsxs(Yh,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(tl,{onClick:()=>{var me;return(me=se.current)==null?void 0:me.click()},className:"cursor-pointer",children:[c.jsx(ae.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(tl,{onClick:()=>{var me;de||(me=ge.current)==null||me.click()},className:`cursor-pointer ${de?"opacity-60 pointer-events-none":""}`,children:[c.jsx(ae.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx(Lx,{initialValue:F,editingMessageId:$,placeholder:$?"Edit your message...":t,isStreaming:L,disabled:!1,maxLength:js,onSend:xt,onCancelEdit:tn,onStop:X,allowEmptySend:be.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${$?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${he?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const Xs=m.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:ee("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}));Xs.displayName="Input";function nl(e,[t,n]){return Math.min(n,Math.max(t,e))}function vC(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var rl="ScrollArea",[Xh,lk]=gn(rl),[bC,Qt]=Xh(rl),Jh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=m.useState(null),[u,d]=m.useState(null),[f,h]=m.useState(null),[p,v]=m.useState(null),[x,g]=m.useState(null),[y,b]=m.useState(0),[S,k]=m.useState(0),[C,T]=m.useState(!1),[I,A]=m.useState(!1),j=We(t,D=>l(D)),P=Rs(o);return c.jsx(bC,{scope:n,type:r,dir:P,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:x,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:k,children:c.jsx(Ae.div,{dir:P,...i,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Jh.displayName=rl;var Zh="ScrollAreaViewport",Qh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Qt(Zh,n),a=m.useRef(null),l=We(t,a,i.onViewportChange);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),c.jsx(Ae.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:c.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Qh.displayName=Zh;var Cn="ScrollAreaScrollbar",ol=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(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(wC,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(SC,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(ep,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(sl,{...r,ref:t}):null});ol.displayName=Cn;var wC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(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(Ut,{present:n||s,children:c.jsx(ep,{"data-state":s?"visible":"hidden",...r,ref:t})})}),SC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(Cn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ei(()=>l("SCROLL_END"),100),[a,l]=vC("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(Ut,{present:n||a!=="hidden",children:c.jsx(sl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:fe(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:fe(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),ep=m.forwardRef((e,t)=>{const n=Qt(Cn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",l=ei(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return Fr(n.viewport,l),Fr(n.content,l),c.jsx(Ut,{present:r||s,children:c.jsx(sl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),sl=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Qt(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=sp(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:u>0&&u<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return NC(h,i.current,a,p)}return n==="horizontal"?c.jsx(CC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=ip(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?c.jsx(TC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=ip(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),CC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Qt(Cn,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=We(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(np,{"data-orientation":"horizontal",...o,ref:u,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Qs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(h),lp(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Zs(i.paddingLeft),paddingEnd:Zs(i.paddingRight)}})}})}),TC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Qt(Cn,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=We(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(np,{"data-orientation":"vertical",...o,ref:u,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Qs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(h),lp(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Zs(i.paddingTop),paddingEnd:Zs(i.paddingBottom)}})}})}),[kC,tp]=Xh(Cn),np=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,p=Qt(Cn,n),[v,x]=m.useState(null),g=We(t,j=>x(j)),y=m.useRef(null),b=m.useRef(""),S=p.viewport,k=r.content-r.viewport,C=Tt(d),T=Tt(l),I=ei(f,10);function A(j){if(y.current){const P=j.clientX-y.current.left,D=j.clientY-y.current.top;u({x:P,y:D})}}return m.useEffect(()=>{const j=P=>{const D=P.target;(v==null?void 0:v.contains(D))&&C(P,k)};return document.addEventListener("wheel",j,{passive:!1}),()=>document.removeEventListener("wheel",j,{passive:!1})},[S,v,k,C]),m.useEffect(T,[r,T]),Fr(v,I),Fr(p.content,I),c.jsx(kC,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:Tt(s),onThumbPointerUp:Tt(i),onThumbPositionChange:T,onThumbPointerDown:Tt(a),children:c.jsx(Ae.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:fe(e.onPointerDown,j=>{j.button===0&&(j.target.setPointerCapture(j.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(j))}),onPointerMove:fe(e.onPointerMove,A),onPointerUp:fe(e.onPointerUp,j=>{const P=j.target;P.hasPointerCapture(j.pointerId)&&P.releasePointerCapture(j.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),Js="ScrollAreaThumb",rp=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=tp(Js,e.__scopeScrollArea);return c.jsx(Ut,{present:n||o.hasThumb,children:c.jsx(EC,{ref:t,...r})})}),EC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Qt(Js,n),i=tp(Js,n),{onThumbPositionChange:a}=i,l=We(t,f=>i.onThumbChange(f)),u=m.useRef(void 0),d=ei(()=>{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=AC(f,a);u.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),c.jsx(Ae.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:fe(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),v=f.clientX-p.left,x=f.clientY-p.top;i.onThumbPointerDown({x:v,y:x})}),onPointerUp:fe(e.onPointerUp,i.onThumbPointerUp)})});rp.displayName=Js;var il="ScrollAreaCorner",op=m.forwardRef((e,t)=>{const n=Qt(il,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(IC,{...e,ref:t}):null});op.displayName=il;var IC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Qt(il,n),[s,i]=m.useState(0),[a,l]=m.useState(0),u=!!(s&&a);return Fr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Fr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?c.jsx(Ae.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 Zs(e){return e?parseInt(e,10):0}function sp(e,t){const n=e/t;return isNaN(n)?0:n}function Qs(e){const t=sp(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function NC(e,t,n,r="ltr"){const o=Qs(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return ap([l,u],f)(e)}function ip(e,t,n="ltr"){const r=Qs(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=nl(e,l);return ap([0,i],[0,a])(u)}function ap(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function lp(e,t){return e>0&&e<t}var AC=(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 ei(e,t){const n=Tt(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 Fr(e,t){const n=Tt(t);wt(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var cp=Jh,_C=Qh,jC=op;const up=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(cp,{ref:r,className:ee("relative overflow-hidden",e),...n,children:[c.jsx(_C,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(dp,{}),c.jsx(jC,{})]}));up.displayName=cp.displayName;const dp=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(ol,{ref:r,orientation:t,className:ee("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:c.jsx(rp,{className:"relative flex-1 rounded-full bg-border"})}));dp.displayName=ol.displayName;function al({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:u,onThreadDelete:d}){const{threads:f,currentThreadId:h,isLoading:p,actions:v}=Uo(),{loadThread:x}=Wo(),{createThread:g,deleteThread:y,renameThread:b}=v,[S,k]=w.useState(Array.isArray(f)?f:[]),C=w.useRef(S.length>0),[T,I]=w.useState(null),[A,j]=w.useState(""),[P,D]=w.useState(!1);w.useEffect(()=>{const F=Array.isArray(f)?f:[];if(F.length>0){C.current=!0,k(F);return}p||(C.current=!1,k(F))},[f,p]);const L=async F=>{try{await x(F),a==null||a(F),l==null||l(F)}catch(Z){console.error("Failed to select thread:",Z)}},B=async()=>{try{D(!0);const F=await g();u==null||u(F),a==null||a(F)}catch(F){console.error("Failed to create thread:",F)}finally{D(!1)}},M=async(F,Z)=>{if(Z.stopPropagation(),!!confirm("Delete this thread?"))try{await y(F),d==null||d(F)}catch(he){console.error("Failed to delete thread:",he)}},X=(F,Z)=>{Z.stopPropagation(),I(F.threadId),j(F.title||`Thread ${F.threadId.slice(0,8)}`)},W=async F=>{if(A.trim())try{await b(F,A.trim()),I(null),j("")}catch(Z){console.error("Failed to update title:",Z)}},V=()=>{I(null),j("")},z=(F,Z)=>{F.key==="Enter"?W(Z):F.key==="Escape"&&V()},$=F=>{if(!F)return"";try{const Z=new Date(F),ve=new Date().getTime()-Z.getTime(),be=Math.floor(ve/(1e3*60*60*24));return be===0?Z.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):be===1?"Yesterday":be<7?`${be} days ago`:Z.toLocaleDateString()}catch{return""}},pe=F=>F.title||`Thread ${F.threadId.slice(0,8)}`;return c.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&c.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:c.jsx(qe,{onClick:B,disabled:P||p,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:P?"Creating...":"New Chat",children:c.jsx(ae.MessageSquarePlus,{size:20})})}),c.jsx(up,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:c.jsx("div",{className:"p-2 space-y-1 pb-4",children:p?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(ae.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):S.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(ae.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),c.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):S.slice().sort((F,Z)=>new Date(Z.updatedAt||Z.createdAt||"").getTime()-new Date(F.updatedAt||F.createdAt||"").getTime()).map(F=>c.jsxs("div",{onClick:()=>L(F.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??h)===F.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"flex-1 min-w-0",children:T===F.threadId?c.jsxs("div",{className:"flex items-center gap-2",onClick:Z=>Z.stopPropagation(),children:[c.jsx(Xs,{value:A,onChange:Z=>j(Z.target.value),onKeyDown:Z=>z(Z,F.threadId),className:"h-6 text-sm",autoFocus:!0}),c.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>W(F.threadId),className:"h-6 w-6 p-0",children:c.jsx(ae.Check,{size:12})}),c.jsx(qe,{variant:"ghost",size:"sm",onClick:V,className:"h-6 w-6 p-0",children:c.jsx(ae.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:pe(F)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(ae.Calendar,{size:10}),c.jsx("span",{children:$(F.updatedAt||F.createdAt)})]})]})}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&T!==F.threadId&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:Z=>X(F,Z),className:"h-6 w-6 p-0",title:"Edit title",children:c.jsx(ae.Edit3,{size:12})}),n&&c.jsx(qe,{variant:"ghost",size:"sm",onClick:Z=>M(F.threadId,Z),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(ae.Trash2,{size:12})})]})]}),i===F.threadId&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},F.threadId))})})]})}function zr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function RC(e){if(typeof e!="string")return;const t=e.trim();if(t)return En(t)}function fp(){const e=[zr("__API_BASE_URL__"),zr("__CHAT_API_BASE_URL__"),zr("__CHAT_API_URL__")];for(const t of e){const n=RC(t);if(n)return n}}function hp(){const e=[zr("__API_AUTH_TOKEN__"),zr("__CHAT_API_KEY__"),zr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function pp(...e){for(const t of e)if(typeof t=="string"&&t.trim())return En(t);return En()}function mp(){const e={},t=fp(),n=hp();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function gp(){const e=mp(),t=Dn.getAuthToken(),n=fp();return{apiBaseUrl:pp(e.baseUrl,Dn.baseUrl,n),apiKey:t||e.apiKey||hp()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const xp="chat-settings";function PC(){try{const e=localStorage.getItem(xp);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function OC(e){try{const t={...e,apiBaseUrl:En(e.apiBaseUrl)};localStorage.setItem(xp,JSON.stringify(t)),t.apiKey&&Dn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function MC(){const e=gp(),t=PC(),n=Dn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:pp(Dn.baseUrl,r,e.apiBaseUrl)}}function DC(e){Dn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),OC(e)}var LC="Label",yp=m.forwardRef((e,t)=>c.jsx(Ae.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));yp.displayName=LC;var vp=yp;const $C=Io.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),en=m.forwardRef(({className:e,...t},n)=>c.jsx(vp,{ref:n,className:ee($C(),e),...t}));en.displayName=vp.displayName;function bp(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var ti="Switch",[FC,ck]=gn(ti),[zC,BC]=FC(ti),wp=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:u,form:d,...f}=e,[h,p]=m.useState(null),v=We(t,S=>p(S)),x=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[y,b]=cr({prop:o,defaultProp:s??!1,onChange:u,caller:ti});return c.jsxs(zC,{scope:n,checked:y,disabled:a,children:[c.jsx(Ae.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":kp(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:v,onClick:fe(e.onClick,S=>{b(k=>!k),g&&(x.current=S.isPropagationStopped(),x.current||S.stopPropagation())})}),g&&c.jsx(Tp,{control:h,bubbles:!x.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});wp.displayName=ti;var Sp="SwitchThumb",Cp=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=BC(Sp,n);return c.jsx(Ae.span,{"data-state":kp(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Cp.displayName=Sp;var HC="SwitchBubbleInput",Tp=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=We(i,s),l=bp(n),u=Mf(t);return m.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const v=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(v)}},[l,n,r]),c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Tp.displayName=HC;function kp(e){return e?"checked":"unchecked"}var Ep=wp,UC=Cp;const Kn=m.forwardRef(({className:e,...t},n)=>c.jsx(Ep,{className:ee("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(UC,{className:ee("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=Ep.displayName;var Ip=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),WC="VisuallyHidden",VC=m.forwardRef((e,t)=>c.jsx(Ae.span,{...e,ref:t,style:{...Ip,...e.style}}));VC.displayName=WC;var KC=[" ","Enter","ArrowUp","ArrowDown"],qC=[" ","Enter"],xr="Select",[ni,ri,GC]=ja(xr),[Br,uk]=gn(xr,[GC,Us]),oi=Us(),[YC,qn]=Br(xr),[XC,JC]=Br(xr),Np=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:u,name:d,autoComplete:f,disabled:h,required:p,form:v}=e,x=oi(t),[g,y]=m.useState(null),[b,S]=m.useState(null),[k,C]=m.useState(!1),T=Rs(u),[I,A]=cr({prop:r,defaultProp:o??!1,onChange:s,caller:xr}),[j,P]=cr({prop:i,defaultProp:a,onChange:l,caller:xr}),D=m.useRef(null),L=g?v||!!g.closest("form"):!0,[B,M]=m.useState(new Set),X=Array.from(B).map(W=>W.props.value).join(";");return c.jsx(Vf,{...x,children:c.jsxs(YC,{required:p,scope:t,trigger:g,onTriggerChange:y,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:xn(),value:j,onValueChange:P,open:I,onOpenChange:A,dir:T,triggerPointerDownPosRef:D,disabled:h,children:[c.jsx(ni.Provider,{scope:t,children:c.jsx(XC,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(W=>{M(V=>new Set(V).add(W))},[]),onNativeOptionRemove:m.useCallback(W=>{M(V=>{const z=new Set(V);return z.delete(W),z})},[]),children:n})}),L?c.jsxs(Zp,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:j,onChange:W=>P(W.target.value),disabled:h,form:v,children:[j===void 0?c.jsx("option",{value:""}):null,Array.from(B)]},X):null]})})};Np.displayName=xr;var Ap="SelectTrigger",_p=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=oi(n),i=qn(Ap,n),a=i.disabled||r,l=We(t,i.onTriggerChange),u=ri(n),d=m.useRef("touch"),[f,h,p]=em(x=>{const g=u().filter(S=>!S.disabled),y=g.find(S=>S.value===i.value),b=tm(g,x,y);b!==void 0&&i.onValueChange(b.value)}),v=x=>{a||(i.onOpenChange(!0),p()),x&&(i.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return c.jsx(Kf,{asChild:!0,...s,children:c.jsx(Ae.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Qp(i.value)?"":void 0,...o,ref:l,onClick:fe(o.onClick,x=>{x.currentTarget.focus(),d.current!=="mouse"&&v(x)}),onPointerDown:fe(o.onPointerDown,x=>{d.current=x.pointerType;const g=x.target;g.hasPointerCapture(x.pointerId)&&g.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(v(x),x.preventDefault())}),onKeyDown:fe(o.onKeyDown,x=>{const g=f.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&h(x.key),!(g&&x.key===" ")&&KC.includes(x.key)&&(v(),x.preventDefault())})})})});_p.displayName=Ap;var jp="SelectValue",Rp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=qn(jp,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=We(t,l.onValueNodeChange);return wt(()=>{u(d)},[u,d]),c.jsx(Ae.span,{...a,ref:f,style:{pointerEvents:"none"},children:Qp(l.value)?c.jsx(c.Fragment,{children:i}):s})});Rp.displayName=jp;var ZC="SelectIcon",Pp=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(Ae.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Pp.displayName=ZC;var QC="SelectPortal",Op=e=>c.jsx(gs,{asChild:!0,...e});Op.displayName=QC;var yr="SelectContent",Mp=m.forwardRef((e,t)=>{const n=qn(yr,e.__scopeSelect),[r,o]=m.useState();if(wt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?No.createPortal(c.jsx(Dp,{scope:e.__scopeSelect,children:c.jsx(ni.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(Lp,{...e,ref:t})});Mp.displayName=yr;var un=10,[Dp,Gn]=Br(yr),eT="SelectContentImpl",tT=tr.createSlot("SelectContent.RemoveScroll"),Lp=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:x,avoidCollisions:g,...y}=e,b=qn(yr,n),[S,k]=m.useState(null),[C,T]=m.useState(null),I=We(t,K=>k(K)),[A,j]=m.useState(null),[P,D]=m.useState(null),L=ri(n),[B,M]=m.useState(!1),X=m.useRef(!1);m.useEffect(()=>{if(S)return ka(S)},[S]),va();const W=m.useCallback(K=>{const[O,...J]=L().map(le=>le.ref.current),[te]=J.slice(-1),de=document.activeElement;for(const le of K)if(le===de||(le==null||le.scrollIntoView({block:"nearest"}),le===O&&C&&(C.scrollTop=0),le===te&&C&&(C.scrollTop=C.scrollHeight),le==null||le.focus(),document.activeElement!==de))return},[L,C]),V=m.useCallback(()=>W([A,S]),[W,A,S]);m.useEffect(()=>{B&&V()},[B,V]);const{onOpenChange:z,triggerPointerDownPosRef:$}=b;m.useEffect(()=>{if(S){let K={x:0,y:0};const O=te=>{var de,le;K={x:Math.abs(Math.round(te.pageX)-(((de=$.current)==null?void 0:de.x)??0)),y:Math.abs(Math.round(te.pageY)-(((le=$.current)==null?void 0:le.y)??0))}},J=te=>{K.x<=10&&K.y<=10?te.preventDefault():S.contains(te.target)||z(!1),document.removeEventListener("pointermove",O),$.current=null};return $.current!==null&&(document.addEventListener("pointermove",O),document.addEventListener("pointerup",J,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",O),document.removeEventListener("pointerup",J,{capture:!0})}}},[S,z,$]),m.useEffect(()=>{const K=()=>z(!1);return window.addEventListener("blur",K),window.addEventListener("resize",K),()=>{window.removeEventListener("blur",K),window.removeEventListener("resize",K)}},[z]);const[pe,F]=em(K=>{const O=L().filter(de=>!de.disabled),J=O.find(de=>de.ref.current===document.activeElement),te=tm(O,K,J);te&&setTimeout(()=>te.ref.current.focus())}),Z=m.useCallback((K,O,J)=>{const te=!X.current&&!J;(b.value!==void 0&&b.value===O||te)&&(j(K),te&&(X.current=!0))},[b.value]),he=m.useCallback(()=>S==null?void 0:S.focus(),[S]),ve=m.useCallback((K,O,J)=>{const te=!X.current&&!J;(b.value!==void 0&&b.value===O||te)&&D(K)},[b.value]),be=r==="popper"?ll:$p,Te=be===ll?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:x,avoidCollisions:g}:{};return c.jsx(Dp,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:Z,selectedItem:A,onItemLeave:he,itemTextRefCallback:ve,focusSelectedItem:V,selectedItemText:P,position:r,isPositioned:B,searchRef:pe,children:c.jsx(Ss,{as:tT,allowPinchZoom:!0,children:c.jsx(ms,{asChild:!0,trapped:b.open,onMountAutoFocus:K=>{K.preventDefault()},onUnmountAutoFocus:fe(o,K=>{var O;(O=b.trigger)==null||O.focus({preventScroll:!0}),K.preventDefault()}),children:c.jsx(ps,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:K=>K.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:c.jsx(be,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:K=>K.preventDefault(),...y,...Te,onPlaced:()=>M(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:fe(y.onKeyDown,K=>{const O=K.ctrlKey||K.altKey||K.metaKey;if(K.key==="Tab"&&K.preventDefault(),!O&&K.key.length===1&&F(K.key),["ArrowUp","ArrowDown","Home","End"].includes(K.key)){let te=L().filter(de=>!de.disabled).map(de=>de.ref.current);if(["ArrowUp","End"].includes(K.key)&&(te=te.slice().reverse()),["ArrowUp","ArrowDown"].includes(K.key)){const de=K.target,le=te.indexOf(de);te=te.slice(le+1)}setTimeout(()=>W(te)),K.preventDefault()}})})})})})})});Lp.displayName=eT;var nT="SelectItemAlignedPosition",$p=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=qn(yr,n),i=Gn(yr,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=We(t,I=>d(I)),h=ri(n),p=m.useRef(!1),v=m.useRef(!0),{viewport:x,selectedItem:g,selectedItemText:y,focusSelectedItem:b}=i,S=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&x&&g&&y){const I=s.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),j=s.valueNode.getBoundingClientRect(),P=y.getBoundingClientRect();if(s.dir!=="rtl"){const de=P.left-A.left,le=j.left-de,ie=I.left-le,tt=I.width+ie,et=Math.max(tt,A.width),Oe=window.innerWidth-un,He=nl(le,[un,Math.max(un,Oe-et)]);a.style.minWidth=tt+"px",a.style.left=He+"px"}else{const de=A.right-P.right,le=window.innerWidth-j.right-de,ie=window.innerWidth-I.right-le,tt=I.width+ie,et=Math.max(tt,A.width),Oe=window.innerWidth-un,He=nl(le,[un,Math.max(un,Oe-et)]);a.style.minWidth=tt+"px",a.style.right=He+"px"}const D=h(),L=window.innerHeight-un*2,B=x.scrollHeight,M=window.getComputedStyle(u),X=parseInt(M.borderTopWidth,10),W=parseInt(M.paddingTop,10),V=parseInt(M.borderBottomWidth,10),z=parseInt(M.paddingBottom,10),$=X+W+B+z+V,pe=Math.min(g.offsetHeight*5,$),F=window.getComputedStyle(x),Z=parseInt(F.paddingTop,10),he=parseInt(F.paddingBottom,10),ve=I.top+I.height/2-un,be=L-ve,Te=g.offsetHeight/2,K=g.offsetTop+Te,O=X+W+K,J=$-O;if(O<=ve){const de=D.length>0&&g===D[D.length-1].ref.current;a.style.bottom="0px";const le=u.clientHeight-x.offsetTop-x.offsetHeight,ie=Math.max(be,Te+(de?he:0)+le+V),tt=O+ie;a.style.height=tt+"px"}else{const de=D.length>0&&g===D[0].ref.current;a.style.top="0px";const ie=Math.max(ve,X+x.offsetTop+(de?Z:0)+Te)+J;a.style.height=ie+"px",x.scrollTop=O-ve+x.offsetTop}a.style.margin=`${un}px 0`,a.style.minHeight=pe+"px",a.style.maxHeight=L+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,x,g,y,s.dir,r]);wt(()=>S(),[S]);const[k,C]=m.useState();wt(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const T=m.useCallback(I=>{I&&v.current===!0&&(S(),b==null||b(),v.current=!1)},[S,b]);return c.jsx(oT,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:T,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:c.jsx(Ae.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});$p.displayName=nT;var rT="SelectPopperPosition",ll=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=un,...s}=e,i=oi(n);return c.jsx(qf,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});ll.displayName=rT;var[oT,cl]=Br(yr,{}),ul="SelectViewport",Fp=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Gn(ul,n),i=cl(ul,n),a=We(t,s.onViewportChange),l=m.useRef(0);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),c.jsx(ni.Slot,{scope:n,children:c.jsx(Ae.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:fe(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const v=window.innerHeight-un*2,x=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),y=Math.max(x,g);if(y<v){const b=y+p,S=Math.min(v,b),k=b-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Fp.displayName=ul;var zp="SelectGroup",[sT,iT]=Br(zp),aT=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=xn();return c.jsx(sT,{scope:n,id:o,children:c.jsx(Ae.div,{role:"group","aria-labelledby":o,...r,ref:t})})});aT.displayName=zp;var Bp="SelectLabel",Hp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=iT(Bp,n);return c.jsx(Ae.div,{id:o.id,...r,ref:t})});Hp.displayName=Bp;var si="SelectItem",[lT,Up]=Br(si),Wp=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=qn(si,n),l=Gn(si,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),v=We(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),x=xn(),g=m.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return c.jsx(lT,{scope:n,value:r,disabled:o,textId:x,isSelected:u,onItemTextChange:m.useCallback(b=>{f(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:c.jsx(ni.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(Ae.div,{role:"option","aria-labelledby":x,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:fe(i.onFocus,()=>p(!0)),onBlur:fe(i.onBlur,()=>p(!1)),onClick:fe(i.onClick,()=>{g.current!=="mouse"&&y()}),onPointerUp:fe(i.onPointerUp,()=>{g.current==="mouse"&&y()}),onPointerDown:fe(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:fe(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:fe(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:fe(i.onKeyDown,b=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(qC.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});Wp.displayName=si;var Co="SelectItemText",Vp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=qn(Co,n),a=Gn(Co,n),l=Up(Co,n),u=JC(Co,n),[d,f]=m.useState(null),h=We(t,y=>f(y),l.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,y,l.value,l.disabled)}),p=d==null?void 0:d.textContent,v=m.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:x,onNativeOptionRemove:g}=u;return wt(()=>(x(v),()=>g(v)),[x,g,v]),c.jsxs(c.Fragment,{children:[c.jsx(Ae.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?No.createPortal(s.children,i.valueNode):null]})});Vp.displayName=Co;var Kp="SelectItemIndicator",qp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Up(Kp,n).isSelected?c.jsx(Ae.span,{"aria-hidden":!0,...r,ref:t}):null});qp.displayName=Kp;var dl="SelectScrollUpButton",Gp=m.forwardRef((e,t)=>{const n=Gn(dl,e.__scopeSelect),r=cl(dl,e.__scopeSelect),[o,s]=m.useState(!1),i=We(t,r.onScrollButtonChange);return wt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollTop>0;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(Xp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Gp.displayName=dl;var fl="SelectScrollDownButton",Yp=m.forwardRef((e,t)=>{const n=Gn(fl,e.__scopeSelect),r=cl(fl,e.__scopeSelect),[o,s]=m.useState(!1),i=We(t,r.onScrollButtonChange);return wt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<u;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(Xp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Yp.displayName=fl;var Xp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Gn("SelectScrollButton",n),i=m.useRef(null),a=ri(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),wt(()=>{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(Ae.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:fe(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:fe(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:fe(o.onPointerLeave,()=>{l()})})}),cT="SelectSeparator",Jp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(Ae.div,{"aria-hidden":!0,...r,ref:t})});Jp.displayName=cT;var hl="SelectArrow",uT=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=oi(n),s=qn(hl,n),i=Gn(hl,n);return s.open&&i.position==="popper"?c.jsx(Gf,{...o,...r,ref:t}):null});uT.displayName=hl;var dT="SelectBubbleInput",Zp=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=We(r,o),i=bp(t);return m.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(Ae.select,{...n,style:{...Ip,...n.style},ref:s,defaultValue:t})});Zp.displayName=dT;function Qp(e){return e===""||e===void 0}function em(e){const t=Tt(e),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(i=>{const a=n.current+i;t(a),function l(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function tm(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=fT(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 fT(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var hT=Np,nm=_p,pT=Rp,mT=Pp,gT=Op,rm=Mp,xT=Fp,om=Hp,sm=Wp,yT=Vp,vT=qp,im=Gp,am=Yp,lm=Jp;const cm=hT,um=pT,pl=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(nm,{ref:r,className:ee("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(mT,{asChild:!0,children:c.jsx(ae.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));pl.displayName=nm.displayName;const dm=m.forwardRef(({className:e,...t},n)=>c.jsx(im,{ref:n,className:ee("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ae.ChevronUp,{className:"h-4 w-4"})}));dm.displayName=im.displayName;const fm=m.forwardRef(({className:e,...t},n)=>c.jsx(am,{ref:n,className:ee("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ae.ChevronDown,{className:"h-4 w-4"})}));fm.displayName=am.displayName;const ml=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(gT,{children:c.jsxs(rm,{ref:o,className:ee("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[c.jsx(dm,{}),c.jsx(xT,{className:ee("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(fm,{})]})}));ml.displayName=rm.displayName;const bT=m.forwardRef(({className:e,...t},n)=>c.jsx(om,{ref:n,className:ee("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));bT.displayName=om.displayName;const vr=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(sm,{ref:r,className:ee("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(vT,{children:c.jsx(ae.Check,{className:"h-4 w-4"})})}),c.jsx(yT,{children:t})]}));vr.displayName=sm.displayName;const wT=m.forwardRef(({className:e,...t},n)=>c.jsx(lm,{ref:n,className:ee("-mx-1 my-1 h-px bg-muted",e),...t}));wT.displayName=lm.displayName;var ST="Separator",hm="horizontal",CT=["horizontal","vertical"],pm=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=hm,...o}=e,s=TT(r)?r:hm,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(Ae.div,{"data-orientation":s,...a,...o,ref:t})});pm.displayName=ST;function TT(e){return CT.includes(e)}var mm=pm;const gm=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(mm,{ref:o,decorative:n,orientation:t,className:ee("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));gm.displayName=mm.displayName;const kT=Zd,ET=sw,IT=Qd,xm=m.forwardRef(({className:e,...t},n)=>c.jsx(Is,{className:ee("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));xm.displayName=Is.displayName;const NT=Io.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),ym=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(IT,{children:[c.jsx(xm,{}),c.jsxs(Ns,{ref:o,className:ee(NT({side:e}),t),...r,children:[n,c.jsxs(ef,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[c.jsx(ae.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ym.displayName=Ns.displayName;const vm=({className:e,...t})=>c.jsx("div",{className:ee("flex flex-col space-y-2 text-center sm:text-left",e),...t});vm.displayName="SheetHeader";const bm=m.forwardRef(({className:e,...t},n)=>c.jsx(fr,{ref:n,className:ee("text-lg font-semibold text-foreground",e),...t}));bm.displayName=fr.displayName;const wm=m.forwardRef(({className:e,...t},n)=>c.jsx(As,{ref:n,className:ee("text-sm text-muted-foreground",e),...t}));wm.displayName=As.displayName;const AT={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 _T({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=w.useState(!1),[s,i]=w.useState(!1),[a,l]=w.useState(e),[u,d]=w.useState(!1),{toast:f}=pa();w.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),w.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(AT),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},v=()=>{l(e),d(!1),o(!1)},x=async()=>{try{const y=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${y.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return c.jsxs(kT,{open:r,onOpenChange:o,children:[c.jsx(ET,{asChild:!0,children:c.jsxs(qe,{variant:"outline",size:"sm",className:n,children:[c.jsx(ae.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(oa,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(ym,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(vm,{children:[c.jsx(bm,{children:"Chat Settings"}),c.jsx(wm,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),c.jsxs("div",{className:"space-y-6 py-6",children:[c.jsxs(lo,{children:[c.jsx(co,{className:"pb-3",children:c.jsxs(uo,{className:"text-lg flex items-center gap-2",children:[c.jsx(ae.Server,{className:"h-5 w-5"}),"API Configuration"]})}),c.jsxs(as,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(en,{htmlFor:"api-url",children:"API Base URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Xs,{id:"api-url",value:a.api.baseUrl,onChange:g=>l(y=>({...y,api:{...y.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(qe,{variant:"outline",onClick:x,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(en,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(Kn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>l(y=>({...y,api:{...y.api,enableAuth:g}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(en,{htmlFor:"auth-token",children:"Authentication Token"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Xs,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>l(y=>({...y,api:{...y.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(qe,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(ae.EyeOff,{className:"h-4 w-4"}):c.jsx(ae.Eye,{className:"h-4 w-4"})})]})]})]})]}),c.jsxs(lo,{children:[c.jsx(co,{className:"pb-3",children:c.jsxs(uo,{className:"text-lg flex items-center gap-2",children:[c.jsx(ae.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),c.jsxs(as,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(en,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(cm,{value:a.ui.layout,onValueChange:g=>l(y=>({...y,ui:{...y.ui,layout:g}})),children:[c.jsx(pl,{children:c.jsx(um,{})}),c.jsxs(ml,{children:[c.jsx(vr,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(vr,{value:"fullscreen",children:"Fullscreen"}),c.jsx(vr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(en,{htmlFor:"theme",children:"Theme"}),c.jsxs(cm,{value:a.ui.theme,onValueChange:g=>l(y=>({...y,ui:{...y.ui,theme:g}})),children:[c.jsx(pl,{children:c.jsx(um,{})}),c.jsxs(ml,{children:[c.jsx(vr,{value:"light",children:"Light"}),c.jsx(vr,{value:"dark",children:"Dark"}),c.jsx(vr,{value:"system",children:"System"})]})]})]}),c.jsx(gm,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(en,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(Kn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,showTimestamps:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(en,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(Kn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,showAgentNames:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(en,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(Kn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,compactMessages:g}}))})]})]})]})]}),c.jsxs(lo,{children:[c.jsx(co,{className:"pb-3",children:c.jsxs(uo,{className:"text-lg flex items-center gap-2",children:[c.jsx(ae.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),c.jsxs(as,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(en,{htmlFor:"auto-save",children:"Auto-save Conversations"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),c.jsx(Kn,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>l(y=>({...y,behavior:{...y.behavior,autoSave:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(en,{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(y=>({...y,behavior:{...y.behavior,enableStreaming:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(en,{htmlFor:"typing-indicator",children:"Typing Indicator"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),c.jsx(Kn,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>l(y=>({...y,behavior:{...y.behavior,showTypingIndicator:g}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(qe,{variant:"outline",onClick:p,children:[c.jsx(ae.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(qe,{variant:"outline",onClick:v,children:"Cancel"}),c.jsxs(qe,{onClick:h,disabled:!u,children:[c.jsx(ae.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function jT({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),l=w.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?c.jsx(Vo,{...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(Vo,{...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(al,{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(Vo,{...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(al,{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})})]})})}_e.ChatApi=xc,_e.ChatInterface=Ys,_e.ChatProviders=Vo,_e.ChatSettings=_T,_e.MarkdownContent=da,_e.MessageComponent=uf,_e.MessageList=_a,_e.ThreadManager=al,_e.applySettings=DC,_e.chatApiClient=Dn,_e.default=jT,_e.del=gc,_e.get=fn,_e.getChatToken=fc,_e.getCurrentSettings=MC,_e.getDefaultApiConfig=mp,_e.getDefaultChatSettings=gp,_e.onChatTokenChanged=hc,_e.post=pc,_e.put=mc,_e.setChatToken=Si,_e.useApi=Ci,_e.useChatStream=Oc,_e.useMessagesReducer=kc,_e.useStream=Hc,_e.useThreadState=Wo,_e.useThreads=Uo,Object.defineProperties(_e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
139
+ `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function Tw(e,t=Ps){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 kw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),Tw(t),Cw(t)}function Ra(e){const t=e+"CollectionProvider",[n,r]=yn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=x=>{const{scope:g,children:y}=x,b=w.useRef(null),S=w.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:S,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=rr.createSlot(a),u=w.forwardRef((x,g)=>{const{scope:y,children:b}=x,S=s(a,y),k=Ue(g,S.collectionRef);return c.jsx(l,{ref:k,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=rr.createSlot(d),p=w.forwardRef((x,g)=>{const{scope:y,children:b,...S}=x,k=w.useRef(null),C=Ue(g,k),T=s(d,y);return w.useEffect(()=>(T.itemMap.set(k,{ref:k,...S}),()=>void T.itemMap.delete(k))),c.jsx(h,{[f]:"",ref:C,children:b})});p.displayName=d;function v(x){const g=s(e+"CollectionConsumer",x);return w.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const 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},v,r]}var Ew=m.createContext(void 0);function Os(e){const t=m.useContext(Ew);return e||t||"ltr"}const Iw=["top","right","bottom","left"],qn=Math.min,qt=Math.max,Ms=Math.round,Ds=Math.floor,wn=e=>({x:e,y:e}),Nw={left:"right",right:"left",bottom:"top",top:"bottom"},Aw={start:"end",end:"start"};function Pa(e,t,n){return qt(e,qn(t,n))}function Pn(e,t){return typeof e=="function"?e(t):e}function On(e){return e.split("-")[0]}function Dr(e){return e.split("-")[1]}function Oa(e){return e==="x"?"y":"x"}function Ma(e){return e==="y"?"height":"width"}const _w=new Set(["top","bottom"]);function Sn(e){return _w.has(On(e))?"y":"x"}function Da(e){return Oa(Sn(e))}function jw(e,t,n){n===void 0&&(n=!1);const r=Dr(e),o=Da(e),s=Ma(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Ls(i)),[i,Ls(i)]}function Rw(e){const t=Ls(e);return[La(e),t,La(t)]}function La(e){return e.replace(/start|end/g,t=>Aw[t])}const hf=["left","right"],pf=["right","left"],Pw=["top","bottom"],Ow=["bottom","top"];function Mw(e,t,n){switch(e){case"top":case"bottom":return n?t?pf:hf:t?hf:pf;case"left":case"right":return t?Pw:Ow;default:return[]}}function Dw(e,t,n,r){const o=Dr(e);let s=Mw(On(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(La)))),s}function Ls(e){return e.replace(/left|right|bottom|top/g,t=>Nw[t])}function Lw(e){return{top:0,right:0,bottom:0,left:0,...e}}function mf(e){return typeof e!="number"?Lw(e):{top:e,right:e,bottom:e,left:e}}function $s(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 gf(e,t,n){let{reference:r,floating:o}=e;const s=Sn(t),i=Da(t),a=Ma(i),l=On(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 $w=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}=gf(u,r,l),h=r,p={},v=0;for(let x=0;x<a.length;x++){const{name:g,fn:y}=a[x],{x:b,y:S,data:k,reset:C}=await y({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});d=b??d,f=S??f,p={...p,[g]:{...p[g],...k}},C&&v<=50&&(v++,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}=gf(u,h,l)),x=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function go(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),v=mf(p),g=a[h?f==="floating"?"reference":"floating":f],y=$s(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)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=$s(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(y.top-C.top+v.top)/k.y,bottom:(C.bottom-y.bottom+v.bottom)/k.y,left:(y.left-C.left+v.left)/k.x,right:(C.right-y.right+v.right)/k.x}}const Fw=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=mf(d),h={x:n,y:r},p=Da(o),v=Ma(p),x=await i.getDimensions(u),g=p==="y",y=g?"top":"left",b=g?"bottom":"right",S=g?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[p]-h[p]-s.floating[v],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[v]);const A=k/2-C/2,j=I/2-x[v]/2-1,P=qn(f[y],j),D=qn(f[b],j),L=P,B=I-x[v]-D,M=I/2-x[v]/2+A,X=Pa(L,M,B),W=!l.arrow&&Dr(o)!=null&&M!==X&&s.reference[v]/2-(M<L?P:D)-x[v]/2<0,V=W?M<L?M-L:M-B:0;return{[p]:h[p]+V,data:{[p]:X,centerOffset:M-X-V,...W&&{alignmentOffset:V}},reset:W}}}),zw=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:x=!0,...g}=Pn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=On(o),b=Sn(a),S=On(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(u.floating)),C=h||(S||!x?[Ls(a)]:Rw(a)),T=v!=="none";!h&&T&&C.push(...Dw(a,x,v,k));const I=[a,...C],A=await go(t,g),j=[];let P=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&j.push(A[y]),f){const M=jw(o,i,k);j.push(A[M[0]],A[M[1]])}if(P=[...P,{placement:o,overflows:j}],!j.every(M=>M<=0)){var D,L;const M=(((D=s.flip)==null?void 0:D.index)||0)+1,X=I[M];if(X&&(!(f==="alignment"?b!==Sn(X):!1)||P.every(z=>Sn(z.placement)===b?z.overflows[0]>0:!0)))return{data:{index:M,overflows:P},reset:{placement:X}};let W=(L=P.filter(V=>V.overflows[0]<=0).sort((V,z)=>V.overflows[1]-z.overflows[1])[0])==null?void 0:L.placement;if(!W)switch(p){case"bestFit":{var B;const V=(B=P.filter(z=>{if(T){const $=Sn(z.placement);return $===b||$==="y"}return!0}).map(z=>[z.placement,z.overflows.filter($=>$>0).reduce(($,pe)=>$+pe,0)]).sort((z,$)=>z[1]-$[1])[0])==null?void 0:B[0];V&&(W=V);break}case"initialPlacement":W=a;break}if(o!==W)return{reset:{placement:W}}}return{}}}};function xf(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function yf(e){return Iw.some(t=>e[t]>=0)}const Bw=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 go(t,{...o,elementContext:"reference"}),i=xf(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:yf(i)}}}case"escaped":{const s=await go(t,{...o,altBoundary:!0}),i=xf(s,n.floating);return{data:{escapedOffsets:i,escaped:yf(i)}}}default:return{}}}}},vf=new Set(["left","top"]);async function Hw(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=On(n),a=Dr(n),l=Sn(n)==="y",u=vf.has(i)?-1:1,d=s&&l?-1:1,f=Pn(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof v=="number"&&(p=a==="end"?v*-1:v),l?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const Uw=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 Hw(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}}}}},Ww=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x:y,y:b}=g;return{x:y,y:b}}},...l}=Pn(e,t),u={x:n,y:r},d=await go(t,l),f=Sn(On(o)),h=Oa(f);let p=u[h],v=u[f];if(s){const g=h==="y"?"top":"left",y=h==="y"?"bottom":"right",b=p+d[g],S=p-d[y];p=Pa(b,p,S)}if(i){const g=f==="y"?"top":"left",y=f==="y"?"bottom":"right",b=v+d[g],S=v-d[y];v=Pa(b,v,S)}const x=a.fn({...t,[h]:p,[f]:v});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[h]:s,[f]:i}}}}}},Vw=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=Oa(f);let p=d[h],v=d[f];const x=Pn(a,t),g=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(l){const S=h==="y"?"height":"width",k=s.reference[h]-s.floating[S]+g.mainAxis,C=s.reference[h]+s.reference[S]-g.mainAxis;p<k?p=k:p>C&&(p=C)}if(u){var y,b;const S=h==="y"?"width":"height",k=vf.has(On(o)),C=s.reference[f]-s.floating[S]+(k&&((y=i.offset)==null?void 0:y[f])||0)+(k?0:g.crossAxis),T=s.reference[f]+s.reference[S]+(k?0:((b=i.offset)==null?void 0:b[f])||0)-(k?g.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[h]:p,[f]:v}}}},Kw=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 go(t,u),f=On(o),h=Dr(o),p=Sn(o)==="y",{width:v,height:x}=s.floating;let g,y;f==="top"||f==="bottom"?(g=f,y=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=f,g=h==="end"?"top":"bottom");const b=x-d.top-d.bottom,S=v-d.left-d.right,k=qn(x-d[g],b),C=qn(v-d[y],S),T=!t.middlewareData.shift;let I=k,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 P=qt(d.left,0),D=qt(d.right,0),L=qt(d.top,0),B=qt(d.bottom,0);p?A=v-2*(P!==0||D!==0?P+D:qt(d.left,d.right)):I=x-2*(L!==0||B!==0?L+B:qt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:I});const j=await i.getDimensions(a.floating);return v!==j.width||x!==j.height?{reset:{rects:!0}}:{}}}};function Fs(){return typeof window<"u"}function Lr(e){return bf(e)?(e.nodeName||"").toLowerCase():"#document"}function Gt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Cn(e){var t;return(t=(bf(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function bf(e){return Fs()?e instanceof Node||e instanceof Gt(e).Node:!1}function un(e){return Fs()?e instanceof Element||e instanceof Gt(e).Element:!1}function Tn(e){return Fs()?e instanceof HTMLElement||e instanceof Gt(e).HTMLElement:!1}function wf(e){return!Fs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Gt(e).ShadowRoot}const qw=new Set(["inline","contents"]);function xo(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=dn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!qw.has(o)}const Gw=new Set(["table","td","th"]);function Yw(e){return Gw.has(Lr(e))}const Xw=[":popover-open",":modal"];function zs(e){return Xw.some(t=>{try{return e.matches(t)}catch{return!1}})}const Jw=["transform","translate","scale","rotate","perspective"],Zw=["transform","translate","scale","rotate","perspective","filter"],Qw=["paint","layout","strict","content"];function $a(e){const t=Fa(),n=un(e)?dn(e):e;return Jw.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)||Zw.some(r=>(n.willChange||"").includes(r))||Qw.some(r=>(n.contain||"").includes(r))}function e0(e){let t=Gn(e);for(;Tn(t)&&!$r(t);){if($a(t))return t;if(zs(t))return null;t=Gn(t)}return null}function Fa(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const t0=new Set(["html","body","#document"]);function $r(e){return t0.has(Lr(e))}function dn(e){return Gt(e).getComputedStyle(e)}function Bs(e){return un(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Gn(e){if(Lr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||wf(e)&&e.host||Cn(e);return wf(t)?t.host:t}function Sf(e){const t=Gn(e);return $r(t)?e.ownerDocument?e.ownerDocument.body:e.body:Tn(t)&&xo(t)?t:Sf(t)}function yo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Sf(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Gt(o);if(s){const a=za(i);return t.concat(i,i.visualViewport||[],xo(o)?o:[],a&&n?yo(a):[])}return t.concat(o,yo(o,[],n))}function za(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Cf(e){const t=dn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Tn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Ms(n)!==s||Ms(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Ba(e){return un(e)?e:e.contextElement}function Fr(e){const t=Ba(e);if(!Tn(t))return wn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Cf(t);let i=(s?Ms(n.width):n.width)/r,a=(s?Ms(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const n0=wn(0);function Tf(e){const t=Gt(e);return!Fa()||!t.visualViewport?n0:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function r0(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Gt(e)?!1:t}function gr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Ba(e);let i=wn(1);t&&(r?un(r)&&(i=Fr(r)):i=Fr(e));const a=r0(s,n,r)?Tf(s):wn(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=Gt(s),p=r&&un(r)?Gt(r):r;let v=h,x=za(v);for(;x&&r&&p!==v;){const g=Fr(x),y=x.getBoundingClientRect(),b=dn(x),S=y.left+(x.clientLeft+parseFloat(b.paddingLeft))*g.x,k=y.top+(x.clientTop+parseFloat(b.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=S,u+=k,v=Gt(x),x=za(v)}}return $s({width:d,height:f,x:l,y:u})}function Hs(e,t){const n=Bs(e).scrollLeft;return t?t.left+n:gr(Cn(e)).left+n}function kf(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Hs(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function o0(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=Cn(r),a=t?zs(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=wn(1);const d=wn(0),f=Tn(r);if((f||!f&&!s)&&((Lr(r)!=="body"||xo(i))&&(l=Bs(r)),Tn(r))){const p=gr(r);u=Fr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?kf(i,l):wn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-l.scrollTop*u.y+d.y+h.y}}function s0(e){return Array.from(e.getClientRects())}function i0(e){const t=Cn(e),n=Bs(e),r=e.ownerDocument.body,o=qt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=qt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Hs(e);const a=-n.scrollTop;return dn(r).direction==="rtl"&&(i+=qt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Ef=25;function a0(e,t){const n=Gt(e),r=Cn(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=Fa();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const u=Hs(r);if(u<=0){const d=r.ownerDocument,f=d.body,h=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-p);v<=Ef&&(s-=v)}else u<=Ef&&(s+=u);return{width:s,height:i,x:a,y:l}}const l0=new Set(["absolute","fixed"]);function c0(e,t){const n=gr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Tn(e)?Fr(e):wn(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 If(e,t,n){let r;if(t==="viewport")r=a0(e,n);else if(t==="document")r=i0(Cn(e));else if(un(t))r=c0(t,n);else{const o=Tf(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return $s(r)}function Nf(e,t){const n=Gn(e);return n===t||!un(n)||$r(n)?!1:dn(n).position==="fixed"||Nf(n,t)}function u0(e,t){const n=t.get(e);if(n)return n;let r=yo(e,[],!1).filter(a=>un(a)&&Lr(a)!=="body"),o=null;const s=dn(e).position==="fixed";let i=s?Gn(e):e;for(;un(i)&&!$r(i);){const a=dn(i),l=$a(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&l0.has(o.position)||xo(i)&&!l&&Nf(e,i))?r=r.filter(d=>d!==i):o=a,i=Gn(i)}return t.set(e,r),r}function d0(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?zs(t)?[]:u0(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=If(t,d,o);return u.top=qt(f.top,u.top),u.right=qn(f.right,u.right),u.bottom=qn(f.bottom,u.bottom),u.left=qt(f.left,u.left),u},If(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function f0(e){const{width:t,height:n}=Cf(e);return{width:t,height:n}}function h0(e,t,n){const r=Tn(t),o=Cn(t),s=n==="fixed",i=gr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=wn(0);function u(){l.x=Hs(o)}if(r||!r&&!s)if((Lr(t)!=="body"||xo(o))&&(a=Bs(t)),r){const p=gr(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?kf(o,a):wn(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 Ha(e){return dn(e).position==="static"}function Af(e,t){if(!Tn(e)||dn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Cn(e)===n&&(n=n.ownerDocument.body),n}function _f(e,t){const n=Gt(e);if(zs(e))return n;if(!Tn(e)){let o=Gn(e);for(;o&&!$r(o);){if(un(o)&&!Ha(o))return o;o=Gn(o)}return n}let r=Af(e,t);for(;r&&Yw(r)&&Ha(r);)r=Af(r,t);return r&&$r(r)&&Ha(r)&&!$a(r)?n:r||e0(e)||n}const p0=async function(e){const t=this.getOffsetParent||_f,n=this.getDimensions,r=await n(e.floating);return{reference:h0(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function m0(e){return dn(e).direction==="rtl"}const g0={convertOffsetParentRelativeRectToViewportRelativeRect:o0,getDocumentElement:Cn,getClippingRect:d0,getOffsetParent:_f,getElementRects:p0,getClientRects:s0,getDimensions:f0,getScale:Fr,isElement:un,isRTL:m0};function jf(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function x0(e,t){let n=null,r;const o=Cn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:p}=u;if(a||t(),!h||!p)return;const v=Ds(f),x=Ds(o.clientWidth-(d+h)),g=Ds(o.clientHeight-(f+p)),y=Ds(d),S={rootMargin:-v+"px "+-x+"px "+-g+"px "+-y+"px",threshold:qt(0,qn(1,l))||1};let k=!0;function C(T){const I=T[0].intersectionRatio;if(I!==l){if(!k)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!jf(u,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function y0(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=Ba(e),d=o||s?[...u?yo(u):[],...yo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const f=u&&a?x0(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(y=>{let[b]=y;b&&b.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let v,x=l?gr(e):null;l&&g();function g(){const y=gr(e);x&&!jf(x,y)&&n(),x=y,v=requestAnimationFrame(g)}return n(),()=>{var y;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(v)}}const v0=Uw,b0=Ww,w0=zw,S0=Kw,C0=Bw,Rf=Fw,T0=Vw,k0=(e,t,n)=>{const r=new Map,o={platform:g0,...n},s={...o.platform,_c:r};return $w(e,t,{...o,platform:s})};var E0=typeof document<"u",I0=function(){},Us=E0?w.useLayoutEffect:I0;function Ws(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(!Ws(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)&&!Ws(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Pf(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Of(e,t){const n=Pf(e);return Math.round(t*n)/n}function Ua(e){const t=m.useRef(e);return Us(()=>{t.current=e}),t}function N0(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);Ws(h,r)||p(r);const[v,x]=m.useState(null),[g,y]=m.useState(null),b=m.useCallback(z=>{z!==T.current&&(T.current=z,x(z))},[]),S=m.useCallback(z=>{z!==I.current&&(I.current=z,y(z))},[]),k=s||v,C=i||g,T=m.useRef(null),I=m.useRef(null),A=m.useRef(d),j=l!=null,P=Ua(l),D=Ua(o),L=Ua(u),B=m.useCallback(()=>{if(!T.current||!I.current)return;const z={placement:t,strategy:n,middleware:h};D.current&&(z.platform=D.current),k0(T.current,I.current,z).then($=>{const pe={...$,isPositioned:L.current!==!1};M.current&&!Ws(A.current,pe)&&(A.current=pe,_o.flushSync(()=>{f(pe)}))})},[h,t,n,D,L]);Us(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(z=>({...z,isPositioned:!1})))},[u]);const M=m.useRef(!1);Us(()=>(M.current=!0,()=>{M.current=!1}),[]),Us(()=>{if(k&&(T.current=k),C&&(I.current=C),k&&C){if(P.current)return P.current(k,C,B);B()}},[k,C,B,P,j]);const X=m.useMemo(()=>({reference:T,floating:I,setReference:b,setFloating:S}),[b,S]),W=m.useMemo(()=>({reference:k,floating:C}),[k,C]),V=m.useMemo(()=>{const z={position:n,left:0,top:0};if(!W.floating)return z;const $=Of(W.floating,d.x),pe=Of(W.floating,d.y);return a?{...z,transform:"translate("+$+"px, "+pe+"px)",...Pf(W.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:$,top:pe}},[n,a,W.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:B,refs:X,elements:W,floatingStyles:V}),[d,B,X,W,V])}const A0=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?Rf({element:r.current,padding:o}).fn(n):{}:r?Rf({element:r,padding:o}).fn(n):{}}}},_0=(e,t)=>({...v0(e),options:[e,t]}),j0=(e,t)=>({...b0(e),options:[e,t]}),R0=(e,t)=>({...T0(e),options:[e,t]}),P0=(e,t)=>({...w0(e),options:[e,t]}),O0=(e,t)=>({...S0(e),options:[e,t]}),M0=(e,t)=>({...C0(e),options:[e,t]}),D0=(e,t)=>({...A0(e),options:[e,t]});var L0="Arrow",Mf=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(Ae.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"})})});Mf.displayName=L0;var $0=Mf;function Df(e){const[t,n]=m.useState(void 0);return wt(()=>{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 Wa="Popper",[Lf,Vs]=yn(Wa),[F0,$f]=Lf(Wa),Ff=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(F0,{scope:t,anchor:r,onAnchorChange:o,children:n})};Ff.displayName=Wa;var zf="PopperAnchor",Bf=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=$f(zf,n),i=m.useRef(null),a=Ue(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(Ae.div,{...o,ref:a})});Bf.displayName=zf;var Va="PopperContent",[z0,B0]=Lf(Va),Hf=m.forwardRef((e,t)=>{var q,O,J,te,de,le;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:v,...x}=e,g=$f(Va,n),[y,b]=m.useState(null),S=Ue(t,ie=>b(ie)),[k,C]=m.useState(null),T=Df(k),I=(T==null?void 0:T.width)??0,A=(T==null?void 0:T.height)??0,j=r+(s!=="center"?"-"+s:""),P=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},D=Array.isArray(u)?u:[u],L=D.length>0,B={padding:P,boundary:D.filter(U0),altBoundary:L},{refs:M,floatingStyles:X,placement:W,isPositioned:V,middlewareData:z}=N0({strategy:"fixed",placement:j,whileElementsMounted:(...ie)=>y0(...ie,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[_0({mainAxis:o+A,alignmentAxis:i}),l&&j0({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?R0():void 0,...B}),l&&P0({...B}),O0({...B,apply:({elements:ie,rects:et,availableWidth:Qe,availableHeight:Oe})=>{const{width:Be,height:ht}=et.reference,tt=ie.floating.style;tt.setProperty("--radix-popper-available-width",`${Qe}px`),tt.setProperty("--radix-popper-available-height",`${Oe}px`),tt.setProperty("--radix-popper-anchor-width",`${Be}px`),tt.setProperty("--radix-popper-anchor-height",`${ht}px`)}}),k&&D0({element:k,padding:a}),W0({arrowWidth:I,arrowHeight:A}),h&&M0({strategy:"referenceHidden",...B})]}),[$,pe]=Vf(W),F=Tt(v);wt(()=>{V&&(F==null||F())},[V,F]);const Q=(q=z.arrow)==null?void 0:q.x,he=(O=z.arrow)==null?void 0:O.y,ve=((J=z.arrow)==null?void 0:J.centerOffset)!==0,[be,Te]=m.useState();return wt(()=>{y&&Te(window.getComputedStyle(y).zIndex)},[y]),c.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...X,transform:V?X.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:be,"--radix-popper-transform-origin":[(te=z.transformOrigin)==null?void 0:te.x,(de=z.transformOrigin)==null?void 0:de.y].join(" "),...((le=z.hide)==null?void 0:le.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(z0,{scope:n,placedSide:$,onArrowChange:C,arrowX:Q,arrowY:he,shouldHideArrow:ve,children:c.jsx(Ae.div,{"data-side":$,"data-align":pe,...x,ref:S,style:{...x.style,animation:V?void 0:"none"}})})})});Hf.displayName=Va;var Uf="PopperArrow",H0={top:"bottom",right:"left",bottom:"top",left:"right"},Wf=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=B0(Uf,r),i=H0[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($0,{...o,ref:n,style:{...o.style,display:"block"}})})});Wf.displayName=Uf;function U0(e){return e!==null}var W0=e=>({name:"transformOrigin",options:e,fn(t){var g,y,b;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[u,d]=Vf(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let v="",x="";return u==="bottom"?(v=i?f:`${h}px`,x=`${-l}px`):u==="top"?(v=i?f:`${h}px`,x=`${r.floating.height+l}px`):u==="right"?(v=`${-l}px`,x=i?f:`${p}px`):u==="left"&&(v=`${r.floating.width+l}px`,x=i?f:`${p}px`),{data:{x:v,y:x}}}});function Vf(e){const[t,n="center"]=e.split("-");return[t,n]}var Kf=Ff,qf=Bf,Gf=Hf,Yf=Wf,Ka="rovingFocusGroup.onEntryFocus",V0={bubbles:!1,cancelable:!0},vo="RovingFocusGroup",[qa,Xf,K0]=Ra(vo),[q0,Jf]=yn(vo,[K0]),[G0,Y0]=q0(vo),Zf=m.forwardRef((e,t)=>c.jsx(qa.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(qa.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(X0,{...e,ref:t})})}));Zf.displayName=vo;var X0=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=Ue(t,h),v=Os(s),[x,g]=dr({prop:i,defaultProp:a??null,onChange:l,caller:vo}),[y,b]=m.useState(!1),S=Tt(u),k=Xf(n),C=m.useRef(!1),[T,I]=m.useState(0);return m.useEffect(()=>{const A=h.current;if(A)return A.addEventListener(Ka,S),()=>A.removeEventListener(Ka,S)},[S]),c.jsx(G0,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:x,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(Ae.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:fe(e.onMouseDown,()=>{C.current=!0}),onFocus:fe(e.onFocus,A=>{const j=!C.current;if(A.target===A.currentTarget&&j&&!y){const P=new CustomEvent(Ka,V0);if(A.currentTarget.dispatchEvent(P),!P.defaultPrevented){const D=k().filter(W=>W.focusable),L=D.find(W=>W.active),B=D.find(W=>W.id===x),X=[L,B,...D].filter(Boolean).map(W=>W.ref.current);th(X,d)}}C.current=!1}),onBlur:fe(e.onBlur,()=>b(!1))})})}),Qf="RovingFocusGroupItem",eh=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=vn(),u=s||l,d=Y0(Qf,n),f=d.currentTabStopId===u,h=Xf(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:x}=d;return m.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),c.jsx(qa.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(Ae.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:fe(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:fe(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:fe(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const y=Q0(g,d.orientation,d.dir);if(y!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let S=h().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const k=S.indexOf(g.currentTarget);S=d.loop?eS(S,k+1):S.slice(k+1)}setTimeout(()=>th(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:x!=null}):i})})});eh.displayName=Qf;var J0={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Z0(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Q0(e,t,n){const r=Z0(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return J0[r]}function th(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function eS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var tS=Zf,nS=eh,Ga=["Enter"," "],rS=["ArrowDown","PageUp","Home"],nh=["ArrowUp","PageDown","End"],oS=[...rS,...nh],sS={ltr:[...Ga,"ArrowRight"],rtl:[...Ga,"ArrowLeft"]},iS={ltr:["ArrowLeft"],rtl:["ArrowRight"]},bo="Menu",[wo,aS,lS]=Ra(bo),[xr,rh]=yn(bo,[lS,Vs,Jf]),Ks=Vs(),oh=Jf(),[cS,yr]=xr(bo),[uS,So]=xr(bo),sh=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=Ks(t),[l,u]=m.useState(null),d=m.useRef(!1),f=Tt(s),h=Os(o);return m.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),c.jsx(Kf,{...a,children:c.jsx(cS,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(uS,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};sh.displayName=bo;var dS="MenuAnchor",Ya=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ks(n);return c.jsx(qf,{...o,...r,ref:t})});Ya.displayName=dS;var Xa="MenuPortal",[fS,ih]=xr(Xa,{forceMount:void 0}),ah=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=yr(Xa,t);return c.jsx(fS,{scope:t,forceMount:n,children:c.jsx(Kt,{present:n||s.open,children:c.jsx(ys,{asChild:!0,container:o,children:r})})})};ah.displayName=Xa;var en="MenuContent",[hS,Ja]=xr(en),lh=m.forwardRef((e,t)=>{const n=ih(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=yr(en,e.__scopeMenu),i=So(en,e.__scopeMenu);return c.jsx(wo.Provider,{scope:e.__scopeMenu,children:c.jsx(Kt,{present:r||s.open,children:c.jsx(wo.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(pS,{...o,ref:t}):c.jsx(mS,{...o,ref:t})})})})}),pS=m.forwardRef((e,t)=>{const n=yr(en,e.__scopeMenu),r=m.useRef(null),o=Ue(t,r);return m.useEffect(()=>{const s=r.current;if(s)return Ea(s)},[]),c.jsx(Za,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:fe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),mS=m.forwardRef((e,t)=>{const n=yr(en,e.__scopeMenu);return c.jsx(Za,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),gS=rr.createSlot("MenuContent.ScrollLock"),Za=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:v,...x}=e,g=yr(en,n),y=So(en,n),b=Ks(n),S=oh(n),k=aS(n),[C,T]=m.useState(null),I=m.useRef(null),A=Ue(t,I,g.onContentChange),j=m.useRef(0),P=m.useRef(""),D=m.useRef(0),L=m.useRef(null),B=m.useRef("right"),M=m.useRef(0),X=v?Ts:m.Fragment,W=v?{as:gS,allowPinchZoom:!0}:void 0,V=$=>{var q,O;const pe=P.current+$,F=k().filter(J=>!J.disabled),Q=document.activeElement,he=(q=F.find(J=>J.ref.current===Q))==null?void 0:q.textValue,ve=F.map(J=>J.textValue),be=NS(ve,pe,he),Te=(O=F.find(J=>J.textValue===be))==null?void 0:O.ref.current;(function J(te){P.current=te,window.clearTimeout(j.current),te!==""&&(j.current=window.setTimeout(()=>J(""),1e3))})(pe),Te&&setTimeout(()=>Te.focus())};m.useEffect(()=>()=>window.clearTimeout(j.current),[]),ba();const z=m.useCallback($=>{var F,Q;return B.current===((F=L.current)==null?void 0:F.side)&&_S($,(Q=L.current)==null?void 0:Q.area)},[]);return c.jsx(hS,{scope:n,searchRef:P,onItemEnter:m.useCallback($=>{z($)&&$.preventDefault()},[z]),onItemLeave:m.useCallback($=>{var pe;z($)||((pe=I.current)==null||pe.focus(),T(null))},[z]),onTriggerLeave:m.useCallback($=>{z($)&&$.preventDefault()},[z]),pointerGraceTimerRef:D,onPointerGraceIntentChange:m.useCallback($=>{L.current=$},[]),children:c.jsx(X,{...W,children:c.jsx(xs,{asChild:!0,trapped:o,onMountAutoFocus:fe(s,$=>{var pe;$.preventDefault(),(pe=I.current)==null||pe.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(gs,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:c.jsx(tS,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:fe(l,$=>{y.isUsingKeyboardRef.current||$.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(Gf,{role:"menu","aria-orientation":"vertical","data-state":kh(g.open),"data-radix-menu-content":"",dir:y.dir,...b,...x,ref:A,style:{outline:"none",...x.style},onKeyDown:fe(x.onKeyDown,$=>{const F=$.target.closest("[data-radix-menu-content]")===$.currentTarget,Q=$.ctrlKey||$.altKey||$.metaKey,he=$.key.length===1;F&&($.key==="Tab"&&$.preventDefault(),!Q&&he&&V($.key));const ve=I.current;if($.target!==ve||!oS.includes($.key))return;$.preventDefault();const Te=k().filter(q=>!q.disabled).map(q=>q.ref.current);nh.includes($.key)&&Te.reverse(),ES(Te)}),onBlur:fe(e.onBlur,$=>{$.currentTarget.contains($.target)||(window.clearTimeout(j.current),P.current="")}),onPointerMove:fe(e.onPointerMove,To($=>{const pe=$.target,F=M.current!==$.clientX;if($.currentTarget.contains(pe)&&F){const Q=$.clientX>M.current?"right":"left";B.current=Q,M.current=$.clientX}}))})})})})})})});lh.displayName=en;var xS="MenuGroup",Qa=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ae.div,{role:"group",...r,ref:t})});Qa.displayName=xS;var yS="MenuLabel",ch=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ae.div,{...r,ref:t})});ch.displayName=yS;var qs="MenuItem",uh="menu.itemSelect",Gs=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=So(qs,e.__scopeMenu),a=Ja(qs,e.__scopeMenu),l=Ue(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(uh,{bubbles:!0,cancelable:!0});f.addEventListener(uh,p=>r==null?void 0:r(p),{once:!0}),Wu(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(dh,{...o,ref:l,disabled:n,onClick:fe(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:fe(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:fe(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||Ga.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Gs.displayName=qs;var dh=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Ja(qs,n),a=oh(n),l=m.useRef(null),u=Ue(t,l),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const v=l.current;v&&p((v.textContent??"").trim())},[s.children]),c.jsx(wo.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(nS,{asChild:!0,...a,focusable:!r,children:c.jsx(Ae.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:fe(e.onPointerMove,To(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:fe(e.onPointerLeave,To(v=>i.onItemLeave(v))),onFocus:fe(e.onFocus,()=>f(!0)),onBlur:fe(e.onBlur,()=>f(!1))})})})}),vS="MenuCheckboxItem",fh=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(xh,{scope:e.__scopeMenu,checked:n,children:c.jsx(Gs,{role:"menuitemcheckbox","aria-checked":Ys(n)?"mixed":n,...o,ref:t,"data-state":tl(n),onSelect:fe(o.onSelect,()=>r==null?void 0:r(Ys(n)?!0:!n),{checkForDefaultPrevented:!1})})})});fh.displayName=vS;var hh="MenuRadioGroup",[bS,wS]=xr(hh,{value:void 0,onValueChange:()=>{}}),ph=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Tt(r);return c.jsx(bS,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(Qa,{...o,ref:t})})});ph.displayName=hh;var mh="MenuRadioItem",gh=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=wS(mh,e.__scopeMenu),s=n===o.value;return c.jsx(xh,{scope:e.__scopeMenu,checked:s,children:c.jsx(Gs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":tl(s),onSelect:fe(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});gh.displayName=mh;var el="MenuItemIndicator",[xh,SS]=xr(el,{checked:!1}),yh=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=SS(el,n);return c.jsx(Kt,{present:r||Ys(s.checked)||s.checked===!0,children:c.jsx(Ae.span,{...o,ref:t,"data-state":tl(s.checked)})})});yh.displayName=el;var CS="MenuSeparator",vh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ae.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});vh.displayName=CS;var TS="MenuArrow",bh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ks(n);return c.jsx(Yf,{...o,...r,ref:t})});bh.displayName=TS;var kS="MenuSub",[ak,wh]=xr(kS),Co="MenuSubTrigger",Sh=m.forwardRef((e,t)=>{const n=yr(Co,e.__scopeMenu),r=So(Co,e.__scopeMenu),o=wh(Co,e.__scopeMenu),s=Ja(Co,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(Ya,{asChild:!0,...u,children:c.jsx(dh,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":kh(n.open),...e,ref:ia(t,o.onTriggerChange),onClick:f=>{var h;(h=e.onClick)==null||h.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:fe(e.onPointerMove,To(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:fe(e.onPointerLeave,To(f=>{var p,v;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const x=(v=n.content)==null?void 0:v.dataset.side,g=x==="right",y=g?-5:5,b=h[g?"left":"right"],S=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+y,y:f.clientY},{x:b,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:b,y:h.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:fe(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||sS[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});Sh.displayName=Co;var Ch="MenuSubContent",Th=m.forwardRef((e,t)=>{const n=ih(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=yr(en,e.__scopeMenu),i=So(en,e.__scopeMenu),a=wh(Ch,e.__scopeMenu),l=m.useRef(null),u=Ue(t,l);return c.jsx(wo.Provider,{scope:e.__scopeMenu,children:c.jsx(Kt,{present:r||s.open,children:c.jsx(wo.Slot,{scope:e.__scopeMenu,children:c.jsx(Za,{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:fe(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:fe(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:fe(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=iS[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});Th.displayName=Ch;function kh(e){return e?"open":"closed"}function Ys(e){return e==="indeterminate"}function tl(e){return Ys(e)?"indeterminate":e?"checked":"unchecked"}function ES(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function IS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function NS(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=IS(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 AS(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 _S(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return AS(n,t)}function To(e){return t=>t.pointerType==="mouse"?e(t):void 0}var jS=sh,RS=Ya,PS=ah,OS=lh,MS=Qa,DS=ch,LS=Gs,$S=fh,FS=ph,zS=gh,BS=yh,HS=vh,US=bh,WS=Sh,VS=Th,Xs="DropdownMenu",[KS,lk]=yn(Xs,[rh]),Lt=rh(),[qS,Eh]=KS(Xs),Ih=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Lt(t),u=m.useRef(null),[d,f]=dr({prop:o,defaultProp:s??!1,onChange:i,caller:Xs});return c.jsx(qS,{scope:t,triggerId:vn(),triggerRef:u,contentId:vn(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(jS,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Ih.displayName=Xs;var Nh="DropdownMenuTrigger",Ah=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Eh(Nh,n),i=Lt(n);return c.jsx(RS,{asChild:!0,...i,children:c.jsx(Ae.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:ia(t,s.triggerRef),onPointerDown:fe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:fe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Ah.displayName=Nh;var GS="DropdownMenuPortal",_h=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Lt(t);return c.jsx(PS,{...r,...n})};_h.displayName=GS;var jh="DropdownMenuContent",Rh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Eh(jh,n),s=Lt(n),i=m.useRef(!1);return c.jsx(OS,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:fe(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:fe(e.onInteractOutside,a=>{const l=a.detail.originalEvent,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)"}})});Rh.displayName=jh;var YS="DropdownMenuGroup",XS=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return c.jsx(MS,{...o,...r,ref:t})});XS.displayName=YS;var JS="DropdownMenuLabel",Ph=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return c.jsx(DS,{...o,...r,ref:t})});Ph.displayName=JS;var ZS="DropdownMenuItem",Oh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return c.jsx(LS,{...o,...r,ref:t})});Oh.displayName=ZS;var QS="DropdownMenuCheckboxItem",Mh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return c.jsx($S,{...o,...r,ref:t})});Mh.displayName=QS;var eC="DropdownMenuRadioGroup",tC=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return c.jsx(FS,{...o,...r,ref:t})});tC.displayName=eC;var nC="DropdownMenuRadioItem",Dh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return c.jsx(zS,{...o,...r,ref:t})});Dh.displayName=nC;var rC="DropdownMenuItemIndicator",Lh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return c.jsx(BS,{...o,...r,ref:t})});Lh.displayName=rC;var oC="DropdownMenuSeparator",$h=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return c.jsx(HS,{...o,...r,ref:t})});$h.displayName=oC;var sC="DropdownMenuArrow",iC=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return c.jsx(US,{...o,...r,ref:t})});iC.displayName=sC;var aC="DropdownMenuSubTrigger",Fh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return c.jsx(WS,{...o,...r,ref:t})});Fh.displayName=aC;var lC="DropdownMenuSubContent",zh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return c.jsx(VS,{...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)"}})});zh.displayName=lC;var cC=Ih,uC=Ah,dC=_h,Bh=Rh,Hh=Ph,Uh=Oh,Wh=Mh,Vh=Dh,Kh=Lh,qh=$h,Gh=Fh,Yh=zh;const fC=cC,hC=uC,pC=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(Gh,{ref:o,className:ee("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(ae.ChevronRight,{className:"ml-auto h-4 w-4"})]}));pC.displayName=Gh.displayName;const mC=m.forwardRef(({className:e,...t},n)=>c.jsx(Yh,{ref:n,className:ee("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}));mC.displayName=Yh.displayName;const Xh=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(dC,{children:c.jsx(Bh,{ref:r,sideOffset:t,className:ee("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})}));Xh.displayName=Bh.displayName;const nl=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Uh,{ref:r,className:ee("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}));nl.displayName=Uh.displayName;const gC=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(Wh,{ref:o,className:ee("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(Kh,{children:c.jsx(ae.Check,{className:"h-4 w-4"})})}),t]}));gC.displayName=Wh.displayName;const xC=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Vh,{ref:r,className:ee("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(Kh,{children:c.jsx(ae.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));xC.displayName=Vh.displayName;const yC=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Hh,{ref:r,className:ee("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));yC.displayName=Hh.displayName;const vC=m.forwardRef(({className:e,...t},n)=>c.jsx(qh,{ref:n,className:ee("-mx-1 my-1 h-px bg-muted",e),...t}));vC.displayName=qh.displayName;function Js({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:h,onError:p}){const{api:v}=Ti(),{currentThreadId:x}=Vo(),{threadId:g,messages:y,hasMore:b,isHistoryLoading:S,isLoading:k,loadOlder:C,navigateToCheckpoint:T,returnToLatest:I,checkpoint:A,checkpoints:j,respondToInterrupt:P,metadata:D}=Ko(),{isStreaming:L,error:B,submit:M,stop:X}=Uc(),W=(A==null?void 0:A.id)??null,V=(A==null?void 0:A.namespace)??null,z=(D==null?void 0:D.assemblingMessageId)??null,[$,pe]=w.useState(null),[F,Q]=w.useState(""),[he,ve]=w.useState(null),[be,Te]=w.useState([]),[q,O]=w.useState(0),[J,te]=w.useState(0),[de,le]=w.useState(!1),[ie,et]=w.useState(null),[Qe,Oe]=w.useState(null),[Be,ht]=w.useState(!1),[tt,Me]=w.useState(null),[bt,ne]=w.useState(!1),oe=w.useRef(null),ge=w.useRef(null),we=w.useCallback(()=>{oe.current&&(oe.current.value=""),ge.current&&(ge.current.value=""),O(me=>me+1),te(me=>me+1)},[]),xe=w.useRef(!1);w.useEffect(()=>{xe.current&&!L&&(Te([]),we()),xe.current=L},[L,we]);const[Fe,ot]=w.useState("desktop");w.useEffect(()=>{const me=()=>{const Ee=window.innerWidth;ot(Ee<640?"phone":Ee<1024?"tablet":"desktop")};return me(),window.addEventListener("resize",me),()=>window.removeEventListener("resize",me)},[]);const $e=w.useCallback(async()=>{if(!(!b||S))try{await C()}catch(me){console.warn("loadOlder failed",me)}},[b,S,C]);w.useEffect(()=>{(async()=>{if(!v.baseUrl){Me(null);return}try{const Ee=await v.getAgent("default");Me(Ee.uiDefaultMessage||null)}catch(Ee){console.warn("Failed to fetch default message:",Ee),Me(null)}})()},[v]),w.useEffect(()=>{B&&!Be&&(p==null||p(B))},[B,Be,p]);const ut=me=>{if(me.length>Ps)return`Message too long (${me.length}/${Ps} characters)`;try{return kw(me),null}catch(Ee){return(Ee==null?void 0:Ee.message)||"Invalid message"}},xt=async me=>{const Ee=me.trim();if(!(!Ee&&be.length===0)){if(Ee){const Pe=ut(Ee);if(Pe){ve(Pe);return}}try{await M({text:Ee||"",attachments:be,payload:$?{edit:!0,originalMessageId:$}:void 0},{checkpointId:W??void 0,checkpointNs:V??void 0}),f==null||f(Ee),ve(null),Te([]),we(),pe(null),Q("")}catch(Pe){const st=(Pe==null?void 0:Pe.message)||"Failed to send message";ve(st),p==null||p(st)}}},Pt=w.useCallback((me,Ee)=>{u&&(pe(me),Q(Ee),ve(null))},[u]),rn=w.useCallback(()=>{pe(null),Q(""),ve(null)},[]),Ur=w.useCallback((me,Ee)=>{Pt(me,Ee)},[Pt]),Zn=w.useCallback(me=>{const Ee=Pe=>{const st=Pe.content||[],Ht=st.filter(er=>er.type==="text").map(er=>er.text).join("");if(Ht)return Ht;try{return JSON.stringify(st,null,2)}catch{return String(st)}};for(let Pe=me-1;Pe>=0;Pe--)if(y[Pe].role==="user"){const st=Ee(y[Pe]);st&&M({text:st},{checkpointId:W??void 0,checkpointNs:V??void 0});break}},[y,M,W,V]),En=me=>{const Ee=Array.from(me.target.files||[]);Te(Pe=>[...Pe,...Ee]),me.target.value=""},Qn=me=>{Te(Ee=>{const Pe=Ee.filter((st,Ht)=>me!==Ht);return Pe.length===0&&we(),Pe})},on=async me=>{const Ee=(me.target.files||[])[0];if(Ee){et(null),Oe(null),le(!0);try{await M({attachments:[Ee]},{checkpointId:W??void 0,checkpointNs:V??void 0});const Pe=`Uploaded ${Ee.name} - processing through chat stream`;Oe(Pe)}catch(Pe){const st=Pe instanceof Error?Pe.message:"Failed to upload Excel file";console.error("Excel upload failed",Pe),et(st),p==null||p(st)}finally{le(!1),me.target.value="",we()}}},Sr=me=>{if(!me)return"Unknown";const Ee=Date.parse(me);return Number.isNaN(Ee)?me:new Date(Ee).toLocaleString()},Mn=async me=>{if(x){ne(!0);try{if(!me){await I();return}const Ee=j.find(st=>st.checkpointId===me),Pe=(Ee==null?void 0:Ee.checkpointNs)??null;await T(me,Pe)}finally{ne(!1)}}},Cr=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,Dn=`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||""}`,Ot=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return c.jsxs("div",{className:Cr,children:[!!B&&!Be&&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:B}),c.jsx(Ke,{variant:"ghost",size:"sm",onClick:()=>ht(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(ae.X,{size:16})})]}),x&&j.length>0&&c.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[c.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),c.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:W??"",onChange:me=>{const Ee=me.target.value||null;Mn(Ee)},children:[c.jsx("option",{value:"",children:"Latest"}),j.map(me=>c.jsxs("option",{value:me.checkpointId,children:[Sr(me.createdAt),me.preview?` — ${me.preview.slice(0,40)}`:""]},me.checkpointId))]})]}),c.jsxs("div",{className:`relative ${Dn}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(ja,{className:"h-full",style:{height:"100%"},messages:y,isStreaming:L,streamingAssistantId:z,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Fe,enableMessageEditing:u,editingMessageId:$,onStartReached:()=>{$e()},onEdit:Ur,onRegenerate:Zn,onCancelEdit:rn,emptyMessage:tt??void 0,isNavigatingCheckpoint:bt}),k&&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(ae.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:Ot,children:[$&&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(ae.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(Ke,{variant:"ghost",size:"sm",onClick:rn,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(ae.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:oe,type:"file",multiple:!0,onChange:me=>En(me),className:"hidden"},q),be.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:be.map((me,Ee)=>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(ae.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:me.name}),c.jsx(Ke,{variant:"ghost",size:"sm",onClick:()=>Qn(Ee),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 ${me.name}`,children:c.jsx(ae.X,{size:12})})]},Ee))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:ge,type:"file",accept:".xls,.xlsx,.xlsm",onChange:on,className:"hidden"},J),de&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(ae.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),Qe&&!de&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:Qe}),ie&&!de&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:ie})]})]}),he&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:he}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(fC,{children:[c.jsx(hC,{asChild:!0,children:c.jsx(Ke,{type:"button",size:"icon",variant:"outline",disabled:L,title:"More input actions",className:d.moreButton||"",children:c.jsx(ae.Plus,{size:16})})}),c.jsxs(Xh,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(nl,{onClick:()=>{var me;return(me=oe.current)==null?void 0:me.click()},className:"cursor-pointer",children:[c.jsx(ae.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(nl,{onClick:()=>{var me;de||(me=ge.current)==null||me.click()},className:`cursor-pointer ${de?"opacity-60 pointer-events-none":""}`,children:[c.jsx(ae.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx($x,{initialValue:F,editingMessageId:$,placeholder:$?"Edit your message...":t,isStreaming:L,disabled:!1,maxLength:Ps,onSend:xt,onCancelEdit:rn,onStop:X,allowEmptySend:be.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${$?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${he?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const Zs=m.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:ee("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}));Zs.displayName="Input";function rl(e,[t,n]){return Math.min(n,Math.max(t,e))}function bC(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var ol="ScrollArea",[Jh,ck]=yn(ol),[wC,tn]=Jh(ol),Zh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=m.useState(null),[u,d]=m.useState(null),[f,h]=m.useState(null),[p,v]=m.useState(null),[x,g]=m.useState(null),[y,b]=m.useState(0),[S,k]=m.useState(0),[C,T]=m.useState(!1),[I,A]=m.useState(!1),j=Ue(t,D=>l(D)),P=Os(o);return c.jsx(wC,{scope:n,type:r,dir:P,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:x,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:k,children:c.jsx(Ae.div,{dir:P,...i,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Zh.displayName=ol;var Qh="ScrollAreaViewport",ep=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=tn(Qh,n),a=m.useRef(null),l=Ue(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(Ae.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})})]})});ep.displayName=Qh;var kn="ScrollAreaScrollbar",sl=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=tn(kn,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(SC,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(CC,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(tp,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(il,{...r,ref:t}):null});sl.displayName=kn;var SC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=tn(kn,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(Kt,{present:n||s,children:c.jsx(tp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),CC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=tn(kn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ni(()=>l("SCROLL_END"),100),[a,l]=bC("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(Kt,{present:n||a!=="hidden",children:c.jsx(il,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:fe(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:fe(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),tp=m.forwardRef((e,t)=>{const n=tn(kn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",l=ni(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return zr(n.viewport,l),zr(n.content,l),c.jsx(Kt,{present:r||s,children:c.jsx(il,{"data-state":s?"visible":"hidden",...o,ref:t})})}),il=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=tn(kn,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=ip(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 AC(h,i.current,a,p)}return n==="horizontal"?c.jsx(TC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=ap(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(kC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=ap(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}),TC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=tn(kn,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Ue(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(rp,{"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":ti(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),cp(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:ei(i.paddingLeft),paddingEnd:ei(i.paddingRight)}})}})}),kC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=tn(kn,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Ue(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(rp,{"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":ti(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),cp(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:ei(i.paddingTop),paddingEnd:ei(i.paddingBottom)}})}})}),[EC,np]=Jh(kn),rp=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=tn(kn,n),[v,x]=m.useState(null),g=Ue(t,j=>x(j)),y=m.useRef(null),b=m.useRef(""),S=p.viewport,k=r.content-r.viewport,C=Tt(d),T=Tt(l),I=ni(f,10);function A(j){if(y.current){const P=j.clientX-y.current.left,D=j.clientY-y.current.top;u({x:P,y:D})}}return m.useEffect(()=>{const j=P=>{const D=P.target;(v==null?void 0:v.contains(D))&&C(P,k)};return document.addEventListener("wheel",j,{passive:!1}),()=>document.removeEventListener("wheel",j,{passive:!1})},[S,v,k,C]),m.useEffect(T,[r,T]),zr(v,I),zr(p.content,I),c.jsx(EC,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:Tt(s),onThumbPointerUp:Tt(i),onThumbPositionChange:T,onThumbPointerDown:Tt(a),children:c.jsx(Ae.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:fe(e.onPointerDown,j=>{j.button===0&&(j.target.setPointerCapture(j.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(j))}),onPointerMove:fe(e.onPointerMove,A),onPointerUp:fe(e.onPointerUp,j=>{const P=j.target;P.hasPointerCapture(j.pointerId)&&P.releasePointerCapture(j.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),Qs="ScrollAreaThumb",op=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=np(Qs,e.__scopeScrollArea);return c.jsx(Kt,{present:n||o.hasThumb,children:c.jsx(IC,{ref:t,...r})})}),IC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=tn(Qs,n),i=np(Qs,n),{onThumbPositionChange:a}=i,l=Ue(t,f=>i.onThumbChange(f)),u=m.useRef(void 0),d=ni(()=>{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=_C(f,a);u.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),c.jsx(Ae.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:fe(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),v=f.clientX-p.left,x=f.clientY-p.top;i.onThumbPointerDown({x:v,y:x})}),onPointerUp:fe(e.onPointerUp,i.onThumbPointerUp)})});op.displayName=Qs;var al="ScrollAreaCorner",sp=m.forwardRef((e,t)=>{const n=tn(al,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(NC,{...e,ref:t}):null});sp.displayName=al;var NC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=tn(al,n),[s,i]=m.useState(0),[a,l]=m.useState(0),u=!!(s&&a);return zr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),zr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?c.jsx(Ae.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 ei(e){return e?parseInt(e,10):0}function ip(e,t){const n=e/t;return isNaN(n)?0:n}function ti(e){const t=ip(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function AC(e,t,n,r="ltr"){const o=ti(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 lp([l,u],f)(e)}function ap(e,t,n="ltr"){const r=ti(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=rl(e,l);return lp([0,i],[0,a])(u)}function lp(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 cp(e,t){return e>0&&e<t}var _C=(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 ni(e,t){const n=Tt(e),r=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),m.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function zr(e,t){const n=Tt(t);wt(()=>{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 up=Zh,jC=ep,RC=sp;const dp=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(up,{ref:r,className:ee("relative overflow-hidden",e),...n,children:[c.jsx(jC,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(fp,{}),c.jsx(RC,{})]}));dp.displayName=up.displayName;const fp=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(sl,{ref:r,orientation:t,className:ee("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(op,{className:"relative flex-1 rounded-full bg-border"})}));fp.displayName=sl.displayName;function ll({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:u,onThreadDelete:d}){const{threads:f,currentThreadId:h,isLoading:p,actions:v}=Vo(),{loadThread:x}=Ko(),{createThread:g,deleteThread:y,renameThread:b}=v,[S,k]=w.useState(Array.isArray(f)?f:[]),C=w.useRef(S.length>0),[T,I]=w.useState(null),[A,j]=w.useState(""),[P,D]=w.useState(!1);w.useEffect(()=>{const F=Array.isArray(f)?f:[];if(F.length>0){C.current=!0,k(F);return}p||(C.current=!1,k(F))},[f,p]);const L=async F=>{try{await x(F),a==null||a(F),l==null||l(F)}catch(Q){console.error("Failed to select thread:",Q)}},B=async()=>{try{D(!0);const F=await g();u==null||u(F),a==null||a(F)}catch(F){console.error("Failed to create thread:",F)}finally{D(!1)}},M=async(F,Q)=>{if(Q.stopPropagation(),!!confirm("Delete this thread?"))try{await y(F),d==null||d(F)}catch(he){console.error("Failed to delete thread:",he)}},X=(F,Q)=>{Q.stopPropagation(),I(F.threadId),j(F.title||`Thread ${F.threadId.slice(0,8)}`)},W=async F=>{if(A.trim())try{await b(F,A.trim()),I(null),j("")}catch(Q){console.error("Failed to update title:",Q)}},V=()=>{I(null),j("")},z=(F,Q)=>{F.key==="Enter"?W(Q):F.key==="Escape"&&V()},$=F=>{if(!F)return"";try{const Q=new Date(F),ve=new Date().getTime()-Q.getTime(),be=Math.floor(ve/(1e3*60*60*24));return be===0?Q.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):be===1?"Yesterday":be<7?`${be} days ago`:Q.toLocaleDateString()}catch{return""}},pe=F=>F.title||`Thread ${F.threadId.slice(0,8)}`;return c.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&c.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:c.jsx(Ke,{onClick:B,disabled:P||p,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:P?"Creating...":"New Chat",children:c.jsx(ae.MessageSquarePlus,{size:20})})}),c.jsx(dp,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:c.jsx("div",{className:"p-2 space-y-1 pb-4",children:p?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(ae.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):S.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(ae.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),c.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):S.slice().sort((F,Q)=>new Date(Q.updatedAt||Q.createdAt||"").getTime()-new Date(F.updatedAt||F.createdAt||"").getTime()).map(F=>c.jsxs("div",{onClick:()=>L(F.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??h)===F.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"flex-1 min-w-0",children:T===F.threadId?c.jsxs("div",{className:"flex items-center gap-2",onClick:Q=>Q.stopPropagation(),children:[c.jsx(Zs,{value:A,onChange:Q=>j(Q.target.value),onKeyDown:Q=>z(Q,F.threadId),className:"h-6 text-sm",autoFocus:!0}),c.jsx(Ke,{variant:"ghost",size:"sm",onClick:()=>W(F.threadId),className:"h-6 w-6 p-0",children:c.jsx(ae.Check,{size:12})}),c.jsx(Ke,{variant:"ghost",size:"sm",onClick:V,className:"h-6 w-6 p-0",children:c.jsx(ae.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:pe(F)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(ae.Calendar,{size:10}),c.jsx("span",{children:$(F.updatedAt||F.createdAt)})]})]})}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&T!==F.threadId&&c.jsx(Ke,{variant:"ghost",size:"sm",onClick:Q=>X(F,Q),className:"h-6 w-6 p-0",title:"Edit title",children:c.jsx(ae.Edit3,{size:12})}),n&&c.jsx(Ke,{variant:"ghost",size:"sm",onClick:Q=>M(F.threadId,Q),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:c.jsx(ae.Trash2,{size:12})})]})]}),i===F.threadId&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},F.threadId))})})]})}function Br(e){if(!(typeof globalThis>"u"))return globalThis[e]}function PC(e){if(typeof e!="string")return;const t=e.trim();if(t)return _n(t)}function hp(){const e=[Br("__API_BASE_URL__"),Br("__CHAT_API_BASE_URL__"),Br("__CHAT_API_URL__")];for(const t of e){const n=PC(t);if(n)return n}}function pp(){const e=[Br("__API_AUTH_TOKEN__"),Br("__CHAT_API_KEY__"),Br("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function mp(...e){for(const t of e)if(typeof t=="string"&&t.trim())return _n(t);return _n()}function gp(){const e={},t=hp(),n=pp();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function xp(){const e=gp(),t=Fn.getAuthToken(),n=hp();return{apiBaseUrl:mp(e.baseUrl,Fn.baseUrl,n),apiKey:t||e.apiKey||pp()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const yp="chat-settings";function OC(){try{const e=localStorage.getItem(yp);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function MC(e){try{const t={...e,apiBaseUrl:_n(e.apiBaseUrl)};localStorage.setItem(yp,JSON.stringify(t)),t.apiKey&&Fn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function DC(){const e=xp(),t=OC(),n=Fn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:mp(Fn.baseUrl,r,e.apiBaseUrl)}}function LC(e){Fn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),MC(e)}var $C="Label",vp=m.forwardRef((e,t)=>c.jsx(Ae.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())}}));vp.displayName=$C;var bp=vp;const FC=Ao.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),nn=m.forwardRef(({className:e,...t},n)=>c.jsx(bp,{ref:n,className:ee(FC(),e),...t}));nn.displayName=bp.displayName;function wp(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 ri="Switch",[zC,uk]=yn(ri),[BC,HC]=zC(ri),Sp=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:u,form:d,...f}=e,[h,p]=m.useState(null),v=Ue(t,S=>p(S)),x=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[y,b]=dr({prop:o,defaultProp:s??!1,onChange:u,caller:ri});return c.jsxs(BC,{scope:n,checked:y,disabled:a,children:[c.jsx(Ae.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":Ep(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:v,onClick:fe(e.onClick,S=>{b(k=>!k),g&&(x.current=S.isPropagationStopped(),x.current||S.stopPropagation())})}),g&&c.jsx(kp,{control:h,bubbles:!x.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Sp.displayName=ri;var Cp="SwitchThumb",Tp=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=HC(Cp,n);return c.jsx(Ae.span,{"data-state":Ep(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Tp.displayName=Cp;var UC="SwitchBubbleInput",kp=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=Ue(i,s),l=wp(n),u=Df(t);return m.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const v=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(v)}},[l,n,r]),c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});kp.displayName=UC;function Ep(e){return e?"checked":"unchecked"}var Ip=Sp,WC=Tp;const Yn=m.forwardRef(({className:e,...t},n)=>c.jsx(Ip,{className:ee("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(WC,{className:ee("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")})}));Yn.displayName=Ip.displayName;var Np=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"}),VC="VisuallyHidden",KC=m.forwardRef((e,t)=>c.jsx(Ae.span,{...e,ref:t,style:{...Np,...e.style}}));KC.displayName=VC;var qC=[" ","Enter","ArrowUp","ArrowDown"],GC=[" ","Enter"],vr="Select",[oi,si,YC]=Ra(vr),[Hr,dk]=yn(vr,[YC,Vs]),ii=Vs(),[XC,Xn]=Hr(vr),[JC,ZC]=Hr(vr),Ap=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:u,name:d,autoComplete:f,disabled:h,required:p,form:v}=e,x=ii(t),[g,y]=m.useState(null),[b,S]=m.useState(null),[k,C]=m.useState(!1),T=Os(u),[I,A]=dr({prop:r,defaultProp:o??!1,onChange:s,caller:vr}),[j,P]=dr({prop:i,defaultProp:a,onChange:l,caller:vr}),D=m.useRef(null),L=g?v||!!g.closest("form"):!0,[B,M]=m.useState(new Set),X=Array.from(B).map(W=>W.props.value).join(";");return c.jsx(Kf,{...x,children:c.jsxs(XC,{required:p,scope:t,trigger:g,onTriggerChange:y,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:vn(),value:j,onValueChange:P,open:I,onOpenChange:A,dir:T,triggerPointerDownPosRef:D,disabled:h,children:[c.jsx(oi.Provider,{scope:t,children:c.jsx(JC,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(W=>{M(V=>new Set(V).add(W))},[]),onNativeOptionRemove:m.useCallback(W=>{M(V=>{const z=new Set(V);return z.delete(W),z})},[]),children:n})}),L?c.jsxs(Qp,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:j,onChange:W=>P(W.target.value),disabled:h,form:v,children:[j===void 0?c.jsx("option",{value:""}):null,Array.from(B)]},X):null]})})};Ap.displayName=vr;var _p="SelectTrigger",jp=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ii(n),i=Xn(_p,n),a=i.disabled||r,l=Ue(t,i.onTriggerChange),u=si(n),d=m.useRef("touch"),[f,h,p]=tm(x=>{const g=u().filter(S=>!S.disabled),y=g.find(S=>S.value===i.value),b=nm(g,x,y);b!==void 0&&i.onValueChange(b.value)}),v=x=>{a||(i.onOpenChange(!0),p()),x&&(i.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return c.jsx(qf,{asChild:!0,...s,children:c.jsx(Ae.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":em(i.value)?"":void 0,...o,ref:l,onClick:fe(o.onClick,x=>{x.currentTarget.focus(),d.current!=="mouse"&&v(x)}),onPointerDown:fe(o.onPointerDown,x=>{d.current=x.pointerType;const g=x.target;g.hasPointerCapture(x.pointerId)&&g.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(v(x),x.preventDefault())}),onKeyDown:fe(o.onKeyDown,x=>{const g=f.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&h(x.key),!(g&&x.key===" ")&&qC.includes(x.key)&&(v(),x.preventDefault())})})})});jp.displayName=_p;var Rp="SelectValue",Pp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Xn(Rp,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=Ue(t,l.onValueNodeChange);return wt(()=>{u(d)},[u,d]),c.jsx(Ae.span,{...a,ref:f,style:{pointerEvents:"none"},children:em(l.value)?c.jsx(c.Fragment,{children:i}):s})});Pp.displayName=Rp;var QC="SelectIcon",Op=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(Ae.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Op.displayName=QC;var eT="SelectPortal",Mp=e=>c.jsx(ys,{asChild:!0,...e});Mp.displayName=eT;var br="SelectContent",Dp=m.forwardRef((e,t)=>{const n=Xn(br,e.__scopeSelect),[r,o]=m.useState();if(wt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?_o.createPortal(c.jsx(Lp,{scope:e.__scopeSelect,children:c.jsx(oi.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx($p,{...e,ref:t})});Dp.displayName=br;var fn=10,[Lp,Jn]=Hr(br),tT="SelectContentImpl",nT=rr.createSlot("SelectContent.RemoveScroll"),$p=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:x,avoidCollisions:g,...y}=e,b=Xn(br,n),[S,k]=m.useState(null),[C,T]=m.useState(null),I=Ue(t,q=>k(q)),[A,j]=m.useState(null),[P,D]=m.useState(null),L=si(n),[B,M]=m.useState(!1),X=m.useRef(!1);m.useEffect(()=>{if(S)return Ea(S)},[S]),ba();const W=m.useCallback(q=>{const[O,...J]=L().map(le=>le.ref.current),[te]=J.slice(-1),de=document.activeElement;for(const le of q)if(le===de||(le==null||le.scrollIntoView({block:"nearest"}),le===O&&C&&(C.scrollTop=0),le===te&&C&&(C.scrollTop=C.scrollHeight),le==null||le.focus(),document.activeElement!==de))return},[L,C]),V=m.useCallback(()=>W([A,S]),[W,A,S]);m.useEffect(()=>{B&&V()},[B,V]);const{onOpenChange:z,triggerPointerDownPosRef:$}=b;m.useEffect(()=>{if(S){let q={x:0,y:0};const O=te=>{var de,le;q={x:Math.abs(Math.round(te.pageX)-(((de=$.current)==null?void 0:de.x)??0)),y:Math.abs(Math.round(te.pageY)-(((le=$.current)==null?void 0:le.y)??0))}},J=te=>{q.x<=10&&q.y<=10?te.preventDefault():S.contains(te.target)||z(!1),document.removeEventListener("pointermove",O),$.current=null};return $.current!==null&&(document.addEventListener("pointermove",O),document.addEventListener("pointerup",J,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",O),document.removeEventListener("pointerup",J,{capture:!0})}}},[S,z,$]),m.useEffect(()=>{const q=()=>z(!1);return window.addEventListener("blur",q),window.addEventListener("resize",q),()=>{window.removeEventListener("blur",q),window.removeEventListener("resize",q)}},[z]);const[pe,F]=tm(q=>{const O=L().filter(de=>!de.disabled),J=O.find(de=>de.ref.current===document.activeElement),te=nm(O,q,J);te&&setTimeout(()=>te.ref.current.focus())}),Q=m.useCallback((q,O,J)=>{const te=!X.current&&!J;(b.value!==void 0&&b.value===O||te)&&(j(q),te&&(X.current=!0))},[b.value]),he=m.useCallback(()=>S==null?void 0:S.focus(),[S]),ve=m.useCallback((q,O,J)=>{const te=!X.current&&!J;(b.value!==void 0&&b.value===O||te)&&D(q)},[b.value]),be=r==="popper"?cl:Fp,Te=be===cl?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:x,avoidCollisions:g}:{};return c.jsx(Lp,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:Q,selectedItem:A,onItemLeave:he,itemTextRefCallback:ve,focusSelectedItem:V,selectedItemText:P,position:r,isPositioned:B,searchRef:pe,children:c.jsx(Ts,{as:nT,allowPinchZoom:!0,children:c.jsx(xs,{asChild:!0,trapped:b.open,onMountAutoFocus:q=>{q.preventDefault()},onUnmountAutoFocus:fe(o,q=>{var O;(O=b.trigger)==null||O.focus({preventScroll:!0}),q.preventDefault()}),children:c.jsx(gs,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:q=>q.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:c.jsx(be,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:q=>q.preventDefault(),...y,...Te,onPlaced:()=>M(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:fe(y.onKeyDown,q=>{const O=q.ctrlKey||q.altKey||q.metaKey;if(q.key==="Tab"&&q.preventDefault(),!O&&q.key.length===1&&F(q.key),["ArrowUp","ArrowDown","Home","End"].includes(q.key)){let te=L().filter(de=>!de.disabled).map(de=>de.ref.current);if(["ArrowUp","End"].includes(q.key)&&(te=te.slice().reverse()),["ArrowUp","ArrowDown"].includes(q.key)){const de=q.target,le=te.indexOf(de);te=te.slice(le+1)}setTimeout(()=>W(te)),q.preventDefault()}})})})})})})});$p.displayName=tT;var rT="SelectItemAlignedPosition",Fp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Xn(br,n),i=Jn(br,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=Ue(t,I=>d(I)),h=si(n),p=m.useRef(!1),v=m.useRef(!0),{viewport:x,selectedItem:g,selectedItemText:y,focusSelectedItem:b}=i,S=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&x&&g&&y){const I=s.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),j=s.valueNode.getBoundingClientRect(),P=y.getBoundingClientRect();if(s.dir!=="rtl"){const de=P.left-A.left,le=j.left-de,ie=I.left-le,et=I.width+ie,Qe=Math.max(et,A.width),Oe=window.innerWidth-fn,Be=rl(le,[fn,Math.max(fn,Oe-Qe)]);a.style.minWidth=et+"px",a.style.left=Be+"px"}else{const de=A.right-P.right,le=window.innerWidth-j.right-de,ie=window.innerWidth-I.right-le,et=I.width+ie,Qe=Math.max(et,A.width),Oe=window.innerWidth-fn,Be=rl(le,[fn,Math.max(fn,Oe-Qe)]);a.style.minWidth=et+"px",a.style.right=Be+"px"}const D=h(),L=window.innerHeight-fn*2,B=x.scrollHeight,M=window.getComputedStyle(u),X=parseInt(M.borderTopWidth,10),W=parseInt(M.paddingTop,10),V=parseInt(M.borderBottomWidth,10),z=parseInt(M.paddingBottom,10),$=X+W+B+z+V,pe=Math.min(g.offsetHeight*5,$),F=window.getComputedStyle(x),Q=parseInt(F.paddingTop,10),he=parseInt(F.paddingBottom,10),ve=I.top+I.height/2-fn,be=L-ve,Te=g.offsetHeight/2,q=g.offsetTop+Te,O=X+W+q,J=$-O;if(O<=ve){const de=D.length>0&&g===D[D.length-1].ref.current;a.style.bottom="0px";const le=u.clientHeight-x.offsetTop-x.offsetHeight,ie=Math.max(be,Te+(de?he:0)+le+V),et=O+ie;a.style.height=et+"px"}else{const de=D.length>0&&g===D[0].ref.current;a.style.top="0px";const ie=Math.max(ve,X+x.offsetTop+(de?Q:0)+Te)+J;a.style.height=ie+"px",x.scrollTop=O-ve+x.offsetTop}a.style.margin=`${fn}px 0`,a.style.minHeight=pe+"px",a.style.maxHeight=L+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,x,g,y,s.dir,r]);wt(()=>S(),[S]);const[k,C]=m.useState();wt(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const T=m.useCallback(I=>{I&&v.current===!0&&(S(),b==null||b(),v.current=!1)},[S,b]);return c.jsx(sT,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:T,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:c.jsx(Ae.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Fp.displayName=rT;var oT="SelectPopperPosition",cl=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=fn,...s}=e,i=ii(n);return c.jsx(Gf,{...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)"}})});cl.displayName=oT;var[sT,ul]=Hr(br,{}),dl="SelectViewport",zp=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Jn(dl,n),i=ul(dl,n),a=Ue(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(oi.Slot,{scope:n,children:c.jsx(Ae.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:fe(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const v=window.innerHeight-fn*2,x=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),y=Math.max(x,g);if(y<v){const b=y+p,S=Math.min(v,b),k=b-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});zp.displayName=dl;var Bp="SelectGroup",[iT,aT]=Hr(Bp),lT=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=vn();return c.jsx(iT,{scope:n,id:o,children:c.jsx(Ae.div,{role:"group","aria-labelledby":o,...r,ref:t})})});lT.displayName=Bp;var Hp="SelectLabel",Up=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=aT(Hp,n);return c.jsx(Ae.div,{id:o.id,...r,ref:t})});Up.displayName=Hp;var ai="SelectItem",[cT,Wp]=Hr(ai),Vp=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Xn(ai,n),l=Jn(ai,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),v=Ue(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),x=vn(),g=m.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return c.jsx(cT,{scope:n,value:r,disabled:o,textId:x,isSelected:u,onItemTextChange:m.useCallback(b=>{f(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:c.jsx(oi.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(Ae.div,{role:"option","aria-labelledby":x,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:fe(i.onFocus,()=>p(!0)),onBlur:fe(i.onBlur,()=>p(!1)),onClick:fe(i.onClick,()=>{g.current!=="mouse"&&y()}),onPointerUp:fe(i.onPointerUp,()=>{g.current==="mouse"&&y()}),onPointerDown:fe(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:fe(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:fe(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:fe(i.onKeyDown,b=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(GC.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});Vp.displayName=ai;var ko="SelectItemText",Kp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Xn(ko,n),a=Jn(ko,n),l=Wp(ko,n),u=ZC(ko,n),[d,f]=m.useState(null),h=Ue(t,y=>f(y),l.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,y,l.value,l.disabled)}),p=d==null?void 0:d.textContent,v=m.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:x,onNativeOptionRemove:g}=u;return wt(()=>(x(v),()=>g(v)),[x,g,v]),c.jsxs(c.Fragment,{children:[c.jsx(Ae.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?_o.createPortal(s.children,i.valueNode):null]})});Kp.displayName=ko;var qp="SelectItemIndicator",Gp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Wp(qp,n).isSelected?c.jsx(Ae.span,{"aria-hidden":!0,...r,ref:t}):null});Gp.displayName=qp;var fl="SelectScrollUpButton",Yp=m.forwardRef((e,t)=>{const n=Jn(fl,e.__scopeSelect),r=ul(fl,e.__scopeSelect),[o,s]=m.useState(!1),i=Ue(t,r.onScrollButtonChange);return wt(()=>{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(Jp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Yp.displayName=fl;var hl="SelectScrollDownButton",Xp=m.forwardRef((e,t)=>{const n=Jn(hl,e.__scopeSelect),r=ul(hl,e.__scopeSelect),[o,s]=m.useState(!1),i=Ue(t,r.onScrollButtonChange);return wt(()=>{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(Jp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Xp.displayName=hl;var Jp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Jn("SelectScrollButton",n),i=m.useRef(null),a=si(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),wt(()=>{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(Ae.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:fe(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:fe(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:fe(o.onPointerLeave,()=>{l()})})}),uT="SelectSeparator",Zp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(Ae.div,{"aria-hidden":!0,...r,ref:t})});Zp.displayName=uT;var pl="SelectArrow",dT=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ii(n),s=Xn(pl,n),i=Jn(pl,n);return s.open&&i.position==="popper"?c.jsx(Yf,{...o,...r,ref:t}):null});dT.displayName=pl;var fT="SelectBubbleInput",Qp=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=Ue(r,o),i=wp(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(Ae.select,{...n,style:{...Np,...n.style},ref:s,defaultValue:t})});Qp.displayName=fT;function em(e){return e===""||e===void 0}function tm(e){const t=Tt(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 nm(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=hT(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 hT(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var pT=Ap,rm=jp,mT=Pp,gT=Op,xT=Mp,om=Dp,yT=zp,sm=Up,im=Vp,vT=Kp,bT=Gp,am=Yp,lm=Xp,cm=Zp;const um=pT,dm=mT,ml=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(rm,{ref:r,className:ee("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(gT,{asChild:!0,children:c.jsx(ae.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));ml.displayName=rm.displayName;const fm=m.forwardRef(({className:e,...t},n)=>c.jsx(am,{ref:n,className:ee("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ae.ChevronUp,{className:"h-4 w-4"})}));fm.displayName=am.displayName;const hm=m.forwardRef(({className:e,...t},n)=>c.jsx(lm,{ref:n,className:ee("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ae.ChevronDown,{className:"h-4 w-4"})}));hm.displayName=lm.displayName;const gl=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(xT,{children:c.jsxs(om,{ref:o,className:ee("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(fm,{}),c.jsx(yT,{className:ee("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(hm,{})]})}));gl.displayName=om.displayName;const wT=m.forwardRef(({className:e,...t},n)=>c.jsx(sm,{ref:n,className:ee("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));wT.displayName=sm.displayName;const wr=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(im,{ref:r,className:ee("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(bT,{children:c.jsx(ae.Check,{className:"h-4 w-4"})})}),c.jsx(vT,{children:t})]}));wr.displayName=im.displayName;const ST=m.forwardRef(({className:e,...t},n)=>c.jsx(cm,{ref:n,className:ee("-mx-1 my-1 h-px bg-muted",e),...t}));ST.displayName=cm.displayName;var CT="Separator",pm="horizontal",TT=["horizontal","vertical"],mm=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=pm,...o}=e,s=kT(r)?r:pm,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(Ae.div,{"data-orientation":s,...a,...o,ref:t})});mm.displayName=CT;function kT(e){return TT.includes(e)}var gm=mm;const xm=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(gm,{ref:o,decorative:n,orientation:t,className:ee("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));xm.displayName=gm.displayName;const ET=Qd,IT=iw,NT=ef,ym=m.forwardRef(({className:e,...t},n)=>c.jsx(As,{className:ee("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}));ym.displayName=As.displayName;const AT=Ao.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"}}),vm=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(NT,{children:[c.jsx(ym,{}),c.jsxs(_s,{ref:o,className:ee(AT({side:e}),t),...r,children:[n,c.jsxs(tf,{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(ae.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));vm.displayName=_s.displayName;const bm=({className:e,...t})=>c.jsx("div",{className:ee("flex flex-col space-y-2 text-center sm:text-left",e),...t});bm.displayName="SheetHeader";const wm=m.forwardRef(({className:e,...t},n)=>c.jsx(pr,{ref:n,className:ee("text-lg font-semibold text-foreground",e),...t}));wm.displayName=pr.displayName;const Sm=m.forwardRef(({className:e,...t},n)=>c.jsx(js,{ref:n,className:ee("text-sm text-muted-foreground",e),...t}));Sm.displayName=js.displayName;const _T={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 jT({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=w.useState(!1),[s,i]=w.useState(!1),[a,l]=w.useState(e),[u,d]=w.useState(!1),{toast:f}=ma();w.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),w.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(_T),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},v=()=>{l(e),d(!1),o(!1)},x=async()=>{try{const y=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${y.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return c.jsxs(ET,{open:r,onOpenChange:o,children:[c.jsx(IT,{asChild:!0,children:c.jsxs(Ke,{variant:"outline",size:"sm",className:n,children:[c.jsx(ae.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(sa,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(vm,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(bm,{children:[c.jsx(wm,{children:"Chat Settings"}),c.jsx(Sm,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),c.jsxs("div",{className:"space-y-6 py-6",children:[c.jsxs(uo,{children:[c.jsx(fo,{className:"pb-3",children:c.jsxs(ho,{className:"text-lg flex items-center gap-2",children:[c.jsx(ae.Server,{className:"h-5 w-5"}),"API Configuration"]})}),c.jsxs(cs,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(nn,{htmlFor:"api-url",children:"API Base URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Zs,{id:"api-url",value:a.api.baseUrl,onChange:g=>l(y=>({...y,api:{...y.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(Ke,{variant:"outline",onClick:x,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(nn,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(Yn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>l(y=>({...y,api:{...y.api,enableAuth:g}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(nn,{htmlFor:"auth-token",children:"Authentication Token"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Zs,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>l(y=>({...y,api:{...y.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(Ke,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(ae.EyeOff,{className:"h-4 w-4"}):c.jsx(ae.Eye,{className:"h-4 w-4"})})]})]})]})]}),c.jsxs(uo,{children:[c.jsx(fo,{className:"pb-3",children:c.jsxs(ho,{className:"text-lg flex items-center gap-2",children:[c.jsx(ae.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),c.jsxs(cs,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(nn,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(um,{value:a.ui.layout,onValueChange:g=>l(y=>({...y,ui:{...y.ui,layout:g}})),children:[c.jsx(ml,{children:c.jsx(dm,{})}),c.jsxs(gl,{children:[c.jsx(wr,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(wr,{value:"fullscreen",children:"Fullscreen"}),c.jsx(wr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(nn,{htmlFor:"theme",children:"Theme"}),c.jsxs(um,{value:a.ui.theme,onValueChange:g=>l(y=>({...y,ui:{...y.ui,theme:g}})),children:[c.jsx(ml,{children:c.jsx(dm,{})}),c.jsxs(gl,{children:[c.jsx(wr,{value:"light",children:"Light"}),c.jsx(wr,{value:"dark",children:"Dark"}),c.jsx(wr,{value:"system",children:"System"})]})]})]}),c.jsx(xm,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(nn,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(Yn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,showTimestamps:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(nn,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(Yn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,showAgentNames:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(nn,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(Yn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,compactMessages:g}}))})]})]})]})]}),c.jsxs(uo,{children:[c.jsx(fo,{className:"pb-3",children:c.jsxs(ho,{className:"text-lg flex items-center gap-2",children:[c.jsx(ae.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),c.jsxs(cs,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(nn,{htmlFor:"auto-save",children:"Auto-save Conversations"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),c.jsx(Yn,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>l(y=>({...y,behavior:{...y.behavior,autoSave:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(nn,{htmlFor:"enable-streaming",children:"Enable Streaming"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),c.jsx(Yn,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>l(y=>({...y,behavior:{...y.behavior,enableStreaming:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(nn,{htmlFor:"typing-indicator",children:"Typing Indicator"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),c.jsx(Yn,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>l(y=>({...y,behavior:{...y.behavior,showTypingIndicator:g}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(Ke,{variant:"outline",onClick:p,children:[c.jsx(ae.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ke,{variant:"outline",onClick:v,children:"Cancel"}),c.jsxs(Ke,{onClick:h,disabled:!u,children:[c.jsx(ae.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function RT({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),l=w.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?c.jsx(qo,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsx(Js,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?c.jsx(qo,{...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(ll,{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(Js,{onError:s.onError,enableFileUpload:!0})})]})})}):c.jsx(qo,{...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(ll,{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(Js,{onError:s.onError,enableFileUpload:!0})})]})})}_e.ChatApi=xc,_e.ChatInterface=Js,_e.ChatProviders=qo,_e.ChatSettings=jT,_e.MarkdownContent=fa,_e.MessageComponent=df,_e.MessageList=ja,_e.ThreadManager=ll,_e.applySettings=LC,_e.chatApiClient=Fn,_e.default=RT,_e.del=gc,_e.get=pn,_e.getChatToken=fc,_e.getCurrentSettings=DC,_e.getDefaultApiConfig=gp,_e.getDefaultChatSettings=xp,_e.onChatTokenChanged=hc,_e.post=pc,_e.put=mc,_e.setChatToken=Ci,_e.useApi=Ti,_e.useChatStream=Oc,_e.useMessagesReducer=kc,_e.useStream=Uc,_e.useThreadState=Ko,_e.useThreads=Vo,Object.defineProperties(_e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});