teodor-new-chat-ui 4.3.284 → 4.3.285
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.esm.js +2551 -2551
- package/dist/index.umd.js +39 -39
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(Ee,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom"],b):(Ee=typeof globalThis<"u"?globalThis:Ee||self,b(Ee.NewChatUI={},Ee.React,Ee.LucideReact,Ee.reactSlot,Ee.classVarianceAuthority,Ee.clsx,Ee.tailwindMerge,Ee.ReactDOM))})(this,function(Ee,b,
|
|
1
|
+
(function(Ee,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom"],b):(Ee=typeof globalThis<"u"?globalThis:Ee||self,b(Ee.NewChatUI={},Ee.React,Ee.LucideReact,Ee.reactSlot,Ee.classVarianceAuthority,Ee.clsx,Ee.tailwindMerge,Ee.ReactDOM))})(this,function(Ee,b,ae,Wn,fo,Hp,Up,Ks){"use strict";var WC=Object.defineProperty;var VC=(Ee,b,ae)=>b in Ee?WC(Ee,b,{enumerable:!0,configurable:!0,writable:!0,value:ae}):Ee[b]=ae;var zp=(Ee,b,ae)=>VC(Ee,typeof b!="symbol"?b+"":b,ae);function qa(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 v=qa(b),ho=qa(Ks);var qs={exports:{}},Ir={};/**
|
|
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 Ga;function Wp(){if(Ga)return
|
|
9
|
+
*/var Ga;function Wp(){if(Ga)return Ir;Ga=1;var e=b,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,l,c){var d,f={},h=null,p=null;c!==void 0&&(h=""+c),l.key!==void 0&&(h=""+l.key),l.ref!==void 0&&(p=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(f[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)f[d]===void 0&&(f[d]=l[d]);return{$$typeof:t,type:a,key:h,ref:p,props:f,_owner:o.current}}return Ir.Fragment=n,Ir.jsx=i,Ir.jsxs=i,Ir}var Nr={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,33 +14,33 @@
|
|
|
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 Ya;function Vp(){return Ya||(Ya=1,process.env.NODE_ENV!=="production"&&function(){var e=b,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),m=Symbol.iterator,x="@@iterator";function y(I){if(I===null||typeof I!="object")return null;var
|
|
18
|
-
`+
|
|
19
|
-
`),
|
|
20
|
-
`),vt=
|
|
21
|
-
`+
|
|
17
|
+
*/var Ya;function Vp(){return Ya||(Ya=1,process.env.NODE_ENV!=="production"&&function(){var e=b,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),m=Symbol.iterator,x="@@iterator";function y(I){if(I===null||typeof I!="object")return null;var K=m&&I[m]||I[x];return typeof K=="function"?K:null}var g=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(I){{for(var K=arguments.length,le=new Array(K>1?K-1:0),ke=1;ke<K;ke++)le[ke-1]=arguments[ke];S("error",I,le)}}function S(I,K,le){{var ke=g.ReactDebugCurrentFrame,et=ke.getStackAddendum();et!==""&&(K+="%s",le=le.concat([et]));var it=le.map(function(Ke){return String(Ke)});it.unshift("Warning: "+K),Function.prototype.apply.call(console[I],console,it)}}var k=!1,T=!1,C=!1,E=!1,N=!1,j;j=Symbol.for("react.module.reference");function D(I){return!!(typeof I=="string"||typeof I=="function"||I===r||I===s||N||I===o||I===c||I===d||E||I===p||k||T||C||typeof I=="object"&&I!==null&&(I.$$typeof===h||I.$$typeof===f||I.$$typeof===i||I.$$typeof===a||I.$$typeof===l||I.$$typeof===j||I.getModuleId!==void 0))}function P(I,K,le){var ke=I.displayName;if(ke)return ke;var et=K.displayName||K.name||"";return et!==""?le+"("+et+")":le}function M(I){return I.displayName||"Context"}function F(I){if(I==null)return null;if(typeof I.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof I=="function")return I.displayName||I.name||null;if(typeof I=="string")return I;switch(I){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case c:return"Suspense";case d:return"SuspenseList"}if(typeof I=="object")switch(I.$$typeof){case a:var K=I;return M(K)+".Consumer";case i:var le=I;return M(le._context)+".Provider";case l:return P(I,I.render,"ForwardRef");case f:var ke=I.displayName||null;return ke!==null?ke:F(I.type)||"Memo";case h:{var et=I,it=et._payload,Ke=et._init;try{return F(Ke(it))}catch{return null}}}return null}var A=Object.assign,z=0,_,X,$,R,J,G,pe;function Ce(){}Ce.__reactDisabledLog=!0;function Ae(){{if(z===0){_=console.log,X=console.info,$=console.warn,R=console.error,J=console.group,G=console.groupCollapsed,pe=console.groupEnd;var I={configurable:!0,enumerable:!0,value:Ce,writable:!0};Object.defineProperties(console,{info:I,log:I,warn:I,error:I,group:I,groupCollapsed:I,groupEnd:I})}z++}}function q(){{if(z--,z===0){var I={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:A({},I,{value:_}),info:A({},I,{value:X}),warn:A({},I,{value:$}),error:A({},I,{value:R}),group:A({},I,{value:J}),groupCollapsed:A({},I,{value:G}),groupEnd:A({},I,{value:pe})})}z<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ne=g.ReactCurrentDispatcher,Y;function L(I,K,le){{if(Y===void 0)try{throw Error()}catch(et){var ke=et.stack.trim().match(/\n( *(at )?)/);Y=ke&&ke[1]||""}return`
|
|
18
|
+
`+Y+I}}var H=!1,V;{var ie=typeof WeakMap=="function"?WeakMap:Map;V=new ie}function re(I,K){if(!I||H)return"";{var le=V.get(I);if(le!==void 0)return le}var ke;H=!0;var et=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var it;it=ne.current,ne.current=null,Ae();try{if(K){var Ke=function(){throw Error()};if(Object.defineProperty(Ke.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ke,[])}catch(we){ke=we}Reflect.construct(I,[],Ke)}else{try{Ke.call()}catch(we){ke=we}I.call(Ke.prototype)}}else{try{throw Error()}catch(we){ke=we}I()}}catch(we){if(we&&ke&&typeof we.stack=="string"){for(var Ue=we.stack.split(`
|
|
19
|
+
`),_t=ke.stack.split(`
|
|
20
|
+
`),vt=Ue.length-1,wt=_t.length-1;vt>=1&&wt>=0&&Ue[vt]!==_t[wt];)wt--;for(;vt>=1&&wt>=0;vt--,wt--)if(Ue[vt]!==_t[wt]){if(vt!==1||wt!==1)do if(vt--,wt--,wt<0||Ue[vt]!==_t[wt]){var Q=`
|
|
21
|
+
`+Ue[vt].replace(" at new "," at ");return I.displayName&&Q.includes("<anonymous>")&&(Q=Q.replace("<anonymous>",I.displayName)),typeof I=="function"&&V.set(I,Q),Q}while(vt>=1&&wt>=0);break}}}finally{H=!1,ne.current=it,q(),Error.prepareStackTrace=et}var de=I?I.displayName||I.name:"",fe=de?L(de):"";return typeof I=="function"&&V.set(I,fe),fe}function ze(I,K,le){return re(I,!1)}function We(I){var K=I.prototype;return!!(K&&K.isReactComponent)}function Ze(I,K,le){if(I==null)return"";if(typeof I=="function")return re(I,We(I));if(typeof I=="string")return L(I);switch(I){case c:return L("Suspense");case d:return L("SuspenseList")}if(typeof I=="object")switch(I.$$typeof){case l:return ze(I.render);case f:return Ze(I.type,K,le);case h:{var ke=I,et=ke._payload,it=ke._init;try{return Ze(it(et),K,le)}catch{}}}return""}var oe=Object.prototype.hasOwnProperty,me={},Te=g.ReactDebugCurrentFrame;function Be(I){if(I){var K=I._owner,le=Ze(I.type,I._source,K?K.type:null);Te.setExtraStackFrame(le)}else Te.setExtraStackFrame(null)}function Je(I,K,le,ke,et){{var it=Function.call.bind(oe);for(var Ke in I)if(it(I,Ke)){var Ue=void 0;try{if(typeof I[Ke]!="function"){var _t=Error((ke||"React class")+": "+le+" type `"+Ke+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof I[Ke]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw _t.name="Invariant Violation",_t}Ue=I[Ke](K,Ke,ke,le,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(vt){Ue=vt}Ue&&!(Ue instanceof Error)&&(Be(et),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",ke||"React class",le,Ke,typeof Ue),Be(null)),Ue instanceof Error&&!(Ue.message in me)&&(me[Ue.message]=!0,Be(et),w("Failed %s type: %s",le,Ue.message),Be(null))}}}var tt=Array.isArray;function $e(I){return tt(I)}function He(I){{var K=typeof Symbol=="function"&&Symbol.toStringTag,le=K&&I[Symbol.toStringTag]||I.constructor.name||"Object";return le}}function Ve(I){try{return nt(I),!1}catch{return!0}}function nt(I){return""+I}function kt(I){if(Ve(I))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",He(I)),nt(I)}var ft=g.ReactCurrentOwner,mt={key:!0,ref:!0,__self:!0,__source:!0},gt,st;function De(I){if(oe.call(I,"ref")){var K=Object.getOwnPropertyDescriptor(I,"ref").get;if(K&&K.isReactWarning)return!1}return I.ref!==void 0}function At(I){if(oe.call(I,"key")){var K=Object.getOwnPropertyDescriptor(I,"key").get;if(K&&K.isReactWarning)return!1}return I.key!==void 0}function jt(I,K){typeof I.ref=="string"&&ft.current}function nn(I,K){{var le=function(){gt||(gt=!0,w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",K))};le.isReactWarning=!0,Object.defineProperty(I,"key",{get:le,configurable:!0})}}function fn(I,K){{var le=function(){st||(st=!0,w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",K))};le.isReactWarning=!0,Object.defineProperty(I,"ref",{get:le,configurable:!0})}}var qe=function(I,K,le,ke,et,it,Ke){var Ue={$$typeof:t,type:I,key:K,ref:le,props:Ke,_owner:it};return Ue._store={},Object.defineProperty(Ue._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Ue,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ke}),Object.defineProperty(Ue,"_source",{configurable:!1,enumerable:!1,writable:!1,value:et}),Object.freeze&&(Object.freeze(Ue.props),Object.freeze(Ue)),Ue};function je(I,K,le,ke,et){{var it,Ke={},Ue=null,_t=null;le!==void 0&&(kt(le),Ue=""+le),At(K)&&(kt(K.key),Ue=""+K.key),De(K)&&(_t=K.ref,jt(K,et));for(it in K)oe.call(K,it)&&!mt.hasOwnProperty(it)&&(Ke[it]=K[it]);if(I&&I.defaultProps){var vt=I.defaultProps;for(it in vt)Ke[it]===void 0&&(Ke[it]=vt[it])}if(Ue||_t){var wt=typeof I=="function"?I.displayName||I.name||"Unknown":I;Ue&&nn(Ke,wt),_t&&fn(Ke,wt)}return qe(I,Ue,_t,et,ke,ft.current,Ke)}}var Et=g.ReactCurrentOwner,Ht=g.ReactDebugCurrentFrame;function U(I){if(I){var K=I._owner,le=Ze(I.type,I._source,K?K.type:null);Ht.setExtraStackFrame(le)}else Ht.setExtraStackFrame(null)}var ve;ve=!1;function B(I){return typeof I=="object"&&I!==null&&I.$$typeof===t}function ee(){{if(Et.current){var I=F(Et.current.type);if(I)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+I+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+I+"`."}return""}}function ye(I){return""}var Ne={};function se(I){{var K=ee();if(!K){var le=typeof I=="string"?I:I.displayName||I.name;le&&(K=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+
|
|
25
|
+
Check the top-level render call using <`+le+">.")}return K}}function Ge(I,K){{if(!I._store||I._store.validated||I.key!=null)return;I._store.validated=!0;var le=se(K);if(Ne[le])return;Ne[le]=!0;var ke="";I&&I._owner&&I._owner!==Et.current&&(ke=" It was passed a child from "+F(I._owner.type)+"."),U(I),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',le,ke),U(null)}}function _e(I,K){{if(typeof I!="object")return;if($e(I))for(var le=0;le<I.length;le++){var ke=I[le];B(ke)&&Ge(ke,K)}else if(B(I))I._store&&(I._store.validated=!0);else if(I){var et=y(I);if(typeof et=="function"&&et!==I.entries)for(var it=et.call(I),Ke;!(Ke=it.next()).done;)B(Ke.value)&&Ge(Ke.value,K)}}}function Le(I){{var K=I.type;if(K==null||typeof K=="string")return;var le;if(typeof K=="function")le=K.propTypes;else if(typeof K=="object"&&(K.$$typeof===l||K.$$typeof===f))le=K.propTypes;else return;if(le){var ke=F(K);Je(le,I.props,"prop",ke,I)}else if(K.PropTypes!==void 0&&!ve){ve=!0;var et=F(K);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",et||"Unknown")}typeof K.getDefaultProps=="function"&&!K.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function rn(I){{for(var K=Object.keys(I.props),le=0;le<K.length;le++){var ke=K[le];if(ke!=="children"&&ke!=="key"){U(I),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ke),U(null);break}}I.ref!==null&&(U(I),w("Invalid attribute `ref` supplied to `React.Fragment`."),U(null))}}var yt={};function jn(I,K,le,ke,et,it){{var Ke=D(I);if(!Ke){var Ue="";(I===void 0||typeof I=="object"&&I!==null&&Object.keys(I).length===0)&&(Ue+=" 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 _t=ye();_t?Ue+=_t:Ue+=ee();var vt;I===null?vt="null":$e(I)?vt="array":I!==void 0&&I.$$typeof===t?(vt="<"+(F(I.type)||"Unknown")+" />",Ue=" Did you accidentally export a JSX literal instead of a component?"):vt=typeof I,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",vt,Ue)}var wt=je(I,K,le,et,it);if(wt==null)return wt;if(Ke){var Q=K.children;if(Q!==void 0)if(ke)if($e(Q)){for(var de=0;de<Q.length;de++)_e(Q[de],I);Object.freeze&&Object.freeze(Q)}else w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else _e(Q,I)}if(oe.call(K,"key")){var fe=F(I),we=Object.keys(K).filter(function(hn){return hn!=="key"}),ct=we.length>0?"{key: someKey, "+we.join(": ..., ")+": ...}":"{key: someKey}";if(!yt[fe+ct]){var xt=we.length>0?"{"+we.join(": ..., ")+": ...}":"{}";w(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,ct,he,xt,he),Cn[he+ct]=!0}}return I===r?yt(wt):et(wt),wt}}function Wa(I,q,ae){return Ws(I,q,ae,!0)}function Va(I,q,ae){return Ws(I,q,ae,!1)}var Ka=Va,Vs=Wa;Ir.Fragment=r,Ir.jsx=Ka,Ir.jsxs=Vs}()),Ir}process.env.NODE_ENV==="production"?qs.exports=Wp():qs.exports=Vp();var u=qs.exports;function Xa(e,t){return function(){return e.apply(t,arguments)}}const{toString:Kp}=Object.prototype,{getPrototypeOf:Gs}=Object,{iterator:ho,toStringTag:Ja}=Symbol,po=(e=>t=>{const n=Kp.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),on=e=>(e=e.toLowerCase(),t=>po(t)===e),mo=e=>t=>typeof t===e,{isArray:ir}=Array,ar=mo("undefined");function Nr(e){return e!==null&&!ar(e)&&e.constructor!==null&&!ar(e.constructor)&&$t(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Za=on("ArrayBuffer");function qp(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Za(e.buffer),t}const Gp=mo("string"),$t=mo("function"),Qa=mo("number"),Ar=e=>e!==null&&typeof e=="object",Yp=e=>e===!0||e===!1,go=e=>{if(po(e)!=="object")return!1;const t=Gs(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Ja in e)&&!(ho in e)},Xp=e=>{if(!Ar(e)||Nr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Jp=on("Date"),Zp=on("File"),Qp=on("Blob"),em=on("FileList"),tm=e=>Ar(e)&&$t(e.pipe),nm=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||$t(e.append)&&((t=po(e))==="formdata"||t==="object"&&$t(e.toString)&&e.toString()==="[object FormData]"))},rm=on("URLSearchParams"),[om,sm,im,am]=["ReadableStream","Request","Response","Headers"].map(on),lm=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function jr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),ir(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Nr(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 el(e,t){if(Nr(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 Wn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,tl=e=>!ar(e)&&e!==Wn;function Ys(){const{caseless:e,skipUndefined:t}=tl(this)&&this||{},n={},r=(o,s)=>{const i=e&&el(n,s)||s;go(n[i])&&go(o)?n[i]=Ys(n[i],o):go(o)?n[i]=Ys({},o):ir(o)?n[i]=o.slice():(!t||!ar(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&jr(arguments[o],r);return n}const cm=(e,t,n,{allOwnKeys:r}={})=>(jr(t,(o,s)=>{n&&$t(o)?e[s]=Xa(o,n):e[s]=o},{allOwnKeys:r}),e),um=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),dm=(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)},fm=(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&&Gs(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},hm=(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},pm=e=>{if(!e)return null;if(ir(e))return e;let t=e.length;if(!Qa(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},mm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Gs(Uint8Array)),gm=(e,t)=>{const r=(e&&e[ho]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},xm=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},ym=on("HTMLFormElement"),vm=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),nl=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),wm=on("RegExp"),rl=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};jr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},bm=e=>{rl(e,(t,n)=>{if($t(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if($t(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+"'")})}})},Sm=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return ir(e)?r(e):r(String(e).split(t)),n},Cm=()=>{},Tm=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function km(e){return!!(e&&$t(e.append)&&e[Ja]==="FormData"&&e[ho])}const Em=e=>{const t=new Array(10),n=(r,o)=>{if(Ar(r)){if(t.indexOf(r)>=0)return;if(Nr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=ir(r)?[]:{};return jr(r,(i,a)=>{const l=n(i,o+1);!ar(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},Im=on("AsyncFunction"),Nm=e=>e&&(Ar(e)||$t(e))&&$t(e.then)&&$t(e.catch),ol=((e,t)=>e?setImmediate:t?((n,r)=>(Wn.addEventListener("message",({source:o,data:s})=>{o===Wn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Wn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",$t(Wn.postMessage)),Am=typeof queueMicrotask<"u"?queueMicrotask.bind(Wn):typeof process<"u"&&process.nextTick||ol,O={isArray:ir,isArrayBuffer:Za,isBuffer:Nr,isFormData:nm,isArrayBufferView:qp,isString:Gp,isNumber:Qa,isBoolean:Yp,isObject:Ar,isPlainObject:go,isEmptyObject:Xp,isReadableStream:om,isRequest:sm,isResponse:im,isHeaders:am,isUndefined:ar,isDate:Jp,isFile:Zp,isBlob:Qp,isRegExp:wm,isFunction:$t,isStream:tm,isURLSearchParams:rm,isTypedArray:mm,isFileList:em,forEach:jr,merge:Ys,extend:cm,trim:lm,stripBOM:um,inherits:dm,toFlatObject:fm,kindOf:po,kindOfTest:on,endsWith:hm,toArray:pm,forEachEntry:gm,matchAll:xm,isHTMLForm:ym,hasOwnProperty:nl,hasOwnProp:nl,reduceDescriptors:rl,freezeMethods:bm,toObjectSet:Sm,toCamelCase:vm,noop:Cm,toFiniteNumber:Tm,findKey:el,global:Wn,isContextDefined:tl,isSpecCompliantForm:km,toJSONObject:Em,isAsyncFn:Im,isThenable:Nm,setImmediate:ol,asap:Am,isIterable:e=>e!=null&&$t(e[ho])};function Pe(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}O.inherits(Pe,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:O.toJSONObject(this.config),code:this.code,status:this.status}}});const sl=Pe.prototype,il={};["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=>{il[e]={value:e}}),Object.defineProperties(Pe,il),Object.defineProperty(sl,"isAxiosError",{value:!0}),Pe.from=(e,t,n,r,o,s)=>{const i=Object.create(sl);O.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Pe.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 jm=null;function Xs(e){return O.isPlainObject(e)||O.isArray(e)}function al(e){return O.endsWith(e,"[]")?e.slice(0,-2):e}function ll(e,t,n){return e?e.concat(t).map(function(o,s){return o=al(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function _m(e){return O.isArray(e)&&!e.some(Xs)}const Rm=O.toFlatObject(O,{},null,function(t){return/^is[A-Z]/.test(t)});function xo(e,t,n){if(!O.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=O.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(x,y){return!O.isUndefined(y[x])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&O.isSpecCompliantForm(t);if(!O.isFunction(o))throw new TypeError("visitor must be a function");function c(m){if(m===null)return"";if(O.isDate(m))return m.toISOString();if(O.isBoolean(m))return m.toString();if(!l&&O.isBlob(m))throw new Pe("Blob is not supported. Use a Buffer instead.");return O.isArrayBuffer(m)||O.isTypedArray(m)?l&&typeof Blob=="function"?new Blob([m]):Buffer.from(m):m}function d(m,x,y){let g=m;if(m&&!y&&typeof m=="object"){if(O.endsWith(x,"{}"))x=r?x:x.slice(0,-2),m=JSON.stringify(m);else if(O.isArray(m)&&_m(m)||(O.isFileList(m)||O.endsWith(x,"[]"))&&(g=O.toArray(m)))return x=al(x),g.forEach(function(S,k){!(O.isUndefined(S)||S===null)&&t.append(i===!0?ll([x],k,s):i===null?x:x+"[]",c(S))}),!1}return Xs(m)?!0:(t.append(ll(y,x,s),c(m)),!1)}const f=[],h=Object.assign(Rm,{defaultVisitor:d,convertValue:c,isVisitable:Xs});function p(m,x){if(!O.isUndefined(m)){if(f.indexOf(m)!==-1)throw Error("Circular reference detected in "+x.join("."));f.push(m),O.forEach(m,function(g,w){(!(O.isUndefined(g)||g===null)&&o.call(t,g,O.isString(w)?w.trim():w,x,h))===!0&&p(g,x?x.concat(w):[w])}),f.pop()}}if(!O.isObject(e))throw new TypeError("data must be an object");return p(e),t}function cl(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Js(e,t){this._pairs=[],e&&xo(e,this,t)}const ul=Js.prototype;ul.append=function(t,n){this._pairs.push([t,n])},ul.toString=function(t){const n=t?function(r){return t.call(this,r,cl)}:cl;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function Pm(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function dl(e,t,n){if(!t)return e;const r=n&&n.encode||Pm;O.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=O.isURLSearchParams(t)?t.toString():new Js(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class fl{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){O.forEach(this.handlers,function(r){r!==null&&t(r)})}}const hl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Om={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Js,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Zs=typeof window<"u"&&typeof document<"u",Qs=typeof navigator=="object"&&navigator||void 0,Mm=Zs&&(!Qs||["ReactNative","NativeScript","NS"].indexOf(Qs.product)<0),Dm=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Lm=Zs&&window.location.href||"http://localhost",_t={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Zs,hasStandardBrowserEnv:Mm,hasStandardBrowserWebWorkerEnv:Dm,navigator:Qs,origin:Lm},Symbol.toStringTag,{value:"Module"})),...Om};function $m(e,t){return xo(e,new _t.classes.URLSearchParams,{visitor:function(n,r,o,s){return _t.isNode&&O.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Fm(e){return O.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function zm(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 pl(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&O.isArray(o)?o.length:i,l?(O.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!O.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&O.isArray(o[i])&&(o[i]=zm(o[i])),!a)}if(O.isFormData(e)&&O.isFunction(e.entries)){const n={};return O.forEachEntry(e,(r,o)=>{t(Fm(r),o,n,0)}),n}return null}function Bm(e,t,n){if(O.isString(e))try{return(t||JSON.parse)(e),O.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const _r={transitional:hl,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=O.isObject(t);if(s&&O.isHTMLForm(t)&&(t=new FormData(t)),O.isFormData(t))return o?JSON.stringify(pl(t)):t;if(O.isArrayBuffer(t)||O.isBuffer(t)||O.isStream(t)||O.isFile(t)||O.isBlob(t)||O.isReadableStream(t))return t;if(O.isArrayBufferView(t))return t.buffer;if(O.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return $m(t,this.formSerializer).toString();if((a=O.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return xo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Bm(t)):t}],transformResponse:[function(t){const n=this.transitional||_r.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(O.isResponse(t)||O.isReadableStream(t))return t;if(t&&O.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Pe.from(a,Pe.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:_t.classes.FormData,Blob:_t.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};O.forEach(["delete","get","head","post","put","patch"],e=>{_r.headers[e]={}});const Hm=O.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Um=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]&&Hm[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},ml=Symbol("internals");function
|
|
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[ml]=this[ml]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Rr(i);r[a]||(qm(o,i),r[a]=!0)}return O.isArray(t)?t.forEach(s):s(t),this}};Ft.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),O.reduceDescriptors(Ft.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),O.freezeMethods(Ft);function ti(e,t){const n=this||_r,r=t||n,o=Ft.from(r.headers);let s=r.data;return O.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function gl(e){return!!(e&&e.__CANCEL__)}function lr(e,t,n){Pe.call(this,e??"canceled",Pe.ERR_CANCELED,t,n),this.name="CanceledError"}O.inherits(lr,Pe,{__CANCEL__:!0});function xl(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Pe("Request failed with status code "+n.status,[Pe.ERR_BAD_REQUEST,Pe.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Gm(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Ym(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;let f=s,h=0;for(;f!==o;)h+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const p=d&&c-d;return p?Math.round(h*1e3/p):void 0}}function Xm(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),f=d-n;f>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const vo=(e,t,n=3)=>{let r=0;const o=Ym(50,250);return Xm(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},yl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},vl=e=>(...t)=>O.asap(()=>e(...t)),Jm=_t.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,_t.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(_t.origin),_t.navigator&&/(msie|trident)/i.test(_t.navigator.userAgent)):()=>!0,Zm=_t.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];O.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),O.isString(r)&&i.push("path="+r),O.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Qm(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function eg(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function wl(e,t,n){let r=!Qm(t);return e&&(r||n==!1)?eg(e,t):t}const bl=e=>e instanceof Ft?{...e}:e;function Vn(e,t){t=t||{};const n={};function r(c,d,f,h){return O.isPlainObject(c)&&O.isPlainObject(d)?O.merge.call({caseless:h},c,d):O.isPlainObject(d)?O.merge({},d):O.isArray(d)?d.slice():d}function o(c,d,f,h){if(O.isUndefined(d)){if(!O.isUndefined(c))return r(void 0,c,f,h)}else return r(c,d,f,h)}function s(c,d){if(!O.isUndefined(d))return r(void 0,d)}function i(c,d){if(O.isUndefined(d)){if(!O.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,f){if(f in t)return r(c,d);if(f in e)return r(void 0,c)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,d,f)=>o(bl(c),bl(d),f,!0)};return O.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,h=f(e[d],t[d],d);O.isUndefined(h)&&f!==a||(n[d]=h)}),n}const Sl=e=>{const t=Vn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ft.from(i),t.url=dl(wl(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),O.isFormData(n)){if(_t.hasStandardBrowserEnv||_t.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(O.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{c.includes(d.toLowerCase())&&i.set(d,f)})}}if(_t.hasStandardBrowserEnv&&(r&&O.isFunction(r)&&(r=r(t)),r||r!==!1&&Jm(t.url))){const l=o&&s&&Zm.read(s);l&&i.set(o,l)}return t},tg=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Sl(e);let s=o.data;const i=Ft.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,f,h,p,m;function x(){p&&p(),m&&m(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let y=new XMLHttpRequest;y.open(o.method.toUpperCase(),o.url,!0),y.timeout=o.timeout;function g(){if(!y)return;const S=Ft.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),T={data:!a||a==="text"||a==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:S,config:e,request:y};xl(function(E){n(E),x()},function(E){r(E),x()},T),y=null}"onloadend"in y?y.onloadend=g:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(g)},y.onabort=function(){y&&(r(new Pe("Request aborted",Pe.ECONNABORTED,e,y)),y=null)},y.onerror=function(k){const T=k&&k.message?k.message:"Network Error",C=new Pe(T,Pe.ERR_NETWORK,e,y);C.event=k||null,r(C),y=null},y.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const T=o.transitional||hl;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Pe(k,T.clarifyTimeoutError?Pe.ETIMEDOUT:Pe.ECONNABORTED,e,y)),y=null},s===void 0&&i.setContentType(null),"setRequestHeader"in y&&O.forEach(i.toJSON(),function(k,T){y.setRequestHeader(T,k)}),O.isUndefined(o.withCredentials)||(y.withCredentials=!!o.withCredentials),a&&a!=="json"&&(y.responseType=o.responseType),c&&([h,m]=vo(c,!0),y.addEventListener("progress",h)),l&&y.upload&&([f,p]=vo(l),y.upload.addEventListener("progress",f),y.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=S=>{y&&(r(!S||S.type?new lr(null,e,y):S),y.abort(),y=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const w=Gm(o.url);if(w&&_t.protocols.indexOf(w)===-1){r(new Pe("Unsupported protocol "+w+":",Pe.ERR_BAD_REQUEST,e));return}y.send(s||null)})},ng=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,a();const d=c instanceof Error?c:this.reason;r.abort(d instanceof Pe?d:new lr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Pe(`timeout ${t} of ms exceeded`,Pe.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>O.asap(a),l}},rg=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},og=async function*(e,t){for await(const n of sg(e))yield*rg(n,t)},sg=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()}},Cl=(e,t,n,r)=>{const o=og(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await o.next();if(c){a(),l.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Tl=64*1024,{isFunction:wo}=O,ig=(({Request:e,Response:t})=>({Request:e,Response:t}))(O.global),{ReadableStream:kl,TextEncoder:El}=O.global,Il=(e,...t)=>{try{return!!e(...t)}catch{return!1}},ag=e=>{e=O.merge.call({skipUndefined:!0},ig,e);const{fetch:t,Request:n,Response:r}=e,o=t?wo(t):typeof fetch=="function",s=wo(n),i=wo(r);if(!o)return!1;const a=o&&wo(kl),l=o&&(typeof El=="function"?(m=>x=>m.encode(x))(new El):async m=>new Uint8Array(await new n(m).arrayBuffer())),c=s&&a&&Il(()=>{let m=!1;const x=new n(_t.origin,{body:new kl,method:"POST",get duplex(){return m=!0,"half"}}).headers.has("Content-Type");return m&&!x}),d=i&&a&&Il(()=>O.isReadableStream(new r("").body)),f={stream:d&&(m=>m.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(m=>{!f[m]&&(f[m]=(x,y)=>{let g=x&&x[m];if(g)return g.call(x);throw new Pe(`Response type '${m}' is not supported`,Pe.ERR_NOT_SUPPORT,y)})});const h=async m=>{if(m==null)return 0;if(O.isBlob(m))return m.size;if(O.isSpecCompliantForm(m))return(await new n(_t.origin,{method:"POST",body:m}).arrayBuffer()).byteLength;if(O.isArrayBufferView(m)||O.isArrayBuffer(m))return m.byteLength;if(O.isURLSearchParams(m)&&(m=m+""),O.isString(m))return(await l(m)).byteLength},p=async(m,x)=>{const y=O.toFiniteNumber(m.getContentLength());return y??h(x)};return async m=>{let{url:x,method:y,data:g,signal:w,cancelToken:S,timeout:k,onDownloadProgress:T,onUploadProgress:C,responseType:E,headers:N,withCredentials:j="same-origin",fetchOptions:D}=Sl(m),P=t||fetch;E=E?(E+"").toLowerCase():"text";let M=ng([w,S&&S.toAbortSignal()],k),F=null;const A=M&&M.unsubscribe&&(()=>{M.unsubscribe()});let z;try{if(C&&c&&y!=="get"&&y!=="head"&&(z=await p(N,g))!==0){let Y=new n(x,{method:"POST",body:g,duplex:"half"}),me;if(O.isFormData(g)&&(me=Y.headers.get("content-type"))&&N.setContentType(me),Y.body){const[Te,je]=yl(z,vo(vl(C)));g=Cl(Y.body,Tl,Te,je)}}O.isString(j)||(j=j?"include":"omit");const _=s&&"credentials"in n.prototype,J={...D,signal:M,method:y.toUpperCase(),headers:N.normalize().toJSON(),body:g,duplex:"half",credentials:_?j:void 0};F=s&&new n(x,J);let $=await(s?P(F,D):P(x,J));const R=d&&(E==="stream"||E==="response");if(d&&(T||R&&A)){const Y={};["status","statusText","headers"].forEach(G=>{Y[G]=$[G]});const me=O.toFiniteNumber($.headers.get("content-length")),[Te,je]=T&&yl(me,vo(vl(T),!0))||[];$=new r(Cl($.body,Tl,Te,()=>{je&&je(),A&&A()}),Y)}E=E||"text";let Z=await f[O.findKey(f,E)||"text"]($,m);return!R&&A&&A(),await new Promise((Y,me)=>{xl(Y,me,{data:Z,headers:Ft.from($.headers),status:$.status,statusText:$.statusText,config:m,request:F})})}catch(_){throw A&&A(),_&&_.name==="TypeError"&&/Load failed|fetch/i.test(_.message)?Object.assign(new Pe("Network Error",Pe.ERR_NETWORK,m,F),{cause:_.cause||_}):Pe.from(_,_&&_.code,m,F)}}},lg=new Map,Nl=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,c,d=lg;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:ag(t)),d=c;return c};Nl();const ni={http:jm,xhr:tg,fetch:{get:Nl}};O.forEach(ni,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Al=e=>`- ${e}`,cg=e=>O.isFunction(e)||e===null||e===!1,jl={getAdapter:(e,t)=>{e=O.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){r=e[i];let a;if(o=r,!cg(r)&&(o=ni[(a=String(r)).toLowerCase()],o===void 0))throw new Pe(`Unknown adapter '${a}'`);if(o&&(O.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!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} />`,ct,fe,xt,fe),yt[fe+ct]=!0}}return I===r?rn(wt):Le(wt),wt}}function Wa(I,K,le){return jn(I,K,le,!0)}function Va(I,K,le){return jn(I,K,le,!1)}var Ka=Va,Vs=Wa;Nr.Fragment=r,Nr.jsx=Ka,Nr.jsxs=Vs}()),Nr}process.env.NODE_ENV==="production"?qs.exports=Wp():qs.exports=Vp();var u=qs.exports;function Xa(e,t){return function(){return e.apply(t,arguments)}}const{toString:Kp}=Object.prototype,{getPrototypeOf:Gs}=Object,{iterator:po,toStringTag:Ja}=Symbol,mo=(e=>t=>{const n=Kp.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),on=e=>(e=e.toLowerCase(),t=>mo(t)===e),go=e=>t=>typeof t===e,{isArray:ar}=Array,lr=go("undefined");function Ar(e){return e!==null&&!lr(e)&&e.constructor!==null&&!lr(e.constructor)&&$t(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Za=on("ArrayBuffer");function qp(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Za(e.buffer),t}const Gp=go("string"),$t=go("function"),Qa=go("number"),jr=e=>e!==null&&typeof e=="object",Yp=e=>e===!0||e===!1,xo=e=>{if(mo(e)!=="object")return!1;const t=Gs(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Ja in e)&&!(po in e)},Xp=e=>{if(!jr(e)||Ar(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Jp=on("Date"),Zp=on("File"),Qp=on("Blob"),em=on("FileList"),tm=e=>jr(e)&&$t(e.pipe),nm=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||$t(e.append)&&((t=mo(e))==="formdata"||t==="object"&&$t(e.toString)&&e.toString()==="[object FormData]"))},rm=on("URLSearchParams"),[om,sm,im,am]=["ReadableStream","Request","Response","Headers"].map(on),lm=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function _r(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),ar(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Ar(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 el(e,t){if(Ar(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 Vn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,tl=e=>!lr(e)&&e!==Vn;function Ys(){const{caseless:e,skipUndefined:t}=tl(this)&&this||{},n={},r=(o,s)=>{const i=e&&el(n,s)||s;xo(n[i])&&xo(o)?n[i]=Ys(n[i],o):xo(o)?n[i]=Ys({},o):ar(o)?n[i]=o.slice():(!t||!lr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&_r(arguments[o],r);return n}const cm=(e,t,n,{allOwnKeys:r}={})=>(_r(t,(o,s)=>{n&&$t(o)?e[s]=Xa(o,n):e[s]=o},{allOwnKeys:r}),e),um=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),dm=(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)},fm=(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&&Gs(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},hm=(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},pm=e=>{if(!e)return null;if(ar(e))return e;let t=e.length;if(!Qa(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},mm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Gs(Uint8Array)),gm=(e,t)=>{const r=(e&&e[po]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},xm=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},ym=on("HTMLFormElement"),vm=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),nl=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),wm=on("RegExp"),rl=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};_r(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},bm=e=>{rl(e,(t,n)=>{if($t(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if($t(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+"'")})}})},Sm=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return ar(e)?r(e):r(String(e).split(t)),n},Cm=()=>{},Tm=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function km(e){return!!(e&&$t(e.append)&&e[Ja]==="FormData"&&e[po])}const Em=e=>{const t=new Array(10),n=(r,o)=>{if(jr(r)){if(t.indexOf(r)>=0)return;if(Ar(r))return r;if(!("toJSON"in r)){t[o]=r;const s=ar(r)?[]:{};return _r(r,(i,a)=>{const l=n(i,o+1);!lr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},Im=on("AsyncFunction"),Nm=e=>e&&(jr(e)||$t(e))&&$t(e.then)&&$t(e.catch),ol=((e,t)=>e?setImmediate:t?((n,r)=>(Vn.addEventListener("message",({source:o,data:s})=>{o===Vn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Vn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",$t(Vn.postMessage)),Am=typeof queueMicrotask<"u"?queueMicrotask.bind(Vn):typeof process<"u"&&process.nextTick||ol,O={isArray:ar,isArrayBuffer:Za,isBuffer:Ar,isFormData:nm,isArrayBufferView:qp,isString:Gp,isNumber:Qa,isBoolean:Yp,isObject:jr,isPlainObject:xo,isEmptyObject:Xp,isReadableStream:om,isRequest:sm,isResponse:im,isHeaders:am,isUndefined:lr,isDate:Jp,isFile:Zp,isBlob:Qp,isRegExp:wm,isFunction:$t,isStream:tm,isURLSearchParams:rm,isTypedArray:mm,isFileList:em,forEach:_r,merge:Ys,extend:cm,trim:lm,stripBOM:um,inherits:dm,toFlatObject:fm,kindOf:mo,kindOfTest:on,endsWith:hm,toArray:pm,forEachEntry:gm,matchAll:xm,isHTMLForm:ym,hasOwnProperty:nl,hasOwnProp:nl,reduceDescriptors:rl,freezeMethods:bm,toObjectSet:Sm,toCamelCase:vm,noop:Cm,toFiniteNumber:Tm,findKey:el,global:Vn,isContextDefined:tl,isSpecCompliantForm:km,toJSONObject:Em,isAsyncFn:Im,isThenable:Nm,setImmediate:ol,asap:Am,isIterable:e=>e!=null&&$t(e[po])};function Oe(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}O.inherits(Oe,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:O.toJSONObject(this.config),code:this.code,status:this.status}}});const sl=Oe.prototype,il={};["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=>{il[e]={value:e}}),Object.defineProperties(Oe,il),Object.defineProperty(sl,"isAxiosError",{value:!0}),Oe.from=(e,t,n,r,o,s)=>{const i=Object.create(sl);O.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Oe.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 jm=null;function Xs(e){return O.isPlainObject(e)||O.isArray(e)}function al(e){return O.endsWith(e,"[]")?e.slice(0,-2):e}function ll(e,t,n){return e?e.concat(t).map(function(o,s){return o=al(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function _m(e){return O.isArray(e)&&!e.some(Xs)}const Rm=O.toFlatObject(O,{},null,function(t){return/^is[A-Z]/.test(t)});function yo(e,t,n){if(!O.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=O.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(x,y){return!O.isUndefined(y[x])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&O.isSpecCompliantForm(t);if(!O.isFunction(o))throw new TypeError("visitor must be a function");function c(m){if(m===null)return"";if(O.isDate(m))return m.toISOString();if(O.isBoolean(m))return m.toString();if(!l&&O.isBlob(m))throw new Oe("Blob is not supported. Use a Buffer instead.");return O.isArrayBuffer(m)||O.isTypedArray(m)?l&&typeof Blob=="function"?new Blob([m]):Buffer.from(m):m}function d(m,x,y){let g=m;if(m&&!y&&typeof m=="object"){if(O.endsWith(x,"{}"))x=r?x:x.slice(0,-2),m=JSON.stringify(m);else if(O.isArray(m)&&_m(m)||(O.isFileList(m)||O.endsWith(x,"[]"))&&(g=O.toArray(m)))return x=al(x),g.forEach(function(S,k){!(O.isUndefined(S)||S===null)&&t.append(i===!0?ll([x],k,s):i===null?x:x+"[]",c(S))}),!1}return Xs(m)?!0:(t.append(ll(y,x,s),c(m)),!1)}const f=[],h=Object.assign(Rm,{defaultVisitor:d,convertValue:c,isVisitable:Xs});function p(m,x){if(!O.isUndefined(m)){if(f.indexOf(m)!==-1)throw Error("Circular reference detected in "+x.join("."));f.push(m),O.forEach(m,function(g,w){(!(O.isUndefined(g)||g===null)&&o.call(t,g,O.isString(w)?w.trim():w,x,h))===!0&&p(g,x?x.concat(w):[w])}),f.pop()}}if(!O.isObject(e))throw new TypeError("data must be an object");return p(e),t}function cl(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Js(e,t){this._pairs=[],e&&yo(e,this,t)}const ul=Js.prototype;ul.append=function(t,n){this._pairs.push([t,n])},ul.toString=function(t){const n=t?function(r){return t.call(this,r,cl)}:cl;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function Pm(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function dl(e,t,n){if(!t)return e;const r=n&&n.encode||Pm;O.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=O.isURLSearchParams(t)?t.toString():new Js(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class fl{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){O.forEach(this.handlers,function(r){r!==null&&t(r)})}}const hl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Om={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Js,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Zs=typeof window<"u"&&typeof document<"u",Qs=typeof navigator=="object"&&navigator||void 0,Mm=Zs&&(!Qs||["ReactNative","NativeScript","NS"].indexOf(Qs.product)<0),Dm=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Lm=Zs&&window.location.href||"http://localhost",Rt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Zs,hasStandardBrowserEnv:Mm,hasStandardBrowserWebWorkerEnv:Dm,navigator:Qs,origin:Lm},Symbol.toStringTag,{value:"Module"})),...Om};function $m(e,t){return yo(e,new Rt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Rt.isNode&&O.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Fm(e){return O.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function zm(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 pl(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&O.isArray(o)?o.length:i,l?(O.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!O.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&O.isArray(o[i])&&(o[i]=zm(o[i])),!a)}if(O.isFormData(e)&&O.isFunction(e.entries)){const n={};return O.forEachEntry(e,(r,o)=>{t(Fm(r),o,n,0)}),n}return null}function Bm(e,t,n){if(O.isString(e))try{return(t||JSON.parse)(e),O.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Rr={transitional:hl,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=O.isObject(t);if(s&&O.isHTMLForm(t)&&(t=new FormData(t)),O.isFormData(t))return o?JSON.stringify(pl(t)):t;if(O.isArrayBuffer(t)||O.isBuffer(t)||O.isStream(t)||O.isFile(t)||O.isBlob(t)||O.isReadableStream(t))return t;if(O.isArrayBufferView(t))return t.buffer;if(O.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return $m(t,this.formSerializer).toString();if((a=O.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return yo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Bm(t)):t}],transformResponse:[function(t){const n=this.transitional||Rr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(O.isResponse(t)||O.isReadableStream(t))return t;if(t&&O.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Oe.from(a,Oe.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:Rt.classes.FormData,Blob:Rt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};O.forEach(["delete","get","head","post","put","patch"],e=>{Rr.headers[e]={}});const Hm=O.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Um=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]&&Hm[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},ml=Symbol("internals");function Pr(e){return e&&String(e).trim().toLowerCase()}function vo(e){return e===!1||e==null?e:O.isArray(e)?e.map(vo):String(e)}function Wm(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 Vm=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function ei(e,t,n,r,o){if(O.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!O.isString(t)){if(O.isString(r))return t.indexOf(r)!==-1;if(O.isRegExp(r))return r.test(t)}}function Km(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function qm(e,t){const n=O.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,i){return this[r].call(this,t,o,s,i)},configurable:!0})})}let Ft=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=Pr(l);if(!d)throw new Error("header name must be a non-empty string");const f=O.findKey(o,d);(!f||o[f]===void 0||c===!0||c===void 0&&o[f]!==!1)&&(o[f||l]=vo(a))}const i=(a,l)=>O.forEach(a,(c,d)=>s(c,d,l));if(O.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(O.isString(t)&&(t=t.trim())&&!Vm(t))i(Um(t),n);else if(O.isObject(t)&&O.isIterable(t)){let a={},l,c;for(const d of t){if(!O.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?O.isArray(l)?[...l,d[1]]:[l,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=Pr(t),t){const r=O.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Wm(o);if(O.isFunction(n))return n.call(this,o,r);if(O.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Pr(t),t){const r=O.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||ei(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Pr(i),i){const a=O.findKey(r,i);a&&(!n||ei(r,r[a],a,n))&&(delete r[a],o=!0)}}return O.isArray(t)?t.forEach(s):s(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const s=n[r];(!t||ei(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return O.forEach(this,(o,s)=>{const i=O.findKey(r,s);if(i){n[i]=vo(o),delete n[s];return}const a=t?Km(s):String(s).trim();a!==s&&delete n[s],n[a]=vo(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return O.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&O.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
|
|
32
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[ml]=this[ml]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Pr(i);r[a]||(qm(o,i),r[a]=!0)}return O.isArray(t)?t.forEach(s):s(t),this}};Ft.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),O.reduceDescriptors(Ft.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),O.freezeMethods(Ft);function ti(e,t){const n=this||Rr,r=t||n,o=Ft.from(r.headers);let s=r.data;return O.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function gl(e){return!!(e&&e.__CANCEL__)}function cr(e,t,n){Oe.call(this,e??"canceled",Oe.ERR_CANCELED,t,n),this.name="CanceledError"}O.inherits(cr,Oe,{__CANCEL__:!0});function xl(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Oe("Request failed with status code "+n.status,[Oe.ERR_BAD_REQUEST,Oe.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Gm(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Ym(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;let f=s,h=0;for(;f!==o;)h+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const p=d&&c-d;return p?Math.round(h*1e3/p):void 0}}function Xm(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),f=d-n;f>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const wo=(e,t,n=3)=>{let r=0;const o=Ym(50,250);return Xm(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},yl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},vl=e=>(...t)=>O.asap(()=>e(...t)),Jm=Rt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Rt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Rt.origin),Rt.navigator&&/(msie|trident)/i.test(Rt.navigator.userAgent)):()=>!0,Zm=Rt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];O.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),O.isString(r)&&i.push("path="+r),O.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Qm(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function eg(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function wl(e,t,n){let r=!Qm(t);return e&&(r||n==!1)?eg(e,t):t}const bl=e=>e instanceof Ft?{...e}:e;function Kn(e,t){t=t||{};const n={};function r(c,d,f,h){return O.isPlainObject(c)&&O.isPlainObject(d)?O.merge.call({caseless:h},c,d):O.isPlainObject(d)?O.merge({},d):O.isArray(d)?d.slice():d}function o(c,d,f,h){if(O.isUndefined(d)){if(!O.isUndefined(c))return r(void 0,c,f,h)}else return r(c,d,f,h)}function s(c,d){if(!O.isUndefined(d))return r(void 0,d)}function i(c,d){if(O.isUndefined(d)){if(!O.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,f){if(f in t)return r(c,d);if(f in e)return r(void 0,c)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,d,f)=>o(bl(c),bl(d),f,!0)};return O.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,h=f(e[d],t[d],d);O.isUndefined(h)&&f!==a||(n[d]=h)}),n}const Sl=e=>{const t=Kn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ft.from(i),t.url=dl(wl(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),O.isFormData(n)){if(Rt.hasStandardBrowserEnv||Rt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(O.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{c.includes(d.toLowerCase())&&i.set(d,f)})}}if(Rt.hasStandardBrowserEnv&&(r&&O.isFunction(r)&&(r=r(t)),r||r!==!1&&Jm(t.url))){const l=o&&s&&Zm.read(s);l&&i.set(o,l)}return t},tg=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Sl(e);let s=o.data;const i=Ft.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,f,h,p,m;function x(){p&&p(),m&&m(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let y=new XMLHttpRequest;y.open(o.method.toUpperCase(),o.url,!0),y.timeout=o.timeout;function g(){if(!y)return;const S=Ft.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),T={data:!a||a==="text"||a==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:S,config:e,request:y};xl(function(E){n(E),x()},function(E){r(E),x()},T),y=null}"onloadend"in y?y.onloadend=g:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(g)},y.onabort=function(){y&&(r(new Oe("Request aborted",Oe.ECONNABORTED,e,y)),y=null)},y.onerror=function(k){const T=k&&k.message?k.message:"Network Error",C=new Oe(T,Oe.ERR_NETWORK,e,y);C.event=k||null,r(C),y=null},y.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const T=o.transitional||hl;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Oe(k,T.clarifyTimeoutError?Oe.ETIMEDOUT:Oe.ECONNABORTED,e,y)),y=null},s===void 0&&i.setContentType(null),"setRequestHeader"in y&&O.forEach(i.toJSON(),function(k,T){y.setRequestHeader(T,k)}),O.isUndefined(o.withCredentials)||(y.withCredentials=!!o.withCredentials),a&&a!=="json"&&(y.responseType=o.responseType),c&&([h,m]=wo(c,!0),y.addEventListener("progress",h)),l&&y.upload&&([f,p]=wo(l),y.upload.addEventListener("progress",f),y.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=S=>{y&&(r(!S||S.type?new cr(null,e,y):S),y.abort(),y=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const w=Gm(o.url);if(w&&Rt.protocols.indexOf(w)===-1){r(new Oe("Unsupported protocol "+w+":",Oe.ERR_BAD_REQUEST,e));return}y.send(s||null)})},ng=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,a();const d=c instanceof Error?c:this.reason;r.abort(d instanceof Oe?d:new cr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Oe(`timeout ${t} of ms exceeded`,Oe.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>O.asap(a),l}},rg=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},og=async function*(e,t){for await(const n of sg(e))yield*rg(n,t)},sg=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()}},Cl=(e,t,n,r)=>{const o=og(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await o.next();if(c){a(),l.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Tl=64*1024,{isFunction:bo}=O,ig=(({Request:e,Response:t})=>({Request:e,Response:t}))(O.global),{ReadableStream:kl,TextEncoder:El}=O.global,Il=(e,...t)=>{try{return!!e(...t)}catch{return!1}},ag=e=>{e=O.merge.call({skipUndefined:!0},ig,e);const{fetch:t,Request:n,Response:r}=e,o=t?bo(t):typeof fetch=="function",s=bo(n),i=bo(r);if(!o)return!1;const a=o&&bo(kl),l=o&&(typeof El=="function"?(m=>x=>m.encode(x))(new El):async m=>new Uint8Array(await new n(m).arrayBuffer())),c=s&&a&&Il(()=>{let m=!1;const x=new n(Rt.origin,{body:new kl,method:"POST",get duplex(){return m=!0,"half"}}).headers.has("Content-Type");return m&&!x}),d=i&&a&&Il(()=>O.isReadableStream(new r("").body)),f={stream:d&&(m=>m.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(m=>{!f[m]&&(f[m]=(x,y)=>{let g=x&&x[m];if(g)return g.call(x);throw new Oe(`Response type '${m}' is not supported`,Oe.ERR_NOT_SUPPORT,y)})});const h=async m=>{if(m==null)return 0;if(O.isBlob(m))return m.size;if(O.isSpecCompliantForm(m))return(await new n(Rt.origin,{method:"POST",body:m}).arrayBuffer()).byteLength;if(O.isArrayBufferView(m)||O.isArrayBuffer(m))return m.byteLength;if(O.isURLSearchParams(m)&&(m=m+""),O.isString(m))return(await l(m)).byteLength},p=async(m,x)=>{const y=O.toFiniteNumber(m.getContentLength());return y??h(x)};return async m=>{let{url:x,method:y,data:g,signal:w,cancelToken:S,timeout:k,onDownloadProgress:T,onUploadProgress:C,responseType:E,headers:N,withCredentials:j="same-origin",fetchOptions:D}=Sl(m),P=t||fetch;E=E?(E+"").toLowerCase():"text";let M=ng([w,S&&S.toAbortSignal()],k),F=null;const A=M&&M.unsubscribe&&(()=>{M.unsubscribe()});let z;try{if(C&&c&&y!=="get"&&y!=="head"&&(z=await p(N,g))!==0){let G=new n(x,{method:"POST",body:g,duplex:"half"}),pe;if(O.isFormData(g)&&(pe=G.headers.get("content-type"))&&N.setContentType(pe),G.body){const[Ce,Ae]=yl(z,wo(vl(C)));g=Cl(G.body,Tl,Ce,Ae)}}O.isString(j)||(j=j?"include":"omit");const _=s&&"credentials"in n.prototype,X={...D,signal:M,method:y.toUpperCase(),headers:N.normalize().toJSON(),body:g,duplex:"half",credentials:_?j:void 0};F=s&&new n(x,X);let $=await(s?P(F,D):P(x,X));const R=d&&(E==="stream"||E==="response");if(d&&(T||R&&A)){const G={};["status","statusText","headers"].forEach(q=>{G[q]=$[q]});const pe=O.toFiniteNumber($.headers.get("content-length")),[Ce,Ae]=T&&yl(pe,wo(vl(T),!0))||[];$=new r(Cl($.body,Tl,Ce,()=>{Ae&&Ae(),A&&A()}),G)}E=E||"text";let J=await f[O.findKey(f,E)||"text"]($,m);return!R&&A&&A(),await new Promise((G,pe)=>{xl(G,pe,{data:J,headers:Ft.from($.headers),status:$.status,statusText:$.statusText,config:m,request:F})})}catch(_){throw A&&A(),_&&_.name==="TypeError"&&/Load failed|fetch/i.test(_.message)?Object.assign(new Oe("Network Error",Oe.ERR_NETWORK,m,F),{cause:_.cause||_}):Oe.from(_,_&&_.code,m,F)}}},lg=new Map,Nl=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,c,d=lg;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:ag(t)),d=c;return c};Nl();const ni={http:jm,xhr:tg,fetch:{get:Nl}};O.forEach(ni,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Al=e=>`- ${e}`,cg=e=>O.isFunction(e)||e===null||e===!1,jl={getAdapter:(e,t)=>{e=O.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){r=e[i];let a;if(o=r,!cg(r)&&(o=ni[(a=String(r)).toLowerCase()],o===void 0))throw new Oe(`Unknown adapter '${a}'`);if(o&&(O.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
33
33
|
`+i.map(Al).join(`
|
|
34
|
-
`):" "+Al(i[0]):"as no adapter specified";throw new
|
|
35
|
-
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Vn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&So.assertOptions(r,{silentJSONParsing:hn.transitional(hn.boolean),forcedJSONParsing:hn.transitional(hn.boolean),clarifyTimeoutError:hn.transitional(hn.boolean)},!1),o!=null&&(O.isFunction(o)?n.paramsSerializer={serialize:o}:So.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),So.assertOptions(n,{baseUrl:hn.spelling("baseURL"),withXsrfToken:hn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&O.merge(s.common,s[n.method]);s&&O.forEach(["delete","get","head","post","put","patch","common"],m=>{delete s[m]}),n.headers=Ft.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 c=[];this.interceptors.response.forEach(function(x){c.push(x.fulfilled,x.rejected)});let d,f=0,h;if(!l){const m=[_l.bind(this),void 0];for(m.unshift(...a),m.push(...c),h=m.length,d=Promise.resolve(n);f<h;)d=d.then(m[f++],m[f++]);return d}h=a.length;let p=n;for(;f<h;){const m=a[f++],x=a[f++];try{p=m(p)}catch(y){x.call(this,y);break}}try{d=_l.call(this,p)}catch(m){return Promise.reject(m)}for(f=0,h=c.length;f<h;)d=d.then(c[f++],c[f++]);return d}getUri(t){t=Vn(this.defaults,t);const n=wl(t.baseURL,t.url,t.allowAbsoluteUrls);return dl(n,t.params,t.paramsSerializer)}};O.forEach(["delete","get","head","options"],function(t){Kn.prototype[t]=function(n,r){return this.request(Vn(r||{},{method:t,url:n,data:(r||{}).data}))}}),O.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Vn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Kn.prototype[t]=n(),Kn.prototype[t+"Form"]=n(!0)});let dg=class Bp{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 lr(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 Bp(function(o){t=o}),cancel:t}}};function fg(e){return function(n){return e.apply(null,n)}}function hg(e){return O.isObject(e)&&e.isAxiosError===!0}const oi={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(oi).forEach(([e,t])=>{oi[t]=e});function Ol(e){const t=new Kn(e),n=Xa(Kn.prototype.request,t);return O.extend(n,Kn.prototype,t,{allOwnKeys:!0}),O.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Ol(Vn(e,o))},n}const bt=Ol(_r);bt.Axios=Kn,bt.CanceledError=lr,bt.CancelToken=dg,bt.isCancel=gl,bt.VERSION=Rl,bt.toFormData=xo,bt.AxiosError=Pe,bt.Cancel=bt.CanceledError,bt.all=function(t){return Promise.all(t)},bt.spread=fg,bt.isAxiosError=hg,bt.mergeConfig=Vn,bt.AxiosHeaders=Ft,bt.formToJSON=e=>pl(O.isHTMLForm(e)?new FormData(e):e),bt.getAdapter=jl.getAdapter,bt.HttpStatusCode=oi,bt.default=bt;const{Axios:ZC,AxiosError:QC,CanceledError:eT,isCancel:tT,CancelToken:nT,VERSION:rT,all:oT,Cancel:sT,isAxiosError:iT,spread:aT,toFormData:lT,AxiosHeaders:cT,HttpStatusCode:uT,formToJSON:dT,getAdapter:fT,mergeConfig:hT}=bt,Ml=typeof window<"u"?window.__API_BASE_URL__:void 0,Dl=Ml?Tn(Ml):void 0;function Tn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Co=null;const si=new Set;function Ll(){return Co}function To(e){Co=e,si.forEach(t=>t(e))}function $l(e){return si.add(e),()=>si.delete(e)}const pg=3e4,mg=9e4,qt=bt.create({...Dl?{baseURL:Dl}:{},timeout:pg,withCredentials:!0});qt.interceptors.request.use(e=>(Co&&(e.headers.Authorization=`Bearer ${Co}`),e)),qt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),To(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function Gt(e,t){return qt.defaults.baseURL?(await qt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function ii(e,t,n){return qt.defaults.baseURL?(await qt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Fl(e,t,n){return qt.defaults.baseURL?(await qt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function zl(e,t){return qt.defaults.baseURL?(await qt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Yt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Bl{get baseUrl(){const t=qt.defaults.baseURL;return t?Tn(String(t)):""}updateConfig(t){t.baseUrl&&(qt.defaults.baseURL=Tn(String(t.baseUrl))),t.authToken!==void 0&&To(t.authToken)}getAuthToken(){return Ll()}setAuthToken(t){To(t)}onTokenChange(t){return $l(t)}async listThreads(){const t=await Gt("/threads"),n=Yt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await ii("/threads",t?{title:t}:void 0);return Yt(r)}async updateThread(t,n){const r=await Fl(`/threads/${t}`,{title:n});return Yt(r)}async deleteThread(t){const n=await zl(`/threads/${t}`);return Yt(n)}async threadInfo(t){const n=await Gt(`/threads/${t}/info`);return Yt(n)}async listAgents(){const t=await Gt("/agents"),n=Yt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Gt(`/agents/${t}`);return Yt(n)}async getAgentSchema(t){const n=await Gt(`/agents/${t}/schema`);return Yt(n)}async getState(t){const n=await Gt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Yt(n)}async getStateHistory(t){const n=await Gt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:mg});return Yt(n)}async cancelRun(t){const n=await ii("/runs/cancel",{threadId:t});return Yt(n)}async listCheckpointSummaries(t){const n=await Gt(`/threads/${t}/state/checkpoints`,{params:{thread_id:t}}),r=Yt(n);return(r==null?void 0:r.items)??[]}}const jn=new Bl,Hl=b.createContext(null);function gg({children:e,apiConfig:t}){const n=jn;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return u.jsx(Hl.Provider,{value:r,children:e})}function ai(){const e=b.useContext(Hl);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function xg(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let l=0;l<a;l++)i+=String.fromCharCode(s[l]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function yg(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const c=await xg(l);a.push({filename:l.name,data:c,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const vg={human:"user",user:"user",ai:"assistant",assistant:"assistant",tool:"tool",function:"tool",system:"system"};function li(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 wg(e,t){return`${e??""}::${t??""}`}function cr(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(!li(r))return{threadId:n,latest:null,checkpoints:[],timeline:[],interrupt:null,snapshots:{}};const{orderedSnapshots:o,snapshotMap:s}=Sg(t),i=Ul(r,0),a=Cg(o);return{threadId:n,latest:i,checkpoints:o,timeline:a,interrupt:(i==null?void 0:i.interrupt)??null,snapshots:s}}function Ul(e,t){if(!li(e))return null;const n=e.values??{messages:[]},r=Array.isArray(n==null?void 0:n.messages)?n.messages:[],{messages:o,...s}=n,i=Object.keys(s).length?s:null,a=e.tasks,l=Array.isArray(a)?a.filter(j=>!!j&&typeof j=="object").map(j=>({...j})):a===null?null:void 0,c=r.map((j,D)=>Rg(j,D)).filter(j=>!!j),d=zt(e.config),f=zt(d==null?void 0:d.configurable),h=ft(f,["checkpoint_id","checkpointId"]),p=ft(f,["checkpoint_ns","checkpointNs"]),m=zt(e==null?void 0:e.parentConfig),x=zt(m==null?void 0:m.configurable),y=ft(x,["checkpoint_id","checkpointId"])??null,g=ft(x,["checkpoint_ns","checkpointNs"])??null,w=e==null?void 0:e.createdAt,S=typeof w=="string"&&w.trim()?w:new Date(Date.now()-t).toISOString();c[c.length-1];const k=c.slice().reverse().find(j=>j.role==="user")??null,T=zt(e==null?void 0:e.metadata),C=ft(T,["branch_label","branchLabel"]),E=ft(x,["checkpoint_id","checkpointId"]),N=Array.isArray(e.next)?[...e.next]:(e==null?void 0:e.next)===null?null:void 0;return{messages:c,checkpointId:h??null,checkpointNs:p??null,nextCursor:y,nextCursorNs:g,interrupt:bg(a,c,t),createdAt:S,parentId:E??null,branchLabel:C??null,lastUserMessageId:(k==null?void 0:k.id)??null,hasMessages:c.length>0,messagesLen:c.length,metadata:T??null,config:d??null,parentConfig:m??null,next:N??null,tasks:l??null,values:i??null}}function bg(e,t,n){const r=jg(e,n);return r||Ag(t,n)}function Sg(e){const t=new Map;e.forEach((o,s)=>{if(!li(o))return;const i=Ul(o,s);if(!(i!=null&&i.checkpointId))return;const a=wg(i.checkpointId,i.checkpointNs??null),l=t.get(a);if(!l){t.set(a,i);return}t.set(a,Eg(l,i))});const n=Array.from(t.values());n.sort((o,s)=>Vl(s.createdAt??"")-Vl(o.createdAt??""));const r={};for(const[o,s]of t.entries())r[o]=s;return{orderedSnapshots:n,snapshotMap:r}}function Cg(e){var n,r;const t=[];for(const o of e){const s=o.checkpointId??null;if(!s)continue;const i=o.metadata??{},a=ft(i,["label"])??ft(i,["branch_label","branchLabel"])??ft(i,["description"])??"User input",l=kg(i,["step"]),c=ft(i,["source"]),d=o.createdAt??null,f=((r=(n=o.messages)==null?void 0:n[o.messages.length-1])==null?void 0:r.id)??null,h=o.lastUserMessageId??f,p=Tg(o.next);t.push({id:s,label:a,messageId:h,step:l,source:c??null,createdAt:d,next:p??void 0})}return t}function Tg(e){if(!Array.isArray(e)||e.length===0)return null;const t=e.map(n=>{if(typeof n=="string")return n.trim();if(n&&typeof n=="object"&&"type"in n){const r=n;if(typeof r.type=="string")return r.type}return null}).filter(n=>!!(n&&n.length));return t.length?t.join(", "):null}function kg(e,t){if(!e)return null;for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}return null}function Eg(e,t){return{...e,metadata:ko(e.metadata,t.metadata)??null,config:ko(e.config,t.config)??null,parentConfig:ko(e.parentConfig,t.parentConfig)??null,next:Ig(e.next,t.next)??null,tasks:Ng(e.tasks,t.tasks)??null,values:ko(e.values,t.values)??null}}function ko(e,t){return t&&typeof t=="object"?{...e&&typeof e=="object"?e:{},...t}:t===null?e&&typeof e=="object"?{...e}:e??null:e&&typeof e=="object"?{...e}:e??void 0}function Ig(e,t){return Array.isArray(t)?t.slice():t===null?Array.isArray(e)?e.slice():e??null:Array.isArray(e)?e.slice():e??void 0}function Ng(e,t){return Array.isArray(t)?t.map(n=>({...n})):t===null?Array.isArray(e)?e.map(n=>({...n})):e??null:Array.isArray(e)?e.map(n=>({...n})):e??void 0}function Ag(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 jg(e,t){if(!Array.isArray(e)||!e.length)return null;for(let n=e.length-1;n>=0;n--){const r=_g(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=Pr(r.interrupts[s],`${o}-interrupt-${s}`);if(i)return i}if(r.state!==void 0&&r.state!==null){const s=Pr(r.state,`${o}-state`);if(s)return s}}return null}function _g(e,t){if(!e)return null;if(Array.isArray(e)){const[a,l,c,,d,,f,...h]=e,p=typeof a=="string"&&a.trim()?a:t,m=typeof l=="string"&&l.trim()?l:Array.isArray(c)&&typeof c[0]=="string"?String(c[0]):"task",x=Array.isArray(d)?d:void 0,y=h.length?h[h.length-1]:void 0;return{id:p,name:m,interrupts:x,state:y!==void 0?y:f}}const n=zt(e);if(!n)return null;const r=ft(n,["id","thread_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 Pr(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=Wl(e,t);if(o)return o;if(Array.isArray(e)){for(let s=e.length-1;s>=0;s--){const i=Pr(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=Pr(s[a],t,n+1,r);if(l)return l}for(const[a,l]of Object.entries(s)){if(i.includes(a)||a==="messages"||a==="results")continue;const c=Pr(l,t,n+1,r);if(c)return c}}return null}function Wl(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=Wl(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 Vl(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function Rg(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=vg[s];if(!i)return null;const a=o.id??o.message_id??o.run_id??null,l=typeof a=="string"&&a.trim()?a:`history-${i}-${t}`,c=zt(o.additional_kwargs)??zt(o.additionalKwargs),d=zt(o.response_metadata)??zt(o.responseMetadata),f=ft(c,["createdAt","created_at"])??ft(o,["created_at","createdAt"]),h=ft(c,["checkpointId","checkpoint_id"]),p=ft(c,["checkpointNs","checkpoint_ns"]),m=Pg(o.content),x={id:l,role:i,content:m};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 y=Lg(c,["createdAt","created_at","checkpointId","checkpoint_id","checkpointNs","checkpoint_ns","tool_calls"]),g=d?{...d}:void 0;y&&Object.keys(y).length&&(x.additionalKwargs=y),g&&Object.keys(g).length&&(x.responseMetadata=g);const w=Og((c==null?void 0:c.tool_calls)??o.tool_calls);if(w.length&&(x.content=[...x.content,...w]),i==="tool"){const S=Mg(o,x.content);S&&(x.content=S)}return x}function Pg(e){if(!e)return[];if(Array.isArray(e))return e.map(t=>Kl(t)).filter(t=>!!t);if(typeof e=="string")return e.trim()?[{type:"text",text:e.trim()}]:[];if(typeof e=="object"){const t=Kl(e);return t?[t]:[]}return[]}function Kl(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 ql(t)??null;if(n==="tool_end"){const o="output"in t?t.output:t.content;return o?{type:"text",text:typeof o=="string"?o:JSON.stringify(o)}:null}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 ql(e,t){var s;const n=ft(e,["id","call_id"])??t,r=ft(e,["name"])??ft(zt(e.function),["name"]);if(!n||!r)return null;const o=Dg(e.args??e.arguments??((s=zt(e.function))==null?void 0:s.arguments));return{type:"tool_call",id:n,name:r,args:o}}function Og(e){return Array.isArray(e)?e.map((t,n)=>ql(t,`tool_call_${n}`)).filter(t=>!!t):[]}function Mg(e,t){const n=e.content??e.output;if(!n)return t;const o={type:"text",text:typeof n=="string"?n:JSON.stringify(n)};return[...t,o]}function Dg(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 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 Lg(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}const ur=120;function $g(e){if(!Array.isArray(e))return"";const t=e.filter(r=>!!(r&&r.type==="text")).map(r=>(r.text??"").trim()).filter(Boolean);if(!t.length)return"";const n=t.join(" ").replace(/\s+/g," ").trim();return n?n.length>ur?`${n.slice(0,ur-3)}…`:n:""}function Fg(e){var r,o;const t=[(r=e.additionalKwargs)==null?void 0:r.summary,(o=e.responseMetadata)==null?void 0:o.summary];for(const s of t)if(typeof s=="string"&&s.trim()){const i=s.trim();return i.length>ur?`${i.slice(0,ur-3)}…`:i}const n=(e.name||e.id||"").toString().trim();return n?n.length>ur?`${n.slice(0,ur-3)}…`:n:""}function Gl(e){const t=new Map;for(const n of e){if(!n.id||n.role!=="user")continue;const o=$g(n.content)||Fg(n);o&&t.set(n.id,o)}return t}function Yl(e={}){const t=b.useMemo(()=>Tn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=b.useState(e.token??null),s=b.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=b.useState(!1),[c,d]=b.useState(null),[f,h]=b.useState(""),[p,m]=b.useState(null),[x,y]=b.useState(0),[g,w]=b.useState(!1),S=b.useRef(null),k=b.useRef(!0),T=b.useRef(0),C=b.useRef(null),E=b.useRef(null),N=b.useRef(null),j=b.useRef(null),D=b.useCallback(A=>{o(A)},[]),P=b.useCallback(()=>{h(""),m(null),d(null),E.current=null,N.current=null,j.current=null},[]),M=b.useCallback(()=>{var A;console.debug("[use-chat] stop() invoked - aborting stream"),(A=S.current)==null||A.abort(),S.current=null,C.current=null,l(!1),w(!1),T.current=0,y(0)},[]),F=b.useCallback((A,z,_)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h(""),m(null),E.current=null,N.current=null,j.current=null;const J=new AbortController;S.current=J;let $=null,R=null,Z=!1;return C.current={threadId:A.threadId??null,headers:{}},(async()=>{var me,Te,je,G,ne,X,L,U,K,se,re,Oe,qe,Ge,oe,le,De,Be;const Y=Ye=>{var Xe;try{const Le=JSON.parse(JSON.stringify(Ye));return(Xe=Le==null?void 0:Le.payload)!=null&&Xe.files_info&&Array.isArray(Le.payload.files_info)&&(Le.payload.files_info=Le.payload.files_info.map(Fe=>({...Fe,data:Fe!=null&&Fe.data?`<base64 ${String(Fe.data).length} chars>`:Fe==null?void 0:Fe.data}))),Le}catch{return Ye}};try{let Ye={};try{if(r)Ye={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ne=window.__AUTH_TOKEN__,Mt=((me=window.localStorage)==null?void 0:me.getItem("authToken"))||null;let Ht=null;try{const B=(Te=window.localStorage)==null?void 0:Te.getItem("chat-settings");B&&(Ht=((je=JSON.parse(B))==null?void 0:je.apiKey)||null)}catch{}const W=Ne||Mt||Ht||null;W&&(Ye={Authorization:`Bearer ${W}`})}}catch{}console.debug("[use-chat] POST",t+n,Y(A));let Xe={};if(typeof window<"u")try{const Ke=(G=window.localStorage)==null?void 0:G.getItem("authSessionId");Ke&&(Xe={"X-Session-Id":Ke})}catch{}const Le={...Ye,...Xe,...s.current},Fe={"Content-Type":"application/json",Accept:"text/event-stream",...Le},Je=await fetch(t+n,{method:"POST",headers:Fe,body:JSON.stringify(A),signal:J.signal,credentials:i});if(C.current&&(C.current.headers=Le),!Je.ok||!Je.body){const Ke=await Je.text().catch(()=>"");console.debug("[use-chat] non-OK response",Je.status,Ke==null?void 0:Ke.slice(0,500));const Ne=`stream ${Je.status}${Ke?": "+Ke:""}`;throw(ne=_==null?void 0:_.onConnectionError)==null||ne.call(_,Ne),Z=!0,$="error",R=Ne,new Error(Ne)}w(!0);const nt=Je.body.getReader(),kt=new TextDecoder;let pt="",mt=[];T.current=0,y(0);let gt=0,Ze=null;const He=()=>{if(mt.length){const Ke=mt.join("");mt=[],k.current&&h(Ne=>Ne+Ke)}Ze=null},Nt=()=>{typeof window<"u"&&Ze==null&&(Ze=requestAnimationFrame(He))};let At=Date.now();const nn=setInterval(()=>{var Ke;if(Date.now()-At>18e5){const Ne="Stream idle timeout";d(Ne),$="error",R=Ne,J.abort(),(Ke=_==null?void 0:_.onError)==null||Ke.call(_,Ne)}},5e3),rn=1024*1024;try{const Ke=Je.headers.get("X-Thread-Id")||Je.headers.get("x-thread-id"),Ne=Je.headers.get("X-Thread-Created")||Je.headers.get("x-thread-created"),Mt=Ke??null,Ht=String(Ne??"").toLowerCase()==="true";for(C.current&&!C.current.threadId&&(C.current={...C.current,threadId:Mt}),(X=_==null?void 0:_.onOpen)==null||X.call(_,{threadId:Mt,created:Ht});;){const{value:W,done:B}=await nt.read();if(B)break;pt+=kt.decode(W,{stream:!0}),pt.length>rn&&(pt="",console.warn("Stream buffer reset: exceeded 1MB"));let H;for(;(H=pt.indexOf(`
|
|
34
|
+
`):" "+Al(i[0]):"as no adapter specified";throw new Oe("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:ni};function ri(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new cr(null,e)}function _l(e){return ri(e),e.headers=Ft.from(e.headers),e.data=ti.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),jl.getAdapter(e.adapter||Rr.adapter,e)(e).then(function(r){return ri(e),r.data=ti.call(e,e.transformResponse,r),r.headers=Ft.from(r.headers),r},function(r){return gl(r)||(ri(e),r&&r.response&&(r.response.data=ti.call(e,e.transformResponse,r.response),r.response.headers=Ft.from(r.response.headers))),Promise.reject(r)})}const Rl="1.12.2",So={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{So[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Pl={};So.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Rl+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Oe(o(i," has been removed"+(n?" in "+n:"")),Oe.ERR_DEPRECATED);return n&&!Pl[i]&&(Pl[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}},So.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function ug(e,t,n){if(typeof e!="object")throw new Oe("options must be an object",Oe.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 Oe("option "+s+" must be "+l,Oe.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Oe("Unknown option "+s,Oe.ERR_BAD_OPTION)}}const Co={assertOptions:ug,validators:So},pn=Co.validators;let qn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new fl,response:new fl}}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=Kn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Co.assertOptions(r,{silentJSONParsing:pn.transitional(pn.boolean),forcedJSONParsing:pn.transitional(pn.boolean),clarifyTimeoutError:pn.transitional(pn.boolean)},!1),o!=null&&(O.isFunction(o)?n.paramsSerializer={serialize:o}:Co.assertOptions(o,{encode:pn.function,serialize:pn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Co.assertOptions(n,{baseUrl:pn.spelling("baseURL"),withXsrfToken:pn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&O.merge(s.common,s[n.method]);s&&O.forEach(["delete","get","head","post","put","patch","common"],m=>{delete s[m]}),n.headers=Ft.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 c=[];this.interceptors.response.forEach(function(x){c.push(x.fulfilled,x.rejected)});let d,f=0,h;if(!l){const m=[_l.bind(this),void 0];for(m.unshift(...a),m.push(...c),h=m.length,d=Promise.resolve(n);f<h;)d=d.then(m[f++],m[f++]);return d}h=a.length;let p=n;for(;f<h;){const m=a[f++],x=a[f++];try{p=m(p)}catch(y){x.call(this,y);break}}try{d=_l.call(this,p)}catch(m){return Promise.reject(m)}for(f=0,h=c.length;f<h;)d=d.then(c[f++],c[f++]);return d}getUri(t){t=Kn(this.defaults,t);const n=wl(t.baseURL,t.url,t.allowAbsoluteUrls);return dl(n,t.params,t.paramsSerializer)}};O.forEach(["delete","get","head","options"],function(t){qn.prototype[t]=function(n,r){return this.request(Kn(r||{},{method:t,url:n,data:(r||{}).data}))}}),O.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Kn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}qn.prototype[t]=n(),qn.prototype[t+"Form"]=n(!0)});let dg=class Bp{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 cr(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 Bp(function(o){t=o}),cancel:t}}};function fg(e){return function(n){return e.apply(null,n)}}function hg(e){return O.isObject(e)&&e.isAxiosError===!0}const oi={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(oi).forEach(([e,t])=>{oi[t]=e});function Ol(e){const t=new qn(e),n=Xa(qn.prototype.request,t);return O.extend(n,qn.prototype,t,{allOwnKeys:!0}),O.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Ol(Kn(e,o))},n}const bt=Ol(Rr);bt.Axios=qn,bt.CanceledError=cr,bt.CancelToken=dg,bt.isCancel=gl,bt.VERSION=Rl,bt.toFormData=yo,bt.AxiosError=Oe,bt.Cancel=bt.CanceledError,bt.all=function(t){return Promise.all(t)},bt.spread=fg,bt.isAxiosError=hg,bt.mergeConfig=Kn,bt.AxiosHeaders=Ft,bt.formToJSON=e=>pl(O.isHTMLForm(e)?new FormData(e):e),bt.getAdapter=jl.getAdapter,bt.HttpStatusCode=oi,bt.default=bt;const{Axios:ZC,AxiosError:QC,CanceledError:eT,isCancel:tT,CancelToken:nT,VERSION:rT,all:oT,Cancel:sT,isAxiosError:iT,spread:aT,toFormData:lT,AxiosHeaders:cT,HttpStatusCode:uT,formToJSON:dT,getAdapter:fT,mergeConfig:hT}=bt,Ml=typeof window<"u"?window.__API_BASE_URL__:void 0,Dl=Ml?Tn(Ml):void 0;function Tn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let To=null;const si=new Set;function Ll(){return To}function ko(e){To=e,si.forEach(t=>t(e))}function $l(e){return si.add(e),()=>si.delete(e)}const pg=3e4,mg=9e4,qt=bt.create({...Dl?{baseURL:Dl}:{},timeout:pg,withCredentials:!0});qt.interceptors.request.use(e=>(To&&(e.headers.Authorization=`Bearer ${To}`),e)),qt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),ko(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function Gt(e,t){return qt.defaults.baseURL?(await qt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function ii(e,t,n){return qt.defaults.baseURL?(await qt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Fl(e,t,n){return qt.defaults.baseURL?(await qt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function zl(e,t){return qt.defaults.baseURL?(await qt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Yt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Bl{get baseUrl(){const t=qt.defaults.baseURL;return t?Tn(String(t)):""}updateConfig(t){t.baseUrl&&(qt.defaults.baseURL=Tn(String(t.baseUrl))),t.authToken!==void 0&&ko(t.authToken)}getAuthToken(){return Ll()}setAuthToken(t){ko(t)}onTokenChange(t){return $l(t)}async listThreads(){const t=await Gt("/threads"),n=Yt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await ii("/threads",t?{title:t}:void 0);return Yt(r)}async updateThread(t,n){const r=await Fl(`/threads/${t}`,{title:n});return Yt(r)}async deleteThread(t){const n=await zl(`/threads/${t}`);return Yt(n)}async threadInfo(t){const n=await Gt(`/threads/${t}/info`);return Yt(n)}async listAgents(){const t=await Gt("/agents"),n=Yt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Gt(`/agents/${t}`);return Yt(n)}async getAgentSchema(t){const n=await Gt(`/agents/${t}/schema`);return Yt(n)}async getState(t){const n=await Gt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Yt(n)}async getStateHistory(t){const n=await Gt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:mg});return Yt(n)}async cancelRun(t){const n=await ii("/runs/cancel",{threadId:t});return Yt(n)}async listCheckpointSummaries(t){const n=await Gt(`/threads/${t}/state/checkpoints`,{params:{thread_id:t}}),r=Yt(n);return(r==null?void 0:r.items)??[]}}const _n=new Bl,Hl=b.createContext(null);function gg({children:e,apiConfig:t}){const n=_n;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return u.jsx(Hl.Provider,{value:r,children:e})}function ai(){const e=b.useContext(Hl);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function xg(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let l=0;l<a;l++)i+=String.fromCharCode(s[l]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function yg(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const c=await xg(l);a.push({filename:l.name,data:c,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const vg={human:"user",user:"user",ai:"assistant",assistant:"assistant",tool:"tool",function:"tool",system:"system"};function li(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 wg(e,t){return`${e??""}::${t??""}`}function ur(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(!li(r))return{threadId:n,latest:null,checkpoints:[],timeline:[],interrupt:null,snapshots:{}};const{orderedSnapshots:o,snapshotMap:s}=Sg(t),i=Ul(r,0),a=Cg(o);return{threadId:n,latest:i,checkpoints:o,timeline:a,interrupt:(i==null?void 0:i.interrupt)??null,snapshots:s}}function Ul(e,t){if(!li(e))return null;const n=e.values??{messages:[]},r=Array.isArray(n==null?void 0:n.messages)?n.messages:[],{messages:o,...s}=n,i=Object.keys(s).length?s:null,a=e.tasks,l=Array.isArray(a)?a.filter(j=>!!j&&typeof j=="object").map(j=>({...j})):a===null?null:void 0,c=r.map((j,D)=>Rg(j,D)).filter(j=>!!j),d=zt(e.config),f=zt(d==null?void 0:d.configurable),h=ht(f,["checkpoint_id","checkpointId"]),p=ht(f,["checkpoint_ns","checkpointNs"]),m=zt(e==null?void 0:e.parentConfig),x=zt(m==null?void 0:m.configurable),y=ht(x,["checkpoint_id","checkpointId"])??null,g=ht(x,["checkpoint_ns","checkpointNs"])??null,w=e==null?void 0:e.createdAt,S=typeof w=="string"&&w.trim()?w:new Date(Date.now()-t).toISOString();c[c.length-1];const k=c.slice().reverse().find(j=>j.role==="user")??null,T=zt(e==null?void 0:e.metadata),C=ht(T,["branch_label","branchLabel"]),E=ht(x,["checkpoint_id","checkpointId"]),N=Array.isArray(e.next)?[...e.next]:(e==null?void 0:e.next)===null?null:void 0;return{messages:c,checkpointId:h??null,checkpointNs:p??null,nextCursor:y,nextCursorNs:g,interrupt:bg(a,c,t),createdAt:S,parentId:E??null,branchLabel:C??null,lastUserMessageId:(k==null?void 0:k.id)??null,hasMessages:c.length>0,messagesLen:c.length,metadata:T??null,config:d??null,parentConfig:m??null,next:N??null,tasks:l??null,values:i??null}}function bg(e,t,n){const r=jg(e,n);return r||Ag(t,n)}function Sg(e){const t=new Map;e.forEach((o,s)=>{if(!li(o))return;const i=Ul(o,s);if(!(i!=null&&i.checkpointId))return;const a=wg(i.checkpointId,i.checkpointNs??null),l=t.get(a);if(!l){t.set(a,i);return}t.set(a,Eg(l,i))});const n=Array.from(t.values());n.sort((o,s)=>Vl(s.createdAt??"")-Vl(o.createdAt??""));const r={};for(const[o,s]of t.entries())r[o]=s;return{orderedSnapshots:n,snapshotMap:r}}function Cg(e){var n,r;const t=[];for(const o of e){const s=o.checkpointId??null;if(!s)continue;const i=o.metadata??{},a=ht(i,["label"])??ht(i,["branch_label","branchLabel"])??ht(i,["description"])??"User input",l=kg(i,["step"]),c=ht(i,["source"]),d=o.createdAt??null,f=((r=(n=o.messages)==null?void 0:n[o.messages.length-1])==null?void 0:r.id)??null,h=o.lastUserMessageId??f,p=Tg(o.next);t.push({id:s,label:a,messageId:h,step:l,source:c??null,createdAt:d,next:p??void 0})}return t}function Tg(e){if(!Array.isArray(e)||e.length===0)return null;const t=e.map(n=>{if(typeof n=="string")return n.trim();if(n&&typeof n=="object"&&"type"in n){const r=n;if(typeof r.type=="string")return r.type}return null}).filter(n=>!!(n&&n.length));return t.length?t.join(", "):null}function kg(e,t){if(!e)return null;for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}return null}function Eg(e,t){return{...e,metadata:Eo(e.metadata,t.metadata)??null,config:Eo(e.config,t.config)??null,parentConfig:Eo(e.parentConfig,t.parentConfig)??null,next:Ig(e.next,t.next)??null,tasks:Ng(e.tasks,t.tasks)??null,values:Eo(e.values,t.values)??null}}function Eo(e,t){return t&&typeof t=="object"?{...e&&typeof e=="object"?e:{},...t}:t===null?e&&typeof e=="object"?{...e}:e??null:e&&typeof e=="object"?{...e}:e??void 0}function Ig(e,t){return Array.isArray(t)?t.slice():t===null?Array.isArray(e)?e.slice():e??null:Array.isArray(e)?e.slice():e??void 0}function Ng(e,t){return Array.isArray(t)?t.map(n=>({...n})):t===null?Array.isArray(e)?e.map(n=>({...n})):e??null:Array.isArray(e)?e.map(n=>({...n})):e??void 0}function Ag(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 jg(e,t){if(!Array.isArray(e)||!e.length)return null;for(let n=e.length-1;n>=0;n--){const r=_g(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=Or(r.interrupts[s],`${o}-interrupt-${s}`);if(i)return i}if(r.state!==void 0&&r.state!==null){const s=Or(r.state,`${o}-state`);if(s)return s}}return null}function _g(e,t){if(!e)return null;if(Array.isArray(e)){const[a,l,c,,d,,f,...h]=e,p=typeof a=="string"&&a.trim()?a:t,m=typeof l=="string"&&l.trim()?l:Array.isArray(c)&&typeof c[0]=="string"?String(c[0]):"task",x=Array.isArray(d)?d:void 0,y=h.length?h[h.length-1]:void 0;return{id:p,name:m,interrupts:x,state:y!==void 0?y:f}}const n=zt(e);if(!n)return null;const r=ht(n,["id","thread_id","taskId"])??t,o=ht(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 Or(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=Wl(e,t);if(o)return o;if(Array.isArray(e)){for(let s=e.length-1;s>=0;s--){const i=Or(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=Or(s[a],t,n+1,r);if(l)return l}for(const[a,l]of Object.entries(s)){if(i.includes(a)||a==="messages"||a==="results")continue;const c=Or(l,t,n+1,r);if(c)return c}}return null}function Wl(e,t){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){const n=e,r=ht(n,["type","event","kind"]),o=ht(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=Wl(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 Vl(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function Rg(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=vg[s];if(!i)return null;const a=o.id??o.message_id??o.run_id??null,l=typeof a=="string"&&a.trim()?a:`history-${i}-${t}`,c=zt(o.additional_kwargs)??zt(o.additionalKwargs),d=zt(o.response_metadata)??zt(o.responseMetadata),f=ht(c,["createdAt","created_at"])??ht(o,["created_at","createdAt"]),h=ht(c,["checkpointId","checkpoint_id"]),p=ht(c,["checkpointNs","checkpoint_ns"]),m=Pg(o.content),x={id:l,role:i,content:m};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 y=Lg(c,["createdAt","created_at","checkpointId","checkpoint_id","checkpointNs","checkpoint_ns","tool_calls"]),g=d?{...d}:void 0;y&&Object.keys(y).length&&(x.additionalKwargs=y),g&&Object.keys(g).length&&(x.responseMetadata=g);const w=Og((c==null?void 0:c.tool_calls)??o.tool_calls);if(w.length&&(x.content=[...x.content,...w]),i==="tool"){const S=Mg(o,x.content);S&&(x.content=S)}return x}function Pg(e){if(!e)return[];if(Array.isArray(e))return e.map(t=>Kl(t)).filter(t=>!!t);if(typeof e=="string")return e.trim()?[{type:"text",text:e.trim()}]:[];if(typeof e=="object"){const t=Kl(e);return t?[t]:[]}return[]}function Kl(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=ht(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=ht(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 ql(t)??null;if(n==="tool_end"){const o="output"in t?t.output:t.content;return o?{type:"text",text:typeof o=="string"?o:JSON.stringify(o)}:null}if(n==="interrupt")return{type:"interrupt",value:t.value,...t};if(n==="tool"){const o=ht(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 ql(e,t){var s;const n=ht(e,["id","call_id"])??t,r=ht(e,["name"])??ht(zt(e.function),["name"]);if(!n||!r)return null;const o=Dg(e.args??e.arguments??((s=zt(e.function))==null?void 0:s.arguments));return{type:"tool_call",id:n,name:r,args:o}}function Og(e){return Array.isArray(e)?e.map((t,n)=>ql(t,`tool_call_${n}`)).filter(t=>!!t):[]}function Mg(e,t){const n=e.content??e.output;if(!n)return t;const o={type:"text",text:typeof n=="string"?n:JSON.stringify(n)};return[...t,o]}function Dg(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 zt(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function ht(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r}}function Lg(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}const dr=120;function $g(e){if(!Array.isArray(e))return"";const t=e.filter(r=>!!(r&&r.type==="text")).map(r=>(r.text??"").trim()).filter(Boolean);if(!t.length)return"";const n=t.join(" ").replace(/\s+/g," ").trim();return n?n.length>dr?`${n.slice(0,dr-3)}…`:n:""}function Fg(e){var r,o;const t=[(r=e.additionalKwargs)==null?void 0:r.summary,(o=e.responseMetadata)==null?void 0:o.summary];for(const s of t)if(typeof s=="string"&&s.trim()){const i=s.trim();return i.length>dr?`${i.slice(0,dr-3)}…`:i}const n=(e.name||e.id||"").toString().trim();return n?n.length>dr?`${n.slice(0,dr-3)}…`:n:""}function Gl(e){const t=new Map;for(const n of e){if(!n.id||n.role!=="user")continue;const o=$g(n.content)||Fg(n);o&&t.set(n.id,o)}return t}function Yl(e={}){const t=b.useMemo(()=>Tn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=b.useState(e.token??null),s=b.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=b.useState(!1),[c,d]=b.useState(null),[f,h]=b.useState(""),[p,m]=b.useState(null),[x,y]=b.useState(0),[g,w]=b.useState(!1),S=b.useRef(null),k=b.useRef(!0),T=b.useRef(0),C=b.useRef(null),E=b.useRef(null),N=b.useRef(null),j=b.useRef(null),D=b.useCallback(A=>{o(A)},[]),P=b.useCallback(()=>{h(""),m(null),d(null),E.current=null,N.current=null,j.current=null},[]),M=b.useCallback(()=>{var A;console.debug("[use-chat] stop() invoked - aborting stream"),(A=S.current)==null||A.abort(),S.current=null,C.current=null,l(!1),w(!1),T.current=0,y(0)},[]),F=b.useCallback((A,z,_)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h(""),m(null),E.current=null,N.current=null,j.current=null;const X=new AbortController;S.current=X;let $=null,R=null,J=!1;return C.current={threadId:A.threadId??null,headers:{}},(async()=>{var pe,Ce,Ae,q,ne,Y,L,H,V,ie,re,ze,We,Ze,oe,me,Te,Be;const G=Je=>{var tt;try{const $e=JSON.parse(JSON.stringify(Je));return(tt=$e==null?void 0:$e.payload)!=null&&tt.files_info&&Array.isArray($e.payload.files_info)&&($e.payload.files_info=$e.payload.files_info.map(He=>({...He,data:He!=null&&He.data?`<base64 ${String(He.data).length} chars>`:He==null?void 0:He.data}))),$e}catch{return Je}};try{let Je={};try{if(r)Je={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const je=window.__AUTH_TOKEN__,Et=((pe=window.localStorage)==null?void 0:pe.getItem("authToken"))||null;let Ht=null;try{const ve=(Ce=window.localStorage)==null?void 0:Ce.getItem("chat-settings");ve&&(Ht=((Ae=JSON.parse(ve))==null?void 0:Ae.apiKey)||null)}catch{}const U=je||Et||Ht||null;U&&(Je={Authorization:`Bearer ${U}`})}}catch{}console.debug("[use-chat] POST",t+n,G(A));let tt={};if(typeof window<"u")try{const qe=(q=window.localStorage)==null?void 0:q.getItem("authSessionId");qe&&(tt={"X-Session-Id":qe})}catch{}const $e={...Je,...tt,...s.current},He={"Content-Type":"application/json",Accept:"text/event-stream",...$e},Ve=await fetch(t+n,{method:"POST",headers:He,body:JSON.stringify(A),signal:X.signal,credentials:i});if(C.current&&(C.current.headers=$e),!Ve.ok||!Ve.body){const qe=await Ve.text().catch(()=>"");console.debug("[use-chat] non-OK response",Ve.status,qe==null?void 0:qe.slice(0,500));const je=`stream ${Ve.status}${qe?": "+qe:""}`;throw(ne=_==null?void 0:_.onConnectionError)==null||ne.call(_,je),J=!0,$="error",R=je,new Error(je)}w(!0);const nt=Ve.body.getReader(),kt=new TextDecoder;let ft="",mt=[];T.current=0,y(0);let gt=0,st=null;const De=()=>{if(mt.length){const qe=mt.join("");mt=[],k.current&&h(je=>je+qe)}st=null},At=()=>{typeof window<"u"&&st==null&&(st=requestAnimationFrame(De))};let jt=Date.now();const nn=setInterval(()=>{var qe;if(Date.now()-jt>18e5){const je="Stream idle timeout";d(je),$="error",R=je,X.abort(),(qe=_==null?void 0:_.onError)==null||qe.call(_,je)}},5e3),fn=1024*1024;try{const qe=Ve.headers.get("X-Thread-Id")||Ve.headers.get("x-thread-id"),je=Ve.headers.get("X-Thread-Created")||Ve.headers.get("x-thread-created"),Et=qe??null,Ht=String(je??"").toLowerCase()==="true";for(C.current&&!C.current.threadId&&(C.current={...C.current,threadId:Et}),(Y=_==null?void 0:_.onOpen)==null||Y.call(_,{threadId:Et,created:Ht});;){const{value:U,done:ve}=await nt.read();if(ve)break;ft+=kt.decode(U,{stream:!0}),ft.length>fn&&(ft="",console.warn("Stream buffer reset: exceeded 1MB"));let B;for(;(B=ft.indexOf(`
|
|
36
36
|
|
|
37
|
-
`))>=0;){const
|
|
38
|
-
`)}function Hg(e){return e.type!=="token"}const Ug={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,messagesStreamMeta:{},pendingInterrupt:null};function Wg(e,t){var n;switch(t.type){case"reset":return{messages:ci(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,pendingInterrupt:null};case"seed":{const r=ci(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),o}case"prepend":{const r=ci(t.payload.messages);if(!r.length)return e;const o=new Set(e.messages.map(i=>i.id)),s=r.filter(i=>!o.has(i.id));return s.length?{...e,messages:[...s,...e.messages]}: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 Jl(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Jl(o,s),e):e}case"interrupt_response":return{...e,messages:Zl(e.messages),pendingInterrupt:null};default:return e}}function Xl(e=[]){const[t,n]=b.useReducer(Wg,{...Ug,messages:e}),r=b.useRef([]),o=b.useRef(null),s=b.useRef(null),i=b.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=b.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=b.useCallback(d=>{r.current.push(d),a()},[a]);b.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=b.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:d=>n({type:"user_message",payload:{message:d}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function Jl(e,t){var n,r,o,s,i;if(t.type==="message_start"&&t.role==="assistant"){const a=t.id,l=Gg(t.model);if(e.messages.some(f=>f.id===a)){const f=e.messagesStreamMeta??{},h={...f,[a]:f[a]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:a,messagesStreamMeta:h}}const d={id:a,role:"assistant",name:l||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:a,messages:[...e.messages,d]}}if(t.type==="message_delta"){const a=e.assemblingId??Ql(e.messages);if(!a)return e;const l=e.messages,c=l.findIndex(k=>k.id===a&&k.role==="assistant");if(c===-1)return e;const d=l[c],f=e.messagesStreamMeta??{},h=f[a]??{lastSeq:null,lastText:nc(d.content)},p=t.seq??null;if(p!==null&&typeof p=="number"&&typeof h.lastSeq=="number"&&p<=h.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:p,lastSeq:h.lastSeq}),e;const{newParts:m,newMeta:x,changed:y}=Vg(d.content,t.delta,h,p);if(!y)return e;const g={...d,content:m},w=Eo(l,c,g),S={...f,[a]:x};return{...e,messages:w,messagesStreamMeta:S}}if(t.type==="message_end"){const a=e.assemblingId??Ql(e.messages);if(!a)return{...e,assemblingId:null};const l=e.messages,c=l.findIndex(d=>d.id===a&&d.role==="assistant");if(c>=0){const d=l[c];if(!((n=d.content)==null?void 0:n.some(h=>{var p;return(h==null?void 0:h.type)==="text"&&((p=h.text)==null?void 0:p.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:d.id,contentTypes:(r=d.content)==null?void 0:r.map(p=>p==null?void 0:p.type),contentPreview:(o=d.content)==null?void 0:o.map(p=>(p==null?void 0:p.type)==="text"?String(p.text).slice(0,100):p==null?void 0:p.type)});const h=[...l.slice(0,c),...l.slice(c+1)];return{...e,assemblingId:null,messages:h}}}return e}if(t.type==="tool_start"){const a=ec(t),l=a[0]??(typeof t.id=="string"?t.id:null)??(typeof t.call_id=="string"?t.call_id:null),c=t.name??t.tool??"tool";!l&&a.length===0&&a.push(`${c}-${Date.now()}`);const d=a.length?a:l?[l]:[],f=tc(e,d,c),h=f>=0?e.messages[f]:null,p=l??d[0]??`${c}-${Date.now()}`,m=(h==null?void 0:h.id)??`tool-${p}`,x=d[0]??p,y={type:"tool_call",id:x,name:c,args:t.args};if(h){const S=di(h,d,c,t.args),k={...h,name:h.name??c,additionalKwargs:S},T=f,C=T>=0?Eo(e.messages,T,k):e.messages,E=Io(k,d),N=fi(e.toolIndex,m,E);return{...e,messages:C,toolIndex:N}}const g={id:m,role:"tool",name:c,createdAt:new Date().toISOString(),content:[y],additionalKwargs:di(void 0,d.length?d:[x],c,t.args)},w=Io(g,d.length?d:[x]);return{...e,messages:[...e.messages,g],toolIndex:fi(e.toolIndex,m,w)}}if(t.type==="tool_end"){const a=ec(t);if(!a.length&&!(typeof t.id=="string"&&t.id))return e;const l=t.name??null,c=tc(e,a,l),d=c>=0?e.messages[c]:null,f=l??(d==null?void 0:d.name)??((s=d==null?void 0:d.additionalKwargs)==null?void 0:s.toolName)??"tool",h=a[0]??((i=d==null?void 0:d.id)==null?void 0:i.replace(/^tool-/,""))??`${f}-${Date.now()}`,p=(d==null?void 0:d.id)??`tool-${h}`,m=Io(d,a);let x=t.output;if(typeof t.output=="string")try{const C=t.output.trim();(C.startsWith("{")||C.startsWith("["))&&(x=JSON.parse(C))}catch{x=t.output}const y={type:"text",text:typeof x=="string"?x:JSON.stringify(x)},g=(d==null?void 0:d.createdAt)??new Date().toISOString(),w=di(d??void 0,m.length?m:a,f),S={id:p,role:"tool",name:f??(d==null?void 0:d.name)??"tool",content:[y],createdAt:g,additionalKwargs:w},k=c>=0?Eo(e.messages,c,S):[...e.messages,S],T=Io(S,a.length?a:m);return{...e,messages:k,toolIndex:fi(e.toolIndex,p,T)}}if(t.type==="checkpoint"){const a=t.checkpointNs??e.lastCheckpointNs??null,l=qg(e.messages,t.checkpointId,a);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:a,messages:l}}if(t.type==="branch"){const a=t.checkpointId??e.lastCheckpointId,l=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:a??null,lastCheckpointNs:l??null}}if(t.type==="error"){const a={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,a]}}if(t.type==="state_history"){const a=cr(t),l=a.interrupt,c=a.latest,d=l===null?Zl(e.messages):e.messages;return{...e,messages:d,pendingInterrupt:l,lastCheckpointId:(c==null?void 0:c.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(c==null?void 0:c.checkpointNs)??e.lastCheckpointNs}}return t.type==="thread_info",e}function ci(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 Eo(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Zl(e){let t=!1;const n=e.map(r=>{const o=(r.content??[]).filter(s=>s.type!=="interrupt");return o.length!==r.content.length?(t=!0,{...r,content:o}):r});return t?n:e}function Ql(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function ec(e){const t=new Set,n=r=>{typeof r=="string"&&r.trim()&&t.add(r.trim())};return n(e.id),n(e==null?void 0:e.call_id),n(e==null?void 0:e.callId),Array.from(t)}function ui(e){if(!e)return[];const t=new Set,n=o=>{typeof o=="string"&&o.trim()&&t.add(o.trim())},r=e.additionalKwargs;if(r){n(r.toolCallId);const o=r.toolCallIds;if(Array.isArray(o))for(const s of o)n(s)}for(const o of e.content??[])(o==null?void 0:o.type)==="tool_call"&&n(o.id);return Array.from(t)}function di(e,t,n,r){const o=new Set,s=l=>{typeof l=="string"&&l.trim()&&o.add(l.trim())};if(e){const l=ui(e);for(const c of l)s(c)}for(const l of t)s(l);const i=Array.from(o),a={...(e==null?void 0:e.additionalKwargs)??{}};if(i.length){a.toolCallIds=i;const l=typeof a.toolCallId=="string"?a.toolCallId.trim():null;a.toolCallId=l&&o.has(l)?l:i[0]}return n&&(a.toolName=n),r!==void 0&&(a.toolArgs=r),a}function Io(e,t){const n=new Set;for(const o of t)typeof o=="string"&&o.trim()&&n.add(o.trim());const r=ui(e);for(const o of r)n.add(o);return Array.from(n)}function fi(e,t,n){if(!n.length)return e;let r=!1;const o={...e};for(const s of n)s&&o[s]!==t&&(o[s]=t,r=!0);return r?o:e}function tc(e,t,n){var o,s;const r=new Set(t.filter(i=>typeof i=="string"&&i.trim()));for(const i of r){const a=e.toolIndex[i];if(a){const l=e.messages.findIndex(c=>c.id===a);if(l!==-1)return l}}for(let i=e.messages.length-1;i>=0;i--){const a=e.messages[i];if(a.role!=="tool")continue;if(ui(a).some(c=>r.has(c)))return i}if(typeof n=="string"&&n.trim())for(let i=e.messages.length-1;i>=0;i--){const a=e.messages[i];if(a.role!=="tool"||a.name&&a.name!==n)continue;if(!((o=a.content)==null?void 0:o.some(c=>c.type!=="tool_call")))return i}for(let i=e.messages.length-1;i>=0;i--){const a=e.messages[i];if(a.role!=="tool")continue;if(!((s=a.content)==null?void 0:s.some(c=>c.type!=="tool_call")))return i}return-1}function nc(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function Vg(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??nc(e);let l="",c=e.slice();if(s){const f=Kg(a,s);if(f===""?l="":f===s?l=s:l=f,l){const h=c[c.length-1];if((h==null?void 0:h.type)==="text"){const p=h.text??"",m={...h,text:p+l};c=[...c.slice(0,c.length-1),m]}else c=[...c,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(c=[...c,...i]);const d=!!(l||i.length);return{newParts:c,newMeta:o,changed:d}}function rc(e){return e.replace(/\s+/g," ").trim()}function Kg(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 qg(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 Eo(e,r,s)}return e}function Gg(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const oc=200;function Yg({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onStateHistory:r,onUnhandledEvent:o,onSequenceGap:s,onStreamClosed:i,onConnectionError:a,onAuthError:l,onHeartbeat:c}){const d=b.useRef(null),f=b.useRef(null),h=b.useRef(new Map),p=b.useRef(null),m=b.useRef(null),x=b.useCallback(P=>{try{const M=globalThis.structuredClone;if(typeof M=="function")return M(P)}catch{}try{return JSON.parse(JSON.stringify(P))}catch{return P}},[]),y=b.useCallback((P,M)=>{if(!P)return;const F=h.current.get(P)??[],A=x(M),z=F.length>=oc?[...F.slice(F.length-oc+1),A]:[...F,A];h.current.set(P,z)},[x]),g=b.useCallback(P=>{P&&h.current.set(P,[])},[]),w=b.useCallback(P=>{const M=P??f.current;if(!M)return;const F=h.current.get(M);F!=null&&F.length&&F.forEach(A=>{try{n(A)}catch(z){console.error("[useChatStreamingService] Failed to replay buffered event",z)}})},[n]),S=b.useCallback(P=>{var A,z,_,J,$;const M=P.seq??null;if(M!==null){const R=d.current;if(R!==null){if(M<=R)return;M>R+1&&(s==null||s({from:R,to:M}))}d.current=M}if(P.type==="thread_info"){f.current=P.threadId,p.current&&(p.current.threadIdGuess=P.threadId),m.current=P,g(P.threadId),console.log("[useChatStreamingService] 🎯 Received thread_info event:",P);try{t(P)}catch(R){console.error("[useChatStreamingService] Error in onThreadInfo handler:",R)}return}if(P.type==="heartbeat"){try{c==null||c(P)}catch(R){console.error("[useChatStreamingService] Error in onHeartbeat handler:",R)}return}if(P.type==="error"){const R=P;if(R.error_type==="auth_error"||R.code==="TOKEN_EXPIRED"||((A=R.message)==null?void 0:A.includes("token"))||((z=R.message)==null?void 0:z.includes("401"))||((_=R.message)==null?void 0:_.includes("unauthorized"))||((J=R.message)==null?void 0:J.includes("Unauthorized"))){console.error("[useChatStreamingService] Auth error event detected:",R.message);try{l==null||l(R.message)}catch(Y){console.warn("[useChatStreamingService] onAuthError handler failed",Y)}}}const F=P.threadId??(P.type==="state_history"?P.threadId:void 0)??f.current??(($=p.current)==null?void 0:$.threadIdGuess)??null;if(P.type==="state_history"){f.current=F??f.current;try{r==null||r(P)}catch(R){console.error("[useChatStreamingService] onStateHistory handler failed",R)}}if(Hg(P)){P.type==="checkpoint"||P.type==="state_history"?g(F??null):y(F??null,P);try{n(P)}catch(R){console.error("[useChatStreamingService] Error in onMessageEvent handler:",R)}return}try{o==null||o(P)}catch(R){console.error("[useChatStreamingService] Error in onUnhandledEvent handler:",R)}},[y,g,n,s,t,r,o]),{stream:k,stop:T,isStreaming:C,error:E,setToken:N}=Yl({baseUrl:e,token:void 0}),j=b.useCallback((P,M)=>{d.current=null,m.current=null,f.current=P.threadId??null,p.current={request:P,callbacks:M,manualStop:!1,threadIdGuess:P.threadId??null},k(P,S,{onOpen:M==null?void 0:M.onOpen,onError:F=>{var A;(A=M==null?void 0:M.onError)==null||A.call(M,F)},onGap:(M==null?void 0:M.onGap)??s,onConnectionError:F=>{var A;a==null||a(F),(A=M==null?void 0:M.onConnectionError)==null||A.call(M,F)},onAuthError:F=>{var A;l==null||l(F),(A=M==null?void 0:M.onAuthError)==null||A.call(M,F)},onHeartbeat:F=>{var A;try{c==null||c(F)}catch(z){console.warn("[useChatStreamingService] onHeartbeat handler failed",z)}try{(A=M==null?void 0:M.onHeartbeat)==null||A.call(M,F)}catch(z){console.warn("[useChatStreamingService] downstream onHeartbeat handler failed",z)}},onClosed:F=>{var J,$,R,Z;const A=((J=p.current)==null?void 0:J.manualStop)??!1,z=f.current??(($=p.current)==null?void 0:$.threadIdGuess)??((R=F.lastStateHistory)==null?void 0:R.threadId)??null;(F.reason==="complete"||F.reason==="aborted"&&A)&&g(z);const _={...F,threadId:z,threadInfo:m.current,manualStop:A};try{i==null||i(_)}catch(Y){console.warn("[useChatStreamingService] onStreamClosed handler failed",Y)}try{(Z=M==null?void 0:M.onClosed)==null||Z.call(M,_)}catch(Y){console.warn("[useChatStreamingService] downstream onClosed handler failed",Y)}p.current&&(p.current=null)}})},[g,S,l,a,c,s,i,k]),D=b.useCallback(()=>{p.current&&(p.current.manualStop=!0),T()},[T]);return b.useMemo(()=>({startStream:j,stop:D,isStreaming:C,error:E,setAuthToken:N,replayBufferedEvents:w}),[j,D,C,E,N,w])}function Xg(){const e=b.useRef(new Map),t=b.useCallback((a,l)=>{const c=e.current.get(a),d=new Map;c&&c.forEach(f=>{d.set(`${f.checkpointId}::${f.checkpointNs}`,f)}),l.forEach(f=>{d.set(`${f.checkpointId}::${f.checkpointNs}`,f)}),e.current.set(a,Array.from(d.values()))},[]),n=b.useCallback((a,l)=>{const c=e.current.get(a);return c==null?void 0:c.find(d=>d.checkpointId===l)},[]),r=b.useCallback((a,l)=>{const c=e.current.get(a);return(c==null?void 0:c.some(d=>d.checkpointId===l))??!1},[]),o=b.useCallback(a=>e.current.get(a),[]),s=b.useCallback(a=>{e.current.delete(a)},[]),i=b.useCallback(()=>{e.current.clear()},[]);return{cache:e.current,setCacheForThread:t,getCachedMetadata:n,checkpointExists:r,getThreadMetadata:o,clearThreadCache:s,clearAllCache:i}}const sc=b.createContext(null),ic=b.createContext(null),ac=b.createContext(null);b.createContext(!1);function Jg({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,checkpointMetadataCache:l}){const{api:c,baseUrl:d}=ai(),f=b.useMemo(()=>Tn(d),[d]),[h,p]=b.useState([]),[m,x]=b.useState(t),[y,g]=b.useState(!1),[w,S]=b.useState(null),[k,T]=b.useState(!1),[C,E]=b.useState(null),{state:N,seed:j,prepend:D,pushUser:P,onEvent:M}=Xl(),[F,A]=b.useState(!1),[z,_]=b.useState(!1),[J,$]=b.useState(null),[R,Z]=b.useState([]),[Y,me]=b.useState([]),[Te,je]=b.useState(!1),G=b.useMemo(()=>R.flatMap(B=>B.messages??[]),[R]),ne=b.useMemo(()=>Gl(G),[G]),X=l??Xg(),{setCacheForThread:L}=X,U=b.useCallback((B,H,de)=>{const we=H.filter(Se=>Se.checkpointId).map(Se=>({checkpointId:Se.checkpointId,checkpointNs:Se.checkpointNs??void 0,createdAt:Se.createdAt??""}));console.log(`[ChatSessionProvider] Cached metadata for ${we.length} checkpoints from ${de}`),L(B,we)},[L]),K=b.useRef(m),se=b.useRef(null),re=b.useRef(null),Oe=b.useRef(null),qe=b.useRef(!1),Ge=b.useRef(null),oe=b.useRef(new Map);b.useEffect(()=>{K.current=m},[m]);const le=b.useCallback(async()=>{g(!0),S(null);try{const B=await c.listThreads();p(B??[])}catch(B){const H=String(B);S(H),s==null||s(H)}finally{g(!1)}},[c,s]),De=b.useCallback(B=>{if(!(B!=null&&B.threadId))return;const H={threadId:B.threadId,title:B.title||`Thread ${B.threadId.slice(0,8)}`,createdAt:B.createdAt||new Date().toISOString(),updatedAt:B.updatedAt||new Date().toISOString(),messageCount:B.messageCount??1};p(de=>de.some(Se=>Se.threadId===H.threadId)?(console.debug("[ChatSessionProvider] thread_info: thread already in list",H.threadId),de):(console.debug("[ChatSessionProvider] thread_info: adding thread to list",H.threadId),[H,...de]))},[]),Be=b.useCallback(B=>{const H=B.threadId??K.current;if(!H||K.current&&K.current!==H)return;const{checkpoints:de,timeline:we}=cr(B);if(!de.length)return;U(H,de,"stream state_history");const Se=de.find(st=>st.messages&&st.messages.length>0)??de.find(st=>!!st.checkpointId)??de[0];j((Se==null?void 0:Se.messages)??[],{checkpointId:(Se==null?void 0:Se.checkpointId)??null,checkpointNs:(Se==null?void 0:Se.checkpointNs)??null}),me(we),Z(de),A(!!(Se!=null&&Se.nextCursor)),$((Se==null?void 0:Se.nextCursor)??null);const ye=`${H}:${(Se==null?void 0:Se.checkpointId)??"latest"}`;Ge.current=ye},[U,j]),Ye=b.useCallback(B=>{console.log("[ChatSessionProvider] 🎯 Received thread_info:",B.threadId),De(B),K.current!==B.threadId&&(re.current=B.threadId,console.log("[ChatSessionProvider] thread_info: marking to skip auto-load for new thread"),x(B.threadId))},[De]),{startStream:Xe,stop:Le,isStreaming:Fe,error:Je,setAuthToken:nt}=Yg({baseUrl:f,onThreadInfo:Ye,onMessageEvent:M,onStateHistory:Be,onUnhandledEvent:B=>{console.warn("[ChatSessionProvider] Unhandled event:",B.type)},onAuthError:i}),kt=b.useCallback(async B=>{try{const H=await c.createThread(B);return x(H.threadId),await le(),H.threadId}catch(H){return s==null||s(String(H)),null}},[c,le,s]),pt=b.useCallback(async B=>{try{await c.deleteThread(B),K.current===B&&(x(null),j([],{})),await le()}catch(H){s==null||s(String(H))}},[c,le,j,s]),mt=b.useCallback(async(B,H)=>{try{await c.updateThread(B,H),await le()}catch(de){s==null||s(String(de))}},[c,le,s]),gt=b.useCallback(async(B,H)=>{if(!B)return;const de=`${B}:${H??"latest"}`,we=oe.current.get(de);if(we)return we;const Se=(async()=>{const ye=B;T(!0),E(null);try{const st=await c.getStateHistory({threadId:ye,checkpointId:H||void 0});if(K.current!==ye){console.log(`[ChatSessionProvider] Thread changed during load (was ${ye}, now ${K.current}), discarding stale data`);return}const{checkpoints:Ae,timeline:et}=cr(st);U(ye,Ae,`thread load (requested: ${H})`);const yt=Ae.find(Cn=>Cn.messages&&Cn.messages.length>0)??(H?Ae.find(Cn=>Cn.checkpointId===H):null)??Ae[0];j((yt==null?void 0:yt.messages)??[],{checkpointId:(yt==null?void 0:yt.checkpointId)??null,checkpointNs:(yt==null?void 0:yt.checkpointNs)??null}),me(et),Z(Ae),A(!!(yt!=null&&yt.nextCursor)),$((yt==null?void 0:yt.nextCursor)??null)}catch(st){if(K.current===ye){const Ae=String(st);E(Ae),s==null||s(Ae)}}finally{T(!1)}})();oe.current.set(de,Se);try{await Se}finally{oe.current.delete(de)}return K.current===B&&(Ge.current=de),Se},[c,j,s,U]),Ze=b.useCallback(async(B,H)=>{Oe.current=B;try{await gt(B,H)}finally{Oe.current===B&&(Oe.current=null)}},[gt]);b.useEffect(()=>{if(!o||!m||k||Fe)return;if(re.current===m){re.current=null;return}if(Oe.current===m){Oe.current=null,se.current=m;return}if(se.current===m)return;se.current=m;const B=!qe.current&&!!n&&m===t;let H;B&&n?(H=n,qe.current=!0,console.log("[ChatSessionProvider] Loading thread with checkpoint:",H,r?`(ns: ${r})`:"")):console.log("[ChatSessionProvider] Loading thread with latest checkpoint");const de=`${m}:${H??"latest"}`;Ge.current!==de&&Ze(m,H)},[o,m,n,r,t,k,Fe,Ze]);const He=b.useCallback(async(B,H)=>{const de=K.current;if(!de)return;const we=de;je(!0);try{const Se=await c.getStateHistory({threadId:we,checkpointId:B,checkpointNs:H??void 0});if(K.current!==we){console.log(`[ChatSessionProvider] Thread changed during checkpoint navigation (was ${we}, now ${K.current}), discarding stale data`);return}const{checkpoints:ye,timeline:st}=cr(Se);U(we,ye,"checkpoint navigation");const Ae=ye.find(et=>et.checkpointId===B&&(H?et.checkpointNs===H:!0));if(!Ae){console.warn("[ChatSessionProvider] Requested checkpoint not found:",{checkpointId:B,checkpointNs:H});return}me(st),Z(ye),j(Ae.messages??[],{checkpointId:Ae.checkpointId??null,checkpointNs:Ae.checkpointNs??null})}catch(Se){K.current===we&&(s==null||s(String(Se)))}finally{je(!1)}},[c,j,s,U]),Nt=b.useCallback((B,H)=>{j(N.messages,{checkpointId:B??null,checkpointNs:H??null})},[j,N.messages]),At=b.useCallback(async()=>{K.current&&await Ze(K.current)},[Ze]),nn=b.useCallback(async()=>{if(!K.current||!J)return;const B=K.current;_(!0);try{const H=await c.getStateHistory({threadId:B,checkpointId:J});if(K.current!==B){console.log(`[ChatSessionProvider] Thread changed during history load (was ${B}, now ${K.current}), discarding stale data`);return}const{checkpoints:de}=cr(H);if(de.length>0){const we=de[de.length-1];D((we==null?void 0:we.messages)??[]),A(!!(we!=null&&we.nextCursor)),$((we==null?void 0:we.nextCursor)??null)}}catch(H){K.current===B&&(s==null||s(String(H)))}finally{_(!1)}},[c,J,D,s]),rn=b.useCallback(async()=>{j([],{}),x(null),Le(),Z([]),me([]),A(!1),$(null),T(!1),je(!1),_(!1),E(null);try{await c.getAgent("default")}catch(B){console.warn("[ChatSessionProvider] Failed to refetch agent after clearing thread:",B)}},[j,Le,c]),Ke=b.useCallback(async(B,H,de)=>{const we=K.current;if(!we)throw new Error("No active thread to handle interrupt");const Se=H?de??!0:!1;try{const ye={threadId:we,checkpointId:N.lastCheckpointId??void 0,checkpointNs:N.lastCheckpointNs??void 0,command:{kind:"resume",value:Se}};Xe(ye)}catch(ye){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${B}:`,ye),ye}},[N.lastCheckpointId,N.lastCheckpointNs,Xe]);b.useEffect(()=>{le()},[le]),b.useEffect(()=>{a==null||a(m)},[m,a]);const Ne=b.useCallback(async(B,H)=>{let de=K.current;const we=(B==null?void 0:B.text)??"";if(!de&&!we)return;if(!de&&we){const et=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),yt=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);de=`${et}${yt}`,re.current=de,x(de)}const{contentParts:Se}=await yg(c,(B==null?void 0:B.attachments)??[]),ye=[...Se];we!=null&&we.trim()&&ye.push({type:"text",text:we});const st={id:`msg-${Date.now()}`,role:"user",content:ye,createdAt:new Date().toISOString()};P(st);const Ae={threadId:de,payload:{messages:[st]},checkpointId:(H==null?void 0:H.checkpointId)??N.lastCheckpointId??void 0,checkpointNs:(H==null?void 0:H.checkpointNs)??N.lastCheckpointNs??void 0};Xe(Ae)},[c,kt,P,N,Xe]),Mt=b.useMemo(()=>({threads:h,currentThreadId:m,setCurrentThreadId:x,isLoading:y,error:w,actions:{createThread:kt,deleteThread:pt,renameThread:mt,refreshThreads:le}}),[h,m,y,w,kt,pt,mt,le]),Ht=b.useMemo(()=>({threadId:m,messages:N.messages,interrupt:null,checkpoint:{id:N.lastCheckpointId??null,namespace:N.lastCheckpointNs??null},checkpoints:R,timelineCheckpoints:Y,metadata:null,isLoading:k,isHistoryLoading:z,isLoadingCheckpoint:Te,error:C,hasMore:F,loadOlder:nn,clearState:rn,navigateToCheckpoint:He,setCurrentCheckpointId:Nt,returnToLatest:At,loadThread:Ze,clearThread:rn,respondToInterrupt:Ke,messagePreviews:ne}),[m,N,R,Y,k,z,Te,C,F,nn,rn,He,Nt,At,Ze,Ke,ne]),W=b.useMemo(()=>({isStreaming:Fe,error:Je,connectionState:Fe?"connected":"idle",submit:Ne,send:Ne,stop:Le,setAuthToken:nt}),[Fe,Je,Ne,Le,nt]);return u.jsx(sc.Provider,{value:Mt,children:u.jsx(ic.Provider,{value:Ht,children:u.jsx(ac.Provider,{value:W,children:e})})})}function No(){const e=b.useContext(sc);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Ao(){const e=b.useContext(ic);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function lc(){const e=b.useContext(ac);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function jo({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onError:i,onAuthError:a,onThreadChange:l,checkpointMetadataCache:c}){return u.jsx(gg,{apiConfig:t,children:u.jsx(Jg,{initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:i,onAuthError:a,onThreadChange:l,checkpointMetadataCache:c,children:e})})}function te(...e){return Up.twMerge(Hp.clsx(e))}const Zg=uo.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"}}),rt=v.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Un.Slot:"button";return u.jsx(i,{className:te(Zg({variant:t,size:n,className:e})),ref:s,...o})});rt.displayName="Button";const cc=v.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:te("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}));cc.displayName="Textarea";function uc({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:f="",textareaClassName:h="",allowEmptySend:p=!1}){const m=i!==void 0,[x,y]=b.useState(e),g=(m?i:x)??"",[w,S]=b.useTransition(),k=b.useRef(null),T=b.useRef(0),C=b.useRef(null);b.useEffect(()=>{m||(y(e??""),C.current=null,k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`))},[e,t,m]);const E=b.useCallback(()=>{const z=k.current;z&&(z.style.height="auto",z.style.height=`${z.scrollHeight}px`)},[]);b.useEffect(()=>{E()},[E,g]);const N=b.useCallback((z,{fromUser:_})=>{m||y(z),_&&(a==null||a(z))},[m,a]),j=b.useCallback(async z=>{z&&z.preventDefault();const _=(g??"").trim();if(!_&&!p)return;const J=++T.current;C.current={id:J,shouldClear:!0},S(()=>{var $,R,Z;try{const Y=l(_);Y&&typeof Y.then=="function"?Y.then(()=>{var me,Te;((me=C.current)==null?void 0:me.id)===J&&C.current.shouldClear&&(m||(y(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((Te=C.current)==null?void 0:Te.id)===J&&(C.current=null)}).catch(()=>{var me;((me=C.current)==null?void 0:me.id)===J&&(C.current=null)}):((($=C.current)==null?void 0:$.id)===J&&C.current.shouldClear&&(m||(y(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((R=C.current)==null?void 0:R.id)===J&&(C.current=null))}catch{((Z=C.current)==null?void 0:Z.id)===J&&(C.current=null)}})},[g,l,p,m,a]),D=b.useCallback(z=>{const _=z.target.value;N(_,{fromUser:!0}),C.current&&(C.current.shouldClear=!1),k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`)},[N]),P=b.useCallback(z=>{z.key==="Enter"&&!z.shiftKey?(z.preventDefault(),j()):z.key==="Escape"&&t&&(z.preventDefault(),c==null||c())},[j,t,c]),A=`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))]":""} ${h}`;return u.jsx("form",{onSubmit:z=>void j(z),className:`w-full ${f}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsx("div",{className:"flex-1",children:u.jsx(cc,{ref:k,value:g,onChange:D,onKeyDown:P,placeholder:t?"Edit your message...":n,className:A,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),u.jsx("div",{children:r?u.jsx(rt,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(ie.Square,{size:16})}):u.jsx(rt,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!g.trim()&&!p||w,children:u.jsx(ie.Send,{size:16})})})]})})}const Qg=b.memo(uc);function pe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function dc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function hi(...e){return t=>{let n=!1;const r=e.map(o=>{const s=dc(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():dc(e[o],null)}}}}function We(...e){return v.useCallback(hi(...e),e)}function ex(e,t){const n=v.createContext(t),r=s=>{const{children:i,...a}=s,l=v.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=v.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 kn(e,t=[]){let n=[];function r(s,i){const a=v.createContext(i),l=n.length;n=[...n,i];const c=f=>{var g;const{scope:h,children:p,...m}=f,x=((g=h==null?void 0:h[e])==null?void 0:g[l])||a,y=v.useMemo(()=>m,Object.values(m));return u.jsx(x.Provider,{value:y,children:p})};c.displayName=s+"Provider";function d(f,h){var x;const p=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,m=v.useContext(p);if(m)return m;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>v.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return v.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,tx(o,...t)]}function tx(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const f=l(s)[`__scope${c}`];return{...a,...f}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Et=globalThis!=null&&globalThis.document?v.useLayoutEffect:()=>{},nx=v[" useInsertionEffect ".trim().toString()]||Et;function dr({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=rx({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=v.useRef(e!==void 0);v.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=v.useCallback(d=>{var f;if(a){const h=ox(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[l,c]}function rx({defaultProp:e,onChange:t}){const[n,r]=v.useState(e),o=v.useRef(n),s=v.useRef(t);return nx(()=>{s.current=t},[t]),v.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function ox(e){return typeof e=="function"}var sx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Re=sx.reduce((e,t)=>{const n=Un.createSlot(`Primitive.${t}`),r=v.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function fc(e,t){e&&fo.flushSync(()=>e.dispatchEvent(t))}function pi(e){const t=e+"CollectionProvider",[n,r]=kn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=x=>{const{scope:y,children:g}=x,w=b.useRef(null),S=b.useRef(new Map).current;return u.jsx(o,{scope:y,itemMap:S,collectionRef:w,children:g})};i.displayName=t;const a=e+"CollectionSlot",l=Un.createSlot(a),c=b.forwardRef((x,y)=>{const{scope:g,children:w}=x,S=s(a,g),k=We(y,S.collectionRef);return u.jsx(l,{ref:k,children:w})});c.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=Un.createSlot(d),p=b.forwardRef((x,y)=>{const{scope:g,children:w,...S}=x,k=b.useRef(null),T=We(y,k),C=s(d,g);return b.useEffect(()=>(C.itemMap.set(k,{ref:k,...S}),()=>void C.itemMap.delete(k))),u.jsx(h,{[f]:"",ref:T,children:w})});p.displayName=d;function m(x){const y=s(e+"CollectionConsumer",x);return b.useCallback(()=>{const w=y.collectionRef.current;if(!w)return[];const S=Array.from(w.querySelectorAll(`[${f}]`));return Array.from(y.itemMap.values()).sort((C,E)=>S.indexOf(C.ref.current)-S.indexOf(E.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:c,ItemSlot:p},m,r]}var ix=v.createContext(void 0);function _o(e){const t=v.useContext(ix);return e||t||"ltr"}function It(e){const t=v.useRef(e);return v.useEffect(()=>{t.current=e}),v.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function ax(e,t=globalThis==null?void 0:globalThis.document){const n=It(e);v.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 lx="DismissableLayer",mi="dismissableLayer.update",cx="dismissableLayer.pointerDownOutside",ux="dismissableLayer.focusOutside",hc,pc=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ro=v.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=v.useContext(pc),[d,f]=v.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=v.useState({}),m=We(t,E=>f(E)),x=Array.from(c.layers),[y]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),g=x.indexOf(y),w=d?x.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=w>=g,T=hx(E=>{const N=E.target,j=[...c.branches].some(D=>D.contains(N));!k||j||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},h),C=px(E=>{const N=E.target;[...c.branches].some(D=>D.contains(N))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},h);return ax(E=>{w===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},h),v.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(hc=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),mc(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=hc)}},[d,h,n,c]),v.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),mc())},[d,c]),v.useEffect(()=>{const E=()=>p({});return document.addEventListener(mi,E),()=>document.removeEventListener(mi,E)},[]),u.jsx(Re.div,{...l,ref:m,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:pe(e.onFocusCapture,C.onFocusCapture),onBlurCapture:pe(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:pe(e.onPointerDownCapture,T.onPointerDownCapture)})});Ro.displayName=lx;var dx="DismissableLayerBranch",fx=v.forwardRef((e,t)=>{const n=v.useContext(pc),r=v.useRef(null),o=We(t,r);return v.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(Re.div,{...e,ref:o})});fx.displayName=dx;function hx(e,t=globalThis==null?void 0:globalThis.document){const n=It(e),r=v.useRef(!1),o=v.useRef(()=>{});return v.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){gc(cx,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function px(e,t=globalThis==null?void 0:globalThis.document){const n=It(e),r=v.useRef(!1);return v.useEffect(()=>{const o=s=>{s.target&&!r.current&&gc(ux,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 mc(){const e=new CustomEvent(mi);document.dispatchEvent(e)}function gc(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?fc(o,s):o.dispatchEvent(s)}var gi=0;function xi(){v.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??xc()),document.body.insertAdjacentElement("beforeend",e[1]??xc()),gi++,()=>{gi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),gi--}},[])}function xc(){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 yi="focusScope.autoFocusOnMount",vi="focusScope.autoFocusOnUnmount",yc={bubbles:!1,cancelable:!0},mx="FocusScope",Po=v.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=v.useState(null),c=It(o),d=It(s),f=v.useRef(null),h=We(t,x=>l(x)),p=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(r){let x=function(S){if(p.paused||!a)return;const k=S.target;a.contains(k)?f.current=k:_n(f.current,{select:!0})},y=function(S){if(p.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||_n(f.current,{select:!0}))},g=function(S){if(document.activeElement===document.body)for(const T of S)T.removedNodes.length>0&&_n(a)};document.addEventListener("focusin",x),document.addEventListener("focusout",y);const w=new MutationObserver(g);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",y),w.disconnect()}}},[r,a,p.paused]),v.useEffect(()=>{if(a){bc.add(p);const x=document.activeElement;if(!a.contains(x)){const g=new CustomEvent(yi,yc);a.addEventListener(yi,c),a.dispatchEvent(g),g.defaultPrevented||(gx(bx(vc(a)),{select:!0}),document.activeElement===x&&_n(a))}return()=>{a.removeEventListener(yi,c),setTimeout(()=>{const g=new CustomEvent(vi,yc);a.addEventListener(vi,d),a.dispatchEvent(g),g.defaultPrevented||_n(x??document.body,{select:!0}),a.removeEventListener(vi,d),bc.remove(p)},0)}}},[a,c,d,p]);const m=v.useCallback(x=>{if(!n&&!r||p.paused)return;const y=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,g=document.activeElement;if(y&&g){const w=x.currentTarget,[S,k]=xx(w);S&&k?!x.shiftKey&&g===k?(x.preventDefault(),n&&_n(S,{select:!0})):x.shiftKey&&g===S&&(x.preventDefault(),n&&_n(k,{select:!0})):g===w&&x.preventDefault()}},[n,r,p.paused]);return u.jsx(Re.div,{tabIndex:-1,...i,ref:h,onKeyDown:m})});Po.displayName=mx;function gx(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(_n(r,{select:t}),document.activeElement!==n)return}function xx(e){const t=vc(e),n=wc(t,e),r=wc(t.reverse(),e);return[n,r]}function vc(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 wc(e,t){for(const n of e)if(!yx(n,{upTo:t}))return n}function yx(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 vx(e){return e instanceof HTMLInputElement&&"select"in e}function _n(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&vx(e)&&t&&e.select()}}var bc=wx();function wx(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Sc(e,t),e.unshift(t)},remove(t){var n;e=Sc(e,t),(n=e[0])==null||n.resume()}}}function Sc(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function bx(e){return e.filter(t=>t.tagName!=="A")}var Sx=v[" useId ".trim().toString()]||(()=>{}),Cx=0;function En(e){const[t,n]=v.useState(Sx());return Et(()=>{n(r=>r??String(Cx++))},[e]),t?`radix-${t}`:""}const Tx=["top","right","bottom","left"],Rn=Math.min,Ut=Math.max,Oo=Math.round,Mo=Math.floor,pn=e=>({x:e,y:e}),kx={left:"right",right:"left",bottom:"top",top:"bottom"},Ex={start:"end",end:"start"};function wi(e,t,n){return Ut(e,Rn(t,n))}function In(e,t){return typeof e=="function"?e(t):e}function Nn(e){return e.split("-")[0]}function fr(e){return e.split("-")[1]}function bi(e){return e==="x"?"y":"x"}function Si(e){return e==="y"?"height":"width"}const Ix=new Set(["top","bottom"]);function mn(e){return Ix.has(Nn(e))?"y":"x"}function Ci(e){return bi(mn(e))}function Nx(e,t,n){n===void 0&&(n=!1);const r=fr(e),o=Ci(e),s=Si(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Do(i)),[i,Do(i)]}function Ax(e){const t=Do(e);return[Ti(e),t,Ti(t)]}function Ti(e){return e.replace(/start|end/g,t=>Ex[t])}const Cc=["left","right"],Tc=["right","left"],jx=["top","bottom"],_x=["bottom","top"];function Rx(e,t,n){switch(e){case"top":case"bottom":return n?t?Tc:Cc:t?Cc:Tc;case"left":case"right":return t?jx:_x;default:return[]}}function Px(e,t,n,r){const o=fr(e);let s=Rx(Nn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ti)))),s}function Do(e){return e.replace(/left|right|bottom|top/g,t=>kx[t])}function Ox(e){return{top:0,right:0,bottom:0,left:0,...e}}function kc(e){return typeof e!="number"?Ox(e):{top:e,right:e,bottom:e,left:e}}function Lo(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 Ec(e,t,n){let{reference:r,floating:o}=e;const s=mn(t),i=Ci(t),a=Si(i),l=Nn(t),c=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(fr(t)){case"start":p[i]-=h*(n&&c?-1:1);break;case"end":p[i]+=h*(n&&c?-1:1);break}return p}const Mx=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=Ec(c,r,l),h=r,p={},m=0;for(let x=0;x<a.length;x++){const{name:y,fn:g}=a[x],{x:w,y:S,data:k,reset:T}=await g({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:c,platform:i,elements:{reference:e,floating:t}});d=w??d,f=S??f,p={...p,[y]:{...p[y],...k}},T&&m<=50&&(m++,typeof T=="object"&&(T.placement&&(h=T.placement),T.rects&&(c=T.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:d,y:f}=Ec(c,h,l)),x=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function Or(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=In(t,e),m=kc(p),y=a[h?f==="floating"?"reference":"floating":f],g=Lo(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(y)))==null||n?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),w=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),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},T=Lo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:S,strategy:l}):w);return{top:(g.top-T.top+m.top)/k.y,bottom:(T.bottom-g.bottom+m.bottom)/k.y,left:(g.left-T.left+m.left)/k.x,right:(T.right-g.right+m.right)/k.x}}const Dx=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=In(e,t)||{};if(c==null)return{};const f=kc(d),h={x:n,y:r},p=Ci(o),m=Si(p),x=await i.getDimensions(c),y=p==="y",g=y?"top":"left",w=y?"bottom":"right",S=y?"clientHeight":"clientWidth",k=s.reference[m]+s.reference[p]-h[p]-s.floating[m],T=h[p]-s.reference[p],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=C?C[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(C)))&&(E=a.floating[S]||s.floating[m]);const N=k/2-T/2,j=E/2-x[m]/2-1,D=Rn(f[g],j),P=Rn(f[w],j),M=D,F=E-x[m]-P,A=E/2-x[m]/2+N,z=wi(M,A,F),_=!l.arrow&&fr(o)!=null&&A!==z&&s.reference[m]/2-(A<M?D:P)-x[m]/2<0,J=_?A<M?A-M:A-F:0;return{[p]:h[p]+J,data:{[p]:z,centerOffset:A-z-J,..._&&{alignmentOffset:J}},reset:_}}}),Lx=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:x=!0,...y}=In(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const g=Nn(o),w=mn(a),S=Nn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),T=h||(S||!x?[Do(a)]:Ax(a)),C=m!=="none";!h&&C&&T.push(...Px(a,x,m,k));const E=[a,...T],N=await Or(t,y),j=[];let D=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&j.push(N[g]),f){const A=Nx(o,i,k);j.push(N[A[0]],N[A[1]])}if(D=[...D,{placement:o,overflows:j}],!j.every(A=>A<=0)){var P,M;const A=(((P=s.flip)==null?void 0:P.index)||0)+1,z=E[A];if(z&&(!(f==="alignment"?w!==mn(z):!1)||D.every($=>mn($.placement)===w?$.overflows[0]>0:!0)))return{data:{index:A,overflows:D},reset:{placement:z}};let _=(M=D.filter(J=>J.overflows[0]<=0).sort((J,$)=>J.overflows[1]-$.overflows[1])[0])==null?void 0:M.placement;if(!_)switch(p){case"bestFit":{var F;const J=(F=D.filter($=>{if(C){const R=mn($.placement);return R===w||R==="y"}return!0}).map($=>[$.placement,$.overflows.filter(R=>R>0).reduce((R,Z)=>R+Z,0)]).sort(($,R)=>$[1]-R[1])[0])==null?void 0:F[0];J&&(_=J);break}case"initialPlacement":_=a;break}if(o!==_)return{reset:{placement:_}}}return{}}}};function Ic(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Nc(e){return Tx.some(t=>e[t]>=0)}const $x=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=In(e,t);switch(r){case"referenceHidden":{const s=await Or(t,{...o,elementContext:"reference"}),i=Ic(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Nc(i)}}}case"escaped":{const s=await Or(t,{...o,altBoundary:!0}),i=Ic(s,n.floating);return{data:{escapedOffsets:i,escaped:Nc(i)}}}default:return{}}}}},Ac=new Set(["left","top"]);async function Fx(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Nn(n),a=fr(n),l=mn(n)==="y",c=Ac.has(i)?-1:1,d=s&&l?-1:1,f=In(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:m}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),l?{x:p*d,y:h*c}:{x:h*c,y:p*d}}const zx=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 Fx(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}}}}},Bx=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:y=>{let{x:g,y:w}=y;return{x:g,y:w}}},...l}=In(e,t),c={x:n,y:r},d=await Or(t,l),f=mn(Nn(o)),h=bi(f);let p=c[h],m=c[f];if(s){const y=h==="y"?"top":"left",g=h==="y"?"bottom":"right",w=p+d[y],S=p-d[g];p=wi(w,p,S)}if(i){const y=f==="y"?"top":"left",g=f==="y"?"bottom":"right",w=m+d[y],S=m-d[g];m=wi(w,m,S)}const x=a.fn({...t,[h]:p,[f]:m});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[h]:s,[f]:i}}}}}},Hx=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=In(e,t),d={x:n,y:r},f=mn(o),h=bi(f);let p=d[h],m=d[f];const x=In(a,t),y=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]+y.mainAxis,T=s.reference[h]+s.reference[S]-y.mainAxis;p<k?p=k:p>T&&(p=T)}if(c){var g,w;const S=h==="y"?"width":"height",k=Ac.has(Nn(o)),T=s.reference[f]-s.floating[S]+(k&&((g=i.offset)==null?void 0:g[f])||0)+(k?0:y.crossAxis),C=s.reference[f]+s.reference[S]+(k?0:((w=i.offset)==null?void 0:w[f])||0)-(k?y.crossAxis:0);m<T?m=T:m>C&&(m=C)}return{[h]:p,[f]:m}}}},Ux=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=In(e,t),d=await Or(t,c),f=Nn(o),h=fr(o),p=mn(o)==="y",{width:m,height:x}=s.floating;let y,g;f==="top"||f==="bottom"?(y=f,g=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(g=f,y=h==="end"?"top":"bottom");const w=x-d.top-d.bottom,S=m-d.left-d.right,k=Rn(x-d[y],w),T=Rn(m-d[g],S),C=!t.middlewareData.shift;let E=k,N=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),C&&!h){const D=Ut(d.left,0),P=Ut(d.right,0),M=Ut(d.top,0),F=Ut(d.bottom,0);p?N=m-2*(D!==0||P!==0?D+P:Ut(d.left,d.right)):E=x-2*(M!==0||F!==0?M+F:Ut(d.top,d.bottom))}await l({...t,availableWidth:N,availableHeight:E});const j=await i.getDimensions(a.floating);return m!==j.width||x!==j.height?{reset:{rects:!0}}:{}}}};function $o(){return typeof window<"u"}function hr(e){return jc(e)?(e.nodeName||"").toLowerCase():"#document"}function Wt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function gn(e){var t;return(t=(jc(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function jc(e){return $o()?e instanceof Node||e instanceof Wt(e).Node:!1}function sn(e){return $o()?e instanceof Element||e instanceof Wt(e).Element:!1}function xn(e){return $o()?e instanceof HTMLElement||e instanceof Wt(e).HTMLElement:!1}function _c(e){return!$o()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Wt(e).ShadowRoot}const Wx=new Set(["inline","contents"]);function Mr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=an(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Wx.has(o)}const Vx=new Set(["table","td","th"]);function Kx(e){return Vx.has(hr(e))}const qx=[":popover-open",":modal"];function Fo(e){return qx.some(t=>{try{return e.matches(t)}catch{return!1}})}const Gx=["transform","translate","scale","rotate","perspective"],Yx=["transform","translate","scale","rotate","perspective","filter"],Xx=["paint","layout","strict","content"];function ki(e){const t=Ei(),n=sn(e)?an(e):e;return Gx.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)||Yx.some(r=>(n.willChange||"").includes(r))||Xx.some(r=>(n.contain||"").includes(r))}function Jx(e){let t=Pn(e);for(;xn(t)&&!pr(t);){if(ki(t))return t;if(Fo(t))return null;t=Pn(t)}return null}function Ei(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Zx=new Set(["html","body","#document"]);function pr(e){return Zx.has(hr(e))}function an(e){return Wt(e).getComputedStyle(e)}function zo(e){return sn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Pn(e){if(hr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||_c(e)&&e.host||gn(e);return _c(t)?t.host:t}function Rc(e){const t=Pn(e);return pr(t)?e.ownerDocument?e.ownerDocument.body:e.body:xn(t)&&Mr(t)?t:Rc(t)}function Dr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Rc(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Wt(o);if(s){const a=Ii(i);return t.concat(i,i.visualViewport||[],Mr(o)?o:[],a&&n?Dr(a):[])}return t.concat(o,Dr(o,[],n))}function Ii(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Pc(e){const t=an(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=xn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Oo(n)!==s||Oo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Ni(e){return sn(e)?e:e.contextElement}function mr(e){const t=Ni(e);if(!xn(t))return pn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Pc(t);let i=(s?Oo(n.width):n.width)/r,a=(s?Oo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Qx=pn(0);function Oc(e){const t=Wt(e);return!Ei()||!t.visualViewport?Qx:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function ey(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Wt(e)?!1:t}function qn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Ni(e);let i=pn(1);t&&(r?sn(r)&&(i=mr(r)):i=mr(e));const a=ey(s,n,r)?Oc(s):pn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=Wt(s),p=r&&sn(r)?Wt(r):r;let m=h,x=Ii(m);for(;x&&r&&p!==m;){const y=mr(x),g=x.getBoundingClientRect(),w=an(x),S=g.left+(x.clientLeft+parseFloat(w.paddingLeft))*y.x,k=g.top+(x.clientTop+parseFloat(w.paddingTop))*y.y;l*=y.x,c*=y.y,d*=y.x,f*=y.y,l+=S,c+=k,m=Wt(x),x=Ii(m)}}return Lo({width:d,height:f,x:l,y:c})}function Bo(e,t){const n=zo(e).scrollLeft;return t?t.left+n:qn(gn(e)).left+n}function Mc(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Bo(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function ty(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=gn(r),a=t?Fo(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=pn(1);const d=pn(0),f=xn(r);if((f||!f&&!s)&&((hr(r)!=="body"||Mr(i))&&(l=zo(r)),xn(r))){const p=qn(r);c=mr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?Mc(i,l):pn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+h.x,y:n.y*c.y-l.scrollTop*c.y+d.y+h.y}}function ny(e){return Array.from(e.getClientRects())}function ry(e){const t=gn(e),n=zo(e),r=e.ownerDocument.body,o=Ut(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Ut(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Bo(e);const a=-n.scrollTop;return an(r).direction==="rtl"&&(i+=Ut(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Dc=25;function oy(e,t){const n=Wt(e),r=gn(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=Ei();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=Bo(r);if(c<=0){const d=r.ownerDocument,f=d.body,h=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,m=Math.abs(r.clientWidth-f.clientWidth-p);m<=Dc&&(s-=m)}else c<=Dc&&(s+=c);return{width:s,height:i,x:a,y:l}}const sy=new Set(["absolute","fixed"]);function iy(e,t){const n=qn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=xn(e)?mr(e):pn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function Lc(e,t,n){let r;if(t==="viewport")r=oy(e,n);else if(t==="document")r=ry(gn(e));else if(sn(t))r=iy(t,n);else{const o=Oc(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Lo(r)}function $c(e,t){const n=Pn(e);return n===t||!sn(n)||pr(n)?!1:an(n).position==="fixed"||$c(n,t)}function ay(e,t){const n=t.get(e);if(n)return n;let r=Dr(e,[],!1).filter(a=>sn(a)&&hr(a)!=="body"),o=null;const s=an(e).position==="fixed";let i=s?Pn(e):e;for(;sn(i)&&!pr(i);){const a=an(i),l=ki(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&sy.has(o.position)||Mr(i)&&!l&&$c(e,i))?r=r.filter(d=>d!==i):o=a,i=Pn(i)}return t.set(e,r),r}function ly(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Fo(t)?[]:ay(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const f=Lc(t,d,o);return c.top=Ut(f.top,c.top),c.right=Rn(f.right,c.right),c.bottom=Rn(f.bottom,c.bottom),c.left=Ut(f.left,c.left),c},Lc(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function cy(e){const{width:t,height:n}=Pc(e);return{width:t,height:n}}function uy(e,t,n){const r=xn(t),o=gn(t),s=n==="fixed",i=qn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=pn(0);function c(){l.x=Bo(o)}if(r||!r&&!s)if((hr(t)!=="body"||Mr(o))&&(a=zo(t)),r){const p=qn(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?Mc(o,a):pn(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 Ai(e){return an(e).position==="static"}function Fc(e,t){if(!xn(e)||an(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return gn(e)===n&&(n=n.ownerDocument.body),n}function zc(e,t){const n=Wt(e);if(Fo(e))return n;if(!xn(e)){let o=Pn(e);for(;o&&!pr(o);){if(sn(o)&&!Ai(o))return o;o=Pn(o)}return n}let r=Fc(e,t);for(;r&&Kx(r)&&Ai(r);)r=Fc(r,t);return r&&pr(r)&&Ai(r)&&!ki(r)?n:r||Jx(e)||n}const dy=async function(e){const t=this.getOffsetParent||zc,n=this.getDimensions,r=await n(e.floating);return{reference:uy(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function fy(e){return an(e).direction==="rtl"}const hy={convertOffsetParentRelativeRectToViewportRelativeRect:ty,getDocumentElement:gn,getClippingRect:ly,getOffsetParent:zc,getElementRects:dy,getClientRects:ny,getDimensions:cy,getScale:mr,isElement:sn,isRTL:fy};function Bc(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function py(e,t){let n=null,r;const o=gn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:f,width:h,height:p}=c;if(a||t(),!h||!p)return;const m=Mo(f),x=Mo(o.clientWidth-(d+h)),y=Mo(o.clientHeight-(f+p)),g=Mo(d),S={rootMargin:-m+"px "+-x+"px "+-y+"px "+-g+"px",threshold:Ut(0,Rn(1,l))||1};let k=!0;function T(C){const E=C[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!Bc(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(T,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(T,S)}n.observe(e)}return i(!0),s}function my(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=Ni(e),d=o||s?[...c?Dr(c):[],...Dr(t)]:[];d.forEach(g=>{o&&g.addEventListener("scroll",n,{passive:!0}),s&&g.addEventListener("resize",n)});const f=c&&a?py(c,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(g=>{let[w]=g;w&&w.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let m,x=l?qn(e):null;l&&y();function y(){const g=qn(e);x&&!Bc(x,g)&&n(),x=g,m=requestAnimationFrame(y)}return n(),()=>{var g;d.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),f==null||f(),(g=p)==null||g.disconnect(),p=null,l&&cancelAnimationFrame(m)}}const gy=zx,xy=Bx,yy=Lx,vy=Ux,wy=$x,Hc=Dx,by=Hx,Sy=(e,t,n)=>{const r=new Map,o={platform:hy,...n},s={...o.platform,_c:r};return Mx(e,t,{...o,platform:s})};var Cy=typeof document<"u",Ty=function(){},Ho=Cy?b.useLayoutEffect:Ty;function Uo(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(!Uo(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)&&!Uo(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Uc(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Wc(e,t){const n=Uc(e);return Math.round(t*n)/n}function ji(e){const t=v.useRef(e);return Ho(()=>{t.current=e}),t}function ky(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,f]=v.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=v.useState(r);Uo(h,r)||p(r);const[m,x]=v.useState(null),[y,g]=v.useState(null),w=v.useCallback($=>{$!==C.current&&(C.current=$,x($))},[]),S=v.useCallback($=>{$!==E.current&&(E.current=$,g($))},[]),k=s||m,T=i||y,C=v.useRef(null),E=v.useRef(null),N=v.useRef(d),j=l!=null,D=ji(l),P=ji(o),M=ji(c),F=v.useCallback(()=>{if(!C.current||!E.current)return;const $={placement:t,strategy:n,middleware:h};P.current&&($.platform=P.current),Sy(C.current,E.current,$).then(R=>{const Z={...R,isPositioned:M.current!==!1};A.current&&!Uo(N.current,Z)&&(N.current=Z,fo.flushSync(()=>{f(Z)}))})},[h,t,n,P,M]);Ho(()=>{c===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,f($=>({...$,isPositioned:!1})))},[c]);const A=v.useRef(!1);Ho(()=>(A.current=!0,()=>{A.current=!1}),[]),Ho(()=>{if(k&&(C.current=k),T&&(E.current=T),k&&T){if(D.current)return D.current(k,T,F);F()}},[k,T,F,D,j]);const z=v.useMemo(()=>({reference:C,floating:E,setReference:w,setFloating:S}),[w,S]),_=v.useMemo(()=>({reference:k,floating:T}),[k,T]),J=v.useMemo(()=>{const $={position:n,left:0,top:0};if(!_.floating)return $;const R=Wc(_.floating,d.x),Z=Wc(_.floating,d.y);return a?{...$,transform:"translate("+R+"px, "+Z+"px)",...Uc(_.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:R,top:Z}},[n,a,_.floating,d.x,d.y]);return v.useMemo(()=>({...d,update:F,refs:z,elements:_,floatingStyles:J}),[d,F,z,_,J])}const Ey=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?Hc({element:r.current,padding:o}).fn(n):{}:r?Hc({element:r,padding:o}).fn(n):{}}}},Iy=(e,t)=>({...gy(e),options:[e,t]}),Ny=(e,t)=>({...xy(e),options:[e,t]}),Ay=(e,t)=>({...by(e),options:[e,t]}),jy=(e,t)=>({...yy(e),options:[e,t]}),_y=(e,t)=>({...vy(e),options:[e,t]}),Ry=(e,t)=>({...wy(e),options:[e,t]}),Py=(e,t)=>({...Ey(e),options:[e,t]});var Oy="Arrow",Vc=v.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(Re.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u.jsx("polygon",{points:"0,0 30,0 15,10"})})});Vc.displayName=Oy;var My=Vc;function Kc(e){const[t,n]=v.useState(void 0);return Et(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var _i="Popper",[qc,Wo]=kn(_i),[Dy,Gc]=qc(_i),Yc=e=>{const{__scopePopper:t,children:n}=e,[r,o]=v.useState(null);return u.jsx(Dy,{scope:t,anchor:r,onAnchorChange:o,children:n})};Yc.displayName=_i;var Xc="PopperAnchor",Jc=v.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Gc(Xc,n),i=v.useRef(null),a=We(t,i),l=v.useRef(null);return v.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(Re.div,{...o,ref:a})});Jc.displayName=Xc;var Ri="PopperContent",[Ly,$y]=qc(Ri),Zc=v.forwardRef((e,t)=>{var X,L,U,K,se,re;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:m,...x}=e,y=Gc(Ri,n),[g,w]=v.useState(null),S=We(t,Oe=>w(Oe)),[k,T]=v.useState(null),C=Kc(k),E=(C==null?void 0:C.width)??0,N=(C==null?void 0:C.height)??0,j=r+(s!=="center"?"-"+s:""),D=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},P=Array.isArray(c)?c:[c],M=P.length>0,F={padding:D,boundary:P.filter(zy),altBoundary:M},{refs:A,floatingStyles:z,placement:_,isPositioned:J,middlewareData:$}=ky({strategy:"fixed",placement:j,whileElementsMounted:(...Oe)=>my(...Oe,{animationFrame:p==="always"}),elements:{reference:y.anchor},middleware:[Iy({mainAxis:o+N,alignmentAxis:i}),l&&Ny({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Ay():void 0,...F}),l&&jy({...F}),_y({...F,apply:({elements:Oe,rects:qe,availableWidth:Ge,availableHeight:oe})=>{const{width:le,height:De}=qe.reference,Be=Oe.floating.style;Be.setProperty("--radix-popper-available-width",`${Ge}px`),Be.setProperty("--radix-popper-available-height",`${oe}px`),Be.setProperty("--radix-popper-anchor-width",`${le}px`),Be.setProperty("--radix-popper-anchor-height",`${De}px`)}}),k&&Py({element:k,padding:a}),By({arrowWidth:E,arrowHeight:N}),h&&Ry({strategy:"referenceHidden",...F})]}),[R,Z]=tu(_),Y=It(m);Et(()=>{J&&(Y==null||Y())},[J,Y]);const me=(X=$.arrow)==null?void 0:X.x,Te=(L=$.arrow)==null?void 0:L.y,je=((U=$.arrow)==null?void 0:U.centerOffset)!==0,[G,ne]=v.useState();return Et(()=>{g&&ne(window.getComputedStyle(g).zIndex)},[g]),u.jsx("div",{ref:A.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:J?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:G,"--radix-popper-transform-origin":[(K=$.transformOrigin)==null?void 0:K.x,(se=$.transformOrigin)==null?void 0:se.y].join(" "),...((re=$.hide)==null?void 0:re.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(Ly,{scope:n,placedSide:R,onArrowChange:T,arrowX:me,arrowY:Te,shouldHideArrow:je,children:u.jsx(Re.div,{"data-side":R,"data-align":Z,...x,ref:S,style:{...x.style,animation:J?void 0:"none"}})})})});Zc.displayName=Ri;var Qc="PopperArrow",Fy={top:"bottom",right:"left",bottom:"top",left:"right"},eu=v.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=$y(Qc,r),i=Fy[s.placedSide];return u.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:u.jsx(My,{...o,ref:n,style:{...o.style,display:"block"}})})});eu.displayName=Qc;function zy(e){return e!==null}var By=e=>({name:"transformOrigin",options:e,fn(t){var y,g,w;const{placement:n,rects:r,middlewareData:o}=t,i=((y=o.arrow)==null?void 0:y.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,d]=tu(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((g=o.arrow)==null?void 0:g.x)??0)+a/2,p=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let m="",x="";return c==="bottom"?(m=i?f:`${h}px`,x=`${-l}px`):c==="top"?(m=i?f:`${h}px`,x=`${r.floating.height+l}px`):c==="right"?(m=`${-l}px`,x=i?f:`${p}px`):c==="left"&&(m=`${r.floating.width+l}px`,x=i?f:`${p}px`),{data:{x:m,y:x}}}});function tu(e){const[t,n="center"]=e.split("-");return[t,n]}var nu=Yc,ru=Jc,ou=Zc,su=eu,Hy="Portal",Vo=v.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=v.useState(!1);Et(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Ks.createPortal(u.jsx(Re.div,{...r,ref:t}),i):null});Vo.displayName=Hy;function Uy(e,t){return v.useReducer((n,r)=>t[n][r]??n,e)}var Xt=e=>{const{present:t,children:n}=e,r=Wy(t),o=typeof n=="function"?n({present:r.isPresent}):v.Children.only(n),s=We(r.ref,Vy(o));return typeof n=="function"||r.isPresent?v.cloneElement(o,{ref:s}):null};Xt.displayName="Presence";function Wy(e){const[t,n]=v.useState(),r=v.useRef(null),o=v.useRef(e),s=v.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Uy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const c=Ko(r.current);s.current=a==="mounted"?c:"none"},[a]),Et(()=>{const c=r.current,d=o.current;if(d!==e){const h=s.current,p=Ko(c);e?l("MOUNT"):p==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),Et(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,f=p=>{const x=Ko(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&x&&(l("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},h=p=>{p.target===t&&(s.current=Ko(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:v.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function Ko(e){return(e==null?void 0:e.animationName)||"none"}function Vy(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 Pi="rovingFocusGroup.onEntryFocus",Ky={bubbles:!1,cancelable:!0},Lr="RovingFocusGroup",[Oi,iu,qy]=pi(Lr),[Gy,au]=kn(Lr,[qy]),[Yy,Xy]=Gy(Lr),lu=v.forwardRef((e,t)=>u.jsx(Oi.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Oi.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Jy,{...e,ref:t})})}));lu.displayName=Lr;var Jy=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...f}=e,h=v.useRef(null),p=We(t,h),m=_o(s),[x,y]=dr({prop:i,defaultProp:a??null,onChange:l,caller:Lr}),[g,w]=v.useState(!1),S=It(c),k=iu(n),T=v.useRef(!1),[C,E]=v.useState(0);return v.useEffect(()=>{const N=h.current;if(N)return N.addEventListener(Pi,S),()=>N.removeEventListener(Pi,S)},[S]),u.jsx(Yy,{scope:n,orientation:r,dir:m,loop:o,currentTabStopId:x,onItemFocus:v.useCallback(N=>y(N),[y]),onItemShiftTab:v.useCallback(()=>w(!0),[]),onFocusableItemAdd:v.useCallback(()=>E(N=>N+1),[]),onFocusableItemRemove:v.useCallback(()=>E(N=>N-1),[]),children:u.jsx(Re.div,{tabIndex:g||C===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:pe(e.onMouseDown,()=>{T.current=!0}),onFocus:pe(e.onFocus,N=>{const j=!T.current;if(N.target===N.currentTarget&&j&&!g){const D=new CustomEvent(Pi,Ky);if(N.currentTarget.dispatchEvent(D),!D.defaultPrevented){const P=k().filter(_=>_.focusable),M=P.find(_=>_.active),F=P.find(_=>_.id===x),z=[M,F,...P].filter(Boolean).map(_=>_.ref.current);du(z,d)}}T.current=!1}),onBlur:pe(e.onBlur,()=>w(!1))})})}),cu="RovingFocusGroupItem",uu=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=En(),c=s||l,d=Xy(cu,n),f=d.currentTabStopId===c,h=iu(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:x}=d;return v.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),u.jsx(Oi.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(Re.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:pe(e.onMouseDown,y=>{r?d.onItemFocus(c):y.preventDefault()}),onFocus:pe(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:pe(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){d.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const g=ev(y,d.orientation,d.dir);if(g!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let S=h().filter(k=>k.focusable).map(k=>k.ref.current);if(g==="last")S.reverse();else if(g==="prev"||g==="next"){g==="prev"&&S.reverse();const k=S.indexOf(y.currentTarget);S=d.loop?tv(S,k+1):S.slice(k+1)}setTimeout(()=>du(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:x!=null}):i})})});uu.displayName=cu;var Zy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Qy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function ev(e,t,n){const r=Qy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Zy[r]}function du(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function tv(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var nv=lu,rv=uu,ov=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},gr=new WeakMap,qo=new WeakMap,Go={},Mi=0,fu=function(e){return e&&(e.host||fu(e.parentNode))},sv=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=fu(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})},iv=function(e,t,n,r){var o=sv(t,Array.isArray(e)?e:[e]);Go[n]||(Go[n]=new WeakMap);var s=Go[n],i=[],a=new Set,l=new Set(o),c=function(f){!f||a.has(f)||(a.add(f),c(f.parentNode))};o.forEach(c);var d=function(f){!f||l.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))d(h);else try{var p=h.getAttribute(r),m=p!==null&&p!=="false",x=(gr.get(h)||0)+1,y=(s.get(h)||0)+1;gr.set(h,x),s.set(h,y),i.push(h),x===1&&m&&qo.set(h,!0),y===1&&h.setAttribute(n,"true"),m||h.setAttribute(r,"true")}catch(g){console.error("aria-hidden: cannot operate on ",h,g)}})};return d(t),a.clear(),Mi++,function(){i.forEach(function(f){var h=gr.get(f)-1,p=s.get(f)-1;gr.set(f,h),s.set(f,p),h||(qo.has(f)||f.removeAttribute(r),qo.delete(f)),p||f.removeAttribute(n)}),Mi--,Mi||(gr=new WeakMap,gr=new WeakMap,qo=new WeakMap,Go={})}},Di=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=ov(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),iv(r,o,n,"aria-hidden")):function(){return null}},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 hu(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 av(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 Yo="right-scroll-bar-position",Xo="width-before-scroll-bar",lv="with-scroll-bars-hidden",cv="--removed-body-scroll-bar-size";function Li(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function uv(e,t){var n=b.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var dv=typeof window<"u"?v.useLayoutEffect:v.useEffect,pu=new WeakMap;function fv(e,t){var n=uv(null,function(r){return e.forEach(function(o){return Li(o,r)})});return dv(function(){var r=pu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Li(a,null)}),s.forEach(function(a){o.has(a)||Li(a,i)})}pu.set(n,e)},[e]),n}function hv(e){return e}function pv(e,t){t===void 0&&(t=hv);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(d){i.push(d),c()},filter:function(d){return i=i.filter(d),n}}}};return o}function mv(e){e===void 0&&(e={});var t=pv(null);return t.options=yn({async:!0,ssr:!1},e),t}var mu=function(e){var t=e.sideCar,n=hu(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 v.createElement(r,yn({},n))};mu.isSideCarExport=!0;function gv(e,t){return e.useMedium(t),mu}var gu=mv(),$i=function(){},Jo=v.forwardRef(function(e,t){var n=v.useRef(null),r=v.useState({onScrollCapture:$i,onWheelCapture:$i,onTouchMoveCapture:$i}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,p=e.noRelative,m=e.noIsolation,x=e.inert,y=e.allowPinchZoom,g=e.as,w=g===void 0?"div":g,S=e.gapMode,k=hu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),T=h,C=fv([n,t]),E=yn(yn({},k),o);return v.createElement(v.Fragment,null,d&&v.createElement(T,{sideCar:gu,removeScrollBar:c,shards:f,noRelative:p,noIsolation:m,inert:x,setCallbacks:s,allowPinchZoom:!!y,lockRef:n,gapMode:S}),i?v.cloneElement(v.Children.only(a),yn(yn({},E),{ref:C})):v.createElement(w,yn({},E,{className:l,ref:C}),a))});Jo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Jo.classNames={fullWidth:Xo,zeroRight:Yo};var xv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function yv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=xv();return t&&e.setAttribute("nonce",t),e}function vv(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function wv(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var bv=function(){var e=0,t=null;return{add:function(n){e==0&&(t=yv())&&(vv(t,n),wv(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Sv=function(){var e=bv();return function(t,n){v.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},xu=function(){var e=Sv(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Cv={left:0,top:0,right:0,gap:0},Fi=function(e){return parseInt(e||"",10)||0},Tv=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[Fi(n),Fi(r),Fi(o)]},kv=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Cv;var t=Tv(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])}},Ev=xu(),xr="data-scroll-locked",Iv=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
37
|
+
`))>=0;){const ee=ft.slice(0,B);ft=ft.slice(B+2);const ye=Bg(ee);if(!ye)continue;let Ne;try{Ne=JSON.parse(ye)}catch{console.debug("[use-chat] malformed SSE:",ye.slice(0,200));continue}const se=zg(Ne)?Ne.data:Ne;jt=Date.now();const Ge=se.seq;if(Ge!==void 0){if(Ge<=gt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:Ge,lastProcessedSeq:gt,type:se.type});continue}gt>0&&Ge>gt+1&&((L=_==null?void 0:_.onGap)==null||L.call(_,{from:gt,to:Ge})),gt=Ge,T.current=Ge,y(Ge)}if(console.debug("[use-chat] received event",{seq:se.seq,type:se.type,preview:(()=>{var _e;try{return se.type==="message_delta"?{deltaTypes:(_e=se.delta)==null?void 0:_e.map(Le=>Le.type),textLen:(se.delta||[]).filter(Le=>Le.type==="text").map(Le=>String(Le.text||"").length)}:se.content||se.delta?{hasContent:!0}:{}}catch(Le){return{err:String(Le)}}})()}),se.type==="checkpoint")E.current=se.checkpointId??null,N.current=se.checkpointNs??null,m(se.checkpointId??null);else if(se.type==="state_history"){j.current=se;try{const Le=ur(se).latest;Le&&(E.current=Le.checkpointId??null,N.current=Le.checkpointNs??null,m(Le.checkpointId??null))}catch(_e){console.warn("[use-chat] Failed to hydrate state_history payload",_e)}}try{z==null||z(se)}catch(_e){console.error("[use-chat] Error in onEvent callback:",_e,"for event:",se.type)}if(se.type==="token"&&e.autoAppendAssistant!==!1)mt.push(se.content),At();else if(se.type==="message_delta"){const _e=se.delta.filter(Le=>Le.type==="text").map(Le=>Le.text).join("");_e&&e.autoAppendAssistant!==!1&&(mt.push(_e),At())}else if(se.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(H=_==null?void 0:_.onHeartbeat)==null||H.call(_,se)}catch(_e){console.warn("[use-chat] heartbeat callback failed",_e)}}else if(st!==null&&cancelAnimationFrame(st),De(),se.type==="checkpoint")m(se.checkpointId);else if(se.type==="error"){const _e=se;if(d(_e.message),$="error",R=_e.message,_e.error_type==="auth_error"||_e.code==="TOKEN_EXPIRED"||((V=_e.message)==null?void 0:V.includes("token"))||((ie=_e.message)==null?void 0:ie.includes("401"))||((re=_e.message)==null?void 0:re.includes("unauthorized"))||((ze=_e.message)==null?void 0:ze.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",_e.message);try{(We=_==null?void 0:_.onAuthError)==null||We.call(_,_e.message)}catch(rn){console.warn("[use-chat] onAuthError handler failed",rn)}X.abort()}}}}De(),$===null&&!X.signal.aborted&&($="complete")}catch(qe){if(qe.name==="AbortError")$=$??"aborted";else{const je=qe.message||String(qe);$="error",R=je,d(je),(Ze=_==null?void 0:_.onError)==null||Ze.call(_,je)}}finally{try{await nt.cancel()}catch{}finally{(oe=nt.releaseLock)==null||oe.call(nt)}st!==null&&typeof window<"u"&&window.cancelAnimationFrame(st),clearInterval(nn)}}catch(Je){if(Je.name==="AbortError")$=$??"aborted";else{const tt=Je.message||String(Je);$="error",R=tt,d(tt),(me=_==null?void 0:_.onError)==null||me.call(_,tt),J||((Te=_==null?void 0:_.onConnectionError)==null||Te.call(_,tt),J=!0)}}finally{const Je=T.current,tt=E.current,$e=N.current,He=j.current,Ve=$??(X.signal.aborted?"aborted":R?"error":"complete");try{(Be=_==null?void 0:_.onClosed)==null||Be.call(_,{reason:Ve,lastSeq:Je,lastCheckpointId:tt,lastCheckpointNs:$e,lastStateHistory:He,error:R})}catch(nt){console.warn("[use-chat] onClosed callback failed",nt)}l(!1),w(!1),S.current=null,T.current=0,y(0),C.current=null}})(),{close:()=>X.abort()}},[t,n,r,e.autoAppendAssistant]);return b.useEffect(()=>()=>{var A;k.current=!1,(A=S.current)==null||A.abort()},[]),{isStreaming:a,error:c,assistantText:f,lastCheckpointId:p,lastSeq:x,connected:g,stream:F,stop:M,clear:P,setToken:D}}function zg(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function Bg(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 Hg(e){return e.type!=="token"}const Ug={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,messagesStreamMeta:{},pendingInterrupt:null};function Wg(e,t){var n;switch(t.type){case"reset":return{messages:ci(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,pendingInterrupt:null};case"seed":{const r=ci(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),o}case"prepend":{const r=ci(t.payload.messages);if(!r.length)return e;const o=new Set(e.messages.map(i=>i.id)),s=r.filter(i=>!o.has(i.id));return s.length?{...e,messages:[...s,...e.messages]}: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 Jl(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Jl(o,s),e):e}case"interrupt_response":return{...e,messages:Zl(e.messages),pendingInterrupt:null};default:return e}}function Xl(e=[]){const[t,n]=b.useReducer(Wg,{...Ug,messages:e}),r=b.useRef([]),o=b.useRef(null),s=b.useRef(null),i=b.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=b.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=b.useCallback(d=>{r.current.push(d),a()},[a]);b.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=b.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:d=>n({type:"user_message",payload:{message:d}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function Jl(e,t){var n,r,o,s,i;if(t.type==="message_start"&&t.role==="assistant"){const a=t.id,l=Gg(t.model);if(e.messages.some(f=>f.id===a)){const f=e.messagesStreamMeta??{},h={...f,[a]:f[a]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:a,messagesStreamMeta:h}}const d={id:a,role:"assistant",name:l||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:a,messages:[...e.messages,d]}}if(t.type==="message_delta"){const a=e.assemblingId??Ql(e.messages);if(!a)return e;const l=e.messages,c=l.findIndex(k=>k.id===a&&k.role==="assistant");if(c===-1)return e;const d=l[c],f=e.messagesStreamMeta??{},h=f[a]??{lastSeq:null,lastText:nc(d.content)},p=t.seq??null;if(p!==null&&typeof p=="number"&&typeof h.lastSeq=="number"&&p<=h.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:p,lastSeq:h.lastSeq}),e;const{newParts:m,newMeta:x,changed:y}=Vg(d.content,t.delta,h,p);if(!y)return e;const g={...d,content:m},w=Io(l,c,g),S={...f,[a]:x};return{...e,messages:w,messagesStreamMeta:S}}if(t.type==="message_end"){const a=e.assemblingId??Ql(e.messages);if(!a)return{...e,assemblingId:null};const l=e.messages,c=l.findIndex(d=>d.id===a&&d.role==="assistant");if(c>=0){const d=l[c];if(!((n=d.content)==null?void 0:n.some(h=>{var p;return(h==null?void 0:h.type)==="text"&&((p=h.text)==null?void 0:p.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:d.id,contentTypes:(r=d.content)==null?void 0:r.map(p=>p==null?void 0:p.type),contentPreview:(o=d.content)==null?void 0:o.map(p=>(p==null?void 0:p.type)==="text"?String(p.text).slice(0,100):p==null?void 0:p.type)});const h=[...l.slice(0,c),...l.slice(c+1)];return{...e,assemblingId:null,messages:h}}}return e}if(t.type==="tool_start"){const a=ec(t),l=a[0]??(typeof t.id=="string"?t.id:null)??(typeof t.call_id=="string"?t.call_id:null),c=t.name??t.tool??"tool";!l&&a.length===0&&a.push(`${c}-${Date.now()}`);const d=a.length?a:l?[l]:[],f=tc(e,d,c),h=f>=0?e.messages[f]:null,p=l??d[0]??`${c}-${Date.now()}`,m=(h==null?void 0:h.id)??`tool-${p}`,x=d[0]??p,y={type:"tool_call",id:x,name:c,args:t.args};if(h){const S=di(h,d,c,t.args),k={...h,name:h.name??c,additionalKwargs:S},T=f,C=T>=0?Io(e.messages,T,k):e.messages,E=No(k,d),N=fi(e.toolIndex,m,E);return{...e,messages:C,toolIndex:N}}const g={id:m,role:"tool",name:c,createdAt:new Date().toISOString(),content:[y],additionalKwargs:di(void 0,d.length?d:[x],c,t.args)},w=No(g,d.length?d:[x]);return{...e,messages:[...e.messages,g],toolIndex:fi(e.toolIndex,m,w)}}if(t.type==="tool_end"){const a=ec(t);if(!a.length&&!(typeof t.id=="string"&&t.id))return e;const l=t.name??null,c=tc(e,a,l),d=c>=0?e.messages[c]:null,f=l??(d==null?void 0:d.name)??((s=d==null?void 0:d.additionalKwargs)==null?void 0:s.toolName)??"tool",h=a[0]??((i=d==null?void 0:d.id)==null?void 0:i.replace(/^tool-/,""))??`${f}-${Date.now()}`,p=(d==null?void 0:d.id)??`tool-${h}`,m=No(d,a);let x=t.output;if(typeof t.output=="string")try{const C=t.output.trim();(C.startsWith("{")||C.startsWith("["))&&(x=JSON.parse(C))}catch{x=t.output}const y={type:"text",text:typeof x=="string"?x:JSON.stringify(x)},g=(d==null?void 0:d.createdAt)??new Date().toISOString(),w=di(d??void 0,m.length?m:a,f),S={id:p,role:"tool",name:f??(d==null?void 0:d.name)??"tool",content:[y],createdAt:g,additionalKwargs:w},k=c>=0?Io(e.messages,c,S):[...e.messages,S],T=No(S,a.length?a:m);return{...e,messages:k,toolIndex:fi(e.toolIndex,p,T)}}if(t.type==="checkpoint"){const a=t.checkpointNs??e.lastCheckpointNs??null,l=qg(e.messages,t.checkpointId,a);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:a,messages:l}}if(t.type==="branch"){const a=t.checkpointId??e.lastCheckpointId,l=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:a??null,lastCheckpointNs:l??null}}if(t.type==="error"){const a={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,a]}}if(t.type==="state_history"){const a=ur(t),l=a.interrupt,c=a.latest,d=l===null?Zl(e.messages):e.messages;return{...e,messages:d,pendingInterrupt:l,lastCheckpointId:(c==null?void 0:c.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(c==null?void 0:c.checkpointNs)??e.lastCheckpointNs}}return t.type==="thread_info",e}function ci(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 Io(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Zl(e){let t=!1;const n=e.map(r=>{const o=(r.content??[]).filter(s=>s.type!=="interrupt");return o.length!==r.content.length?(t=!0,{...r,content:o}):r});return t?n:e}function Ql(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function ec(e){const t=new Set,n=r=>{typeof r=="string"&&r.trim()&&t.add(r.trim())};return n(e.id),n(e==null?void 0:e.call_id),n(e==null?void 0:e.callId),Array.from(t)}function ui(e){if(!e)return[];const t=new Set,n=o=>{typeof o=="string"&&o.trim()&&t.add(o.trim())},r=e.additionalKwargs;if(r){n(r.toolCallId);const o=r.toolCallIds;if(Array.isArray(o))for(const s of o)n(s)}for(const o of e.content??[])(o==null?void 0:o.type)==="tool_call"&&n(o.id);return Array.from(t)}function di(e,t,n,r){const o=new Set,s=l=>{typeof l=="string"&&l.trim()&&o.add(l.trim())};if(e){const l=ui(e);for(const c of l)s(c)}for(const l of t)s(l);const i=Array.from(o),a={...(e==null?void 0:e.additionalKwargs)??{}};if(i.length){a.toolCallIds=i;const l=typeof a.toolCallId=="string"?a.toolCallId.trim():null;a.toolCallId=l&&o.has(l)?l:i[0]}return n&&(a.toolName=n),r!==void 0&&(a.toolArgs=r),a}function No(e,t){const n=new Set;for(const o of t)typeof o=="string"&&o.trim()&&n.add(o.trim());const r=ui(e);for(const o of r)n.add(o);return Array.from(n)}function fi(e,t,n){if(!n.length)return e;let r=!1;const o={...e};for(const s of n)s&&o[s]!==t&&(o[s]=t,r=!0);return r?o:e}function tc(e,t,n){var o,s;const r=new Set(t.filter(i=>typeof i=="string"&&i.trim()));for(const i of r){const a=e.toolIndex[i];if(a){const l=e.messages.findIndex(c=>c.id===a);if(l!==-1)return l}}for(let i=e.messages.length-1;i>=0;i--){const a=e.messages[i];if(a.role!=="tool")continue;if(ui(a).some(c=>r.has(c)))return i}if(typeof n=="string"&&n.trim())for(let i=e.messages.length-1;i>=0;i--){const a=e.messages[i];if(a.role!=="tool"||a.name&&a.name!==n)continue;if(!((o=a.content)==null?void 0:o.some(c=>c.type!=="tool_call")))return i}for(let i=e.messages.length-1;i>=0;i--){const a=e.messages[i];if(a.role!=="tool")continue;if(!((s=a.content)==null?void 0:s.some(c=>c.type!=="tool_call")))return i}return-1}function nc(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function Vg(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??nc(e);let l="",c=e.slice();if(s){const f=Kg(a,s);if(f===""?l="":f===s?l=s:l=f,l){const h=c[c.length-1];if((h==null?void 0:h.type)==="text"){const p=h.text??"",m={...h,text:p+l};c=[...c.slice(0,c.length-1),m]}else c=[...c,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(c=[...c,...i]);const d=!!(l||i.length);return{newParts:c,newMeta:o,changed:d}}function rc(e){return e.replace(/\s+/g," ").trim()}function Kg(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 qg(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 Io(e,r,s)}return e}function Gg(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const oc=200;function Yg({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onStateHistory:r,onUnhandledEvent:o,onSequenceGap:s,onStreamClosed:i,onConnectionError:a,onAuthError:l,onHeartbeat:c}){const d=b.useRef(null),f=b.useRef(null),h=b.useRef(new Map),p=b.useRef(null),m=b.useRef(null),x=b.useCallback(P=>{try{const M=globalThis.structuredClone;if(typeof M=="function")return M(P)}catch{}try{return JSON.parse(JSON.stringify(P))}catch{return P}},[]),y=b.useCallback((P,M)=>{if(!P)return;const F=h.current.get(P)??[],A=x(M),z=F.length>=oc?[...F.slice(F.length-oc+1),A]:[...F,A];h.current.set(P,z)},[x]),g=b.useCallback(P=>{P&&h.current.set(P,[])},[]),w=b.useCallback(P=>{const M=P??f.current;if(!M)return;const F=h.current.get(M);F!=null&&F.length&&F.forEach(A=>{try{n(A)}catch(z){console.error("[useChatStreamingService] Failed to replay buffered event",z)}})},[n]),S=b.useCallback(P=>{var A,z,_,X,$;const M=P.seq??null;if(M!==null){const R=d.current;if(R!==null){if(M<=R)return;M>R+1&&(s==null||s({from:R,to:M}))}d.current=M}if(P.type==="thread_info"){f.current=P.threadId,p.current&&(p.current.threadIdGuess=P.threadId),m.current=P,g(P.threadId),console.log("[useChatStreamingService] 🎯 Received thread_info event:",P);try{t(P)}catch(R){console.error("[useChatStreamingService] Error in onThreadInfo handler:",R)}return}if(P.type==="heartbeat"){try{c==null||c(P)}catch(R){console.error("[useChatStreamingService] Error in onHeartbeat handler:",R)}return}if(P.type==="error"){const R=P;if(R.error_type==="auth_error"||R.code==="TOKEN_EXPIRED"||((A=R.message)==null?void 0:A.includes("token"))||((z=R.message)==null?void 0:z.includes("401"))||((_=R.message)==null?void 0:_.includes("unauthorized"))||((X=R.message)==null?void 0:X.includes("Unauthorized"))){console.error("[useChatStreamingService] Auth error event detected:",R.message);try{l==null||l(R.message)}catch(G){console.warn("[useChatStreamingService] onAuthError handler failed",G)}}}const F=P.threadId??(P.type==="state_history"?P.threadId:void 0)??f.current??(($=p.current)==null?void 0:$.threadIdGuess)??null;if(P.type==="state_history"){f.current=F??f.current;try{r==null||r(P)}catch(R){console.error("[useChatStreamingService] onStateHistory handler failed",R)}}if(Hg(P)){P.type==="checkpoint"||P.type==="state_history"?g(F??null):y(F??null,P);try{n(P)}catch(R){console.error("[useChatStreamingService] Error in onMessageEvent handler:",R)}return}try{o==null||o(P)}catch(R){console.error("[useChatStreamingService] Error in onUnhandledEvent handler:",R)}},[y,g,n,s,t,r,o]),{stream:k,stop:T,isStreaming:C,error:E,setToken:N}=Yl({baseUrl:e,token:void 0}),j=b.useCallback((P,M)=>{d.current=null,m.current=null,f.current=P.threadId??null,p.current={request:P,callbacks:M,manualStop:!1,threadIdGuess:P.threadId??null},k(P,S,{onOpen:M==null?void 0:M.onOpen,onError:F=>{var A;(A=M==null?void 0:M.onError)==null||A.call(M,F)},onGap:(M==null?void 0:M.onGap)??s,onConnectionError:F=>{var A;a==null||a(F),(A=M==null?void 0:M.onConnectionError)==null||A.call(M,F)},onAuthError:F=>{var A;l==null||l(F),(A=M==null?void 0:M.onAuthError)==null||A.call(M,F)},onHeartbeat:F=>{var A;try{c==null||c(F)}catch(z){console.warn("[useChatStreamingService] onHeartbeat handler failed",z)}try{(A=M==null?void 0:M.onHeartbeat)==null||A.call(M,F)}catch(z){console.warn("[useChatStreamingService] downstream onHeartbeat handler failed",z)}},onClosed:F=>{var X,$,R,J;const A=((X=p.current)==null?void 0:X.manualStop)??!1,z=f.current??(($=p.current)==null?void 0:$.threadIdGuess)??((R=F.lastStateHistory)==null?void 0:R.threadId)??null;(F.reason==="complete"||F.reason==="aborted"&&A)&&g(z);const _={...F,threadId:z,threadInfo:m.current,manualStop:A};try{i==null||i(_)}catch(G){console.warn("[useChatStreamingService] onStreamClosed handler failed",G)}try{(J=M==null?void 0:M.onClosed)==null||J.call(M,_)}catch(G){console.warn("[useChatStreamingService] downstream onClosed handler failed",G)}p.current&&(p.current=null)}})},[g,S,l,a,c,s,i,k]),D=b.useCallback(()=>{p.current&&(p.current.manualStop=!0),T()},[T]);return b.useMemo(()=>({startStream:j,stop:D,isStreaming:C,error:E,setAuthToken:N,replayBufferedEvents:w}),[j,D,C,E,N,w])}function Xg(){const e=b.useRef(new Map),t=b.useCallback((a,l)=>{const c=e.current.get(a),d=new Map;c&&c.forEach(f=>{d.set(`${f.checkpointId}::${f.checkpointNs}`,f)}),l.forEach(f=>{d.set(`${f.checkpointId}::${f.checkpointNs}`,f)}),e.current.set(a,Array.from(d.values()))},[]),n=b.useCallback((a,l)=>{const c=e.current.get(a);return c==null?void 0:c.find(d=>d.checkpointId===l)},[]),r=b.useCallback((a,l)=>{const c=e.current.get(a);return(c==null?void 0:c.some(d=>d.checkpointId===l))??!1},[]),o=b.useCallback(a=>e.current.get(a),[]),s=b.useCallback(a=>{e.current.delete(a)},[]),i=b.useCallback(()=>{e.current.clear()},[]);return{cache:e.current,setCacheForThread:t,getCachedMetadata:n,checkpointExists:r,getThreadMetadata:o,clearThreadCache:s,clearAllCache:i}}const sc=b.createContext(null),ic=b.createContext(null),ac=b.createContext(null);b.createContext(!1);function Jg({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,checkpointMetadataCache:l}){const{api:c,baseUrl:d}=ai(),f=b.useMemo(()=>Tn(d),[d]),[h,p]=b.useState([]),[m,x]=b.useState(t),[y,g]=b.useState(!1),[w,S]=b.useState(null),[k,T]=b.useState(!1),[C,E]=b.useState(null),{state:N,seed:j,prepend:D,pushUser:P,onEvent:M}=Xl(),[F,A]=b.useState(!1),[z,_]=b.useState(!1),[X,$]=b.useState(null),[R,J]=b.useState([]),[G,pe]=b.useState([]),[Ce,Ae]=b.useState(!1),q=b.useMemo(()=>R.flatMap(B=>B.messages??[]),[R]),ne=b.useMemo(()=>Gl(q),[q]),Y=l??Xg(),{setCacheForThread:L}=Y,H=b.useCallback((B,ee,ye)=>{const Ne=ee.filter(se=>se.checkpointId).map(se=>({checkpointId:se.checkpointId,checkpointNs:se.checkpointNs??void 0,createdAt:se.createdAt??""}));console.log(`[ChatSessionProvider] Cached metadata for ${Ne.length} checkpoints from ${ye}`),L(B,Ne)},[L]),V=b.useRef(m),ie=b.useRef(null),re=b.useRef(null),ze=b.useRef(null),We=b.useRef(null),Ze=b.useRef(!1),oe=b.useRef(null),me=b.useRef(new Map);b.useEffect(()=>{V.current=m},[m]);const Te=b.useCallback(async()=>{g(!0),S(null);try{const B=await c.listThreads();p(B??[])}catch(B){const ee=String(B);S(ee),s==null||s(ee)}finally{g(!1)}},[c,s]),Be=b.useCallback(B=>{if(!(B!=null&&B.threadId))return;const ee={threadId:B.threadId,title:B.title||`Thread ${B.threadId.slice(0,8)}`,createdAt:B.createdAt||new Date().toISOString(),updatedAt:B.updatedAt||new Date().toISOString(),messageCount:B.messageCount??1};p(ye=>ye.some(se=>se.threadId===ee.threadId)?(console.debug("[ChatSessionProvider] thread_info: thread already in list",ee.threadId),ye):(console.debug("[ChatSessionProvider] thread_info: adding thread to list",ee.threadId),[ee,...ye]))},[]),Je=b.useCallback(B=>{const ee=B.threadId??V.current;if(!ee||V.current&&V.current!==ee)return;const{checkpoints:ye,timeline:Ne}=ur(B);if(!ye.length)return;H(ee,ye,"stream state_history");const se=ye.find(_e=>_e.messages&&_e.messages.length>0)??ye.find(_e=>!!_e.checkpointId)??ye[0];j((se==null?void 0:se.messages)??[],{checkpointId:(se==null?void 0:se.checkpointId)??null,checkpointNs:(se==null?void 0:se.checkpointNs)??null}),pe(Ne),J(ye),A(!!(se!=null&&se.nextCursor)),$((se==null?void 0:se.nextCursor)??null);const Ge=`${ee}:${(se==null?void 0:se.checkpointId)??"latest"}`;oe.current=Ge},[H,j]),tt=b.useCallback(B=>{console.log("[ChatSessionProvider] 🎯 Received thread_info:",B.threadId),Be(B),V.current!==B.threadId&&(re.current=B.threadId,ze.current=B.threadId,console.log("[ChatSessionProvider] thread_info: marking to skip auto-load for new thread"),x(B.threadId))},[Be]),{startStream:$e,stop:He,isStreaming:Ve,error:nt,setAuthToken:kt}=Yg({baseUrl:f,onThreadInfo:tt,onMessageEvent:M,onStateHistory:Je,onUnhandledEvent:B=>{console.warn("[ChatSessionProvider] Unhandled event:",B.type)},onAuthError:i}),ft=b.useCallback(async B=>{try{const ee=await c.createThread(B);return x(ee.threadId),await Te(),ee.threadId}catch(ee){return s==null||s(String(ee)),null}},[c,Te,s]),mt=b.useCallback(async B=>{try{await c.deleteThread(B),V.current===B&&(x(null),j([],{})),await Te()}catch(ee){s==null||s(String(ee))}},[c,Te,j,s]),gt=b.useCallback(async(B,ee)=>{try{await c.updateThread(B,ee),await Te()}catch(ye){s==null||s(String(ye))}},[c,Te,s]),st=b.useCallback(async(B,ee)=>{if(!B)return;const ye=`${B}:${ee??"latest"}`,Ne=me.current.get(ye);if(Ne)return Ne;const se=(async()=>{const Ge=B;T(!0),E(null);try{const _e=await c.getStateHistory({threadId:Ge,checkpointId:ee||void 0});if(V.current!==Ge){console.log(`[ChatSessionProvider] Thread changed during load (was ${Ge}, now ${V.current}), discarding stale data`);return}const{checkpoints:Le,timeline:rn}=ur(_e);H(Ge,Le,`thread load (requested: ${ee})`);const yt=Le.find(jn=>jn.messages&&jn.messages.length>0)??(ee?Le.find(jn=>jn.checkpointId===ee):null)??Le[0];j((yt==null?void 0:yt.messages)??[],{checkpointId:(yt==null?void 0:yt.checkpointId)??null,checkpointNs:(yt==null?void 0:yt.checkpointNs)??null}),pe(rn),J(Le),A(!!(yt!=null&&yt.nextCursor)),$((yt==null?void 0:yt.nextCursor)??null)}catch(_e){if(V.current===Ge){const Le=String(_e);E(Le),s==null||s(Le)}}finally{T(!1)}})();me.current.set(ye,se);try{await se}finally{me.current.delete(ye)}return V.current===B&&(oe.current=ye),se},[c,j,s,H]),De=b.useCallback(async(B,ee)=>{We.current=B;try{await st(B,ee)}finally{We.current===B&&(We.current=null)}},[st]);b.useEffect(()=>{if(!o||!m||k||Ve)return;if(re.current===m){re.current=null;return}if(We.current===m){We.current=null,ie.current=m;return}if(ie.current===m)return;ie.current=m;const B=!Ze.current&&!!n&&m===t;let ee;B&&n?(ee=n,Ze.current=!0,console.log("[ChatSessionProvider] Loading thread with checkpoint:",ee,r?`(ns: ${r})`:"")):console.log("[ChatSessionProvider] Loading thread with latest checkpoint");const ye=`${m}:${ee??"latest"}`;oe.current!==ye&&De(m,ee)},[o,m,n,r,t,k,Ve,De]);const At=b.useCallback(async(B,ee)=>{const ye=V.current;if(!ye)return;const Ne=ye;Ae(!0);try{const se=await c.getStateHistory({threadId:Ne,checkpointId:B,checkpointNs:ee??void 0});if(V.current!==Ne){console.log(`[ChatSessionProvider] Thread changed during checkpoint navigation (was ${Ne}, now ${V.current}), discarding stale data`);return}const{checkpoints:Ge,timeline:_e}=ur(se);H(Ne,Ge,"checkpoint navigation");const Le=Ge.find(rn=>rn.checkpointId===B&&(ee?rn.checkpointNs===ee:!0));if(!Le){console.warn("[ChatSessionProvider] Requested checkpoint not found:",{checkpointId:B,checkpointNs:ee});return}pe(_e),J(Ge),j(Le.messages??[],{checkpointId:Le.checkpointId??null,checkpointNs:Le.checkpointNs??null})}catch(se){V.current===Ne&&(s==null||s(String(se)))}finally{Ae(!1)}},[c,j,s,H]),jt=b.useCallback((B,ee)=>{j(N.messages,{checkpointId:B??null,checkpointNs:ee??null})},[j,N.messages]),nn=b.useCallback(async()=>{V.current&&await De(V.current)},[De]),fn=b.useCallback(async()=>{if(!V.current||!X)return;const B=V.current;_(!0);try{const ee=await c.getStateHistory({threadId:B,checkpointId:X});if(V.current!==B){console.log(`[ChatSessionProvider] Thread changed during history load (was ${B}, now ${V.current}), discarding stale data`);return}const{checkpoints:ye}=ur(ee);if(ye.length>0){const Ne=ye[ye.length-1];D((Ne==null?void 0:Ne.messages)??[]),A(!!(Ne!=null&&Ne.nextCursor)),$((Ne==null?void 0:Ne.nextCursor)??null)}}catch(ee){V.current===B&&(s==null||s(String(ee)))}finally{_(!1)}},[c,X,D,s]),qe=b.useCallback(async()=>{j([],{}),x(null),He(),J([]),pe([]),A(!1),$(null),T(!1),Ae(!1),_(!1),E(null);try{await c.getAgent("default")}catch(B){console.warn("[ChatSessionProvider] Failed to refetch agent after clearing thread:",B)}},[j,He,c]),je=b.useCallback(async(B,ee,ye)=>{const Ne=V.current;if(!Ne)throw new Error("No active thread to handle interrupt");const se=ee?ye??!0:!1;try{const Ge={threadId:Ne,checkpointId:N.lastCheckpointId??void 0,checkpointNs:N.lastCheckpointNs??void 0,command:{kind:"resume",value:se}};$e(Ge)}catch(Ge){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${B}:`,Ge),Ge}},[N.lastCheckpointId,N.lastCheckpointNs,$e]);b.useEffect(()=>{Te()},[Te]),b.useEffect(()=>{a==null||a(m)},[m,a]);const Et=b.useCallback(async(B,ee)=>{let ye=V.current;const Ne=(B==null?void 0:B.text)??"";if(!ye&&!Ne)return;if(!ye&&Ne){const rn=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),yt=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);ye=`${rn}${yt}`,re.current=ye,x(ye)}const{contentParts:se}=await yg(c,(B==null?void 0:B.attachments)??[]),Ge=[...se];Ne!=null&&Ne.trim()&&Ge.push({type:"text",text:Ne});const _e={id:`msg-${Date.now()}`,role:"user",content:Ge,createdAt:new Date().toISOString()};P(_e);const Le={threadId:ye,payload:{messages:[_e]},checkpointId:(ee==null?void 0:ee.checkpointId)??N.lastCheckpointId??void 0,checkpointNs:(ee==null?void 0:ee.checkpointNs)??N.lastCheckpointNs??void 0};$e(Le)},[c,ft,P,N,$e]),Ht=b.useMemo(()=>({threads:h,currentThreadId:m,setCurrentThreadId:x,isLoading:y,error:w,actions:{createThread:ft,deleteThread:mt,renameThread:gt,refreshThreads:Te}}),[h,m,y,w,ft,mt,gt,Te]),U=b.useMemo(()=>({threadId:m,messages:N.messages,interrupt:null,checkpoint:{id:N.lastCheckpointId??null,namespace:N.lastCheckpointNs??null},checkpoints:R,timelineCheckpoints:G,metadata:null,isLoading:k,isHistoryLoading:z,isLoadingCheckpoint:Ce,error:C,hasMore:F,loadOlder:fn,clearState:qe,navigateToCheckpoint:At,setCurrentCheckpointId:jt,returnToLatest:nn,loadThread:De,clearThread:qe,respondToInterrupt:je,messagePreviews:ne}),[m,N,R,G,k,z,Ce,C,F,fn,qe,At,jt,nn,De,je,ne]),ve=b.useMemo(()=>({isStreaming:Ve,error:nt,connectionState:Ve?"connected":"idle",submit:Et,send:Et,stop:He,setAuthToken:kt}),[Ve,nt,Et,He,kt]);return u.jsx(sc.Provider,{value:Ht,children:u.jsx(ic.Provider,{value:U,children:u.jsx(ac.Provider,{value:ve,children:e})})})}function Ao(){const e=b.useContext(sc);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function jo(){const e=b.useContext(ic);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function lc(){const e=b.useContext(ac);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function _o({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onError:i,onAuthError:a,onThreadChange:l,checkpointMetadataCache:c}){return u.jsx(gg,{apiConfig:t,children:u.jsx(Jg,{initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:i,onAuthError:a,onThreadChange:l,checkpointMetadataCache:c,children:e})})}function te(...e){return Up.twMerge(Hp.clsx(e))}const Zg=fo.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"}}),rt=v.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Wn.Slot:"button";return u.jsx(i,{className:te(Zg({variant:t,size:n,className:e})),ref:s,...o})});rt.displayName="Button";const cc=v.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:te("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}));cc.displayName="Textarea";function uc({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:f="",textareaClassName:h="",allowEmptySend:p=!1}){const m=i!==void 0,[x,y]=b.useState(e),g=(m?i:x)??"",[w,S]=b.useTransition(),k=b.useRef(null),T=b.useRef(0),C=b.useRef(null);b.useEffect(()=>{m||(y(e??""),C.current=null,k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`))},[e,t,m]);const E=b.useCallback(()=>{const z=k.current;z&&(z.style.height="auto",z.style.height=`${z.scrollHeight}px`)},[]);b.useEffect(()=>{E()},[E,g]);const N=b.useCallback((z,{fromUser:_})=>{m||y(z),_&&(a==null||a(z))},[m,a]),j=b.useCallback(async z=>{z&&z.preventDefault();const _=(g??"").trim();if(!_&&!p)return;const X=++T.current;C.current={id:X,shouldClear:!0},S(()=>{var $,R,J;try{const G=l(_);G&&typeof G.then=="function"?G.then(()=>{var pe,Ce;((pe=C.current)==null?void 0:pe.id)===X&&C.current.shouldClear&&(m||(y(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((Ce=C.current)==null?void 0:Ce.id)===X&&(C.current=null)}).catch(()=>{var pe;((pe=C.current)==null?void 0:pe.id)===X&&(C.current=null)}):((($=C.current)==null?void 0:$.id)===X&&C.current.shouldClear&&(m||(y(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((R=C.current)==null?void 0:R.id)===X&&(C.current=null))}catch{((J=C.current)==null?void 0:J.id)===X&&(C.current=null)}})},[g,l,p,m,a]),D=b.useCallback(z=>{const _=z.target.value;N(_,{fromUser:!0}),C.current&&(C.current.shouldClear=!1),k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`)},[N]),P=b.useCallback(z=>{z.key==="Enter"&&!z.shiftKey?(z.preventDefault(),j()):z.key==="Escape"&&t&&(z.preventDefault(),c==null||c())},[j,t,c]),A=`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))]":""} ${h}`;return u.jsx("form",{onSubmit:z=>void j(z),className:`w-full ${f}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsx("div",{className:"flex-1",children:u.jsx(cc,{ref:k,value:g,onChange:D,onKeyDown:P,placeholder:t?"Edit your message...":n,className:A,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),u.jsx("div",{children:r?u.jsx(rt,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(ae.Square,{size:16})}):u.jsx(rt,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!g.trim()&&!p||w,children:u.jsx(ae.Send,{size:16})})})]})})}const Qg=b.memo(uc);function he(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function dc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function hi(...e){return t=>{let n=!1;const r=e.map(o=>{const s=dc(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():dc(e[o],null)}}}}function Ye(...e){return v.useCallback(hi(...e),e)}function ex(e,t){const n=v.createContext(t),r=s=>{const{children:i,...a}=s,l=v.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=v.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 kn(e,t=[]){let n=[];function r(s,i){const a=v.createContext(i),l=n.length;n=[...n,i];const c=f=>{var g;const{scope:h,children:p,...m}=f,x=((g=h==null?void 0:h[e])==null?void 0:g[l])||a,y=v.useMemo(()=>m,Object.values(m));return u.jsx(x.Provider,{value:y,children:p})};c.displayName=s+"Provider";function d(f,h){var x;const p=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,m=v.useContext(p);if(m)return m;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>v.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return v.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,tx(o,...t)]}function tx(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const f=l(s)[`__scope${c}`];return{...a,...f}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var It=globalThis!=null&&globalThis.document?v.useLayoutEffect:()=>{},nx=v[" useInsertionEffect ".trim().toString()]||It;function fr({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=rx({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=v.useRef(e!==void 0);v.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=v.useCallback(d=>{var f;if(a){const h=ox(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[l,c]}function rx({defaultProp:e,onChange:t}){const[n,r]=v.useState(e),o=v.useRef(n),s=v.useRef(t);return nx(()=>{s.current=t},[t]),v.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function ox(e){return typeof e=="function"}var sx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Pe=sx.reduce((e,t)=>{const n=Wn.createSlot(`Primitive.${t}`),r=v.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function fc(e,t){e&&ho.flushSync(()=>e.dispatchEvent(t))}function pi(e){const t=e+"CollectionProvider",[n,r]=kn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=x=>{const{scope:y,children:g}=x,w=b.useRef(null),S=b.useRef(new Map).current;return u.jsx(o,{scope:y,itemMap:S,collectionRef:w,children:g})};i.displayName=t;const a=e+"CollectionSlot",l=Wn.createSlot(a),c=b.forwardRef((x,y)=>{const{scope:g,children:w}=x,S=s(a,g),k=Ye(y,S.collectionRef);return u.jsx(l,{ref:k,children:w})});c.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=Wn.createSlot(d),p=b.forwardRef((x,y)=>{const{scope:g,children:w,...S}=x,k=b.useRef(null),T=Ye(y,k),C=s(d,g);return b.useEffect(()=>(C.itemMap.set(k,{ref:k,...S}),()=>void C.itemMap.delete(k))),u.jsx(h,{[f]:"",ref:T,children:w})});p.displayName=d;function m(x){const y=s(e+"CollectionConsumer",x);return b.useCallback(()=>{const w=y.collectionRef.current;if(!w)return[];const S=Array.from(w.querySelectorAll(`[${f}]`));return Array.from(y.itemMap.values()).sort((C,E)=>S.indexOf(C.ref.current)-S.indexOf(E.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:c,ItemSlot:p},m,r]}var ix=v.createContext(void 0);function Ro(e){const t=v.useContext(ix);return e||t||"ltr"}function Nt(e){const t=v.useRef(e);return v.useEffect(()=>{t.current=e}),v.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function ax(e,t=globalThis==null?void 0:globalThis.document){const n=Nt(e);v.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 lx="DismissableLayer",mi="dismissableLayer.update",cx="dismissableLayer.pointerDownOutside",ux="dismissableLayer.focusOutside",hc,pc=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Po=v.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=v.useContext(pc),[d,f]=v.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=v.useState({}),m=Ye(t,E=>f(E)),x=Array.from(c.layers),[y]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),g=x.indexOf(y),w=d?x.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=w>=g,T=hx(E=>{const N=E.target,j=[...c.branches].some(D=>D.contains(N));!k||j||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},h),C=px(E=>{const N=E.target;[...c.branches].some(D=>D.contains(N))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},h);return ax(E=>{w===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},h),v.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(hc=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),mc(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=hc)}},[d,h,n,c]),v.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),mc())},[d,c]),v.useEffect(()=>{const E=()=>p({});return document.addEventListener(mi,E),()=>document.removeEventListener(mi,E)},[]),u.jsx(Pe.div,{...l,ref:m,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:he(e.onFocusCapture,C.onFocusCapture),onBlurCapture:he(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:he(e.onPointerDownCapture,T.onPointerDownCapture)})});Po.displayName=lx;var dx="DismissableLayerBranch",fx=v.forwardRef((e,t)=>{const n=v.useContext(pc),r=v.useRef(null),o=Ye(t,r);return v.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(Pe.div,{...e,ref:o})});fx.displayName=dx;function hx(e,t=globalThis==null?void 0:globalThis.document){const n=Nt(e),r=v.useRef(!1),o=v.useRef(()=>{});return v.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){gc(cx,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function px(e,t=globalThis==null?void 0:globalThis.document){const n=Nt(e),r=v.useRef(!1);return v.useEffect(()=>{const o=s=>{s.target&&!r.current&&gc(ux,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 mc(){const e=new CustomEvent(mi);document.dispatchEvent(e)}function gc(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?fc(o,s):o.dispatchEvent(s)}var gi=0;function xi(){v.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??xc()),document.body.insertAdjacentElement("beforeend",e[1]??xc()),gi++,()=>{gi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),gi--}},[])}function xc(){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 yi="focusScope.autoFocusOnMount",vi="focusScope.autoFocusOnUnmount",yc={bubbles:!1,cancelable:!0},mx="FocusScope",Oo=v.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=v.useState(null),c=Nt(o),d=Nt(s),f=v.useRef(null),h=Ye(t,x=>l(x)),p=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(r){let x=function(S){if(p.paused||!a)return;const k=S.target;a.contains(k)?f.current=k:Rn(f.current,{select:!0})},y=function(S){if(p.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||Rn(f.current,{select:!0}))},g=function(S){if(document.activeElement===document.body)for(const T of S)T.removedNodes.length>0&&Rn(a)};document.addEventListener("focusin",x),document.addEventListener("focusout",y);const w=new MutationObserver(g);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",y),w.disconnect()}}},[r,a,p.paused]),v.useEffect(()=>{if(a){bc.add(p);const x=document.activeElement;if(!a.contains(x)){const g=new CustomEvent(yi,yc);a.addEventListener(yi,c),a.dispatchEvent(g),g.defaultPrevented||(gx(bx(vc(a)),{select:!0}),document.activeElement===x&&Rn(a))}return()=>{a.removeEventListener(yi,c),setTimeout(()=>{const g=new CustomEvent(vi,yc);a.addEventListener(vi,d),a.dispatchEvent(g),g.defaultPrevented||Rn(x??document.body,{select:!0}),a.removeEventListener(vi,d),bc.remove(p)},0)}}},[a,c,d,p]);const m=v.useCallback(x=>{if(!n&&!r||p.paused)return;const y=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,g=document.activeElement;if(y&&g){const w=x.currentTarget,[S,k]=xx(w);S&&k?!x.shiftKey&&g===k?(x.preventDefault(),n&&Rn(S,{select:!0})):x.shiftKey&&g===S&&(x.preventDefault(),n&&Rn(k,{select:!0})):g===w&&x.preventDefault()}},[n,r,p.paused]);return u.jsx(Pe.div,{tabIndex:-1,...i,ref:h,onKeyDown:m})});Oo.displayName=mx;function gx(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Rn(r,{select:t}),document.activeElement!==n)return}function xx(e){const t=vc(e),n=wc(t,e),r=wc(t.reverse(),e);return[n,r]}function vc(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 wc(e,t){for(const n of e)if(!yx(n,{upTo:t}))return n}function yx(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 vx(e){return e instanceof HTMLInputElement&&"select"in e}function Rn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&vx(e)&&t&&e.select()}}var bc=wx();function wx(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Sc(e,t),e.unshift(t)},remove(t){var n;e=Sc(e,t),(n=e[0])==null||n.resume()}}}function Sc(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function bx(e){return e.filter(t=>t.tagName!=="A")}var Sx=v[" useId ".trim().toString()]||(()=>{}),Cx=0;function En(e){const[t,n]=v.useState(Sx());return It(()=>{n(r=>r??String(Cx++))},[e]),t?`radix-${t}`:""}const Tx=["top","right","bottom","left"],Pn=Math.min,Ut=Math.max,Mo=Math.round,Do=Math.floor,mn=e=>({x:e,y:e}),kx={left:"right",right:"left",bottom:"top",top:"bottom"},Ex={start:"end",end:"start"};function wi(e,t,n){return Ut(e,Pn(t,n))}function In(e,t){return typeof e=="function"?e(t):e}function Nn(e){return e.split("-")[0]}function hr(e){return e.split("-")[1]}function bi(e){return e==="x"?"y":"x"}function Si(e){return e==="y"?"height":"width"}const Ix=new Set(["top","bottom"]);function gn(e){return Ix.has(Nn(e))?"y":"x"}function Ci(e){return bi(gn(e))}function Nx(e,t,n){n===void 0&&(n=!1);const r=hr(e),o=Ci(e),s=Si(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Lo(i)),[i,Lo(i)]}function Ax(e){const t=Lo(e);return[Ti(e),t,Ti(t)]}function Ti(e){return e.replace(/start|end/g,t=>Ex[t])}const Cc=["left","right"],Tc=["right","left"],jx=["top","bottom"],_x=["bottom","top"];function Rx(e,t,n){switch(e){case"top":case"bottom":return n?t?Tc:Cc:t?Cc:Tc;case"left":case"right":return t?jx:_x;default:return[]}}function Px(e,t,n,r){const o=hr(e);let s=Rx(Nn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ti)))),s}function Lo(e){return e.replace(/left|right|bottom|top/g,t=>kx[t])}function Ox(e){return{top:0,right:0,bottom:0,left:0,...e}}function kc(e){return typeof e!="number"?Ox(e):{top:e,right:e,bottom:e,left:e}}function $o(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 Ec(e,t,n){let{reference:r,floating:o}=e;const s=gn(t),i=Ci(t),a=Si(i),l=Nn(t),c=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(hr(t)){case"start":p[i]-=h*(n&&c?-1:1);break;case"end":p[i]+=h*(n&&c?-1:1);break}return p}const Mx=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=Ec(c,r,l),h=r,p={},m=0;for(let x=0;x<a.length;x++){const{name:y,fn:g}=a[x],{x:w,y:S,data:k,reset:T}=await g({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:c,platform:i,elements:{reference:e,floating:t}});d=w??d,f=S??f,p={...p,[y]:{...p[y],...k}},T&&m<=50&&(m++,typeof T=="object"&&(T.placement&&(h=T.placement),T.rects&&(c=T.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:d,y:f}=Ec(c,h,l)),x=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function Mr(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=In(t,e),m=kc(p),y=a[h?f==="floating"?"reference":"floating":f],g=$o(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(y)))==null||n?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),w=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),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},T=$o(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:S,strategy:l}):w);return{top:(g.top-T.top+m.top)/k.y,bottom:(T.bottom-g.bottom+m.bottom)/k.y,left:(g.left-T.left+m.left)/k.x,right:(T.right-g.right+m.right)/k.x}}const Dx=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=In(e,t)||{};if(c==null)return{};const f=kc(d),h={x:n,y:r},p=Ci(o),m=Si(p),x=await i.getDimensions(c),y=p==="y",g=y?"top":"left",w=y?"bottom":"right",S=y?"clientHeight":"clientWidth",k=s.reference[m]+s.reference[p]-h[p]-s.floating[m],T=h[p]-s.reference[p],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=C?C[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(C)))&&(E=a.floating[S]||s.floating[m]);const N=k/2-T/2,j=E/2-x[m]/2-1,D=Pn(f[g],j),P=Pn(f[w],j),M=D,F=E-x[m]-P,A=E/2-x[m]/2+N,z=wi(M,A,F),_=!l.arrow&&hr(o)!=null&&A!==z&&s.reference[m]/2-(A<M?D:P)-x[m]/2<0,X=_?A<M?A-M:A-F:0;return{[p]:h[p]+X,data:{[p]:z,centerOffset:A-z-X,..._&&{alignmentOffset:X}},reset:_}}}),Lx=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:x=!0,...y}=In(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const g=Nn(o),w=gn(a),S=Nn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),T=h||(S||!x?[Lo(a)]:Ax(a)),C=m!=="none";!h&&C&&T.push(...Px(a,x,m,k));const E=[a,...T],N=await Mr(t,y),j=[];let D=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&j.push(N[g]),f){const A=Nx(o,i,k);j.push(N[A[0]],N[A[1]])}if(D=[...D,{placement:o,overflows:j}],!j.every(A=>A<=0)){var P,M;const A=(((P=s.flip)==null?void 0:P.index)||0)+1,z=E[A];if(z&&(!(f==="alignment"?w!==gn(z):!1)||D.every($=>gn($.placement)===w?$.overflows[0]>0:!0)))return{data:{index:A,overflows:D},reset:{placement:z}};let _=(M=D.filter(X=>X.overflows[0]<=0).sort((X,$)=>X.overflows[1]-$.overflows[1])[0])==null?void 0:M.placement;if(!_)switch(p){case"bestFit":{var F;const X=(F=D.filter($=>{if(C){const R=gn($.placement);return R===w||R==="y"}return!0}).map($=>[$.placement,$.overflows.filter(R=>R>0).reduce((R,J)=>R+J,0)]).sort(($,R)=>$[1]-R[1])[0])==null?void 0:F[0];X&&(_=X);break}case"initialPlacement":_=a;break}if(o!==_)return{reset:{placement:_}}}return{}}}};function Ic(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Nc(e){return Tx.some(t=>e[t]>=0)}const $x=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=In(e,t);switch(r){case"referenceHidden":{const s=await Mr(t,{...o,elementContext:"reference"}),i=Ic(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Nc(i)}}}case"escaped":{const s=await Mr(t,{...o,altBoundary:!0}),i=Ic(s,n.floating);return{data:{escapedOffsets:i,escaped:Nc(i)}}}default:return{}}}}},Ac=new Set(["left","top"]);async function Fx(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Nn(n),a=hr(n),l=gn(n)==="y",c=Ac.has(i)?-1:1,d=s&&l?-1:1,f=In(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:m}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),l?{x:p*d,y:h*c}:{x:h*c,y:p*d}}const zx=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 Fx(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}}}}},Bx=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:y=>{let{x:g,y:w}=y;return{x:g,y:w}}},...l}=In(e,t),c={x:n,y:r},d=await Mr(t,l),f=gn(Nn(o)),h=bi(f);let p=c[h],m=c[f];if(s){const y=h==="y"?"top":"left",g=h==="y"?"bottom":"right",w=p+d[y],S=p-d[g];p=wi(w,p,S)}if(i){const y=f==="y"?"top":"left",g=f==="y"?"bottom":"right",w=m+d[y],S=m-d[g];m=wi(w,m,S)}const x=a.fn({...t,[h]:p,[f]:m});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[h]:s,[f]:i}}}}}},Hx=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=In(e,t),d={x:n,y:r},f=gn(o),h=bi(f);let p=d[h],m=d[f];const x=In(a,t),y=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]+y.mainAxis,T=s.reference[h]+s.reference[S]-y.mainAxis;p<k?p=k:p>T&&(p=T)}if(c){var g,w;const S=h==="y"?"width":"height",k=Ac.has(Nn(o)),T=s.reference[f]-s.floating[S]+(k&&((g=i.offset)==null?void 0:g[f])||0)+(k?0:y.crossAxis),C=s.reference[f]+s.reference[S]+(k?0:((w=i.offset)==null?void 0:w[f])||0)-(k?y.crossAxis:0);m<T?m=T:m>C&&(m=C)}return{[h]:p,[f]:m}}}},Ux=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=In(e,t),d=await Mr(t,c),f=Nn(o),h=hr(o),p=gn(o)==="y",{width:m,height:x}=s.floating;let y,g;f==="top"||f==="bottom"?(y=f,g=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(g=f,y=h==="end"?"top":"bottom");const w=x-d.top-d.bottom,S=m-d.left-d.right,k=Pn(x-d[y],w),T=Pn(m-d[g],S),C=!t.middlewareData.shift;let E=k,N=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),C&&!h){const D=Ut(d.left,0),P=Ut(d.right,0),M=Ut(d.top,0),F=Ut(d.bottom,0);p?N=m-2*(D!==0||P!==0?D+P:Ut(d.left,d.right)):E=x-2*(M!==0||F!==0?M+F:Ut(d.top,d.bottom))}await l({...t,availableWidth:N,availableHeight:E});const j=await i.getDimensions(a.floating);return m!==j.width||x!==j.height?{reset:{rects:!0}}:{}}}};function Fo(){return typeof window<"u"}function pr(e){return jc(e)?(e.nodeName||"").toLowerCase():"#document"}function Wt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function xn(e){var t;return(t=(jc(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function jc(e){return Fo()?e instanceof Node||e instanceof Wt(e).Node:!1}function sn(e){return Fo()?e instanceof Element||e instanceof Wt(e).Element:!1}function yn(e){return Fo()?e instanceof HTMLElement||e instanceof Wt(e).HTMLElement:!1}function _c(e){return!Fo()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Wt(e).ShadowRoot}const Wx=new Set(["inline","contents"]);function Dr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=an(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Wx.has(o)}const Vx=new Set(["table","td","th"]);function Kx(e){return Vx.has(pr(e))}const qx=[":popover-open",":modal"];function zo(e){return qx.some(t=>{try{return e.matches(t)}catch{return!1}})}const Gx=["transform","translate","scale","rotate","perspective"],Yx=["transform","translate","scale","rotate","perspective","filter"],Xx=["paint","layout","strict","content"];function ki(e){const t=Ei(),n=sn(e)?an(e):e;return Gx.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)||Yx.some(r=>(n.willChange||"").includes(r))||Xx.some(r=>(n.contain||"").includes(r))}function Jx(e){let t=On(e);for(;yn(t)&&!mr(t);){if(ki(t))return t;if(zo(t))return null;t=On(t)}return null}function Ei(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Zx=new Set(["html","body","#document"]);function mr(e){return Zx.has(pr(e))}function an(e){return Wt(e).getComputedStyle(e)}function Bo(e){return sn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function On(e){if(pr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||_c(e)&&e.host||xn(e);return _c(t)?t.host:t}function Rc(e){const t=On(e);return mr(t)?e.ownerDocument?e.ownerDocument.body:e.body:yn(t)&&Dr(t)?t:Rc(t)}function Lr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Rc(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Wt(o);if(s){const a=Ii(i);return t.concat(i,i.visualViewport||[],Dr(o)?o:[],a&&n?Lr(a):[])}return t.concat(o,Lr(o,[],n))}function Ii(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Pc(e){const t=an(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=yn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Mo(n)!==s||Mo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Ni(e){return sn(e)?e:e.contextElement}function gr(e){const t=Ni(e);if(!yn(t))return mn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Pc(t);let i=(s?Mo(n.width):n.width)/r,a=(s?Mo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Qx=mn(0);function Oc(e){const t=Wt(e);return!Ei()||!t.visualViewport?Qx:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function ey(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Wt(e)?!1:t}function Gn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Ni(e);let i=mn(1);t&&(r?sn(r)&&(i=gr(r)):i=gr(e));const a=ey(s,n,r)?Oc(s):mn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=Wt(s),p=r&&sn(r)?Wt(r):r;let m=h,x=Ii(m);for(;x&&r&&p!==m;){const y=gr(x),g=x.getBoundingClientRect(),w=an(x),S=g.left+(x.clientLeft+parseFloat(w.paddingLeft))*y.x,k=g.top+(x.clientTop+parseFloat(w.paddingTop))*y.y;l*=y.x,c*=y.y,d*=y.x,f*=y.y,l+=S,c+=k,m=Wt(x),x=Ii(m)}}return $o({width:d,height:f,x:l,y:c})}function Ho(e,t){const n=Bo(e).scrollLeft;return t?t.left+n:Gn(xn(e)).left+n}function Mc(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Ho(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function ty(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=xn(r),a=t?zo(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=mn(1);const d=mn(0),f=yn(r);if((f||!f&&!s)&&((pr(r)!=="body"||Dr(i))&&(l=Bo(r)),yn(r))){const p=Gn(r);c=gr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?Mc(i,l):mn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+h.x,y:n.y*c.y-l.scrollTop*c.y+d.y+h.y}}function ny(e){return Array.from(e.getClientRects())}function ry(e){const t=xn(e),n=Bo(e),r=e.ownerDocument.body,o=Ut(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Ut(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Ho(e);const a=-n.scrollTop;return an(r).direction==="rtl"&&(i+=Ut(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Dc=25;function oy(e,t){const n=Wt(e),r=xn(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=Ei();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=Ho(r);if(c<=0){const d=r.ownerDocument,f=d.body,h=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,m=Math.abs(r.clientWidth-f.clientWidth-p);m<=Dc&&(s-=m)}else c<=Dc&&(s+=c);return{width:s,height:i,x:a,y:l}}const sy=new Set(["absolute","fixed"]);function iy(e,t){const n=Gn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=yn(e)?gr(e):mn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function Lc(e,t,n){let r;if(t==="viewport")r=oy(e,n);else if(t==="document")r=ry(xn(e));else if(sn(t))r=iy(t,n);else{const o=Oc(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return $o(r)}function $c(e,t){const n=On(e);return n===t||!sn(n)||mr(n)?!1:an(n).position==="fixed"||$c(n,t)}function ay(e,t){const n=t.get(e);if(n)return n;let r=Lr(e,[],!1).filter(a=>sn(a)&&pr(a)!=="body"),o=null;const s=an(e).position==="fixed";let i=s?On(e):e;for(;sn(i)&&!mr(i);){const a=an(i),l=ki(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&sy.has(o.position)||Dr(i)&&!l&&$c(e,i))?r=r.filter(d=>d!==i):o=a,i=On(i)}return t.set(e,r),r}function ly(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?zo(t)?[]:ay(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const f=Lc(t,d,o);return c.top=Ut(f.top,c.top),c.right=Pn(f.right,c.right),c.bottom=Pn(f.bottom,c.bottom),c.left=Ut(f.left,c.left),c},Lc(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function cy(e){const{width:t,height:n}=Pc(e);return{width:t,height:n}}function uy(e,t,n){const r=yn(t),o=xn(t),s=n==="fixed",i=Gn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=mn(0);function c(){l.x=Ho(o)}if(r||!r&&!s)if((pr(t)!=="body"||Dr(o))&&(a=Bo(t)),r){const p=Gn(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?Mc(o,a):mn(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 Ai(e){return an(e).position==="static"}function Fc(e,t){if(!yn(e)||an(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return xn(e)===n&&(n=n.ownerDocument.body),n}function zc(e,t){const n=Wt(e);if(zo(e))return n;if(!yn(e)){let o=On(e);for(;o&&!mr(o);){if(sn(o)&&!Ai(o))return o;o=On(o)}return n}let r=Fc(e,t);for(;r&&Kx(r)&&Ai(r);)r=Fc(r,t);return r&&mr(r)&&Ai(r)&&!ki(r)?n:r||Jx(e)||n}const dy=async function(e){const t=this.getOffsetParent||zc,n=this.getDimensions,r=await n(e.floating);return{reference:uy(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function fy(e){return an(e).direction==="rtl"}const hy={convertOffsetParentRelativeRectToViewportRelativeRect:ty,getDocumentElement:xn,getClippingRect:ly,getOffsetParent:zc,getElementRects:dy,getClientRects:ny,getDimensions:cy,getScale:gr,isElement:sn,isRTL:fy};function Bc(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function py(e,t){let n=null,r;const o=xn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:f,width:h,height:p}=c;if(a||t(),!h||!p)return;const m=Do(f),x=Do(o.clientWidth-(d+h)),y=Do(o.clientHeight-(f+p)),g=Do(d),S={rootMargin:-m+"px "+-x+"px "+-y+"px "+-g+"px",threshold:Ut(0,Pn(1,l))||1};let k=!0;function T(C){const E=C[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!Bc(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(T,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(T,S)}n.observe(e)}return i(!0),s}function my(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=Ni(e),d=o||s?[...c?Lr(c):[],...Lr(t)]:[];d.forEach(g=>{o&&g.addEventListener("scroll",n,{passive:!0}),s&&g.addEventListener("resize",n)});const f=c&&a?py(c,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(g=>{let[w]=g;w&&w.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let m,x=l?Gn(e):null;l&&y();function y(){const g=Gn(e);x&&!Bc(x,g)&&n(),x=g,m=requestAnimationFrame(y)}return n(),()=>{var g;d.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),f==null||f(),(g=p)==null||g.disconnect(),p=null,l&&cancelAnimationFrame(m)}}const gy=zx,xy=Bx,yy=Lx,vy=Ux,wy=$x,Hc=Dx,by=Hx,Sy=(e,t,n)=>{const r=new Map,o={platform:hy,...n},s={...o.platform,_c:r};return Mx(e,t,{...o,platform:s})};var Cy=typeof document<"u",Ty=function(){},Uo=Cy?b.useLayoutEffect:Ty;function Wo(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(!Wo(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)&&!Wo(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Uc(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Wc(e,t){const n=Uc(e);return Math.round(t*n)/n}function ji(e){const t=v.useRef(e);return Uo(()=>{t.current=e}),t}function ky(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,f]=v.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=v.useState(r);Wo(h,r)||p(r);const[m,x]=v.useState(null),[y,g]=v.useState(null),w=v.useCallback($=>{$!==C.current&&(C.current=$,x($))},[]),S=v.useCallback($=>{$!==E.current&&(E.current=$,g($))},[]),k=s||m,T=i||y,C=v.useRef(null),E=v.useRef(null),N=v.useRef(d),j=l!=null,D=ji(l),P=ji(o),M=ji(c),F=v.useCallback(()=>{if(!C.current||!E.current)return;const $={placement:t,strategy:n,middleware:h};P.current&&($.platform=P.current),Sy(C.current,E.current,$).then(R=>{const J={...R,isPositioned:M.current!==!1};A.current&&!Wo(N.current,J)&&(N.current=J,ho.flushSync(()=>{f(J)}))})},[h,t,n,P,M]);Uo(()=>{c===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,f($=>({...$,isPositioned:!1})))},[c]);const A=v.useRef(!1);Uo(()=>(A.current=!0,()=>{A.current=!1}),[]),Uo(()=>{if(k&&(C.current=k),T&&(E.current=T),k&&T){if(D.current)return D.current(k,T,F);F()}},[k,T,F,D,j]);const z=v.useMemo(()=>({reference:C,floating:E,setReference:w,setFloating:S}),[w,S]),_=v.useMemo(()=>({reference:k,floating:T}),[k,T]),X=v.useMemo(()=>{const $={position:n,left:0,top:0};if(!_.floating)return $;const R=Wc(_.floating,d.x),J=Wc(_.floating,d.y);return a?{...$,transform:"translate("+R+"px, "+J+"px)",...Uc(_.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:R,top:J}},[n,a,_.floating,d.x,d.y]);return v.useMemo(()=>({...d,update:F,refs:z,elements:_,floatingStyles:X}),[d,F,z,_,X])}const Ey=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?Hc({element:r.current,padding:o}).fn(n):{}:r?Hc({element:r,padding:o}).fn(n):{}}}},Iy=(e,t)=>({...gy(e),options:[e,t]}),Ny=(e,t)=>({...xy(e),options:[e,t]}),Ay=(e,t)=>({...by(e),options:[e,t]}),jy=(e,t)=>({...yy(e),options:[e,t]}),_y=(e,t)=>({...vy(e),options:[e,t]}),Ry=(e,t)=>({...wy(e),options:[e,t]}),Py=(e,t)=>({...Ey(e),options:[e,t]});var Oy="Arrow",Vc=v.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(Pe.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u.jsx("polygon",{points:"0,0 30,0 15,10"})})});Vc.displayName=Oy;var My=Vc;function Kc(e){const[t,n]=v.useState(void 0);return It(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var _i="Popper",[qc,Vo]=kn(_i),[Dy,Gc]=qc(_i),Yc=e=>{const{__scopePopper:t,children:n}=e,[r,o]=v.useState(null);return u.jsx(Dy,{scope:t,anchor:r,onAnchorChange:o,children:n})};Yc.displayName=_i;var Xc="PopperAnchor",Jc=v.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Gc(Xc,n),i=v.useRef(null),a=Ye(t,i),l=v.useRef(null);return v.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(Pe.div,{...o,ref:a})});Jc.displayName=Xc;var Ri="PopperContent",[Ly,$y]=qc(Ri),Zc=v.forwardRef((e,t)=>{var Y,L,H,V,ie,re;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:m,...x}=e,y=Gc(Ri,n),[g,w]=v.useState(null),S=Ye(t,ze=>w(ze)),[k,T]=v.useState(null),C=Kc(k),E=(C==null?void 0:C.width)??0,N=(C==null?void 0:C.height)??0,j=r+(s!=="center"?"-"+s:""),D=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},P=Array.isArray(c)?c:[c],M=P.length>0,F={padding:D,boundary:P.filter(zy),altBoundary:M},{refs:A,floatingStyles:z,placement:_,isPositioned:X,middlewareData:$}=ky({strategy:"fixed",placement:j,whileElementsMounted:(...ze)=>my(...ze,{animationFrame:p==="always"}),elements:{reference:y.anchor},middleware:[Iy({mainAxis:o+N,alignmentAxis:i}),l&&Ny({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Ay():void 0,...F}),l&&jy({...F}),_y({...F,apply:({elements:ze,rects:We,availableWidth:Ze,availableHeight:oe})=>{const{width:me,height:Te}=We.reference,Be=ze.floating.style;Be.setProperty("--radix-popper-available-width",`${Ze}px`),Be.setProperty("--radix-popper-available-height",`${oe}px`),Be.setProperty("--radix-popper-anchor-width",`${me}px`),Be.setProperty("--radix-popper-anchor-height",`${Te}px`)}}),k&&Py({element:k,padding:a}),By({arrowWidth:E,arrowHeight:N}),h&&Ry({strategy:"referenceHidden",...F})]}),[R,J]=tu(_),G=Nt(m);It(()=>{X&&(G==null||G())},[X,G]);const pe=(Y=$.arrow)==null?void 0:Y.x,Ce=(L=$.arrow)==null?void 0:L.y,Ae=((H=$.arrow)==null?void 0:H.centerOffset)!==0,[q,ne]=v.useState();return It(()=>{g&&ne(window.getComputedStyle(g).zIndex)},[g]),u.jsx("div",{ref:A.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:X?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:q,"--radix-popper-transform-origin":[(V=$.transformOrigin)==null?void 0:V.x,(ie=$.transformOrigin)==null?void 0:ie.y].join(" "),...((re=$.hide)==null?void 0:re.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(Ly,{scope:n,placedSide:R,onArrowChange:T,arrowX:pe,arrowY:Ce,shouldHideArrow:Ae,children:u.jsx(Pe.div,{"data-side":R,"data-align":J,...x,ref:S,style:{...x.style,animation:X?void 0:"none"}})})})});Zc.displayName=Ri;var Qc="PopperArrow",Fy={top:"bottom",right:"left",bottom:"top",left:"right"},eu=v.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=$y(Qc,r),i=Fy[s.placedSide];return u.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:u.jsx(My,{...o,ref:n,style:{...o.style,display:"block"}})})});eu.displayName=Qc;function zy(e){return e!==null}var By=e=>({name:"transformOrigin",options:e,fn(t){var y,g,w;const{placement:n,rects:r,middlewareData:o}=t,i=((y=o.arrow)==null?void 0:y.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,d]=tu(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((g=o.arrow)==null?void 0:g.x)??0)+a/2,p=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let m="",x="";return c==="bottom"?(m=i?f:`${h}px`,x=`${-l}px`):c==="top"?(m=i?f:`${h}px`,x=`${r.floating.height+l}px`):c==="right"?(m=`${-l}px`,x=i?f:`${p}px`):c==="left"&&(m=`${r.floating.width+l}px`,x=i?f:`${p}px`),{data:{x:m,y:x}}}});function tu(e){const[t,n="center"]=e.split("-");return[t,n]}var nu=Yc,ru=Jc,ou=Zc,su=eu,Hy="Portal",Ko=v.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=v.useState(!1);It(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Ks.createPortal(u.jsx(Pe.div,{...r,ref:t}),i):null});Ko.displayName=Hy;function Uy(e,t){return v.useReducer((n,r)=>t[n][r]??n,e)}var Xt=e=>{const{present:t,children:n}=e,r=Wy(t),o=typeof n=="function"?n({present:r.isPresent}):v.Children.only(n),s=Ye(r.ref,Vy(o));return typeof n=="function"||r.isPresent?v.cloneElement(o,{ref:s}):null};Xt.displayName="Presence";function Wy(e){const[t,n]=v.useState(),r=v.useRef(null),o=v.useRef(e),s=v.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Uy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const c=qo(r.current);s.current=a==="mounted"?c:"none"},[a]),It(()=>{const c=r.current,d=o.current;if(d!==e){const h=s.current,p=qo(c);e?l("MOUNT"):p==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),It(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,f=p=>{const x=qo(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&x&&(l("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},h=p=>{p.target===t&&(s.current=qo(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:v.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function qo(e){return(e==null?void 0:e.animationName)||"none"}function Vy(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 Pi="rovingFocusGroup.onEntryFocus",Ky={bubbles:!1,cancelable:!0},$r="RovingFocusGroup",[Oi,iu,qy]=pi($r),[Gy,au]=kn($r,[qy]),[Yy,Xy]=Gy($r),lu=v.forwardRef((e,t)=>u.jsx(Oi.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Oi.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Jy,{...e,ref:t})})}));lu.displayName=$r;var Jy=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...f}=e,h=v.useRef(null),p=Ye(t,h),m=Ro(s),[x,y]=fr({prop:i,defaultProp:a??null,onChange:l,caller:$r}),[g,w]=v.useState(!1),S=Nt(c),k=iu(n),T=v.useRef(!1),[C,E]=v.useState(0);return v.useEffect(()=>{const N=h.current;if(N)return N.addEventListener(Pi,S),()=>N.removeEventListener(Pi,S)},[S]),u.jsx(Yy,{scope:n,orientation:r,dir:m,loop:o,currentTabStopId:x,onItemFocus:v.useCallback(N=>y(N),[y]),onItemShiftTab:v.useCallback(()=>w(!0),[]),onFocusableItemAdd:v.useCallback(()=>E(N=>N+1),[]),onFocusableItemRemove:v.useCallback(()=>E(N=>N-1),[]),children:u.jsx(Pe.div,{tabIndex:g||C===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:he(e.onMouseDown,()=>{T.current=!0}),onFocus:he(e.onFocus,N=>{const j=!T.current;if(N.target===N.currentTarget&&j&&!g){const D=new CustomEvent(Pi,Ky);if(N.currentTarget.dispatchEvent(D),!D.defaultPrevented){const P=k().filter(_=>_.focusable),M=P.find(_=>_.active),F=P.find(_=>_.id===x),z=[M,F,...P].filter(Boolean).map(_=>_.ref.current);du(z,d)}}T.current=!1}),onBlur:he(e.onBlur,()=>w(!1))})})}),cu="RovingFocusGroupItem",uu=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=En(),c=s||l,d=Xy(cu,n),f=d.currentTabStopId===c,h=iu(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:x}=d;return v.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),u.jsx(Oi.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(Pe.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:he(e.onMouseDown,y=>{r?d.onItemFocus(c):y.preventDefault()}),onFocus:he(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:he(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){d.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const g=ev(y,d.orientation,d.dir);if(g!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let S=h().filter(k=>k.focusable).map(k=>k.ref.current);if(g==="last")S.reverse();else if(g==="prev"||g==="next"){g==="prev"&&S.reverse();const k=S.indexOf(y.currentTarget);S=d.loop?tv(S,k+1):S.slice(k+1)}setTimeout(()=>du(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:x!=null}):i})})});uu.displayName=cu;var Zy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Qy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function ev(e,t,n){const r=Qy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Zy[r]}function du(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function tv(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var nv=lu,rv=uu,ov=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},xr=new WeakMap,Go=new WeakMap,Yo={},Mi=0,fu=function(e){return e&&(e.host||fu(e.parentNode))},sv=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=fu(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})},iv=function(e,t,n,r){var o=sv(t,Array.isArray(e)?e:[e]);Yo[n]||(Yo[n]=new WeakMap);var s=Yo[n],i=[],a=new Set,l=new Set(o),c=function(f){!f||a.has(f)||(a.add(f),c(f.parentNode))};o.forEach(c);var d=function(f){!f||l.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))d(h);else try{var p=h.getAttribute(r),m=p!==null&&p!=="false",x=(xr.get(h)||0)+1,y=(s.get(h)||0)+1;xr.set(h,x),s.set(h,y),i.push(h),x===1&&m&&Go.set(h,!0),y===1&&h.setAttribute(n,"true"),m||h.setAttribute(r,"true")}catch(g){console.error("aria-hidden: cannot operate on ",h,g)}})};return d(t),a.clear(),Mi++,function(){i.forEach(function(f){var h=xr.get(f)-1,p=s.get(f)-1;xr.set(f,h),s.set(f,p),h||(Go.has(f)||f.removeAttribute(r),Go.delete(f)),p||f.removeAttribute(n)}),Mi--,Mi||(xr=new WeakMap,xr=new WeakMap,Go=new WeakMap,Yo={})}},Di=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=ov(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),iv(r,o,n,"aria-hidden")):function(){return null}},vn=function(){return vn=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},vn.apply(this,arguments)};function hu(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 av(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 Xo="right-scroll-bar-position",Jo="width-before-scroll-bar",lv="with-scroll-bars-hidden",cv="--removed-body-scroll-bar-size";function Li(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function uv(e,t){var n=b.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var dv=typeof window<"u"?v.useLayoutEffect:v.useEffect,pu=new WeakMap;function fv(e,t){var n=uv(null,function(r){return e.forEach(function(o){return Li(o,r)})});return dv(function(){var r=pu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Li(a,null)}),s.forEach(function(a){o.has(a)||Li(a,i)})}pu.set(n,e)},[e]),n}function hv(e){return e}function pv(e,t){t===void 0&&(t=hv);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(d){i.push(d),c()},filter:function(d){return i=i.filter(d),n}}}};return o}function mv(e){e===void 0&&(e={});var t=pv(null);return t.options=vn({async:!0,ssr:!1},e),t}var mu=function(e){var t=e.sideCar,n=hu(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 v.createElement(r,vn({},n))};mu.isSideCarExport=!0;function gv(e,t){return e.useMedium(t),mu}var gu=mv(),$i=function(){},Zo=v.forwardRef(function(e,t){var n=v.useRef(null),r=v.useState({onScrollCapture:$i,onWheelCapture:$i,onTouchMoveCapture:$i}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,p=e.noRelative,m=e.noIsolation,x=e.inert,y=e.allowPinchZoom,g=e.as,w=g===void 0?"div":g,S=e.gapMode,k=hu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),T=h,C=fv([n,t]),E=vn(vn({},k),o);return v.createElement(v.Fragment,null,d&&v.createElement(T,{sideCar:gu,removeScrollBar:c,shards:f,noRelative:p,noIsolation:m,inert:x,setCallbacks:s,allowPinchZoom:!!y,lockRef:n,gapMode:S}),i?v.cloneElement(v.Children.only(a),vn(vn({},E),{ref:C})):v.createElement(w,vn({},E,{className:l,ref:C}),a))});Zo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Zo.classNames={fullWidth:Jo,zeroRight:Xo};var xv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function yv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=xv();return t&&e.setAttribute("nonce",t),e}function vv(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function wv(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var bv=function(){var e=0,t=null;return{add:function(n){e==0&&(t=yv())&&(vv(t,n),wv(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Sv=function(){var e=bv();return function(t,n){v.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},xu=function(){var e=Sv(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Cv={left:0,top:0,right:0,gap:0},Fi=function(e){return parseInt(e||"",10)||0},Tv=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[Fi(n),Fi(r),Fi(o)]},kv=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Cv;var t=Tv(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])}},Ev=xu(),yr="data-scroll-locked",Iv=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
39
39
|
.`.concat(lv,` {
|
|
40
40
|
overflow: hidden `).concat(r,`;
|
|
41
41
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
42
42
|
}
|
|
43
|
-
body[`).concat(
|
|
43
|
+
body[`).concat(yr,`] {
|
|
44
44
|
overflow: hidden `).concat(r,`;
|
|
45
45
|
overscroll-behavior: contain;
|
|
46
46
|
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
@@ -53,29 +53,29 @@ React keys must be passed directly to JSX without using spread:
|
|
|
53
53
|
`),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
.`).concat(
|
|
56
|
+
.`).concat(Xo,` {
|
|
57
57
|
right: `).concat(a,"px ").concat(r,`;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
.`).concat(
|
|
60
|
+
.`).concat(Jo,` {
|
|
61
61
|
margin-right: `).concat(a,"px ").concat(r,`;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
.`).concat(
|
|
64
|
+
.`).concat(Xo," .").concat(Xo,` {
|
|
65
65
|
right: 0 `).concat(r,`;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
.`).concat(
|
|
68
|
+
.`).concat(Jo," .").concat(Jo,` {
|
|
69
69
|
margin-right: 0 `).concat(r,`;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
body[`).concat(
|
|
72
|
+
body[`).concat(yr,`] {
|
|
73
73
|
`).concat(cv,": ").concat(a,`px;
|
|
74
74
|
}
|
|
75
|
-
`)},yu=function(){var e=parseInt(document.body.getAttribute(
|
|
75
|
+
`)},yu=function(){var e=parseInt(document.body.getAttribute(yr)||"0",10);return isFinite(e)?e:0},Nv=function(){v.useEffect(function(){return document.body.setAttribute(yr,(yu()+1).toString()),function(){var e=yu()-1;e<=0?document.body.removeAttribute(yr):document.body.setAttribute(yr,e.toString())}},[])},Av=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Nv();var s=v.useMemo(function(){return kv(o)},[o]);return v.createElement(Ev,{styles:Iv(s,!t,o,n?"":"!important")})},zi=!1;if(typeof window<"u")try{var Qo=Object.defineProperty({},"passive",{get:function(){return zi=!0,!0}});window.addEventListener("test",Qo,Qo),window.removeEventListener("test",Qo,Qo)}catch{zi=!1}var vr=zi?{passive:!1}:!1,jv=function(e){return e.tagName==="TEXTAREA"},vu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!jv(e)&&n[t]==="visible")},_v=function(e){return vu(e,"overflowY")},Rv=function(e){return vu(e,"overflowX")},wu=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=bu(e,r);if(o){var s=Su(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Pv=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Ov=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},bu=function(e,t){return e==="v"?_v(t):Rv(t)},Su=function(e,t){return e==="v"?Pv(t):Ov(t)},Mv=function(e,t){return e==="h"&&t==="rtl"?-1:1},Dv=function(e,t,n,r,o){var s=Mv(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,f=0,h=0;do{if(!a)break;var p=Su(e,a),m=p[0],x=p[1],y=p[2],g=x-y-s*m;(m||g)&&bu(e,a)&&(f+=g,h+=m);var w=a.parentNode;a=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(c=!0),c},es=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Cu=function(e){return[e.deltaX,e.deltaY]},Tu=function(e){return e&&"current"in e?e.current:e},Lv=function(e,t){return e[0]===t[0]&&e[1]===t[1]},$v=function(e){return`
|
|
76
76
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
77
77
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
78
|
-
`)},Fv=0,vr=[];function zv(e){var t=v.useRef([]),n=v.useRef([0,0]),r=v.useRef(),o=v.useState(Fv++)[0],s=v.useState(xu)[0],i=v.useRef(e);v.useEffect(function(){i.current=e},[e]),v.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var x=av([e.lockRef.current],(e.shards||[]).map(Tu),!0).filter(Boolean);return x.forEach(function(y){return y.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),x.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=v.useCallback(function(x,y){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var g=Qo(x),w=n.current,S="deltaX"in x?x.deltaX:w[0]-g[0],k="deltaY"in x?x.deltaY:w[1]-g[1],T,C=x.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in x&&E==="h"&&C.type==="range")return!1;var N=wu(E,C);if(!N)return!0;if(N?T=E:(T=E==="v"?"h":"v",N=wu(E,C)),!N)return!1;if(!r.current&&"changedTouches"in x&&(S||k)&&(r.current=T),!T)return!0;var j=r.current||T;return Dv(j,y,x,j==="h"?S:k)},[]),l=v.useCallback(function(x){var y=x;if(!(!vr.length||vr[vr.length-1]!==s)){var g="deltaY"in y?Cu(y):Qo(y),w=t.current.filter(function(T){return T.name===y.type&&(T.target===y.target||y.target===T.shadowParent)&&Lv(T.delta,g)})[0];if(w&&w.should){y.cancelable&&y.preventDefault();return}if(!w){var S=(i.current.shards||[]).map(Tu).filter(Boolean).filter(function(T){return T.contains(y.target)}),k=S.length>0?a(y,S[0]):!i.current.noIsolation;k&&y.cancelable&&y.preventDefault()}}},[]),c=v.useCallback(function(x,y,g,w){var S={name:x,delta:y,target:g,should:w,shadowParent:Bv(g)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=v.useCallback(function(x){n.current=Qo(x),r.current=void 0},[]),f=v.useCallback(function(x){c(x.type,Cu(x),x.target,a(x,e.lockRef.current))},[]),h=v.useCallback(function(x){c(x.type,Qo(x),x.target,a(x,e.lockRef.current))},[]);v.useEffect(function(){return vr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,yr),document.addEventListener("touchmove",l,yr),document.addEventListener("touchstart",d,yr),function(){vr=vr.filter(function(x){return x!==s}),document.removeEventListener("wheel",l,yr),document.removeEventListener("touchmove",l,yr),document.removeEventListener("touchstart",d,yr)}},[]);var p=e.removeScrollBar,m=e.inert;return v.createElement(v.Fragment,null,m?v.createElement(s,{styles:$v(o)}):null,p?v.createElement(Av,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Bv(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Hv=gv(gu,zv);var es=v.forwardRef(function(e,t){return v.createElement(Jo,yn({},e,{ref:t,sideCar:Hv}))});es.classNames=Jo.classNames;var Bi=["Enter"," "],Uv=["ArrowDown","PageUp","Home"],ku=["ArrowUp","PageDown","End"],Wv=[...Uv,...ku],Vv={ltr:[...Bi,"ArrowRight"],rtl:[...Bi,"ArrowLeft"]},Kv={ltr:["ArrowLeft"],rtl:["ArrowRight"]},$r="Menu",[Fr,qv,Gv]=pi($r),[Gn,Eu]=kn($r,[Gv,Wo,au]),ts=Wo(),Iu=au(),[Yv,Yn]=Gn($r),[Xv,zr]=Gn($r),Nu=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=ts(t),[l,c]=v.useState(null),d=v.useRef(!1),f=It(s),h=_o(o);return v.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},m=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),u.jsx(nu,{...a,children:u.jsx(Yv,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c,children:u.jsx(Xv,{scope:t,onClose:v.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};Nu.displayName=$r;var Jv="MenuAnchor",Hi=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ts(n);return u.jsx(ru,{...o,...r,ref:t})});Hi.displayName=Jv;var Ui="MenuPortal",[Zv,Au]=Gn(Ui,{forceMount:void 0}),ju=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Yn(Ui,t);return u.jsx(Zv,{scope:t,forceMount:n,children:u.jsx(Xt,{present:n||s.open,children:u.jsx(Vo,{asChild:!0,container:o,children:r})})})};ju.displayName=Ui;var Jt="MenuContent",[Qv,Wi]=Gn(Jt),_u=v.forwardRef((e,t)=>{const n=Au(Jt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Yn(Jt,e.__scopeMenu),i=zr(Jt,e.__scopeMenu);return u.jsx(Fr.Provider,{scope:e.__scopeMenu,children:u.jsx(Xt,{present:r||s.open,children:u.jsx(Fr.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(ew,{...o,ref:t}):u.jsx(tw,{...o,ref:t})})})})}),ew=v.forwardRef((e,t)=>{const n=Yn(Jt,e.__scopeMenu),r=v.useRef(null),o=We(t,r);return v.useEffect(()=>{const s=r.current;if(s)return Di(s)},[]),u.jsx(Vi,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:pe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),tw=v.forwardRef((e,t)=>{const n=Yn(Jt,e.__scopeMenu);return u.jsx(Vi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),nw=Un.createSlot("MenuContent.ScrollLock"),Vi=v.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:m,...x}=e,y=Yn(Jt,n),g=zr(Jt,n),w=ts(n),S=Iu(n),k=qv(n),[T,C]=v.useState(null),E=v.useRef(null),N=We(t,E,y.onContentChange),j=v.useRef(0),D=v.useRef(""),P=v.useRef(0),M=v.useRef(null),F=v.useRef("right"),A=v.useRef(0),z=m?es:v.Fragment,_=m?{as:nw,allowPinchZoom:!0}:void 0,J=R=>{var X,L;const Z=D.current+R,Y=k().filter(U=>!U.disabled),me=document.activeElement,Te=(X=Y.find(U=>U.ref.current===me))==null?void 0:X.textValue,je=Y.map(U=>U.textValue),G=pw(je,Z,Te),ne=(L=Y.find(U=>U.textValue===G))==null?void 0:L.ref.current;(function U(K){D.current=K,window.clearTimeout(j.current),K!==""&&(j.current=window.setTimeout(()=>U(""),1e3))})(Z),ne&&setTimeout(()=>ne.focus())};v.useEffect(()=>()=>window.clearTimeout(j.current),[]),xi();const $=v.useCallback(R=>{var Y,me;return F.current===((Y=M.current)==null?void 0:Y.side)&&gw(R,(me=M.current)==null?void 0:me.area)},[]);return u.jsx(Qv,{scope:n,searchRef:D,onItemEnter:v.useCallback(R=>{$(R)&&R.preventDefault()},[$]),onItemLeave:v.useCallback(R=>{var Z;$(R)||((Z=E.current)==null||Z.focus(),C(null))},[$]),onTriggerLeave:v.useCallback(R=>{$(R)&&R.preventDefault()},[$]),pointerGraceTimerRef:P,onPointerGraceIntentChange:v.useCallback(R=>{M.current=R},[]),children:u.jsx(z,{..._,children:u.jsx(Po,{asChild:!0,trapped:o,onMountAutoFocus:pe(s,R=>{var Z;R.preventDefault(),(Z=E.current)==null||Z.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Ro,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:u.jsx(nv,{asChild:!0,...S,dir:g.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:C,onEntryFocus:pe(l,R=>{g.isUsingKeyboardRef.current||R.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(ou,{role:"menu","aria-orientation":"vertical","data-state":Gu(y.open),"data-radix-menu-content":"",dir:g.dir,...w,...x,ref:N,style:{outline:"none",...x.style},onKeyDown:pe(x.onKeyDown,R=>{const Y=R.target.closest("[data-radix-menu-content]")===R.currentTarget,me=R.ctrlKey||R.altKey||R.metaKey,Te=R.key.length===1;Y&&(R.key==="Tab"&&R.preventDefault(),!me&&Te&&J(R.key));const je=E.current;if(R.target!==je||!Wv.includes(R.key))return;R.preventDefault();const ne=k().filter(X=>!X.disabled).map(X=>X.ref.current);ku.includes(R.key)&&ne.reverse(),fw(ne)}),onBlur:pe(e.onBlur,R=>{R.currentTarget.contains(R.target)||(window.clearTimeout(j.current),D.current="")}),onPointerMove:pe(e.onPointerMove,Hr(R=>{const Z=R.target,Y=A.current!==R.clientX;if(R.currentTarget.contains(Z)&&Y){const me=R.clientX>A.current?"right":"left";F.current=me,A.current=R.clientX}}))})})})})})})});_u.displayName=Jt;var rw="MenuGroup",Ki=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Re.div,{role:"group",...r,ref:t})});Ki.displayName=rw;var ow="MenuLabel",Ru=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Re.div,{...r,ref:t})});Ru.displayName=ow;var ns="MenuItem",Pu="menu.itemSelect",rs=v.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=v.useRef(null),i=zr(ns,e.__scopeMenu),a=Wi(ns,e.__scopeMenu),l=We(t,s),c=v.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(Pu,{bubbles:!0,cancelable:!0});f.addEventListener(Pu,p=>r==null?void 0:r(p),{once:!0}),fc(f,h),h.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(Ou,{...o,ref:l,disabled:n,onClick:pe(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),c.current=!0},onPointerUp:pe(e.onPointerUp,f=>{var h;c.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:pe(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||Bi.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});rs.displayName=ns;var Ou=v.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Wi(ns,n),a=Iu(n),l=v.useRef(null),c=We(t,l),[d,f]=v.useState(!1),[h,p]=v.useState("");return v.useEffect(()=>{const m=l.current;m&&p((m.textContent??"").trim())},[s.children]),u.jsx(Fr.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:u.jsx(rv,{asChild:!0,...a,focusable:!r,children:u.jsx(Re.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:pe(e.onPointerMove,Hr(m=>{r?i.onItemLeave(m):(i.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:pe(e.onPointerLeave,Hr(m=>i.onItemLeave(m))),onFocus:pe(e.onFocus,()=>f(!0)),onBlur:pe(e.onBlur,()=>f(!1))})})})}),sw="MenuCheckboxItem",Mu=v.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(zu,{scope:e.__scopeMenu,checked:n,children:u.jsx(rs,{role:"menuitemcheckbox","aria-checked":os(n)?"mixed":n,...o,ref:t,"data-state":Gi(n),onSelect:pe(o.onSelect,()=>r==null?void 0:r(os(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Mu.displayName=sw;var Du="MenuRadioGroup",[iw,aw]=Gn(Du,{value:void 0,onValueChange:()=>{}}),Lu=v.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=It(r);return u.jsx(iw,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Ki,{...o,ref:t})})});Lu.displayName=Du;var $u="MenuRadioItem",Fu=v.forwardRef((e,t)=>{const{value:n,...r}=e,o=aw($u,e.__scopeMenu),s=n===o.value;return u.jsx(zu,{scope:e.__scopeMenu,checked:s,children:u.jsx(rs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Gi(s),onSelect:pe(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Fu.displayName=$u;var qi="MenuItemIndicator",[zu,lw]=Gn(qi,{checked:!1}),Bu=v.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=lw(qi,n);return u.jsx(Xt,{present:r||os(s.checked)||s.checked===!0,children:u.jsx(Re.span,{...o,ref:t,"data-state":Gi(s.checked)})})});Bu.displayName=qi;var cw="MenuSeparator",Hu=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Re.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Hu.displayName=cw;var uw="MenuArrow",Uu=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ts(n);return u.jsx(su,{...o,...r,ref:t})});Uu.displayName=uw;var dw="MenuSub",[pT,Wu]=Gn(dw),Br="MenuSubTrigger",Vu=v.forwardRef((e,t)=>{const n=Yn(Br,e.__scopeMenu),r=zr(Br,e.__scopeMenu),o=Wu(Br,e.__scopeMenu),s=Wi(Br,e.__scopeMenu),i=v.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=v.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return v.useEffect(()=>d,[d]),v.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),u.jsx(Hi,{asChild:!0,...c,children:u.jsx(Ou,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Gu(n.open),...e,ref:hi(t,o.onTriggerChange),onClick:f=>{var h;(h=e.onClick)==null||h.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:pe(e.onPointerMove,Hr(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:pe(e.onPointerLeave,Hr(f=>{var p,m;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const x=(m=n.content)==null?void 0:m.dataset.side,y=x==="right",g=y?-5:5,w=h[y?"left":"right"],S=h[y?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+g,y:f.clientY},{x:w,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:w,y:h.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:pe(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||Vv[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});Vu.displayName=Br;var Ku="MenuSubContent",qu=v.forwardRef((e,t)=>{const n=Au(Jt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Yn(Jt,e.__scopeMenu),i=zr(Jt,e.__scopeMenu),a=Wu(Ku,e.__scopeMenu),l=v.useRef(null),c=We(t,l);return u.jsx(Fr.Provider,{scope:e.__scopeMenu,children:u.jsx(Xt,{present:r||s.open,children:u.jsx(Fr.Slot,{scope:e.__scopeMenu,children:u.jsx(Vi,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:pe(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:pe(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:pe(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=Kv[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});qu.displayName=Ku;function Gu(e){return e?"open":"closed"}function os(e){return e==="indeterminate"}function Gi(e){return os(e)?"indeterminate":e?"checked":"unchecked"}function fw(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function hw(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function pw(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=hw(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function mw(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,f=l.x,h=l.y;d>r!=h>r&&n<(f-c)*(r-d)/(h-d)+c&&(o=!o)}return o}function gw(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return mw(n,t)}function Hr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var xw=Nu,yw=Hi,vw=ju,ww=_u,bw=Ki,Sw=Ru,Cw=rs,Tw=Mu,kw=Lu,Ew=Fu,Iw=Bu,Nw=Hu,Aw=Uu,jw=Vu,_w=qu,ss="DropdownMenu",[Rw,mT]=kn(ss,[Eu]),Dt=Eu(),[Pw,Yu]=Rw(ss),Xu=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Dt(t),c=v.useRef(null),[d,f]=dr({prop:o,defaultProp:s??!1,onChange:i,caller:ss});return u.jsx(Pw,{scope:t,triggerId:En(),triggerRef:c,contentId:En(),open:d,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(h=>!h),[f]),modal:a,children:u.jsx(xw,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Xu.displayName=ss;var Ju="DropdownMenuTrigger",Zu=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Yu(Ju,n),i=Dt(n);return u.jsx(yw,{asChild:!0,...i,children:u.jsx(Re.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:hi(t,s.triggerRef),onPointerDown:pe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:pe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Zu.displayName=Ju;var Ow="DropdownMenuPortal",Qu=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Dt(t);return u.jsx(vw,{...r,...n})};Qu.displayName=Ow;var ed="DropdownMenuContent",td=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Yu(ed,n),s=Dt(n),i=v.useRef(!1);return u.jsx(ww,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:pe(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:pe(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});td.displayName=ed;var Mw="DropdownMenuGroup",Dw=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(bw,{...o,...r,ref:t})});Dw.displayName=Mw;var Lw="DropdownMenuLabel",nd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Sw,{...o,...r,ref:t})});nd.displayName=Lw;var $w="DropdownMenuItem",rd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Cw,{...o,...r,ref:t})});rd.displayName=$w;var Fw="DropdownMenuCheckboxItem",od=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Tw,{...o,...r,ref:t})});od.displayName=Fw;var zw="DropdownMenuRadioGroup",Bw=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(kw,{...o,...r,ref:t})});Bw.displayName=zw;var Hw="DropdownMenuRadioItem",sd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Ew,{...o,...r,ref:t})});sd.displayName=Hw;var Uw="DropdownMenuItemIndicator",id=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Iw,{...o,...r,ref:t})});id.displayName=Uw;var Ww="DropdownMenuSeparator",ad=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Nw,{...o,...r,ref:t})});ad.displayName=Ww;var Vw="DropdownMenuArrow",Kw=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Aw,{...o,...r,ref:t})});Kw.displayName=Vw;var qw="DropdownMenuSubTrigger",ld=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(jw,{...o,...r,ref:t})});ld.displayName=qw;var Gw="DropdownMenuSubContent",cd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(_w,{...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)"}})});cd.displayName=Gw;var Yw=Xu,Xw=Zu,Jw=Qu,ud=td,dd=nd,fd=rd,hd=od,pd=sd,md=id,gd=ad,xd=ld,yd=cd;const Zw=Yw,Qw=Xw,eb=v.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(xd,{ref:o,className:te("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,u.jsx(ie.ChevronRight,{className:"ml-auto h-4 w-4"})]}));eb.displayName=xd.displayName;const tb=v.forwardRef(({className:e,...t},n)=>u.jsx(yd,{ref:n,className:te("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}));tb.displayName=yd.displayName;const vd=v.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Jw,{children:u.jsx(ud,{ref:r,sideOffset:t,className:te("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})}));vd.displayName=ud.displayName;const Yi=v.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(fd,{ref:r,className:te("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}));Yi.displayName=fd.displayName;const nb=v.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(hd,{ref:o,className:te("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(md,{children:u.jsx(ie.Check,{className:"h-4 w-4"})})}),t]}));nb.displayName=hd.displayName;const rb=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(pd,{ref:r,className:te("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(md,{children:u.jsx(ie.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));rb.displayName=pd.displayName;const ob=v.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(dd,{ref:r,className:te("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));ob.displayName=dd.displayName;const sb=v.forwardRef(({className:e,...t},n)=>u.jsx(gd,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));sb.displayName=gd.displayName;const is=1e4;function ib(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,`
|
|
78
|
+
`)},Fv=0,wr=[];function zv(e){var t=v.useRef([]),n=v.useRef([0,0]),r=v.useRef(),o=v.useState(Fv++)[0],s=v.useState(xu)[0],i=v.useRef(e);v.useEffect(function(){i.current=e},[e]),v.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var x=av([e.lockRef.current],(e.shards||[]).map(Tu),!0).filter(Boolean);return x.forEach(function(y){return y.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),x.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=v.useCallback(function(x,y){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var g=es(x),w=n.current,S="deltaX"in x?x.deltaX:w[0]-g[0],k="deltaY"in x?x.deltaY:w[1]-g[1],T,C=x.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in x&&E==="h"&&C.type==="range")return!1;var N=wu(E,C);if(!N)return!0;if(N?T=E:(T=E==="v"?"h":"v",N=wu(E,C)),!N)return!1;if(!r.current&&"changedTouches"in x&&(S||k)&&(r.current=T),!T)return!0;var j=r.current||T;return Dv(j,y,x,j==="h"?S:k)},[]),l=v.useCallback(function(x){var y=x;if(!(!wr.length||wr[wr.length-1]!==s)){var g="deltaY"in y?Cu(y):es(y),w=t.current.filter(function(T){return T.name===y.type&&(T.target===y.target||y.target===T.shadowParent)&&Lv(T.delta,g)})[0];if(w&&w.should){y.cancelable&&y.preventDefault();return}if(!w){var S=(i.current.shards||[]).map(Tu).filter(Boolean).filter(function(T){return T.contains(y.target)}),k=S.length>0?a(y,S[0]):!i.current.noIsolation;k&&y.cancelable&&y.preventDefault()}}},[]),c=v.useCallback(function(x,y,g,w){var S={name:x,delta:y,target:g,should:w,shadowParent:Bv(g)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=v.useCallback(function(x){n.current=es(x),r.current=void 0},[]),f=v.useCallback(function(x){c(x.type,Cu(x),x.target,a(x,e.lockRef.current))},[]),h=v.useCallback(function(x){c(x.type,es(x),x.target,a(x,e.lockRef.current))},[]);v.useEffect(function(){return wr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,vr),document.addEventListener("touchmove",l,vr),document.addEventListener("touchstart",d,vr),function(){wr=wr.filter(function(x){return x!==s}),document.removeEventListener("wheel",l,vr),document.removeEventListener("touchmove",l,vr),document.removeEventListener("touchstart",d,vr)}},[]);var p=e.removeScrollBar,m=e.inert;return v.createElement(v.Fragment,null,m?v.createElement(s,{styles:$v(o)}):null,p?v.createElement(Av,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Bv(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Hv=gv(gu,zv);var ts=v.forwardRef(function(e,t){return v.createElement(Zo,vn({},e,{ref:t,sideCar:Hv}))});ts.classNames=Zo.classNames;var Bi=["Enter"," "],Uv=["ArrowDown","PageUp","Home"],ku=["ArrowUp","PageDown","End"],Wv=[...Uv,...ku],Vv={ltr:[...Bi,"ArrowRight"],rtl:[...Bi,"ArrowLeft"]},Kv={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Fr="Menu",[zr,qv,Gv]=pi(Fr),[Yn,Eu]=kn(Fr,[Gv,Vo,au]),ns=Vo(),Iu=au(),[Yv,Xn]=Yn(Fr),[Xv,Br]=Yn(Fr),Nu=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=ns(t),[l,c]=v.useState(null),d=v.useRef(!1),f=Nt(s),h=Ro(o);return v.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},m=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),u.jsx(nu,{...a,children:u.jsx(Yv,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c,children:u.jsx(Xv,{scope:t,onClose:v.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};Nu.displayName=Fr;var Jv="MenuAnchor",Hi=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ns(n);return u.jsx(ru,{...o,...r,ref:t})});Hi.displayName=Jv;var Ui="MenuPortal",[Zv,Au]=Yn(Ui,{forceMount:void 0}),ju=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Xn(Ui,t);return u.jsx(Zv,{scope:t,forceMount:n,children:u.jsx(Xt,{present:n||s.open,children:u.jsx(Ko,{asChild:!0,container:o,children:r})})})};ju.displayName=Ui;var Jt="MenuContent",[Qv,Wi]=Yn(Jt),_u=v.forwardRef((e,t)=>{const n=Au(Jt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Xn(Jt,e.__scopeMenu),i=Br(Jt,e.__scopeMenu);return u.jsx(zr.Provider,{scope:e.__scopeMenu,children:u.jsx(Xt,{present:r||s.open,children:u.jsx(zr.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(ew,{...o,ref:t}):u.jsx(tw,{...o,ref:t})})})})}),ew=v.forwardRef((e,t)=>{const n=Xn(Jt,e.__scopeMenu),r=v.useRef(null),o=Ye(t,r);return v.useEffect(()=>{const s=r.current;if(s)return Di(s)},[]),u.jsx(Vi,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:he(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),tw=v.forwardRef((e,t)=>{const n=Xn(Jt,e.__scopeMenu);return u.jsx(Vi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),nw=Wn.createSlot("MenuContent.ScrollLock"),Vi=v.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:m,...x}=e,y=Xn(Jt,n),g=Br(Jt,n),w=ns(n),S=Iu(n),k=qv(n),[T,C]=v.useState(null),E=v.useRef(null),N=Ye(t,E,y.onContentChange),j=v.useRef(0),D=v.useRef(""),P=v.useRef(0),M=v.useRef(null),F=v.useRef("right"),A=v.useRef(0),z=m?ts:v.Fragment,_=m?{as:nw,allowPinchZoom:!0}:void 0,X=R=>{var Y,L;const J=D.current+R,G=k().filter(H=>!H.disabled),pe=document.activeElement,Ce=(Y=G.find(H=>H.ref.current===pe))==null?void 0:Y.textValue,Ae=G.map(H=>H.textValue),q=pw(Ae,J,Ce),ne=(L=G.find(H=>H.textValue===q))==null?void 0:L.ref.current;(function H(V){D.current=V,window.clearTimeout(j.current),V!==""&&(j.current=window.setTimeout(()=>H(""),1e3))})(J),ne&&setTimeout(()=>ne.focus())};v.useEffect(()=>()=>window.clearTimeout(j.current),[]),xi();const $=v.useCallback(R=>{var G,pe;return F.current===((G=M.current)==null?void 0:G.side)&&gw(R,(pe=M.current)==null?void 0:pe.area)},[]);return u.jsx(Qv,{scope:n,searchRef:D,onItemEnter:v.useCallback(R=>{$(R)&&R.preventDefault()},[$]),onItemLeave:v.useCallback(R=>{var J;$(R)||((J=E.current)==null||J.focus(),C(null))},[$]),onTriggerLeave:v.useCallback(R=>{$(R)&&R.preventDefault()},[$]),pointerGraceTimerRef:P,onPointerGraceIntentChange:v.useCallback(R=>{M.current=R},[]),children:u.jsx(z,{..._,children:u.jsx(Oo,{asChild:!0,trapped:o,onMountAutoFocus:he(s,R=>{var J;R.preventDefault(),(J=E.current)==null||J.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Po,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:u.jsx(nv,{asChild:!0,...S,dir:g.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:C,onEntryFocus:he(l,R=>{g.isUsingKeyboardRef.current||R.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(ou,{role:"menu","aria-orientation":"vertical","data-state":Gu(y.open),"data-radix-menu-content":"",dir:g.dir,...w,...x,ref:N,style:{outline:"none",...x.style},onKeyDown:he(x.onKeyDown,R=>{const G=R.target.closest("[data-radix-menu-content]")===R.currentTarget,pe=R.ctrlKey||R.altKey||R.metaKey,Ce=R.key.length===1;G&&(R.key==="Tab"&&R.preventDefault(),!pe&&Ce&&X(R.key));const Ae=E.current;if(R.target!==Ae||!Wv.includes(R.key))return;R.preventDefault();const ne=k().filter(Y=>!Y.disabled).map(Y=>Y.ref.current);ku.includes(R.key)&&ne.reverse(),fw(ne)}),onBlur:he(e.onBlur,R=>{R.currentTarget.contains(R.target)||(window.clearTimeout(j.current),D.current="")}),onPointerMove:he(e.onPointerMove,Ur(R=>{const J=R.target,G=A.current!==R.clientX;if(R.currentTarget.contains(J)&&G){const pe=R.clientX>A.current?"right":"left";F.current=pe,A.current=R.clientX}}))})})})})})})});_u.displayName=Jt;var rw="MenuGroup",Ki=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Pe.div,{role:"group",...r,ref:t})});Ki.displayName=rw;var ow="MenuLabel",Ru=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Pe.div,{...r,ref:t})});Ru.displayName=ow;var rs="MenuItem",Pu="menu.itemSelect",os=v.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=v.useRef(null),i=Br(rs,e.__scopeMenu),a=Wi(rs,e.__scopeMenu),l=Ye(t,s),c=v.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(Pu,{bubbles:!0,cancelable:!0});f.addEventListener(Pu,p=>r==null?void 0:r(p),{once:!0}),fc(f,h),h.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(Ou,{...o,ref:l,disabled:n,onClick:he(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),c.current=!0},onPointerUp:he(e.onPointerUp,f=>{var h;c.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:he(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||Bi.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});os.displayName=rs;var Ou=v.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Wi(rs,n),a=Iu(n),l=v.useRef(null),c=Ye(t,l),[d,f]=v.useState(!1),[h,p]=v.useState("");return v.useEffect(()=>{const m=l.current;m&&p((m.textContent??"").trim())},[s.children]),u.jsx(zr.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:u.jsx(rv,{asChild:!0,...a,focusable:!r,children:u.jsx(Pe.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:he(e.onPointerMove,Ur(m=>{r?i.onItemLeave(m):(i.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:he(e.onPointerLeave,Ur(m=>i.onItemLeave(m))),onFocus:he(e.onFocus,()=>f(!0)),onBlur:he(e.onBlur,()=>f(!1))})})})}),sw="MenuCheckboxItem",Mu=v.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(zu,{scope:e.__scopeMenu,checked:n,children:u.jsx(os,{role:"menuitemcheckbox","aria-checked":ss(n)?"mixed":n,...o,ref:t,"data-state":Gi(n),onSelect:he(o.onSelect,()=>r==null?void 0:r(ss(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Mu.displayName=sw;var Du="MenuRadioGroup",[iw,aw]=Yn(Du,{value:void 0,onValueChange:()=>{}}),Lu=v.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Nt(r);return u.jsx(iw,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Ki,{...o,ref:t})})});Lu.displayName=Du;var $u="MenuRadioItem",Fu=v.forwardRef((e,t)=>{const{value:n,...r}=e,o=aw($u,e.__scopeMenu),s=n===o.value;return u.jsx(zu,{scope:e.__scopeMenu,checked:s,children:u.jsx(os,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Gi(s),onSelect:he(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Fu.displayName=$u;var qi="MenuItemIndicator",[zu,lw]=Yn(qi,{checked:!1}),Bu=v.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=lw(qi,n);return u.jsx(Xt,{present:r||ss(s.checked)||s.checked===!0,children:u.jsx(Pe.span,{...o,ref:t,"data-state":Gi(s.checked)})})});Bu.displayName=qi;var cw="MenuSeparator",Hu=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Pe.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Hu.displayName=cw;var uw="MenuArrow",Uu=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ns(n);return u.jsx(su,{...o,...r,ref:t})});Uu.displayName=uw;var dw="MenuSub",[pT,Wu]=Yn(dw),Hr="MenuSubTrigger",Vu=v.forwardRef((e,t)=>{const n=Xn(Hr,e.__scopeMenu),r=Br(Hr,e.__scopeMenu),o=Wu(Hr,e.__scopeMenu),s=Wi(Hr,e.__scopeMenu),i=v.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=v.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return v.useEffect(()=>d,[d]),v.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),u.jsx(Hi,{asChild:!0,...c,children:u.jsx(Ou,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Gu(n.open),...e,ref:hi(t,o.onTriggerChange),onClick:f=>{var h;(h=e.onClick)==null||h.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:he(e.onPointerMove,Ur(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:he(e.onPointerLeave,Ur(f=>{var p,m;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const x=(m=n.content)==null?void 0:m.dataset.side,y=x==="right",g=y?-5:5,w=h[y?"left":"right"],S=h[y?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+g,y:f.clientY},{x:w,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:w,y:h.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:he(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||Vv[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});Vu.displayName=Hr;var Ku="MenuSubContent",qu=v.forwardRef((e,t)=>{const n=Au(Jt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Xn(Jt,e.__scopeMenu),i=Br(Jt,e.__scopeMenu),a=Wu(Ku,e.__scopeMenu),l=v.useRef(null),c=Ye(t,l);return u.jsx(zr.Provider,{scope:e.__scopeMenu,children:u.jsx(Xt,{present:r||s.open,children:u.jsx(zr.Slot,{scope:e.__scopeMenu,children:u.jsx(Vi,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:he(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:he(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:he(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=Kv[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});qu.displayName=Ku;function Gu(e){return e?"open":"closed"}function ss(e){return e==="indeterminate"}function Gi(e){return ss(e)?"indeterminate":e?"checked":"unchecked"}function fw(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function hw(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function pw(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=hw(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function mw(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,f=l.x,h=l.y;d>r!=h>r&&n<(f-c)*(r-d)/(h-d)+c&&(o=!o)}return o}function gw(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return mw(n,t)}function Ur(e){return t=>t.pointerType==="mouse"?e(t):void 0}var xw=Nu,yw=Hi,vw=ju,ww=_u,bw=Ki,Sw=Ru,Cw=os,Tw=Mu,kw=Lu,Ew=Fu,Iw=Bu,Nw=Hu,Aw=Uu,jw=Vu,_w=qu,is="DropdownMenu",[Rw,mT]=kn(is,[Eu]),Dt=Eu(),[Pw,Yu]=Rw(is),Xu=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Dt(t),c=v.useRef(null),[d,f]=fr({prop:o,defaultProp:s??!1,onChange:i,caller:is});return u.jsx(Pw,{scope:t,triggerId:En(),triggerRef:c,contentId:En(),open:d,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(h=>!h),[f]),modal:a,children:u.jsx(xw,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Xu.displayName=is;var Ju="DropdownMenuTrigger",Zu=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Yu(Ju,n),i=Dt(n);return u.jsx(yw,{asChild:!0,...i,children:u.jsx(Pe.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:hi(t,s.triggerRef),onPointerDown:he(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:he(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Zu.displayName=Ju;var Ow="DropdownMenuPortal",Qu=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Dt(t);return u.jsx(vw,{...r,...n})};Qu.displayName=Ow;var ed="DropdownMenuContent",td=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Yu(ed,n),s=Dt(n),i=v.useRef(!1);return u.jsx(ww,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:he(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:he(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});td.displayName=ed;var Mw="DropdownMenuGroup",Dw=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(bw,{...o,...r,ref:t})});Dw.displayName=Mw;var Lw="DropdownMenuLabel",nd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Sw,{...o,...r,ref:t})});nd.displayName=Lw;var $w="DropdownMenuItem",rd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Cw,{...o,...r,ref:t})});rd.displayName=$w;var Fw="DropdownMenuCheckboxItem",od=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Tw,{...o,...r,ref:t})});od.displayName=Fw;var zw="DropdownMenuRadioGroup",Bw=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(kw,{...o,...r,ref:t})});Bw.displayName=zw;var Hw="DropdownMenuRadioItem",sd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Ew,{...o,...r,ref:t})});sd.displayName=Hw;var Uw="DropdownMenuItemIndicator",id=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Iw,{...o,...r,ref:t})});id.displayName=Uw;var Ww="DropdownMenuSeparator",ad=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Nw,{...o,...r,ref:t})});ad.displayName=Ww;var Vw="DropdownMenuArrow",Kw=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Aw,{...o,...r,ref:t})});Kw.displayName=Vw;var qw="DropdownMenuSubTrigger",ld=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(jw,{...o,...r,ref:t})});ld.displayName=qw;var Gw="DropdownMenuSubContent",cd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(_w,{...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)"}})});cd.displayName=Gw;var Yw=Xu,Xw=Zu,Jw=Qu,ud=td,dd=nd,fd=rd,hd=od,pd=sd,md=id,gd=ad,xd=ld,yd=cd;const Zw=Yw,Qw=Xw,eb=v.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(xd,{ref:o,className:te("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,u.jsx(ae.ChevronRight,{className:"ml-auto h-4 w-4"})]}));eb.displayName=xd.displayName;const tb=v.forwardRef(({className:e,...t},n)=>u.jsx(yd,{ref:n,className:te("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}));tb.displayName=yd.displayName;const vd=v.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Jw,{children:u.jsx(ud,{ref:r,sideOffset:t,className:te("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})}));vd.displayName=ud.displayName;const Yi=v.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(fd,{ref:r,className:te("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}));Yi.displayName=fd.displayName;const nb=v.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(hd,{ref:o,className:te("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(md,{children:u.jsx(ae.Check,{className:"h-4 w-4"})})}),t]}));nb.displayName=hd.displayName;const rb=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(pd,{ref:r,className:te("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(md,{children:u.jsx(ae.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));rb.displayName=pd.displayName;const ob=v.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(dd,{ref:r,className:te("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));ob.displayName=dd.displayName;const sb=v.forwardRef(({className:e,...t},n)=>u.jsx(gd,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));sb.displayName=gd.displayName;const as=1e4;function ib(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,`
|
|
79
79
|
`).replace(/<p>(.*?)<\/p>/gi,`$1
|
|
80
80
|
|
|
81
81
|
`).replace(/<h([1-6])>(.*?)<\/h[1-6]>/gi,(o,s,i)=>`${"#".repeat(parseInt(s))} ${i}
|
|
@@ -83,24 +83,24 @@ React keys must be passed directly to JSX without using spread:
|
|
|
83
83
|
`).replace(/<ul>/gi,"").replace(/<\/ul>/gi,`
|
|
84
84
|
`).replace(/<ol>/gi,"").replace(/<\/ol>/gi,`
|
|
85
85
|
`).replace(/<li>(.*?)<\/li>/gi,`- $1
|
|
86
|
-
`).trim():n.replace(/</g,"<").replace(/>/g,">").trim()}function ab(e,t=is){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 lb(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),ab(t),ib(t)}const as=0,On=1,wr=2,wd=4;function bd(e){return()=>e}function cb(e){e()}function Sd(e,t){return n=>e(t(n))}function Cd(e,t){return()=>e(t)}function ub(e,t){return n=>e(t,n)}function Xi(e){return e!==void 0}function db(...e){return()=>{e.map(cb)}}function br(){}function ls(e,t){return t(e),e}function fb(e,t){return t(e)}function ut(...e){return e}function ot(e,t){return e(On,t)}function Me(e,t){e(as,t)}function Ji(e){e(wr)}function St(e){return e(wd)}function ge(e,t){return ot(e,ub(t,as))}function ln(e,t){const n=e(On,r=>{n(),t(r)});return n}function Td(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function kd(e,t){return e===t}function dt(e=kd){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ie(e){return t=>n=>{e(n)&&t(n)}}function ce(e){return t=>Sd(t,e)}function vn(e){return t=>()=>{t(e)}}function V(e,...t){const n=hb(...t);return(r,o)=>{switch(r){case wr:Ji(e);return;case On:return ot(e,n(o))}}}function wn(e,t){return n=>r=>{n(t=e(t,r))}}function Xn(e){return t=>n=>{e>0?e--:t(n)}}function An(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function $e(...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);ot(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function hb(...e){return t=>e.reduceRight(fb,t)}function pb(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case On:return s?n===s?void 0:(r(),n=s,t=ot(e,s),t):(r(),br);case wr:r(),n=null;return}}}function Q(e){let t=e;const n=Ve();return(r,o)=>{switch(r){case as:t=o;break;case On:{o(t);break}case wd:return t}return n(r,o)}}function Rt(e,t){return ls(Q(t),n=>ge(e,n))}function Ve(){const e=[];return(t,n)=>{switch(t){case as:e.slice().forEach(r=>{r(n)});return;case wr:e.splice(0,e.length);return;case On:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Vt(e){return ls(Ve(),t=>ge(e,t))}function Qe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:mb(),singleton:n}}const mb=()=>Symbol();function gb(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 Ct(...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);ot(s,l=>{n[i]=l,r=r|a,r===o&&Me(t,n)})}),function(s,i){switch(s){case wr:{Ji(t);return}case On:return r===o&&i(n),ot(t,i)}}}function Ce(e,t=kd){return V(e,dt(t))}function Zi(...e){return function(t,n){switch(t){case wr:return;case On:return db(...e.map(r=>ot(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 xb={0:"debug",3:"error",1:"log",2:"warn"},yb=()=>typeof globalThis>"u"?window:globalThis,Mn=Qe(()=>{const e=Q(3);return{log:Q((t,n,r=1)=>{var o;const s=(o=yb().VIRTUOSO_LOG_LEVEL)!=null?o:St(e);r>=s&&console[xb[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Jn(e,t,n){return Qi(e,t,n).callbackRef}function Qi(e,t,n){const r=b.useRef(null);let o=i=>{};const s=b.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function vb(e,t,n,r,o,s,i,a,l){const c=b.useCallback(d=>{const f=wb(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 m;p&&(m=h.ownerDocument.defaultView);const x=i?a?i.scrollLeft:i.scrollTop:p?a?m.scrollX||m.document.documentElement.scrollLeft:m.scrollY||m.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,y=i?a?i.scrollWidth:i.scrollHeight:p?a?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,g=i?a?i.offsetWidth:i.offsetHeight:p?a?m.innerWidth:m.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:y,scrollTop:Math.max(x,0),viewportHeight:g}),s==null||s(a?Ed("column-gap",getComputedStyle(d).columnGap,o):Ed("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return Qi(c,n,l)}function wb(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),c=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Bt.ERROR),d===c)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Ed(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 Id(e,t,n){const r=b.useRef(null),o=b.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let f,h;if(t){const p=t.getBoundingClientRect(),m=c.top-p.top;h=p.height-Math.max(0,m),f=m+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;h=p.innerHeight-Math.max(0,c.top),f=c.top+p.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Qi(o,!0,n),a=b.useCallback(()=>{o(i.current)},[o,i]);return b.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const Lt=Qe(()=>{const e=Ve(),t=Ve(),n=Q(0),r=Ve(),o=Q(0),s=Ve(),i=Ve(),a=Q(0),l=Q(0),c=Q(0),d=Q(0),f=Ve(),h=Ve(),p=Q(!1),m=Q(!1),x=Q(!1);return ge(V(e,ce(({scrollTop:y})=>y)),t),ge(V(e,ce(({scrollHeight:y})=>y)),i),ge(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:m,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:x,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Ur={lvl:0};function Nd(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 at(e){return e===Ur}function Wr(e,t){if(!at(e))return t===e.k?e.v:t<e.k?Wr(e.l,t):Wr(e.r,t)}function cn(e,t,n="k"){if(at(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=cn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return cn(e.l,t,n)}function Kt(e,t,n){return at(e)?_d(t,n,1):t===e.k?Tt(e,{k:t,v:n}):t<e.k?Rd(Tt(e,{l:Kt(e.l,t,n)})):Rd(Tt(e,{r:Kt(e.r,t,n)}))}function Sr(){return Ur}function cs(e,t,n){if(at(e))return[];const r=cn(e,t)[0];return bb(ta(e,r,n))}function ea(e,t){if(at(e))return Ur;const{k:n,l:r,r:o}=e;if(t===n){if(at(r))return o;if(at(o))return r;{const[s,i]=jd(r);return us(Tt(e,{k:s,l:Ad(r),v:i}))}}else return t<n?us(Tt(e,{l:ea(r,t)})):us(Tt(e,{r:ea(o,t)}))}function Zn(e){return at(e)?[]:[...Zn(e.l),{k:e.k,v:e.v},...Zn(e.r)]}function ta(e,t,n){if(at(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(ta(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(ta(s,t,n))),a}function us(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(na(t))return Pd(Tt(e,{lvl:n-1}));if(!at(t)&&!at(t.r))return Tt(t.r,{l:Tt(t,{r:t.r.l}),lvl:n,r:Tt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(na(e))return ra(Tt(e,{lvl:n-1}));if(!at(r)&&!at(r.l)){const o=r.l,s=na(o)?r.lvl-1:r.lvl;return Tt(o,{l:Tt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:ra(Tt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Tt(e,t){return _d(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 Ad(e){return at(e.r)?e.l:us(Tt(e,{r:Ad(e.r)}))}function na(e){return at(e)||e.lvl>e.r.lvl}function jd(e){return at(e.r)?[e.k,e.v]:jd(e.r)}function _d(e,t,n,r=Ur,o=Ur){return{k:e,l:r,lvl:n,r:o,v:t}}function Rd(e){return ra(Pd(e))}function Pd(e){const{l:t}=e;return!at(t)&&t.lvl===e.lvl?Tt(t,{r:Tt(e,{l:t.r})}):e}function ra(e){const{lvl:t,r:n}=e;return!at(n)&&!at(n.r)&&n.lvl===t&&n.r.lvl===t?Tt(n,{l:Tt(e,{r:n.l}),lvl:t+1}):e}function bb(e){return Nd(e,({k:t,v:n})=>({index:t,value:n}))}function Od(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Vr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const oa=Qe(()=>({recalcInProgress:Q(!1)}),[],{singleton:!0});function Md(e,t,n){return e[ds(e,t,n)]}function ds(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 Sb(e,t,n,r){const o=ds(e,t,r),s=ds(e,n,r,o);return e.slice(o,s+1)}function Dn(e,t){return Math.round(e.getBoundingClientRect()[t])}function fs(e){return!at(e.groupOffsetTree)}function sa({index:e},t){return t===e?0:t<e?-1:1}function Cb(){return{groupIndices:[],groupOffsetTree:Sr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Sr()}}function Tb(e,t){let n=at(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),at(e)){e=Kt(e,0,s);continue}const a=cs(e,i-1,o+1);if(a.some(_b(r)))continue;let l=!1,c=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=ea(e,f)):(c=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=Kt(e,o+1,h));c&&(e=Kt(e,i,s))}return[e,n]}function kb(e){return typeof e.groupIndex<"u"}function Eb({offset:e},t){return t===e?0:t<e?-1:1}function Kr(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Md(t,e,sa),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Dd(e,t){if(!fs(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Ld(e,t,n){if(kb(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Dd(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function Ib(e,t,n,r=0){return r>0&&(t=Math.max(t,Md(e,r,sa).offset)),Nd(Sb(e,t,n,Eb),jb)}function Nb(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&&at(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((m,x)=>Kt(Kt(m,x,h),x+1,p),i)}else[i,a]=Tb(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f}=ia(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>Kt(h,p,Kr(p,f,o)),Sr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f,sizeTree:i}}function Ab(e){return Zn(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 $d(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 ia(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=ds(o,t-1,sa),a=o[l].offset;const c=cn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===cn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of cs(n,t,1/0)){const f=c-s,h=f*i+a+f*r;o.push({index:c,offset:h,size:d}),s=c,a=h,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function jb(e){return{index:e.index,value:e}}function _b(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 Rb={offsetHeight:"height",offsetWidth:"width"},bn=Qe(([{log:e},{recalcInProgress:t}])=>{const n=Ve(),r=Ve(),o=Rt(r,0),s=Ve(),i=Ve(),a=Q(0),l=Q([]),c=Q(void 0),d=Q(void 0),f=Q((T,C)=>Dn(T,Rb[C])),h=Q(void 0),p=Q(0),m=Cb(),x=Rt(V(n,$e(l,e,p),wn(Nb,m),dt()),m),y=Rt(V(l,dt(),wn((T,C)=>({current:C,prev:T.current}),{current:[],prev:[]}),ce(({prev:T})=>T)),[]);ge(V(l,Ie(T=>T.length>0),$e(x,p),ce(([T,C,E])=>{const N=T.reduce((j,D,P)=>Kt(j,D,Kr(D,C.offsetTree,E)||P),Sr());return{...C,groupIndices:T,groupOffsetTree:N}})),x),ge(V(r,$e(x),Ie(([T,{lastIndex:C}])=>T<C),ce(([T,{lastIndex:C,lastSize:E}])=>[{endIndex:C,size:E,startIndex:T}])),n),ge(c,d);const g=Rt(V(c,ce(T=>T===void 0)),!0);ge(V(d,Ie(T=>T!==void 0&&at(St(x).sizeTree)),ce(T=>[{endIndex:0,size:T,startIndex:0}])),n);const w=Vt(V(n,$e(x),wn(({sizes:T},[C,E])=>({changed:E!==T,sizes:E}),{changed:!1,sizes:m}),ce(T=>T.changed)));ot(V(a,wn((T,C)=>({diff:T.prev-C,prev:C}),{diff:0,prev:0}),ce(T=>T.diff)),T=>{const{groupIndices:C}=St(x);if(T>0)Me(t,!0),Me(s,T+$d(T,C));else if(T<0){const E=St(y);E.length>0&&(T-=$d(-T,E)),Me(i,T)}}),ot(V(a,$e(e)),([T,C])=>{T<0&&C("`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=Vt(s);ge(V(s,$e(x),ce(([T,C])=>{const E=C.groupIndices.length>0,N=[],j=C.lastSize;if(E){const D=Wr(C.sizeTree,0);let P=0,M=0;for(;P<T;){const A=C.groupIndices[M],z=C.groupIndices.length===M+1?1/0:C.groupIndices[M+1]-A-1;N.push({endIndex:A,size:D,startIndex:A}),N.push({endIndex:A+1+z-1,size:j,startIndex:A+1}),M++,P+=z+1}const F=Zn(C.sizeTree);return P!==T&&F.shift(),F.reduce((A,{k:z,v:_})=>{let J=A.ranges;return A.prevSize!==0&&(J=[...A.ranges,{endIndex:z+T-1,size:A.prevSize,startIndex:A.prevIndex}]),{prevIndex:z+T,prevSize:_,ranges:J}},{prevIndex:T,prevSize:0,ranges:N}).ranges}return Zn(C.sizeTree).reduce((D,{k:P,v:M})=>({prevIndex:P+T,prevSize:M,ranges:[...D.ranges,{endIndex:P+T-1,size:D.prevSize,startIndex:D.prevIndex}]}),{prevIndex:0,prevSize:j,ranges:[]}).ranges})),n);const k=Vt(V(i,$e(x,p),ce(([T,{offsetTree:C},E])=>{const N=-T;return Kr(N,C,E)})));return ge(V(i,$e(x,p),ce(([T,C,E])=>{if(C.groupIndices.length>0){if(at(C.sizeTree))return C;let N=Sr();const j=St(y);let D=0,P=0,M=0;for(;D<-T;){M=j[P];const F=j[P+1]-M-1;P++,D+=F+1}if(N=Zn(C.sizeTree).reduce((F,{k:A,v:z})=>Kt(F,Math.max(0,A+T),z),N),D!==-T){const F=Wr(C.sizeTree,M);N=Kt(N,0,F);const A=cn(C.sizeTree,-T+1)[1];N=Kt(N,1,A)}return{...C,sizeTree:N,...ia(C.offsetTree,0,N,E)}}else{const N=Zn(C.sizeTree).reduce((j,{k:D,v:P})=>Kt(j,Math.max(0,D+T),P),Sr());return{...C,sizeTree:N,...ia(C.offsetTree,0,N,E)}}})),x),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:p,groupIndices:l,itemSize:f,listRefresh:w,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:x,statefulTotalCount:o,totalCount:r,trackItemSizes:g,unshiftWith:s}},ut(Mn,oa),{singleton:!0});function Pb(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Fd=Qe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Ve(),i=Ve(),a=Vt(V(s,ce(Pb)));return ge(V(a,ce(l=>l.totalCount)),n),ge(V(a,ce(l=>l.groupIndices)),e),ge(V(Ct(o,t,r),Ie(([l,c])=>fs(c)),ce(([l,c,d])=>cn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),dt(),ce(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},ut(bn,Lt)),Ln=Qe(([{log:e}])=>{const t=Q(!1),n=Vt(V(t,Ie(r=>r),dt()));return ot(t,r=>{r&&St(e)("props updated",{},Bt.DEBUG)}),{didMount:n,propsReady:t}},ut(Mn),{singleton:!0}),Ob=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function zd(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Ob)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const qr=Qe(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const p=Ve(),m=Ve(),x=Q(0);let y=null,g=null,w=null;function S(){y&&(y(),y=null),w&&(w(),w=null),g&&(clearTimeout(g),g=null),Me(l,!1)}return ge(V(p,$e(n,f,r,x,a,i,h),$e(e,s,o),ce(([[k,T,C,E,N,j,D,P],M,F,A])=>{const z=zd(k),{align:_,behavior:J,offset:$}=z,R=E-1,Z=Ld(z,T,R);let Y=Kr(Z,T.offsetTree,M)+j;_==="end"?(Y+=F+cn(T.sizeTree,Z)[1]-C+A,Z===R&&(Y+=D)):_==="center"?Y+=(F+cn(T.sizeTree,Z)[1]-C+A)/2:Y-=N,$&&(Y+=$);const me=Te=>{S(),Te?(P("retrying to scroll to",{location:k},Bt.DEBUG),Me(p,k)):(Me(m,!0),P("list did not change, scroll successful",{},Bt.DEBUG))};if(S(),J==="smooth"){let Te=!1;w=ot(t,je=>{Te=Te||je}),y=ln(d,()=>{me(Te)})}else y=ln(V(t,Mb(150)),me);return g=setTimeout(()=>{S()},1200),Me(l,!0),P("scrolling from index to",{behavior:J,index:Z,top:Y},Bt.DEBUG),{behavior:J,top:Y}})),c),{scrollTargetReached:m,scrollToIndex:p,topListHeight:x}},ut(bn,Lt,Mn),{singleton:!0});function Mb(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function aa(e,t){e==0?t():requestAnimationFrame(()=>{aa(e-1,t)})}function la(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Gr=Qe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=Q(!0),l=Q(0),c=Q(!0);return ge(V(i,$e(l),Ie(([d,f])=>!!f),vn(!1)),a),ge(V(i,$e(l),Ie(([d,f])=>!!f),vn(!1)),c),ot(V(Ct(t,i),$e(a,n,e,c),Ie(([[,d],f,{sizeTree:h},p,m])=>d&&(!at(h)||Xi(p))&&!f&&!m),$e(l)),([,d])=>{ln(o,()=>{Me(c,!0)}),aa(4,()=>{ln(r,()=>{Me(a,!0)}),Me(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},ut(bn,Lt,qr,Ln),{singleton:!0});function Bd(e,t){return Math.abs(e-t)<1.01}const Yr="up",Xr="down",Db="none",Lb={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},$b=0,Jr=Qe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=Q(!1),a=Q(!0),l=Ve(),c=Ve(),d=Q(4),f=Q($b),h=Rt(V(Zi(V(Ce(o),Xn(1),vn(!0)),V(Ce(o),Xn(1),vn(!1),Td(100))),dt()),!1),p=Rt(V(Zi(V(n,vn(!0)),V(n,vn(!1),Td(200))),dt()),!1);ge(V(Ct(Ce(o),Ce(f)),ce(([w,S])=>w<=S),dt()),a),ge(V(a,An(50)),c);const m=Vt(V(Ct(r,Ce(s),Ce(t),Ce(e),Ce(d)),wn((w,[{scrollHeight:S,scrollTop:k},T,C,E,N])=>{const j=k+T-S>-N,D={scrollHeight:S,scrollTop:k,viewportHeight:T};if(j){let M,F;return k>w.state.scrollTop?(M="SCROLLED_DOWN",F=w.state.scrollTop-k):(M="SIZE_DECREASED",F=w.state.scrollTop-k||w.scrollTopDelta),{atBottom:!0,atBottomBecause:M,scrollTopDelta:F,state:D}}let P;return D.scrollHeight>w.state.scrollHeight?P="SIZE_INCREASED":T<w.state.viewportHeight?P="VIEWPORT_HEIGHT_DECREASING":k<w.state.scrollTop?P="SCROLLING_UPWARDS":P="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:P,state:D}},Lb),dt((w,S)=>w&&w.atBottom===S.atBottom))),x=Rt(V(r,wn((w,{scrollHeight:S,scrollTop:k,viewportHeight:T})=>{if(Bd(w.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const C=S-(k+T)<1;return w.scrollTop!==k&&C?{changed:!0,jump:w.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ie(w=>w.changed),ce(w=>w.jump)),0);ge(V(m,ce(w=>w.atBottom)),i),ge(V(i,An(50)),l);const y=Q(Xr);ge(V(r,ce(({scrollTop:w})=>w),dt(),wn((w,S)=>St(p)?{direction:w.direction,prevScrollTop:S}:{direction:S<w.prevScrollTop?Yr:Xr,prevScrollTop:S},{direction:Xr,prevScrollTop:0}),ce(w=>w.direction)),y),ge(V(r,An(50),vn(Db)),y);const g=Q(0);return ge(V(h,Ie(w=>!w),vn(0)),g),ge(V(o,An(100),$e(h),Ie(([w,S])=>!!S),wn(([w,S],[k])=>[S,k],[0,0]),ce(([w,S])=>S-w)),g),{atBottomState:m,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:x,scrollDirection:y,scrollVelocity:g}},ut(Lt)),hs="top",ps="bottom",Hd="none";function Ud(e,t,n){return typeof e=="number"?n===Yr&&t===hs||n===Xr&&t===ps?e:0:n===Yr?t===hs?e.main:e.reverse:t===ps?e.main:e.reverse}function Wd(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const ca=Qe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Ve(),i=Q(0),a=Q(0),l=Q(0),c=Rt(V(Ct(Ce(r),Ce(o),Ce(n),Ce(s,Vr),Ce(l),Ce(i),Ce(t),Ce(e),Ce(a)),ce(([d,f,h,[p,m],x,y,g,w,S])=>{const k=d-w,T=y+g,C=Math.max(h-k,0);let E=Hd;const N=Wd(S,hs),j=Wd(S,ps);return p-=w,p+=h+g,m+=h+g,m-=w,p>d+T-N&&(E=Yr),m<d-C+f+j&&(E=Xr),E!==Hd?[Math.max(k-h-Ud(x,hs,E)-N,0),k-C-g+f+Ud(x,ps,E)+j]:null}),Ie(d=>d!=null),dt(Vr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},ut(Lt),{singleton:!0});function Fb(e,t,n){if(fs(t)){const r=Dd(e,t);return[{index:cn(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 ua={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function ms(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const x=e[e.length-1];d=x.offset+x.size}const f=n-i,h=a+f*l+(f-1)*r,p=c,m=h-d;return{bottom:d,firstItemIndex:s,items:Kd(e,o,s),offsetBottom:m,offsetTop:c,top:p,topItems:Kd(t,o,s),topListHeight:t.reduce((x,y)=>y.size+x,0),totalCount:n}}function Vd(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=la(t,a),c=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return ms(c,[],a,o,n,r)}function Kd(e,t,n){if(e.length===0)return[];if(!fs(t))return e.map(c=>({...c,index:c.index+n,originalIndex:c.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=cs(t.groupOffsetTree,r,o);let a,l=0;for(const c of e){(!a||a.end<c.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;c.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},s.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}const Qn=Qe(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:p},{recalcInProgress:m}])=>{const x=Q([]),y=Q(0),g=Ve();ge(s.topItemsIndexes,x);const w=Rt(V(Ct(p,m,Ce(l,Vr),Ce(o),Ce(r),Ce(c),d,Ce(x),Ce(t),Ce(n),e),Ie(([C,E,,N,,,,,,,j])=>{const D=j&&j.length!==N;return C&&!E&&!D}),ce(([,,[C,E],N,j,D,P,M,F,A,z])=>{const _=j,{offsetTree:J,sizeTree:$}=_,R=St(y);if(N===0)return{...ua,totalCount:N};if(C===0&&E===0)return R===0?{...ua,totalCount:N}:Vd(R,D,j,F,A,z||[]);if(at($))return R>0?null:ms(Fb(la(D,N),_,z),[],N,A,_,F);const Z=[];if(M.length>0){const G=M[0],ne=M[M.length-1];let X=0;for(const L of cs($,G,ne)){const U=L.value,K=Math.max(L.start,G),se=Math.min(L.end,ne);for(let re=K;re<=se;re++)Z.push({data:z==null?void 0:z[re],index:re,offset:X,size:U}),X+=U}}if(!P)return ms([],Z,N,A,_,F);const Y=M.length>0?M[M.length-1]+1:0,me=Ib(J,C,E,Y);if(me.length===0)return null;const Te=N-1,je=ls([],G=>{for(const ne of me){const X=ne.value;let L=X.offset,U=ne.start;const K=X.size;if(X.offset<C){U+=Math.floor((C-X.offset+A)/(K+A));const re=U-ne.start;L+=re*K+re*A}U<Y&&(L+=(Y-U)*K,U=Y);const se=Math.min(ne.end,Te);for(let re=U;re<=se&&!(L>=E);re++)G.push({data:z==null?void 0:z[re],index:re,offset:L,size:K}),L+=K+A}});return ms(je,Z,N,A,_,F)}),Ie(C=>C!==null),dt()),ua);ge(V(e,Ie(Xi),ce(C=>C==null?void 0:C.length)),o),ge(V(w,ce(C=>C.topListHeight)),f),ge(f,a),ge(V(w,ce(C=>[C.top,C.bottom])),i),ge(V(w,ce(C=>C.items)),g);const S=Vt(V(w,Ie(({items:C})=>C.length>0),$e(o,e),Ie(([{items:C},E])=>C[C.length-1].originalIndex===E-1),ce(([,C,E])=>[C-1,E]),dt(Vr),ce(([C])=>C))),k=Vt(V(w,An(200),Ie(({items:C,topItems:E})=>C.length>0&&C[0].originalIndex===E.length),ce(({items:C})=>C[0].index),dt())),T=Vt(V(w,Ie(({items:C})=>C.length>0),ce(({items:C})=>{let E=0,N=C.length-1;for(;C[E].type==="group"&&E<N;)E++;for(;C[N].type==="group"&&N>E;)N--;return{endIndex:C[N].index,startIndex:C[E].index}}),dt(Od)));return{endReached:S,initialItemCount:y,itemsRendered:g,listState:w,rangeChanged:T,startReached:k,topItemsIndexes:x,...h}},ut(bn,Fd,ca,Gr,qr,Jr,Ln,oa),{singleton:!0}),qd=Qe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Ve(),i=Rt(V(Ct(n,e,r,t,o),ce(([a,l,c,d,f])=>a+l+c+d+f.offsetBottom+f.bottom)),0);return ge(Ce(i),s),{totalListHeight:i,totalListHeightChanged:s}},ut(Lt,Qn),{singleton:!0}),zb=Qe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=Q(!1),r=Rt(V(Ct(n,e,t),Ie(([o])=>o),ce(([,o,s])=>Math.max(0,o-s)),An(0),dt()),0);return{alignToBottom:n,paddingTopAddition:r}},ut(Lt,qd),{singleton:!0}),Gd=Qe(()=>({context:Q(null)})),Bb=({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,Yd=Qe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=Ve();return ge(V(d,$e(t,l,n,s,o,r,a),$e(e),ce(([[f,h,p,m,x,y,g,w],S])=>{const{align:k,behavior:T,calculateViewLocation:C=Bb,done:E,...N}=f,j=Ld(f,h,m-1),D=Kr(j,h.offsetTree,S)+x+y,P=D+cn(h.sizeTree,j)[1],M=w+y,F=w+p-g,A=C({itemBottom:P,itemTop:D,locationParams:{align:k,behavior:T,...N},viewportBottom:F,viewportTop:M});return A?E&&ln(V(i,Ie(z=>!z),Xn(St(i)?1:2)),E):E&&E(),A}),Ie(f=>f!==null)),c),{scrollIntoView:d}},ut(bn,Lt,qr,Qn,Mn),{singleton:!0});function Xd(e){return e?e==="smooth"?"smooth":"auto":!1}const Hb=(e,t)=>typeof e=="function"?Xd(e(t)):t&&Xd(e),Ub=Qe(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:p}])=>{const m=Q(!1),x=Ve();let y=null;function g(T){Me(i,{align:"end",behavior:T,index:"LAST"})}ot(V(Ct(V(Ce(t),Xn(1)),l),$e(Ce(m),s,a,f),ce(([[T,C],E,N,j,D])=>{let P=C&&j,M="auto";return P&&(M=Hb(E,N||D),P=P&&!!M),{followOutputBehavior:M,shouldFollow:P,totalCount:T}}),Ie(({shouldFollow:T})=>T)),({followOutputBehavior:T,totalCount:C})=>{y&&(y(),y=null),St(n)?requestAnimationFrame(()=>{St(d)("following output to ",{totalCount:C},Bt.DEBUG),g(T)}):y=ln(e,()=>{St(d)("following output to ",{totalCount:C},Bt.DEBUG),g(T),y=null})});function w(T){const C=ln(o,E=>{T&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!y&&(St(d)("scrolling to bottom due to increased size",{},Bt.DEBUG),g("auto"))});setTimeout(C,100)}ot(V(Ct(Ce(m),t,c),Ie(([T,,C])=>T&&C),wn(({value:T},[,C])=>({refreshed:T===C,value:C}),{refreshed:!1,value:0}),Ie(({refreshed:T})=>T),$e(m,t)),([,T])=>{St(a)&&w(T!==!1)}),ot(x,()=>{w(St(m)!==!1)}),ot(Ct(Ce(m),o),([T,C])=>{T&&!C.atBottom&&C.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&g("auto")});const S=Q(null),k=Ve();return ge(Zi(V(Ce(r),ce(T=>{var C;return(C=T==null?void 0:T.length)!=null?C:0})),V(Ce(t))),k),ot(V(Ct(V(k,Xn(1)),l),$e(Ce(S),a,f,h),ce(([[T,C],E,N,j,D])=>C&&N&&(E==null?void 0:E({context:D,totalCount:T,scrollingInProgress:j}))),Ie(T=>!!T),An(0)),T=>{y&&(y(),y=null),St(n)?requestAnimationFrame(()=>{St(d)("scrolling into view",{}),Me(p,T)}):y=ln(e,()=>{St(d)("scrolling into view",{}),Me(p,T),y=null})}),{autoscrollToBottom:x,followOutput:m,scrollIntoViewOnChange:S}},ut(bn,Jr,qr,Gr,Ln,Mn,Lt,Gd,Yd)),Wb=Qe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ge(V(a,$e(s),Ie(([,l])=>l!==0),$e(o,r,t,n,e),ce(([[,l],c,d,f,h,p=[]])=>Vd(l,c,d,f,h,p))),i),{}),ut(bn,Gr,Qn,Ln),{singleton:!0}),Vb=Qe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=Q(0);return ot(V(e,$e(r),Ie(([,o])=>o!==0),ce(([,o])=>({top:o}))),o=>{ln(V(n,Xn(1),Ie(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Me(t,o)})})}),{initialScrollTop:r}},ut(Ln,Lt,Qn),{singleton:!0}),Jd=Qe(([{scrollVelocity:e}])=>{const t=Q(!1),n=Ve(),r=Q(!1);return ge(V(e,$e(r,t,n),Ie(([o,s])=>!!s),ce(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),dt()),t),ot(V(Ct(t,e,n),$e(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},ut(Jr),{singleton:!0}),da=Qe(([{scrollContainerState:e,scrollTo:t}])=>{const n=Ve(),r=Ve(),o=Ve(),s=Q(!1),i=Q(void 0);return ge(V(Ct(n,r),ce(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),ge(V(t,$e(r),ce(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},ut(Lt)),Kb=Qe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=Ve(),d=Q(void 0),f=Q(null),h=Q(null);return ge(a,f),ge(l,h),ot(V(c,$e(t,r,i,f,h,n)),([p,m,x,y,g,w,S])=>{const k=Ab(m.sizeTree);y&&g!==null&&w!==null&&(x=g.scrollTop-w.offsetTop),x-=S,p({ranges:k,scrollTop:x})}),ge(V(d,Ie(Xi),ce(qb)),o),ge(V(s,$e(d),Ie(([,p])=>p!==void 0),dt(),ce(([,p])=>p.ranges)),e),{getState:c,restoreStateFrom:d}},ut(bn,Lt,Gr,Ln,da));function qb(e){return{align:"start",index:0,offset:e.scrollTop}}const Gb=Qe(([{topItemsIndexes:e}])=>{const t=Q(0);return ge(V(t,Ie(n=>n>=0),ce(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ut(Qn));function Zd(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const Yb=Zd(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Xb=Qe(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:f,sizes:h},{log:p},{recalcInProgress:m}])=>{const x=Vt(V(l,$e(i),wn(([,g,w,S],[{bottom:k,items:T,offsetBottom:C,totalCount:E},N])=>{const j=k+C;let D=0;return w===E&&g.length>0&&T.length>0&&(T[0].originalIndex===0&&g[0].originalIndex===0||(D=j-S,D!==0&&(D+=N))),[D,T,E,j]},[0,[],0,0]),Ie(([g])=>g!==0),$e(r,a,n,o,p,m),Ie(([,g,w,S,,,k])=>!k&&!S&&g!==0&&w===Yr),ce(([[g],,,,,w])=>(w("Upward scrolling compensation",{amount:g},Bt.DEBUG),g))));function y(g){g>0?(Me(t,{behavior:"auto",top:-g}),Me(e,0)):(Me(e,0),Me(t,{behavior:"auto",top:-g}))}return ot(V(x,$e(e,s)),([g,w,S])=>{S&&Yb()?Me(e,w-g):y(-g)}),ot(V(Ct(Rt(s,!1),e,m),Ie(([g,w,S])=>!g&&!S&&w!==0),ce(([g,w])=>w),An(1)),y),ge(V(f,ce(g=>({top:-g}))),t),ot(V(c,$e(h,d),ce(([g,{groupIndices:w,lastSize:S,sizeTree:k},T])=>{function C(E){return E*(S+T)}if(w.length===0)return C(g);{let E=0;const N=Wr(k,0);let j=0,D=0;for(;j<g;){j++,E+=N;let P=w.length===D+1?1/0:w[D+1]-w[D]-1;j+P>g&&(E-=N,P=g-j+1),j+=P,E+=C(P),D++}return E}})),g=>{Me(e,g),requestAnimationFrame(()=>{Me(t,{top:g}),requestAnimationFrame(()=>{Me(e,0),Me(m,!1)})})}),{deviation:e}},ut(Lt,Jr,Qn,bn,Mn,oa)),Jb=Qe(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),ut(ca,Wb,Ln,Jd,qd,Vb,zb,da,Yd,Mn,Gd)),Qd=Qe(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:m},x,y,g,{listState:w,topItemsIndexes:S,...k},{scrollToIndex:T},C,{topItemCount:E},{groupCounts:N},j])=>(ge(k.rangeChanged,j.scrollSeekRangeChanged),ge(V(j.windowViewportRect,ce(D=>D.visibleHeight)),x.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:N,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:m,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...g,groupIndices:s,itemSize:i,listState:w,scrollToIndex:T,statefulTotalCount:c,trackItemSizes:f,...k,...j,...x,sizes:l,...y}),ut(bn,Gr,Lt,Kb,Ub,Qn,qr,Xb,Gb,Fd,Jb));function Zb(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 gs=typeof document<"u"?b.useLayoutEffect:b.useEffect;function ef(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=b.createContext({});function l(y,g){y.propsReady&&Me(y.propsReady,!1);for(const w of r){const S=y[t.required[w]];Me(S,g[w])}for(const w of o)if(w in g){const S=y[t.optional[w]];Me(S,g[w])}y.propsReady&&Me(y.propsReady,!0)}function c(y){return s.reduce((g,w)=>(g[w]=S=>{const k=y[t.methods[w]];Me(k,S)},g),{})}function d(y){return i.reduce((g,w)=>(g[w]=pb(y[t.events[w]]),g),{})}const f=b.forwardRef((y,g)=>{const{children:w,...S}=y,[k]=b.useState(()=>ls(gb(e),E=>{l(E,S)})),[T]=b.useState(Cd(d,k));gs(()=>{for(const E of i)E in S&&ot(T[E],S[E]);return()=>{Object.values(T).map(Ji)}},[S,T,k]),gs(()=>{l(k,S)}),b.useImperativeHandle(g,bd(c(k)));const C=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(C,{...Zb([...r,...o,...i],S),children:w}):w})}),h=y=>{const g=b.useContext(a);return b.useCallback(w=>{Me(g[y],w)},[g,y])},p=y=>{const g=b.useContext(a)[y],w=b.useCallback(S=>ot(g,S),[g]);return b.useSyncExternalStore(w,()=>St(g),()=>St(g))},m=y=>{const g=b.useContext(a)[y],[w,S]=b.useState(Cd(St,g));return gs(()=>ot(g,k=>{k!==w&&S(bd(k))}),[g,w]),w},x=b.version.startsWith("18")?p:m;return{Component:f,useEmitter:(y,g)=>{const w=b.useContext(a)[y];gs(()=>ot(w,g),[g,w])},useEmitterValue:x,usePublisher:h}}const tf=b.createContext(void 0),nf=b.createContext(void 0),rf=typeof document<"u"?b.useLayoutEffect:b.useEffect;function fa(e){return"self"in e}function Qb(e){return"body"in e}function of(e,t,n,r=br,o,s){const i=b.useRef(null),a=b.useRef(null),l=b.useRef(null),c=b.useCallback(h=>{let p,m,x;const y=h.target;if(Qb(y)||fa(y)){const w=fa(y)?y:y.defaultView;x=s?w.scrollX:w.scrollY,p=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,m=s?w.innerWidth:w.innerHeight}else x=s?y.scrollLeft:y.scrollTop,p=s?y.scrollWidth:y.scrollHeight,m=s?y.offsetWidth:y.offsetHeight;const g=()=>{e({scrollHeight:p,scrollTop:Math.max(x,0),viewportHeight:m})};h.suppressFlushSync?g():Ks.flushSync(g),a.current!==null&&(x===a.current||x<=0||x===p-m)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);b.useEffect(()=>{const h=o||i.current;return r(o||i.current),c({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",c,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",c)}},[i,c,n,r,o]);function d(h){const p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const m=h.behavior==="smooth";let x,y,g;fa(p)?(y=Math.max(Dn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),x=s?p.innerWidth:p.innerHeight,g=s?window.scrollX:window.scrollY):(y=p[s?"scrollWidth":"scrollHeight"],x=Dn(p,s?"width":"height"),g=p[s?"scrollLeft":"scrollTop"]);const w=y-x;if(h.top=Math.ceil(Math.max(Math.min(w,h.top),0)),Bd(x,y)||h.top===g){e({scrollHeight:y,scrollTop:g,viewportHeight:x}),m&&t(!0);return}m?(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 ha="-webkit-sticky",sf="sticky",pa=Zd(()=>{if(typeof document>"u")return sf;const e=document.createElement("div");return e.style.position=ha,e.style.position===ha?ha:sf});function ma(e){return e}const e0=Qe(()=>{const e=Q(a=>`Item ${a}`),t=Q(a=>`Group ${a}`),n=Q({}),r=Q(ma),o=Q("div"),s=Q(br),i=(a,l=null)=>Rt(V(n,ce(c=>c[a]),dt()),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")}}),t0=Qe(([e,t])=>({...e,...t}),ut(Qd,e0)),n0=({height:e})=>u.jsx("div",{style:{height:e}}),r0={overflowAnchor:"none",position:pa(),zIndex:1},af={overflowAnchor:"none"},o0={...af,display:"inline-block",height:"100%"},lf=b.memo(function({showTopList:e=!1}){const t=_e("listState"),n=Zt("sizeRanges"),r=_e("useWindowScroll"),o=_e("customScrollParent"),s=Zt("windowScrollContainerState"),i=Zt("scrollContainerState"),a=o||r?s:i,l=_e("itemContent"),c=_e("context"),d=_e("groupContent"),f=_e("trackItemSizes"),h=_e("itemSize"),p=_e("log"),m=Zt("gap"),x=_e("horizontalDirection"),{callbackRef:y}=vb(n,h,f,e?br:a,p,m,o,x,_e("skipAnimationFrameInResizeObserver")),[g,w]=b.useState(0);ga("deviation",A=>{g!==A&&w(A)});const S=_e("EmptyPlaceholder"),k=_e("ScrollSeekPlaceholder")||n0,T=_e("ListComponent"),C=_e("ItemComponent"),E=_e("GroupComponent"),N=_e("computeItemKey"),j=_e("isSeeking"),D=_e("groupIndices").length>0,P=_e("alignToBottom"),M=_e("initialItemFinalLocationReached"),F=e?{}:{boxSizing:"border-box",...x?{display:"inline-block",height:"100%",marginLeft:g!==0?g:P?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:g!==0?g:P?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...M?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{...Pt(S,c)}):u.jsx(T,{...Pt(T,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:y,style:F,children:(e?t.topItems:t.items).map(A=>{const z=A.originalIndex,_=N(z+t.firstItemIndex,A.data,c);return j?b.createElement(k,{...Pt(k,c),height:A.size,index:A.index,key:_,type:A.type||"item",...A.type==="group"?{}:{groupIndex:A.groupIndex}}):A.type==="group"?b.createElement(E,{...Pt(E,c),"data-index":z,"data-item-index":A.index,"data-known-size":A.size,key:_,style:r0},d(A.index,c)):b.createElement(C,{...Pt(C,c),...l0(C,A.data),"data-index":z,"data-item-group-index":A.groupIndex,"data-item-index":A.index,"data-known-size":A.size,key:_,style:x?o0:af},D?l(A.index,A.groupIndex,A.data,c):l(A.index,A.data,c))})})}),s0={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},i0={outline:"none",overflowX:"auto",position:"relative"},xs=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),a0={position:pa(),top:0,width:"100%",zIndex:1};function Pt(e,t){if(typeof e!="string")return{context:t}}function l0(e,t){return{item:typeof e=="string"?void 0:t}}const c0=b.memo(function(){const e=_e("HeaderComponent"),t=Zt("headerHeight"),n=_e("HeaderFooterTag"),r=Jn(b.useMemo(()=>s=>{t(Dn(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Pt(e,o)})}):null}),u0=b.memo(function(){const e=_e("FooterComponent"),t=Zt("footerHeight"),n=_e("HeaderFooterTag"),r=Jn(b.useMemo(()=>s=>{t(Dn(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Pt(e,o)})}):null});function cf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:m}=of(a,c,l,d,void 0,f);return e("scrollTo",m),e("scrollBy",h),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?i0:s0,...o},tabIndex:0,...i,...Pt(l,s),children:r})})}function uf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=b.useRef(null),m=t("scrollerRef"),{scrollByCallback:x,scrollerRef:y,scrollToCallback:g}=of(a,c,l,m,h);return rf(()=>{var w;return y.current=h||((w=p.current)==null?void 0:w.ownerDocument.defaultView),()=>{y.current=null}},[y,h]),e("windowScrollTo",g),e("scrollBy",x),u.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Pt(l,s),children:r})})}const d0=({children:e})=>{const t=b.useContext(tf),n=Zt("viewportHeight"),r=Zt("fixedItemHeight"),o=_e("alignToBottom"),s=_e("horizontalDirection"),i=b.useMemo(()=>Sd(n,l=>Dn(l,s?"width":"height")),[n,s]),a=Jn(i,!0,_e("skipAnimationFrameInResizeObserver"));return b.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:xs(o),children:e})},f0=({children:e})=>{const t=b.useContext(tf),n=Zt("windowViewportRect"),r=Zt("fixedItemHeight"),o=_e("customScrollParent"),s=Id(n,o,_e("skipAnimationFrameInResizeObserver")),i=_e("alignToBottom");return b.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:s,style:xs(i),children:e})},h0=({children:e})=>{const t=_e("TopItemListComponent")||"div",n=_e("headerHeight"),r={...a0,marginTop:`${n}px`},o=_e("context");return u.jsx(t,{style:r,...Pt(t,o),children:e})},p0=b.memo(function(e){const t=_e("useWindowScroll"),n=_e("topItemsIndexes").length>0,r=_e("customScrollParent"),o=_e("context");return u.jsxs(r||t?x0:g0,{...e,context:o,children:[n&&u.jsx(h0,{children:u.jsx(lf,{showTopList:!0})}),u.jsxs(r||t?f0:d0,{children:[u.jsx(c0,{}),u.jsx(lf,{}),u.jsx(u0,{})]})]})}),{Component:m0,useEmitter:ga,useEmitterValue:_e,usePublisher:Zt}=ef(t0,{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"}},p0),g0=cf({useEmitter:ga,useEmitterValue:_e,usePublisher:Zt}),x0=uf({useEmitter:ga,useEmitterValue:_e,usePublisher:Zt}),y0=m0;ut(Qd,Qe(()=>{const e=Q(c=>u.jsxs("td",{children:["Item $",c]})),t=Q(null),n=Q(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=Q(null),o=Q(null),s=Q({}),i=Q(ma),a=Q(br),l=(c,d=null)=>Rt(V(s,ce(f=>f[c]),dt()),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")}})),pa();const df={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},v0={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:ff,floor:ys,max:Zr,min:xa,round:hf}=Math;function pf(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function w0(e){return{...v0,items:e}}function vs(e,t){return e&&e.width===t.width&&e.height===t.height}function b0(e,t){return e&&e.column===t.column&&e.row===t.row}const S0=Qe(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:f},h,p,{didMount:m,propsReady:x},{customScrollParent:y,useWindowScroll:g,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k},T])=>{const C=Q(0),E=Q(0),N=Q(df),j=Q({height:0,width:0}),D=Q({height:0,width:0}),P=Ve(),M=Ve(),F=Q(0),A=Q(null),z=Q({column:0,row:0}),_=Ve(),J=Ve(),$=Q(!1),R=Q(0),Z=Q(!0),Y=Q(!1),me=Q(!1);ot(V(m,$e(R),Ie(([L,U])=>!!U)),()=>{Me(Z,!1)}),ot(V(Ct(m,Z,D,j,R,Y),Ie(([L,U,K,se,,re])=>L&&!U&&K.height!==0&&se.height!==0&&!re)),([,,,,L])=>{Me(Y,!0),aa(1,()=>{Me(P,L)}),ln(V(c),()=>{Me(t,[0,0]),Me(Z,!0)})}),ge(V(J,Ie(L=>L!=null&&L.scrollTop>0),vn(0)),E),ot(V(m,$e(J),Ie(([,L])=>L!=null)),([,L])=>{L&&(Me(j,L.viewport),Me(D,L.item),Me(z,L.gap),L.scrollTop>0&&(Me($,!0),ln(V(c,Xn(1)),U=>{Me($,!1)}),Me(l,{top:L.scrollTop})))}),ge(V(j,ce(({height:L})=>L)),f),ge(V(Ct(Ce(j,vs),Ce(D,vs),Ce(z,(L,U)=>L&&L.column===U.column&&L.row===U.row),Ce(c)),ce(([L,U,K,se])=>({gap:K,item:U,scrollTop:se,viewport:L}))),_),ge(V(Ct(Ce(C),r,Ce(z,b0),Ce(D,vs),Ce(j,vs),Ce(A),Ce(E),Ce($),Ce(Z),Ce(R)),Ie(([,,,,,,,L])=>!L),ce(([L,[U,K],se,re,Oe,qe,Ge,,oe,le])=>{const{column:De,row:Be}=se,{height:Ye,width:Xe}=re,{width:Le}=Oe;if(Ge===0&&(L===0||Le===0))return df;if(Xe===0){const He=la(le,L),Nt=He+Math.max(Ge-1,0);return w0(pf(He,Nt,qe))}const Fe=mf(Le,Xe,De);let Je,nt;oe?U===0&&K===0&&Ge>0?(Je=0,nt=Ge-1):(Je=Fe*ys((U+Be)/(Ye+Be)),nt=Fe*ff((K+Be)/(Ye+Be))-1,nt=xa(L-1,Zr(nt,Fe-1)),Je=xa(nt,Zr(0,Je))):(Je=0,nt=-1);const kt=pf(Je,nt,qe),{bottom:pt,top:mt}=gf(Oe,se,re,kt),gt=ff(L/Fe),Ze=gt*Ye+(gt-1)*Be-pt;return{bottom:pt,itemHeight:Ye,items:kt,itemWidth:Xe,offsetBottom:Ze,offsetTop:mt,top:mt}})),N),ge(V(A,Ie(L=>L!==null),ce(L=>L.length)),C),ge(V(Ct(j,D,N,z),Ie(([L,U,{items:K}])=>K.length>0&&U.height!==0&&L.height!==0),ce(([L,U,{items:K},se])=>{const{bottom:re,top:Oe}=gf(L,se,U,K);return[Oe,re]}),dt(Vr)),t);const Te=Q(!1);ge(V(c,$e(Te),ce(([L,U])=>U||L!==0)),Te);const je=Vt(V(Ct(N,C),Ie(([{items:L}])=>L.length>0),$e(Te),Ie(([[L,U],K])=>{const se=L.items[L.items.length-1].index===U-1;return(K||L.bottom>0&&L.itemHeight>0&&L.offsetBottom===0&&L.items.length===U)&&se}),ce(([[,L]])=>L-1),dt())),G=Vt(V(Ce(N),Ie(({items:L})=>L.length>0&&L[0].index===0),vn(0),dt())),ne=Vt(V(Ce(N),$e($),Ie(([{items:L},U])=>L.length>0&&!U),ce(([{items:L}])=>({endIndex:L[L.length-1].index,startIndex:L[0].index})),dt(Od),An(0)));ge(ne,p.scrollSeekRangeChanged),ge(V(P,$e(j,D,C,z),ce(([L,U,K,se,re])=>{const Oe=zd(L),{align:qe,behavior:Ge,offset:oe}=Oe;let le=Oe.index;le==="LAST"&&(le=se-1),le=Zr(0,le,xa(se-1,le));let De=ya(U,re,K,le);return qe==="end"?De=hf(De-U.height+K.height):qe==="center"&&(De=hf(De-U.height/2+K.height/2)),oe&&(De+=oe),{behavior:Ge,top:De}})),l);const X=Rt(V(N,ce(L=>L.offsetBottom+L.bottom)),0);return ge(V(k,ce(L=>({height:L.visibleHeight,width:L.visibleWidth}))),j),{customScrollParent:y,data:A,deviation:F,footerHeight:o,gap:z,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:D,overscan:n,restoreStateFrom:J,scrollBy:i,scrollContainerState:a,scrollHeight:M,scrollTo:l,scrollToIndex:P,scrollTop:c,smoothScrollTargetReached:d,totalCount:C,useWindowScroll:g,viewportDimensions:j,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k,...p,gridState:N,horizontalDirection:me,initialTopMostItemIndex:R,totalListHeight:X,...h,endReached:je,propsReady:x,rangeChanged:ne,startReached:G,stateChanged:_,stateRestoreInProgress:$,...T}},ut(ca,Lt,Jr,Jd,Ln,da,Mn));function mf(e,t,n){return Zr(1,ys((e+n)/(ys(t)+n)))}function gf(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=ya(e,t,n,r[0].index);return{bottom:ya(e,t,n,r[r.length-1].index)+o,top:s}}function ya(e,t,n,r){const o=mf(e.width,n.width,t.column),s=ys(r/o),i=s*n.height+Zr(0,s-1)*t.row;return i>0?i+t.row:i}const C0=Qe(()=>{const e=Q(f=>`Item ${f}`),t=Q({}),n=Q(null),r=Q("virtuoso-grid-item"),o=Q("virtuoso-grid-list"),s=Q(ma),i=Q("div"),a=Q(br),l=(f,h=null)=>Rt(V(t,ce(p=>p[f]),dt()),h),c=Q(!1),d=Q(!1);return ge(Ce(d),c),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),T0=Qe(([e,t])=>({...e,...t}),ut(S0,C0)),k0=b.memo(function(){const e=ht("gridState"),t=ht("listClassName"),n=ht("itemClassName"),r=ht("itemContent"),o=ht("computeItemKey"),s=ht("isSeeking"),i=Qt("scrollHeight"),a=ht("ItemComponent"),l=ht("ListComponent"),c=ht("ScrollSeekPlaceholder"),d=ht("context"),f=Qt("itemDimensions"),h=Qt("gap"),p=ht("log"),m=ht("stateRestoreInProgress"),x=Qt("reportReadyState"),y=Jn(b.useMemo(()=>g=>{const w=g.parentElement.parentElement.scrollHeight;i(w);const S=g.firstChild;if(S){const{height:k,width:T}=S.getBoundingClientRect();f({height:k,width:T})}h({column:yf("column-gap",getComputedStyle(g).columnGap,p),row:yf("row-gap",getComputedStyle(g).rowGap,p)})},[i,f,h,p]),!0,!1);return rf(()=>{e.itemHeight>0&&e.itemWidth>0&&x(!0)},[e]),m?null:u.jsx(l,{className:t,ref:y,...Pt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(g=>{const w=o(g.index,g.data,d);return s?u.jsx(c,{...Pt(c,d),height:e.itemHeight,index:g.index,width:e.itemWidth},w):b.createElement(a,{...Pt(a,d),className:n,"data-index":g.index,key:w},r(g.index,g.data,d))})})}),E0=b.memo(function(){const e=ht("HeaderComponent"),t=Qt("headerHeight"),n=ht("headerFooterTag"),r=Jn(b.useMemo(()=>s=>{t(Dn(s,"height"))},[t]),!0,!1),o=ht("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Pt(e,o)})}):null}),I0=b.memo(function(){const e=ht("FooterComponent"),t=Qt("footerHeight"),n=ht("headerFooterTag"),r=Jn(b.useMemo(()=>s=>{t(Dn(s,"height"))},[t]),!0,!1),o=ht("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Pt(e,o)})}):null}),N0=({children:e})=>{const t=b.useContext(nf),n=Qt("itemDimensions"),r=Qt("viewportDimensions"),o=Jn(b.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return b.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),u.jsx("div",{ref:o,style:xs(!1),children:e})},A0=({children:e})=>{const t=b.useContext(nf),n=Qt("windowViewportRect"),r=Qt("itemDimensions"),o=ht("customScrollParent"),s=Id(n,o,!1);return b.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),u.jsx("div",{ref:s,style:xs(!1),children:e})},j0=b.memo(function({...e}){const t=ht("useWindowScroll"),n=ht("customScrollParent"),r=n||t?R0:_0,o=n||t?A0:N0,s=ht("context");return u.jsx(r,{...e,...Pt(r,s),children:u.jsxs(o,{children:[u.jsx(E0,{}),u.jsx(k0,{}),u.jsx(I0,{})]})})}),{useEmitter:xf,useEmitterValue:ht,usePublisher:Qt}=ef(T0,{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"}},j0),_0=cf({useEmitter:xf,useEmitterValue:ht,usePublisher:Qt}),R0=uf({useEmitter:xf,useEmitterValue:ht,usePublisher:Qt});function yf(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 P0=uo.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 vf({className:e,variant:t,...n}){return u.jsx("div",{className:te(P0({variant:t}),e),...n})}const Qr=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Qr.displayName="Card";const eo=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("flex flex-col space-y-1.5 p-6",e),...t}));eo.displayName="CardHeader";const to=v.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:te("text-2xl font-semibold leading-none tracking-tight",e),...t}));to.displayName="CardTitle";const wf=v.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:te("text-sm text-muted-foreground",e),...t}));wf.displayName="CardDescription";const no=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("p-6 pt-0",e),...t}));no.displayName="CardContent";const bf=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("flex items-center p-6 pt-0",e),...t}));bf.displayName="CardFooter";const O0=1,M0=1e6;let va=0;function D0(){return va=(va+1)%Number.MAX_SAFE_INTEGER,va.toString()}const wa=new Map,Sf=e=>{if(wa.has(e))return;const t=setTimeout(()=>{wa.delete(e),ro({type:"REMOVE_TOAST",toastId:e})},M0);wa.set(e,t)},L0=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,O0)};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?Sf(n):e.toasts.forEach(r=>{Sf(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)}}},ws=[];let bs={toasts:[]};function ro(e){bs=L0(bs,e),ws.forEach(t=>{t(bs)})}function $0({...e}){const t=D0(),n=o=>ro({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>ro({type:"DISMISS_TOAST",toastId:t});return ro({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function ba(){const[e,t]=v.useState(bs);return v.useEffect(()=>(ws.push(t),()=>{const n=ws.indexOf(t);n>-1&&ws.splice(n,1)}),[e]),{...e,toast:$0,dismiss:n=>ro({type:"DISMISS_TOAST",toastId:n})}}async function Cf(e,t){return await Gt(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function Tf(e,t){return await(await Cf(`/files/${e}/view`,t)).text()}async function F0(e,t){const n=await Cf(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Gt(`/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 z0(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Gt("/files",{params:r})}function Sa(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 kf(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function oo(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(oo).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(kf(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=oo(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 so(e){if(typeof e=="string")return e;if(kf(e))return"";try{const t=oo(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function B0(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function H0(e){const t=so(e);return typeof e=="string"&&B0(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function Ss(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Sa(t);if(n!==null)return Ss(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?Ss(e.content):e}var Cs="Dialog",[Ef,xT]=kn(Cs),[U0,un]=Ef(Cs),If=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=v.useRef(null),l=v.useRef(null),[c,d]=dr({prop:r,defaultProp:o??!1,onChange:s,caller:Cs});return u.jsx(U0,{scope:t,triggerRef:a,contentRef:l,contentId:En(),titleId:En(),descriptionId:En(),open:c,onOpenChange:d,onOpenToggle:v.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};If.displayName=Cs;var Nf="DialogTrigger",Af=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(Nf,n),s=We(t,o.triggerRef);return u.jsx(Re.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":ka(o.open),...r,ref:s,onClick:pe(e.onClick,o.onOpenToggle)})});Af.displayName=Nf;var Ca="DialogPortal",[W0,jf]=Ef(Ca,{forceMount:void 0}),_f=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=un(Ca,t);return u.jsx(W0,{scope:t,forceMount:n,children:v.Children.map(r,i=>u.jsx(Xt,{present:n||s.open,children:u.jsx(Vo,{asChild:!0,container:o,children:i})}))})};_f.displayName=Ca;var Ts="DialogOverlay",Rf=v.forwardRef((e,t)=>{const n=jf(Ts,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=un(Ts,e.__scopeDialog);return s.modal?u.jsx(Xt,{present:r||s.open,children:u.jsx(K0,{...o,ref:t})}):null});Rf.displayName=Ts;var V0=Un.createSlot("DialogOverlay.RemoveScroll"),K0=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(Ts,n);return u.jsx(es,{as:V0,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(Re.div,{"data-state":ka(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),er="DialogContent",Pf=v.forwardRef((e,t)=>{const n=jf(er,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=un(er,e.__scopeDialog);return u.jsx(Xt,{present:r||s.open,children:s.modal?u.jsx(q0,{...o,ref:t}):u.jsx(G0,{...o,ref:t})})});Pf.displayName=er;var q0=v.forwardRef((e,t)=>{const n=un(er,e.__scopeDialog),r=v.useRef(null),o=We(t,n.contentRef,r);return v.useEffect(()=>{const s=r.current;if(s)return Di(s)},[]),u.jsx(Of,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:pe(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:pe(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:pe(e.onFocusOutside,s=>s.preventDefault())})}),G0=v.forwardRef((e,t)=>{const n=un(er,e.__scopeDialog),r=v.useRef(!1),o=v.useRef(!1);return u.jsx(Of,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Of=v.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=un(er,n),l=v.useRef(null),c=We(t,l);return xi(),u.jsxs(u.Fragment,{children:[u.jsx(Po,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(Ro,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":ka(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(Y0,{titleId:a.titleId}),u.jsx(J0,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ta="DialogTitle",Mf=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(Ta,n);return u.jsx(Re.h2,{id:o.titleId,...r,ref:t})});Mf.displayName=Ta;var Df="DialogDescription",Lf=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(Df,n);return u.jsx(Re.p,{id:o.descriptionId,...r,ref:t})});Lf.displayName=Df;var $f="DialogClose",Ff=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un($f,n);return u.jsx(Re.button,{type:"button",...r,ref:t,onClick:pe(e.onClick,()=>o.onOpenChange(!1))})});Ff.displayName=$f;function ka(e){return e?"open":"closed"}var zf="DialogTitleWarning",[yT,Bf]=ex(zf,{contentName:er,titleName:Ta,docsSlug:"dialog"}),Y0=({titleId:e})=>{const t=Bf(zf),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
86
|
+
`).trim():n.replace(/</g,"<").replace(/>/g,">").trim()}function ab(e,t=as){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 lb(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),ab(t),ib(t)}const ls=0,Mn=1,br=2,wd=4;function bd(e){return()=>e}function cb(e){e()}function Sd(e,t){return n=>e(t(n))}function Cd(e,t){return()=>e(t)}function ub(e,t){return n=>e(t,n)}function Xi(e){return e!==void 0}function db(...e){return()=>{e.map(cb)}}function Sr(){}function cs(e,t){return t(e),e}function fb(e,t){return t(e)}function ut(...e){return e}function ot(e,t){return e(Mn,t)}function Me(e,t){e(ls,t)}function Ji(e){e(br)}function St(e){return e(wd)}function ge(e,t){return ot(e,ub(t,ls))}function ln(e,t){const n=e(Mn,r=>{n(),t(r)});return n}function Td(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function kd(e,t){return e===t}function dt(e=kd){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ie(e){return t=>n=>{e(n)&&t(n)}}function ce(e){return t=>Sd(t,e)}function wn(e){return t=>()=>{t(e)}}function W(e,...t){const n=hb(...t);return(r,o)=>{switch(r){case br:Ji(e);return;case Mn:return ot(e,n(o))}}}function bn(e,t){return n=>r=>{n(t=e(t,r))}}function Jn(e){return t=>n=>{e>0?e--:t(n)}}function An(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Fe(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);ot(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function hb(...e){return t=>e.reduceRight(fb,t)}function pb(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Mn:return s?n===s?void 0:(r(),n=s,t=ot(e,s),t):(r(),Sr);case br:r(),n=null;return}}}function Z(e){let t=e;const n=Xe();return(r,o)=>{switch(r){case ls:t=o;break;case Mn:{o(t);break}case wd:return t}return n(r,o)}}function Pt(e,t){return cs(Z(t),n=>ge(e,n))}function Xe(){const e=[];return(t,n)=>{switch(t){case ls:e.slice().forEach(r=>{r(n)});return;case br:e.splice(0,e.length);return;case Mn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Vt(e){return cs(Xe(),t=>ge(e,t))}function Qe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:mb(),singleton:n}}const mb=()=>Symbol();function gb(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 Ct(...e){const t=Xe(),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);ot(s,l=>{n[i]=l,r=r|a,r===o&&Me(t,n)})}),function(s,i){switch(s){case br:{Ji(t);return}case Mn:return r===o&&i(n),ot(t,i)}}}function Se(e,t=kd){return W(e,dt(t))}function Zi(...e){return function(t,n){switch(t){case br:return;case Mn:return db(...e.map(r=>ot(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 xb={0:"debug",3:"error",1:"log",2:"warn"},yb=()=>typeof globalThis>"u"?window:globalThis,Dn=Qe(()=>{const e=Z(3);return{log:Z((t,n,r=1)=>{var o;const s=(o=yb().VIRTUOSO_LOG_LEVEL)!=null?o:St(e);r>=s&&console[xb[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Zn(e,t,n){return Qi(e,t,n).callbackRef}function Qi(e,t,n){const r=b.useRef(null);let o=i=>{};const s=b.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function vb(e,t,n,r,o,s,i,a,l){const c=b.useCallback(d=>{const f=wb(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 m;p&&(m=h.ownerDocument.defaultView);const x=i?a?i.scrollLeft:i.scrollTop:p?a?m.scrollX||m.document.documentElement.scrollLeft:m.scrollY||m.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,y=i?a?i.scrollWidth:i.scrollHeight:p?a?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,g=i?a?i.offsetWidth:i.offsetHeight:p?a?m.innerWidth:m.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:y,scrollTop:Math.max(x,0),viewportHeight:g}),s==null||s(a?Ed("column-gap",getComputedStyle(d).columnGap,o):Ed("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return Qi(c,n,l)}function wb(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),c=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Bt.ERROR),d===c)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Ed(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 Id(e,t,n){const r=b.useRef(null),o=b.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let f,h;if(t){const p=t.getBoundingClientRect(),m=c.top-p.top;h=p.height-Math.max(0,m),f=m+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;h=p.innerHeight-Math.max(0,c.top),f=c.top+p.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Qi(o,!0,n),a=b.useCallback(()=>{o(i.current)},[o,i]);return b.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const Lt=Qe(()=>{const e=Xe(),t=Xe(),n=Z(0),r=Xe(),o=Z(0),s=Xe(),i=Xe(),a=Z(0),l=Z(0),c=Z(0),d=Z(0),f=Xe(),h=Xe(),p=Z(!1),m=Z(!1),x=Z(!1);return ge(W(e,ce(({scrollTop:y})=>y)),t),ge(W(e,ce(({scrollHeight:y})=>y)),i),ge(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:m,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:x,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Wr={lvl:0};function Nd(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 at(e){return e===Wr}function Vr(e,t){if(!at(e))return t===e.k?e.v:t<e.k?Vr(e.l,t):Vr(e.r,t)}function cn(e,t,n="k"){if(at(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=cn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return cn(e.l,t,n)}function Kt(e,t,n){return at(e)?_d(t,n,1):t===e.k?Tt(e,{k:t,v:n}):t<e.k?Rd(Tt(e,{l:Kt(e.l,t,n)})):Rd(Tt(e,{r:Kt(e.r,t,n)}))}function Cr(){return Wr}function us(e,t,n){if(at(e))return[];const r=cn(e,t)[0];return bb(ta(e,r,n))}function ea(e,t){if(at(e))return Wr;const{k:n,l:r,r:o}=e;if(t===n){if(at(r))return o;if(at(o))return r;{const[s,i]=jd(r);return ds(Tt(e,{k:s,l:Ad(r),v:i}))}}else return t<n?ds(Tt(e,{l:ea(r,t)})):ds(Tt(e,{r:ea(o,t)}))}function Qn(e){return at(e)?[]:[...Qn(e.l),{k:e.k,v:e.v},...Qn(e.r)]}function ta(e,t,n){if(at(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(ta(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(ta(s,t,n))),a}function ds(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(na(t))return Pd(Tt(e,{lvl:n-1}));if(!at(t)&&!at(t.r))return Tt(t.r,{l:Tt(t,{r:t.r.l}),lvl:n,r:Tt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(na(e))return ra(Tt(e,{lvl:n-1}));if(!at(r)&&!at(r.l)){const o=r.l,s=na(o)?r.lvl-1:r.lvl;return Tt(o,{l:Tt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:ra(Tt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Tt(e,t){return _d(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 Ad(e){return at(e.r)?e.l:ds(Tt(e,{r:Ad(e.r)}))}function na(e){return at(e)||e.lvl>e.r.lvl}function jd(e){return at(e.r)?[e.k,e.v]:jd(e.r)}function _d(e,t,n,r=Wr,o=Wr){return{k:e,l:r,lvl:n,r:o,v:t}}function Rd(e){return ra(Pd(e))}function Pd(e){const{l:t}=e;return!at(t)&&t.lvl===e.lvl?Tt(t,{r:Tt(e,{l:t.r})}):e}function ra(e){const{lvl:t,r:n}=e;return!at(n)&&!at(n.r)&&n.lvl===t&&n.r.lvl===t?Tt(n,{l:Tt(e,{r:n.l}),lvl:t+1}):e}function bb(e){return Nd(e,({k:t,v:n})=>({index:t,value:n}))}function Od(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Kr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const oa=Qe(()=>({recalcInProgress:Z(!1)}),[],{singleton:!0});function Md(e,t,n){return e[fs(e,t,n)]}function fs(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 Sb(e,t,n,r){const o=fs(e,t,r),s=fs(e,n,r,o);return e.slice(o,s+1)}function Ln(e,t){return Math.round(e.getBoundingClientRect()[t])}function hs(e){return!at(e.groupOffsetTree)}function sa({index:e},t){return t===e?0:t<e?-1:1}function Cb(){return{groupIndices:[],groupOffsetTree:Cr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Cr()}}function Tb(e,t){let n=at(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),at(e)){e=Kt(e,0,s);continue}const a=us(e,i-1,o+1);if(a.some(_b(r)))continue;let l=!1,c=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=ea(e,f)):(c=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=Kt(e,o+1,h));c&&(e=Kt(e,i,s))}return[e,n]}function kb(e){return typeof e.groupIndex<"u"}function Eb({offset:e},t){return t===e?0:t<e?-1:1}function qr(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Md(t,e,sa),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Dd(e,t){if(!hs(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Ld(e,t,n){if(kb(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Dd(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function Ib(e,t,n,r=0){return r>0&&(t=Math.max(t,Md(e,r,sa).offset)),Nd(Sb(e,t,n,Eb),jb)}function Nb(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&&at(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((m,x)=>Kt(Kt(m,x,h),x+1,p),i)}else[i,a]=Tb(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f}=ia(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>Kt(h,p,qr(p,f,o)),Cr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f,sizeTree:i}}function Ab(e){return Qn(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 $d(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 ia(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=fs(o,t-1,sa),a=o[l].offset;const c=cn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===cn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of us(n,t,1/0)){const f=c-s,h=f*i+a+f*r;o.push({index:c,offset:h,size:d}),s=c,a=h,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function jb(e){return{index:e.index,value:e}}function _b(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 Rb={offsetHeight:"height",offsetWidth:"width"},Sn=Qe(([{log:e},{recalcInProgress:t}])=>{const n=Xe(),r=Xe(),o=Pt(r,0),s=Xe(),i=Xe(),a=Z(0),l=Z([]),c=Z(void 0),d=Z(void 0),f=Z((T,C)=>Ln(T,Rb[C])),h=Z(void 0),p=Z(0),m=Cb(),x=Pt(W(n,Fe(l,e,p),bn(Nb,m),dt()),m),y=Pt(W(l,dt(),bn((T,C)=>({current:C,prev:T.current}),{current:[],prev:[]}),ce(({prev:T})=>T)),[]);ge(W(l,Ie(T=>T.length>0),Fe(x,p),ce(([T,C,E])=>{const N=T.reduce((j,D,P)=>Kt(j,D,qr(D,C.offsetTree,E)||P),Cr());return{...C,groupIndices:T,groupOffsetTree:N}})),x),ge(W(r,Fe(x),Ie(([T,{lastIndex:C}])=>T<C),ce(([T,{lastIndex:C,lastSize:E}])=>[{endIndex:C,size:E,startIndex:T}])),n),ge(c,d);const g=Pt(W(c,ce(T=>T===void 0)),!0);ge(W(d,Ie(T=>T!==void 0&&at(St(x).sizeTree)),ce(T=>[{endIndex:0,size:T,startIndex:0}])),n);const w=Vt(W(n,Fe(x),bn(({sizes:T},[C,E])=>({changed:E!==T,sizes:E}),{changed:!1,sizes:m}),ce(T=>T.changed)));ot(W(a,bn((T,C)=>({diff:T.prev-C,prev:C}),{diff:0,prev:0}),ce(T=>T.diff)),T=>{const{groupIndices:C}=St(x);if(T>0)Me(t,!0),Me(s,T+$d(T,C));else if(T<0){const E=St(y);E.length>0&&(T-=$d(-T,E)),Me(i,T)}}),ot(W(a,Fe(e)),([T,C])=>{T<0&&C("`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=Vt(s);ge(W(s,Fe(x),ce(([T,C])=>{const E=C.groupIndices.length>0,N=[],j=C.lastSize;if(E){const D=Vr(C.sizeTree,0);let P=0,M=0;for(;P<T;){const A=C.groupIndices[M],z=C.groupIndices.length===M+1?1/0:C.groupIndices[M+1]-A-1;N.push({endIndex:A,size:D,startIndex:A}),N.push({endIndex:A+1+z-1,size:j,startIndex:A+1}),M++,P+=z+1}const F=Qn(C.sizeTree);return P!==T&&F.shift(),F.reduce((A,{k:z,v:_})=>{let X=A.ranges;return A.prevSize!==0&&(X=[...A.ranges,{endIndex:z+T-1,size:A.prevSize,startIndex:A.prevIndex}]),{prevIndex:z+T,prevSize:_,ranges:X}},{prevIndex:T,prevSize:0,ranges:N}).ranges}return Qn(C.sizeTree).reduce((D,{k:P,v:M})=>({prevIndex:P+T,prevSize:M,ranges:[...D.ranges,{endIndex:P+T-1,size:D.prevSize,startIndex:D.prevIndex}]}),{prevIndex:0,prevSize:j,ranges:[]}).ranges})),n);const k=Vt(W(i,Fe(x,p),ce(([T,{offsetTree:C},E])=>{const N=-T;return qr(N,C,E)})));return ge(W(i,Fe(x,p),ce(([T,C,E])=>{if(C.groupIndices.length>0){if(at(C.sizeTree))return C;let N=Cr();const j=St(y);let D=0,P=0,M=0;for(;D<-T;){M=j[P];const F=j[P+1]-M-1;P++,D+=F+1}if(N=Qn(C.sizeTree).reduce((F,{k:A,v:z})=>Kt(F,Math.max(0,A+T),z),N),D!==-T){const F=Vr(C.sizeTree,M);N=Kt(N,0,F);const A=cn(C.sizeTree,-T+1)[1];N=Kt(N,1,A)}return{...C,sizeTree:N,...ia(C.offsetTree,0,N,E)}}else{const N=Qn(C.sizeTree).reduce((j,{k:D,v:P})=>Kt(j,Math.max(0,D+T),P),Cr());return{...C,sizeTree:N,...ia(C.offsetTree,0,N,E)}}})),x),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:p,groupIndices:l,itemSize:f,listRefresh:w,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:x,statefulTotalCount:o,totalCount:r,trackItemSizes:g,unshiftWith:s}},ut(Dn,oa),{singleton:!0});function Pb(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Fd=Qe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Xe(),i=Xe(),a=Vt(W(s,ce(Pb)));return ge(W(a,ce(l=>l.totalCount)),n),ge(W(a,ce(l=>l.groupIndices)),e),ge(W(Ct(o,t,r),Ie(([l,c])=>hs(c)),ce(([l,c,d])=>cn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),dt(),ce(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},ut(Sn,Lt)),$n=Qe(([{log:e}])=>{const t=Z(!1),n=Vt(W(t,Ie(r=>r),dt()));return ot(t,r=>{r&&St(e)("props updated",{},Bt.DEBUG)}),{didMount:n,propsReady:t}},ut(Dn),{singleton:!0}),Ob=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function zd(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Ob)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Gr=Qe(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const p=Xe(),m=Xe(),x=Z(0);let y=null,g=null,w=null;function S(){y&&(y(),y=null),w&&(w(),w=null),g&&(clearTimeout(g),g=null),Me(l,!1)}return ge(W(p,Fe(n,f,r,x,a,i,h),Fe(e,s,o),ce(([[k,T,C,E,N,j,D,P],M,F,A])=>{const z=zd(k),{align:_,behavior:X,offset:$}=z,R=E-1,J=Ld(z,T,R);let G=qr(J,T.offsetTree,M)+j;_==="end"?(G+=F+cn(T.sizeTree,J)[1]-C+A,J===R&&(G+=D)):_==="center"?G+=(F+cn(T.sizeTree,J)[1]-C+A)/2:G-=N,$&&(G+=$);const pe=Ce=>{S(),Ce?(P("retrying to scroll to",{location:k},Bt.DEBUG),Me(p,k)):(Me(m,!0),P("list did not change, scroll successful",{},Bt.DEBUG))};if(S(),X==="smooth"){let Ce=!1;w=ot(t,Ae=>{Ce=Ce||Ae}),y=ln(d,()=>{pe(Ce)})}else y=ln(W(t,Mb(150)),pe);return g=setTimeout(()=>{S()},1200),Me(l,!0),P("scrolling from index to",{behavior:X,index:J,top:G},Bt.DEBUG),{behavior:X,top:G}})),c),{scrollTargetReached:m,scrollToIndex:p,topListHeight:x}},ut(Sn,Lt,Dn),{singleton:!0});function Mb(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function aa(e,t){e==0?t():requestAnimationFrame(()=>{aa(e-1,t)})}function la(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Yr=Qe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=Z(!0),l=Z(0),c=Z(!0);return ge(W(i,Fe(l),Ie(([d,f])=>!!f),wn(!1)),a),ge(W(i,Fe(l),Ie(([d,f])=>!!f),wn(!1)),c),ot(W(Ct(t,i),Fe(a,n,e,c),Ie(([[,d],f,{sizeTree:h},p,m])=>d&&(!at(h)||Xi(p))&&!f&&!m),Fe(l)),([,d])=>{ln(o,()=>{Me(c,!0)}),aa(4,()=>{ln(r,()=>{Me(a,!0)}),Me(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},ut(Sn,Lt,Gr,$n),{singleton:!0});function Bd(e,t){return Math.abs(e-t)<1.01}const Xr="up",Jr="down",Db="none",Lb={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},$b=0,Zr=Qe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=Z(!1),a=Z(!0),l=Xe(),c=Xe(),d=Z(4),f=Z($b),h=Pt(W(Zi(W(Se(o),Jn(1),wn(!0)),W(Se(o),Jn(1),wn(!1),Td(100))),dt()),!1),p=Pt(W(Zi(W(n,wn(!0)),W(n,wn(!1),Td(200))),dt()),!1);ge(W(Ct(Se(o),Se(f)),ce(([w,S])=>w<=S),dt()),a),ge(W(a,An(50)),c);const m=Vt(W(Ct(r,Se(s),Se(t),Se(e),Se(d)),bn((w,[{scrollHeight:S,scrollTop:k},T,C,E,N])=>{const j=k+T-S>-N,D={scrollHeight:S,scrollTop:k,viewportHeight:T};if(j){let M,F;return k>w.state.scrollTop?(M="SCROLLED_DOWN",F=w.state.scrollTop-k):(M="SIZE_DECREASED",F=w.state.scrollTop-k||w.scrollTopDelta),{atBottom:!0,atBottomBecause:M,scrollTopDelta:F,state:D}}let P;return D.scrollHeight>w.state.scrollHeight?P="SIZE_INCREASED":T<w.state.viewportHeight?P="VIEWPORT_HEIGHT_DECREASING":k<w.state.scrollTop?P="SCROLLING_UPWARDS":P="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:P,state:D}},Lb),dt((w,S)=>w&&w.atBottom===S.atBottom))),x=Pt(W(r,bn((w,{scrollHeight:S,scrollTop:k,viewportHeight:T})=>{if(Bd(w.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const C=S-(k+T)<1;return w.scrollTop!==k&&C?{changed:!0,jump:w.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ie(w=>w.changed),ce(w=>w.jump)),0);ge(W(m,ce(w=>w.atBottom)),i),ge(W(i,An(50)),l);const y=Z(Jr);ge(W(r,ce(({scrollTop:w})=>w),dt(),bn((w,S)=>St(p)?{direction:w.direction,prevScrollTop:S}:{direction:S<w.prevScrollTop?Xr:Jr,prevScrollTop:S},{direction:Jr,prevScrollTop:0}),ce(w=>w.direction)),y),ge(W(r,An(50),wn(Db)),y);const g=Z(0);return ge(W(h,Ie(w=>!w),wn(0)),g),ge(W(o,An(100),Fe(h),Ie(([w,S])=>!!S),bn(([w,S],[k])=>[S,k],[0,0]),ce(([w,S])=>S-w)),g),{atBottomState:m,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:x,scrollDirection:y,scrollVelocity:g}},ut(Lt)),ps="top",ms="bottom",Hd="none";function Ud(e,t,n){return typeof e=="number"?n===Xr&&t===ps||n===Jr&&t===ms?e:0:n===Xr?t===ps?e.main:e.reverse:t===ms?e.main:e.reverse}function Wd(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const ca=Qe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Xe(),i=Z(0),a=Z(0),l=Z(0),c=Pt(W(Ct(Se(r),Se(o),Se(n),Se(s,Kr),Se(l),Se(i),Se(t),Se(e),Se(a)),ce(([d,f,h,[p,m],x,y,g,w,S])=>{const k=d-w,T=y+g,C=Math.max(h-k,0);let E=Hd;const N=Wd(S,ps),j=Wd(S,ms);return p-=w,p+=h+g,m+=h+g,m-=w,p>d+T-N&&(E=Xr),m<d-C+f+j&&(E=Jr),E!==Hd?[Math.max(k-h-Ud(x,ps,E)-N,0),k-C-g+f+Ud(x,ms,E)+j]:null}),Ie(d=>d!=null),dt(Kr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},ut(Lt),{singleton:!0});function Fb(e,t,n){if(hs(t)){const r=Dd(e,t);return[{index:cn(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 ua={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function gs(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const x=e[e.length-1];d=x.offset+x.size}const f=n-i,h=a+f*l+(f-1)*r,p=c,m=h-d;return{bottom:d,firstItemIndex:s,items:Kd(e,o,s),offsetBottom:m,offsetTop:c,top:p,topItems:Kd(t,o,s),topListHeight:t.reduce((x,y)=>y.size+x,0),totalCount:n}}function Vd(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=la(t,a),c=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return gs(c,[],a,o,n,r)}function Kd(e,t,n){if(e.length===0)return[];if(!hs(t))return e.map(c=>({...c,index:c.index+n,originalIndex:c.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=us(t.groupOffsetTree,r,o);let a,l=0;for(const c of e){(!a||a.end<c.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;c.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},s.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}const er=Qe(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:p},{recalcInProgress:m}])=>{const x=Z([]),y=Z(0),g=Xe();ge(s.topItemsIndexes,x);const w=Pt(W(Ct(p,m,Se(l,Kr),Se(o),Se(r),Se(c),d,Se(x),Se(t),Se(n),e),Ie(([C,E,,N,,,,,,,j])=>{const D=j&&j.length!==N;return C&&!E&&!D}),ce(([,,[C,E],N,j,D,P,M,F,A,z])=>{const _=j,{offsetTree:X,sizeTree:$}=_,R=St(y);if(N===0)return{...ua,totalCount:N};if(C===0&&E===0)return R===0?{...ua,totalCount:N}:Vd(R,D,j,F,A,z||[]);if(at($))return R>0?null:gs(Fb(la(D,N),_,z),[],N,A,_,F);const J=[];if(M.length>0){const q=M[0],ne=M[M.length-1];let Y=0;for(const L of us($,q,ne)){const H=L.value,V=Math.max(L.start,q),ie=Math.min(L.end,ne);for(let re=V;re<=ie;re++)J.push({data:z==null?void 0:z[re],index:re,offset:Y,size:H}),Y+=H}}if(!P)return gs([],J,N,A,_,F);const G=M.length>0?M[M.length-1]+1:0,pe=Ib(X,C,E,G);if(pe.length===0)return null;const Ce=N-1,Ae=cs([],q=>{for(const ne of pe){const Y=ne.value;let L=Y.offset,H=ne.start;const V=Y.size;if(Y.offset<C){H+=Math.floor((C-Y.offset+A)/(V+A));const re=H-ne.start;L+=re*V+re*A}H<G&&(L+=(G-H)*V,H=G);const ie=Math.min(ne.end,Ce);for(let re=H;re<=ie&&!(L>=E);re++)q.push({data:z==null?void 0:z[re],index:re,offset:L,size:V}),L+=V+A}});return gs(Ae,J,N,A,_,F)}),Ie(C=>C!==null),dt()),ua);ge(W(e,Ie(Xi),ce(C=>C==null?void 0:C.length)),o),ge(W(w,ce(C=>C.topListHeight)),f),ge(f,a),ge(W(w,ce(C=>[C.top,C.bottom])),i),ge(W(w,ce(C=>C.items)),g);const S=Vt(W(w,Ie(({items:C})=>C.length>0),Fe(o,e),Ie(([{items:C},E])=>C[C.length-1].originalIndex===E-1),ce(([,C,E])=>[C-1,E]),dt(Kr),ce(([C])=>C))),k=Vt(W(w,An(200),Ie(({items:C,topItems:E})=>C.length>0&&C[0].originalIndex===E.length),ce(({items:C})=>C[0].index),dt())),T=Vt(W(w,Ie(({items:C})=>C.length>0),ce(({items:C})=>{let E=0,N=C.length-1;for(;C[E].type==="group"&&E<N;)E++;for(;C[N].type==="group"&&N>E;)N--;return{endIndex:C[N].index,startIndex:C[E].index}}),dt(Od)));return{endReached:S,initialItemCount:y,itemsRendered:g,listState:w,rangeChanged:T,startReached:k,topItemsIndexes:x,...h}},ut(Sn,Fd,ca,Yr,Gr,Zr,$n,oa),{singleton:!0}),qd=Qe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Xe(),i=Pt(W(Ct(n,e,r,t,o),ce(([a,l,c,d,f])=>a+l+c+d+f.offsetBottom+f.bottom)),0);return ge(Se(i),s),{totalListHeight:i,totalListHeightChanged:s}},ut(Lt,er),{singleton:!0}),zb=Qe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=Z(!1),r=Pt(W(Ct(n,e,t),Ie(([o])=>o),ce(([,o,s])=>Math.max(0,o-s)),An(0),dt()),0);return{alignToBottom:n,paddingTopAddition:r}},ut(Lt,qd),{singleton:!0}),Gd=Qe(()=>({context:Z(null)})),Bb=({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,Yd=Qe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=Xe();return ge(W(d,Fe(t,l,n,s,o,r,a),Fe(e),ce(([[f,h,p,m,x,y,g,w],S])=>{const{align:k,behavior:T,calculateViewLocation:C=Bb,done:E,...N}=f,j=Ld(f,h,m-1),D=qr(j,h.offsetTree,S)+x+y,P=D+cn(h.sizeTree,j)[1],M=w+y,F=w+p-g,A=C({itemBottom:P,itemTop:D,locationParams:{align:k,behavior:T,...N},viewportBottom:F,viewportTop:M});return A?E&&ln(W(i,Ie(z=>!z),Jn(St(i)?1:2)),E):E&&E(),A}),Ie(f=>f!==null)),c),{scrollIntoView:d}},ut(Sn,Lt,Gr,er,Dn),{singleton:!0});function Xd(e){return e?e==="smooth"?"smooth":"auto":!1}const Hb=(e,t)=>typeof e=="function"?Xd(e(t)):t&&Xd(e),Ub=Qe(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:p}])=>{const m=Z(!1),x=Xe();let y=null;function g(T){Me(i,{align:"end",behavior:T,index:"LAST"})}ot(W(Ct(W(Se(t),Jn(1)),l),Fe(Se(m),s,a,f),ce(([[T,C],E,N,j,D])=>{let P=C&&j,M="auto";return P&&(M=Hb(E,N||D),P=P&&!!M),{followOutputBehavior:M,shouldFollow:P,totalCount:T}}),Ie(({shouldFollow:T})=>T)),({followOutputBehavior:T,totalCount:C})=>{y&&(y(),y=null),St(n)?requestAnimationFrame(()=>{St(d)("following output to ",{totalCount:C},Bt.DEBUG),g(T)}):y=ln(e,()=>{St(d)("following output to ",{totalCount:C},Bt.DEBUG),g(T),y=null})});function w(T){const C=ln(o,E=>{T&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!y&&(St(d)("scrolling to bottom due to increased size",{},Bt.DEBUG),g("auto"))});setTimeout(C,100)}ot(W(Ct(Se(m),t,c),Ie(([T,,C])=>T&&C),bn(({value:T},[,C])=>({refreshed:T===C,value:C}),{refreshed:!1,value:0}),Ie(({refreshed:T})=>T),Fe(m,t)),([,T])=>{St(a)&&w(T!==!1)}),ot(x,()=>{w(St(m)!==!1)}),ot(Ct(Se(m),o),([T,C])=>{T&&!C.atBottom&&C.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&g("auto")});const S=Z(null),k=Xe();return ge(Zi(W(Se(r),ce(T=>{var C;return(C=T==null?void 0:T.length)!=null?C:0})),W(Se(t))),k),ot(W(Ct(W(k,Jn(1)),l),Fe(Se(S),a,f,h),ce(([[T,C],E,N,j,D])=>C&&N&&(E==null?void 0:E({context:D,totalCount:T,scrollingInProgress:j}))),Ie(T=>!!T),An(0)),T=>{y&&(y(),y=null),St(n)?requestAnimationFrame(()=>{St(d)("scrolling into view",{}),Me(p,T)}):y=ln(e,()=>{St(d)("scrolling into view",{}),Me(p,T),y=null})}),{autoscrollToBottom:x,followOutput:m,scrollIntoViewOnChange:S}},ut(Sn,Zr,Gr,Yr,$n,Dn,Lt,Gd,Yd)),Wb=Qe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ge(W(a,Fe(s),Ie(([,l])=>l!==0),Fe(o,r,t,n,e),ce(([[,l],c,d,f,h,p=[]])=>Vd(l,c,d,f,h,p))),i),{}),ut(Sn,Yr,er,$n),{singleton:!0}),Vb=Qe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=Z(0);return ot(W(e,Fe(r),Ie(([,o])=>o!==0),ce(([,o])=>({top:o}))),o=>{ln(W(n,Jn(1),Ie(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Me(t,o)})})}),{initialScrollTop:r}},ut($n,Lt,er),{singleton:!0}),Jd=Qe(([{scrollVelocity:e}])=>{const t=Z(!1),n=Xe(),r=Z(!1);return ge(W(e,Fe(r,t,n),Ie(([o,s])=>!!s),ce(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),dt()),t),ot(W(Ct(t,e,n),Fe(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},ut(Zr),{singleton:!0}),da=Qe(([{scrollContainerState:e,scrollTo:t}])=>{const n=Xe(),r=Xe(),o=Xe(),s=Z(!1),i=Z(void 0);return ge(W(Ct(n,r),ce(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),ge(W(t,Fe(r),ce(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},ut(Lt)),Kb=Qe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=Xe(),d=Z(void 0),f=Z(null),h=Z(null);return ge(a,f),ge(l,h),ot(W(c,Fe(t,r,i,f,h,n)),([p,m,x,y,g,w,S])=>{const k=Ab(m.sizeTree);y&&g!==null&&w!==null&&(x=g.scrollTop-w.offsetTop),x-=S,p({ranges:k,scrollTop:x})}),ge(W(d,Ie(Xi),ce(qb)),o),ge(W(s,Fe(d),Ie(([,p])=>p!==void 0),dt(),ce(([,p])=>p.ranges)),e),{getState:c,restoreStateFrom:d}},ut(Sn,Lt,Yr,$n,da));function qb(e){return{align:"start",index:0,offset:e.scrollTop}}const Gb=Qe(([{topItemsIndexes:e}])=>{const t=Z(0);return ge(W(t,Ie(n=>n>=0),ce(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ut(er));function Zd(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const Yb=Zd(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Xb=Qe(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:f,sizes:h},{log:p},{recalcInProgress:m}])=>{const x=Vt(W(l,Fe(i),bn(([,g,w,S],[{bottom:k,items:T,offsetBottom:C,totalCount:E},N])=>{const j=k+C;let D=0;return w===E&&g.length>0&&T.length>0&&(T[0].originalIndex===0&&g[0].originalIndex===0||(D=j-S,D!==0&&(D+=N))),[D,T,E,j]},[0,[],0,0]),Ie(([g])=>g!==0),Fe(r,a,n,o,p,m),Ie(([,g,w,S,,,k])=>!k&&!S&&g!==0&&w===Xr),ce(([[g],,,,,w])=>(w("Upward scrolling compensation",{amount:g},Bt.DEBUG),g))));function y(g){g>0?(Me(t,{behavior:"auto",top:-g}),Me(e,0)):(Me(e,0),Me(t,{behavior:"auto",top:-g}))}return ot(W(x,Fe(e,s)),([g,w,S])=>{S&&Yb()?Me(e,w-g):y(-g)}),ot(W(Ct(Pt(s,!1),e,m),Ie(([g,w,S])=>!g&&!S&&w!==0),ce(([g,w])=>w),An(1)),y),ge(W(f,ce(g=>({top:-g}))),t),ot(W(c,Fe(h,d),ce(([g,{groupIndices:w,lastSize:S,sizeTree:k},T])=>{function C(E){return E*(S+T)}if(w.length===0)return C(g);{let E=0;const N=Vr(k,0);let j=0,D=0;for(;j<g;){j++,E+=N;let P=w.length===D+1?1/0:w[D+1]-w[D]-1;j+P>g&&(E-=N,P=g-j+1),j+=P,E+=C(P),D++}return E}})),g=>{Me(e,g),requestAnimationFrame(()=>{Me(t,{top:g}),requestAnimationFrame(()=>{Me(e,0),Me(m,!1)})})}),{deviation:e}},ut(Lt,Zr,er,Sn,Dn,oa)),Jb=Qe(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),ut(ca,Wb,$n,Jd,qd,Vb,zb,da,Yd,Dn,Gd)),Qd=Qe(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:m},x,y,g,{listState:w,topItemsIndexes:S,...k},{scrollToIndex:T},C,{topItemCount:E},{groupCounts:N},j])=>(ge(k.rangeChanged,j.scrollSeekRangeChanged),ge(W(j.windowViewportRect,ce(D=>D.visibleHeight)),x.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:N,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:m,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...g,groupIndices:s,itemSize:i,listState:w,scrollToIndex:T,statefulTotalCount:c,trackItemSizes:f,...k,...j,...x,sizes:l,...y}),ut(Sn,Yr,Lt,Kb,Ub,er,Gr,Xb,Gb,Fd,Jb));function Zb(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 xs=typeof document<"u"?b.useLayoutEffect:b.useEffect;function ef(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=b.createContext({});function l(y,g){y.propsReady&&Me(y.propsReady,!1);for(const w of r){const S=y[t.required[w]];Me(S,g[w])}for(const w of o)if(w in g){const S=y[t.optional[w]];Me(S,g[w])}y.propsReady&&Me(y.propsReady,!0)}function c(y){return s.reduce((g,w)=>(g[w]=S=>{const k=y[t.methods[w]];Me(k,S)},g),{})}function d(y){return i.reduce((g,w)=>(g[w]=pb(y[t.events[w]]),g),{})}const f=b.forwardRef((y,g)=>{const{children:w,...S}=y,[k]=b.useState(()=>cs(gb(e),E=>{l(E,S)})),[T]=b.useState(Cd(d,k));xs(()=>{for(const E of i)E in S&&ot(T[E],S[E]);return()=>{Object.values(T).map(Ji)}},[S,T,k]),xs(()=>{l(k,S)}),b.useImperativeHandle(g,bd(c(k)));const C=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(C,{...Zb([...r,...o,...i],S),children:w}):w})}),h=y=>{const g=b.useContext(a);return b.useCallback(w=>{Me(g[y],w)},[g,y])},p=y=>{const g=b.useContext(a)[y],w=b.useCallback(S=>ot(g,S),[g]);return b.useSyncExternalStore(w,()=>St(g),()=>St(g))},m=y=>{const g=b.useContext(a)[y],[w,S]=b.useState(Cd(St,g));return xs(()=>ot(g,k=>{k!==w&&S(bd(k))}),[g,w]),w},x=b.version.startsWith("18")?p:m;return{Component:f,useEmitter:(y,g)=>{const w=b.useContext(a)[y];xs(()=>ot(w,g),[g,w])},useEmitterValue:x,usePublisher:h}}const tf=b.createContext(void 0),nf=b.createContext(void 0),rf=typeof document<"u"?b.useLayoutEffect:b.useEffect;function fa(e){return"self"in e}function Qb(e){return"body"in e}function of(e,t,n,r=Sr,o,s){const i=b.useRef(null),a=b.useRef(null),l=b.useRef(null),c=b.useCallback(h=>{let p,m,x;const y=h.target;if(Qb(y)||fa(y)){const w=fa(y)?y:y.defaultView;x=s?w.scrollX:w.scrollY,p=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,m=s?w.innerWidth:w.innerHeight}else x=s?y.scrollLeft:y.scrollTop,p=s?y.scrollWidth:y.scrollHeight,m=s?y.offsetWidth:y.offsetHeight;const g=()=>{e({scrollHeight:p,scrollTop:Math.max(x,0),viewportHeight:m})};h.suppressFlushSync?g():Ks.flushSync(g),a.current!==null&&(x===a.current||x<=0||x===p-m)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);b.useEffect(()=>{const h=o||i.current;return r(o||i.current),c({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",c,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",c)}},[i,c,n,r,o]);function d(h){const p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const m=h.behavior==="smooth";let x,y,g;fa(p)?(y=Math.max(Ln(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),x=s?p.innerWidth:p.innerHeight,g=s?window.scrollX:window.scrollY):(y=p[s?"scrollWidth":"scrollHeight"],x=Ln(p,s?"width":"height"),g=p[s?"scrollLeft":"scrollTop"]);const w=y-x;if(h.top=Math.ceil(Math.max(Math.min(w,h.top),0)),Bd(x,y)||h.top===g){e({scrollHeight:y,scrollTop:g,viewportHeight:x}),m&&t(!0);return}m?(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 ha="-webkit-sticky",sf="sticky",pa=Zd(()=>{if(typeof document>"u")return sf;const e=document.createElement("div");return e.style.position=ha,e.style.position===ha?ha:sf});function ma(e){return e}const e0=Qe(()=>{const e=Z(a=>`Item ${a}`),t=Z(a=>`Group ${a}`),n=Z({}),r=Z(ma),o=Z("div"),s=Z(Sr),i=(a,l=null)=>Pt(W(n,ce(c=>c[a]),dt()),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")}}),t0=Qe(([e,t])=>({...e,...t}),ut(Qd,e0)),n0=({height:e})=>u.jsx("div",{style:{height:e}}),r0={overflowAnchor:"none",position:pa(),zIndex:1},af={overflowAnchor:"none"},o0={...af,display:"inline-block",height:"100%"},lf=b.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"),c=Re("context"),d=Re("groupContent"),f=Re("trackItemSizes"),h=Re("itemSize"),p=Re("log"),m=Zt("gap"),x=Re("horizontalDirection"),{callbackRef:y}=vb(n,h,f,e?Sr:a,p,m,o,x,Re("skipAnimationFrameInResizeObserver")),[g,w]=b.useState(0);ga("deviation",A=>{g!==A&&w(A)});const S=Re("EmptyPlaceholder"),k=Re("ScrollSeekPlaceholder")||n0,T=Re("ListComponent"),C=Re("ItemComponent"),E=Re("GroupComponent"),N=Re("computeItemKey"),j=Re("isSeeking"),D=Re("groupIndices").length>0,P=Re("alignToBottom"),M=Re("initialItemFinalLocationReached"),F=e?{}:{boxSizing:"border-box",...x?{display:"inline-block",height:"100%",marginLeft:g!==0?g:P?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:g!==0?g:P?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...M?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{...Ot(S,c)}):u.jsx(T,{...Ot(T,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:y,style:F,children:(e?t.topItems:t.items).map(A=>{const z=A.originalIndex,_=N(z+t.firstItemIndex,A.data,c);return j?b.createElement(k,{...Ot(k,c),height:A.size,index:A.index,key:_,type:A.type||"item",...A.type==="group"?{}:{groupIndex:A.groupIndex}}):A.type==="group"?b.createElement(E,{...Ot(E,c),"data-index":z,"data-item-index":A.index,"data-known-size":A.size,key:_,style:r0},d(A.index,c)):b.createElement(C,{...Ot(C,c),...l0(C,A.data),"data-index":z,"data-item-group-index":A.groupIndex,"data-item-index":A.index,"data-known-size":A.size,key:_,style:x?o0:af},D?l(A.index,A.groupIndex,A.data,c):l(A.index,A.data,c))})})}),s0={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},i0={outline:"none",overflowX:"auto",position:"relative"},ys=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),a0={position:pa(),top:0,width:"100%",zIndex:1};function Ot(e,t){if(typeof e!="string")return{context:t}}function l0(e,t){return{item:typeof e=="string"?void 0:t}}const c0=b.memo(function(){const e=Re("HeaderComponent"),t=Zt("headerHeight"),n=Re("HeaderFooterTag"),r=Zn(b.useMemo(()=>s=>{t(Ln(s,"height"))},[t]),!0,Re("skipAnimationFrameInResizeObserver")),o=Re("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null}),u0=b.memo(function(){const e=Re("FooterComponent"),t=Zt("footerHeight"),n=Re("HeaderFooterTag"),r=Zn(b.useMemo(()=>s=>{t(Ln(s,"height"))},[t]),!0,Re("skipAnimationFrameInResizeObserver")),o=Re("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null});function cf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:m}=of(a,c,l,d,void 0,f);return e("scrollTo",m),e("scrollBy",h),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?i0:s0,...o},tabIndex:0,...i,...Ot(l,s),children:r})})}function uf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=b.useRef(null),m=t("scrollerRef"),{scrollByCallback:x,scrollerRef:y,scrollToCallback:g}=of(a,c,l,m,h);return rf(()=>{var w;return y.current=h||((w=p.current)==null?void 0:w.ownerDocument.defaultView),()=>{y.current=null}},[y,h]),e("windowScrollTo",g),e("scrollBy",x),u.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Ot(l,s),children:r})})}const d0=({children:e})=>{const t=b.useContext(tf),n=Zt("viewportHeight"),r=Zt("fixedItemHeight"),o=Re("alignToBottom"),s=Re("horizontalDirection"),i=b.useMemo(()=>Sd(n,l=>Ln(l,s?"width":"height")),[n,s]),a=Zn(i,!0,Re("skipAnimationFrameInResizeObserver"));return b.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:ys(o),children:e})},f0=({children:e})=>{const t=b.useContext(tf),n=Zt("windowViewportRect"),r=Zt("fixedItemHeight"),o=Re("customScrollParent"),s=Id(n,o,Re("skipAnimationFrameInResizeObserver")),i=Re("alignToBottom");return b.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:s,style:ys(i),children:e})},h0=({children:e})=>{const t=Re("TopItemListComponent")||"div",n=Re("headerHeight"),r={...a0,marginTop:`${n}px`},o=Re("context");return u.jsx(t,{style:r,...Ot(t,o),children:e})},p0=b.memo(function(e){const t=Re("useWindowScroll"),n=Re("topItemsIndexes").length>0,r=Re("customScrollParent"),o=Re("context");return u.jsxs(r||t?x0:g0,{...e,context:o,children:[n&&u.jsx(h0,{children:u.jsx(lf,{showTopList:!0})}),u.jsxs(r||t?f0:d0,{children:[u.jsx(c0,{}),u.jsx(lf,{}),u.jsx(u0,{})]})]})}),{Component:m0,useEmitter:ga,useEmitterValue:Re,usePublisher:Zt}=ef(t0,{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"}},p0),g0=cf({useEmitter:ga,useEmitterValue:Re,usePublisher:Zt}),x0=uf({useEmitter:ga,useEmitterValue:Re,usePublisher:Zt}),y0=m0;ut(Qd,Qe(()=>{const e=Z(c=>u.jsxs("td",{children:["Item $",c]})),t=Z(null),n=Z(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=Z(null),o=Z(null),s=Z({}),i=Z(ma),a=Z(Sr),l=(c,d=null)=>Pt(W(s,ce(f=>f[c]),dt()),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")}})),pa();const df={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},v0={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:ff,floor:vs,max:Qr,min:xa,round:hf}=Math;function pf(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function w0(e){return{...v0,items:e}}function ws(e,t){return e&&e.width===t.width&&e.height===t.height}function b0(e,t){return e&&e.column===t.column&&e.row===t.row}const S0=Qe(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:f},h,p,{didMount:m,propsReady:x},{customScrollParent:y,useWindowScroll:g,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k},T])=>{const C=Z(0),E=Z(0),N=Z(df),j=Z({height:0,width:0}),D=Z({height:0,width:0}),P=Xe(),M=Xe(),F=Z(0),A=Z(null),z=Z({column:0,row:0}),_=Xe(),X=Xe(),$=Z(!1),R=Z(0),J=Z(!0),G=Z(!1),pe=Z(!1);ot(W(m,Fe(R),Ie(([L,H])=>!!H)),()=>{Me(J,!1)}),ot(W(Ct(m,J,D,j,R,G),Ie(([L,H,V,ie,,re])=>L&&!H&&V.height!==0&&ie.height!==0&&!re)),([,,,,L])=>{Me(G,!0),aa(1,()=>{Me(P,L)}),ln(W(c),()=>{Me(t,[0,0]),Me(J,!0)})}),ge(W(X,Ie(L=>L!=null&&L.scrollTop>0),wn(0)),E),ot(W(m,Fe(X),Ie(([,L])=>L!=null)),([,L])=>{L&&(Me(j,L.viewport),Me(D,L.item),Me(z,L.gap),L.scrollTop>0&&(Me($,!0),ln(W(c,Jn(1)),H=>{Me($,!1)}),Me(l,{top:L.scrollTop})))}),ge(W(j,ce(({height:L})=>L)),f),ge(W(Ct(Se(j,ws),Se(D,ws),Se(z,(L,H)=>L&&L.column===H.column&&L.row===H.row),Se(c)),ce(([L,H,V,ie])=>({gap:V,item:H,scrollTop:ie,viewport:L}))),_),ge(W(Ct(Se(C),r,Se(z,b0),Se(D,ws),Se(j,ws),Se(A),Se(E),Se($),Se(J),Se(R)),Ie(([,,,,,,,L])=>!L),ce(([L,[H,V],ie,re,ze,We,Ze,,oe,me])=>{const{column:Te,row:Be}=ie,{height:Je,width:tt}=re,{width:$e}=ze;if(Ze===0&&(L===0||$e===0))return df;if(tt===0){const De=la(me,L),At=De+Math.max(Ze-1,0);return w0(pf(De,At,We))}const He=mf($e,tt,Te);let Ve,nt;oe?H===0&&V===0&&Ze>0?(Ve=0,nt=Ze-1):(Ve=He*vs((H+Be)/(Je+Be)),nt=He*ff((V+Be)/(Je+Be))-1,nt=xa(L-1,Qr(nt,He-1)),Ve=xa(nt,Qr(0,Ve))):(Ve=0,nt=-1);const kt=pf(Ve,nt,We),{bottom:ft,top:mt}=gf(ze,ie,re,kt),gt=ff(L/He),st=gt*Je+(gt-1)*Be-ft;return{bottom:ft,itemHeight:Je,items:kt,itemWidth:tt,offsetBottom:st,offsetTop:mt,top:mt}})),N),ge(W(A,Ie(L=>L!==null),ce(L=>L.length)),C),ge(W(Ct(j,D,N,z),Ie(([L,H,{items:V}])=>V.length>0&&H.height!==0&&L.height!==0),ce(([L,H,{items:V},ie])=>{const{bottom:re,top:ze}=gf(L,ie,H,V);return[ze,re]}),dt(Kr)),t);const Ce=Z(!1);ge(W(c,Fe(Ce),ce(([L,H])=>H||L!==0)),Ce);const Ae=Vt(W(Ct(N,C),Ie(([{items:L}])=>L.length>0),Fe(Ce),Ie(([[L,H],V])=>{const ie=L.items[L.items.length-1].index===H-1;return(V||L.bottom>0&&L.itemHeight>0&&L.offsetBottom===0&&L.items.length===H)&&ie}),ce(([[,L]])=>L-1),dt())),q=Vt(W(Se(N),Ie(({items:L})=>L.length>0&&L[0].index===0),wn(0),dt())),ne=Vt(W(Se(N),Fe($),Ie(([{items:L},H])=>L.length>0&&!H),ce(([{items:L}])=>({endIndex:L[L.length-1].index,startIndex:L[0].index})),dt(Od),An(0)));ge(ne,p.scrollSeekRangeChanged),ge(W(P,Fe(j,D,C,z),ce(([L,H,V,ie,re])=>{const ze=zd(L),{align:We,behavior:Ze,offset:oe}=ze;let me=ze.index;me==="LAST"&&(me=ie-1),me=Qr(0,me,xa(ie-1,me));let Te=ya(H,re,V,me);return We==="end"?Te=hf(Te-H.height+V.height):We==="center"&&(Te=hf(Te-H.height/2+V.height/2)),oe&&(Te+=oe),{behavior:Ze,top:Te}})),l);const Y=Pt(W(N,ce(L=>L.offsetBottom+L.bottom)),0);return ge(W(k,ce(L=>({height:L.visibleHeight,width:L.visibleWidth}))),j),{customScrollParent:y,data:A,deviation:F,footerHeight:o,gap:z,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:D,overscan:n,restoreStateFrom:X,scrollBy:i,scrollContainerState:a,scrollHeight:M,scrollTo:l,scrollToIndex:P,scrollTop:c,smoothScrollTargetReached:d,totalCount:C,useWindowScroll:g,viewportDimensions:j,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k,...p,gridState:N,horizontalDirection:pe,initialTopMostItemIndex:R,totalListHeight:Y,...h,endReached:Ae,propsReady:x,rangeChanged:ne,startReached:q,stateChanged:_,stateRestoreInProgress:$,...T}},ut(ca,Lt,Zr,Jd,$n,da,Dn));function mf(e,t,n){return Qr(1,vs((e+n)/(vs(t)+n)))}function gf(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=ya(e,t,n,r[0].index);return{bottom:ya(e,t,n,r[r.length-1].index)+o,top:s}}function ya(e,t,n,r){const o=mf(e.width,n.width,t.column),s=vs(r/o),i=s*n.height+Qr(0,s-1)*t.row;return i>0?i+t.row:i}const C0=Qe(()=>{const e=Z(f=>`Item ${f}`),t=Z({}),n=Z(null),r=Z("virtuoso-grid-item"),o=Z("virtuoso-grid-list"),s=Z(ma),i=Z("div"),a=Z(Sr),l=(f,h=null)=>Pt(W(t,ce(p=>p[f]),dt()),h),c=Z(!1),d=Z(!1);return ge(Se(d),c),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),T0=Qe(([e,t])=>({...e,...t}),ut(S0,C0)),k0=b.memo(function(){const e=pt("gridState"),t=pt("listClassName"),n=pt("itemClassName"),r=pt("itemContent"),o=pt("computeItemKey"),s=pt("isSeeking"),i=Qt("scrollHeight"),a=pt("ItemComponent"),l=pt("ListComponent"),c=pt("ScrollSeekPlaceholder"),d=pt("context"),f=Qt("itemDimensions"),h=Qt("gap"),p=pt("log"),m=pt("stateRestoreInProgress"),x=Qt("reportReadyState"),y=Zn(b.useMemo(()=>g=>{const w=g.parentElement.parentElement.scrollHeight;i(w);const S=g.firstChild;if(S){const{height:k,width:T}=S.getBoundingClientRect();f({height:k,width:T})}h({column:yf("column-gap",getComputedStyle(g).columnGap,p),row:yf("row-gap",getComputedStyle(g).rowGap,p)})},[i,f,h,p]),!0,!1);return rf(()=>{e.itemHeight>0&&e.itemWidth>0&&x(!0)},[e]),m?null:u.jsx(l,{className:t,ref:y,...Ot(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(g=>{const w=o(g.index,g.data,d);return s?u.jsx(c,{...Ot(c,d),height:e.itemHeight,index:g.index,width:e.itemWidth},w):b.createElement(a,{...Ot(a,d),className:n,"data-index":g.index,key:w},r(g.index,g.data,d))})})}),E0=b.memo(function(){const e=pt("HeaderComponent"),t=Qt("headerHeight"),n=pt("headerFooterTag"),r=Zn(b.useMemo(()=>s=>{t(Ln(s,"height"))},[t]),!0,!1),o=pt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null}),I0=b.memo(function(){const e=pt("FooterComponent"),t=Qt("footerHeight"),n=pt("headerFooterTag"),r=Zn(b.useMemo(()=>s=>{t(Ln(s,"height"))},[t]),!0,!1),o=pt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null}),N0=({children:e})=>{const t=b.useContext(nf),n=Qt("itemDimensions"),r=Qt("viewportDimensions"),o=Zn(b.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return b.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),u.jsx("div",{ref:o,style:ys(!1),children:e})},A0=({children:e})=>{const t=b.useContext(nf),n=Qt("windowViewportRect"),r=Qt("itemDimensions"),o=pt("customScrollParent"),s=Id(n,o,!1);return b.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),u.jsx("div",{ref:s,style:ys(!1),children:e})},j0=b.memo(function({...e}){const t=pt("useWindowScroll"),n=pt("customScrollParent"),r=n||t?R0:_0,o=n||t?A0:N0,s=pt("context");return u.jsx(r,{...e,...Ot(r,s),children:u.jsxs(o,{children:[u.jsx(E0,{}),u.jsx(k0,{}),u.jsx(I0,{})]})})}),{useEmitter:xf,useEmitterValue:pt,usePublisher:Qt}=ef(T0,{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"}},j0),_0=cf({useEmitter:xf,useEmitterValue:pt,usePublisher:Qt}),R0=uf({useEmitter:xf,useEmitterValue:pt,usePublisher:Qt});function yf(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 P0=fo.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 vf({className:e,variant:t,...n}){return u.jsx("div",{className:te(P0({variant:t}),e),...n})}const eo=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));eo.displayName="Card";const to=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("flex flex-col space-y-1.5 p-6",e),...t}));to.displayName="CardHeader";const no=v.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:te("text-2xl font-semibold leading-none tracking-tight",e),...t}));no.displayName="CardTitle";const wf=v.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:te("text-sm text-muted-foreground",e),...t}));wf.displayName="CardDescription";const ro=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("p-6 pt-0",e),...t}));ro.displayName="CardContent";const bf=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("flex items-center p-6 pt-0",e),...t}));bf.displayName="CardFooter";const O0=1,M0=1e6;let va=0;function D0(){return va=(va+1)%Number.MAX_SAFE_INTEGER,va.toString()}const wa=new Map,Sf=e=>{if(wa.has(e))return;const t=setTimeout(()=>{wa.delete(e),oo({type:"REMOVE_TOAST",toastId:e})},M0);wa.set(e,t)},L0=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,O0)};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?Sf(n):e.toasts.forEach(r=>{Sf(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)}}},bs=[];let Ss={toasts:[]};function oo(e){Ss=L0(Ss,e),bs.forEach(t=>{t(Ss)})}function $0({...e}){const t=D0(),n=o=>oo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>oo({type:"DISMISS_TOAST",toastId:t});return oo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function ba(){const[e,t]=v.useState(Ss);return v.useEffect(()=>(bs.push(t),()=>{const n=bs.indexOf(t);n>-1&&bs.splice(n,1)}),[e]),{...e,toast:$0,dismiss:n=>oo({type:"DISMISS_TOAST",toastId:n})}}async function Cf(e,t){return await Gt(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function Tf(e,t){return await(await Cf(`/files/${e}/view`,t)).text()}async function F0(e,t){const n=await Cf(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Gt(`/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 z0(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Gt("/files",{params:r})}function Sa(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 kf(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function so(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(so).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(kf(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=so(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 io(e){if(typeof e=="string")return e;if(kf(e))return"";try{const t=so(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function B0(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function H0(e){const t=io(e);return typeof e=="string"&&B0(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function Cs(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Sa(t);if(n!==null)return Cs(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?Cs(e.content):e}var Ts="Dialog",[Ef,xT]=kn(Ts),[U0,un]=Ef(Ts),If=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=v.useRef(null),l=v.useRef(null),[c,d]=fr({prop:r,defaultProp:o??!1,onChange:s,caller:Ts});return u.jsx(U0,{scope:t,triggerRef:a,contentRef:l,contentId:En(),titleId:En(),descriptionId:En(),open:c,onOpenChange:d,onOpenToggle:v.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};If.displayName=Ts;var Nf="DialogTrigger",Af=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(Nf,n),s=Ye(t,o.triggerRef);return u.jsx(Pe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":ka(o.open),...r,ref:s,onClick:he(e.onClick,o.onOpenToggle)})});Af.displayName=Nf;var Ca="DialogPortal",[W0,jf]=Ef(Ca,{forceMount:void 0}),_f=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=un(Ca,t);return u.jsx(W0,{scope:t,forceMount:n,children:v.Children.map(r,i=>u.jsx(Xt,{present:n||s.open,children:u.jsx(Ko,{asChild:!0,container:o,children:i})}))})};_f.displayName=Ca;var ks="DialogOverlay",Rf=v.forwardRef((e,t)=>{const n=jf(ks,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=un(ks,e.__scopeDialog);return s.modal?u.jsx(Xt,{present:r||s.open,children:u.jsx(K0,{...o,ref:t})}):null});Rf.displayName=ks;var V0=Wn.createSlot("DialogOverlay.RemoveScroll"),K0=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(ks,n);return u.jsx(ts,{as:V0,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(Pe.div,{"data-state":ka(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),tr="DialogContent",Pf=v.forwardRef((e,t)=>{const n=jf(tr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=un(tr,e.__scopeDialog);return u.jsx(Xt,{present:r||s.open,children:s.modal?u.jsx(q0,{...o,ref:t}):u.jsx(G0,{...o,ref:t})})});Pf.displayName=tr;var q0=v.forwardRef((e,t)=>{const n=un(tr,e.__scopeDialog),r=v.useRef(null),o=Ye(t,n.contentRef,r);return v.useEffect(()=>{const s=r.current;if(s)return Di(s)},[]),u.jsx(Of,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:he(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:he(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:he(e.onFocusOutside,s=>s.preventDefault())})}),G0=v.forwardRef((e,t)=>{const n=un(tr,e.__scopeDialog),r=v.useRef(!1),o=v.useRef(!1);return u.jsx(Of,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Of=v.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=un(tr,n),l=v.useRef(null),c=Ye(t,l);return xi(),u.jsxs(u.Fragment,{children:[u.jsx(Oo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(Po,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":ka(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(Y0,{titleId:a.titleId}),u.jsx(J0,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ta="DialogTitle",Mf=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(Ta,n);return u.jsx(Pe.h2,{id:o.titleId,...r,ref:t})});Mf.displayName=Ta;var Df="DialogDescription",Lf=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(Df,n);return u.jsx(Pe.p,{id:o.descriptionId,...r,ref:t})});Lf.displayName=Df;var $f="DialogClose",Ff=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un($f,n);return u.jsx(Pe.button,{type:"button",...r,ref:t,onClick:he(e.onClick,()=>o.onOpenChange(!1))})});Ff.displayName=$f;function ka(e){return e?"open":"closed"}var zf="DialogTitleWarning",[yT,Bf]=ex(zf,{contentName:tr,titleName:Ta,docsSlug:"dialog"}),Y0=({titleId:e})=>{const t=Bf(zf),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
87
87
|
|
|
88
88
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
89
89
|
|
|
90
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return v.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},X0="DialogDescriptionWarning",J0=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Bf(X0).contentName}}.`;return v.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},Hf=If,Z0=Af,Uf=_f,
|
|
90
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return v.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},X0="DialogDescriptionWarning",J0=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Bf(X0).contentName}}.`;return v.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},Hf=If,Z0=Af,Uf=_f,Es=Rf,Is=Pf,nr=Mf,Ns=Lf,Wf=Ff;const Q0=Hf,eS=Uf,Vf=v.forwardRef(({className:e,...t},n)=>u.jsx(Es,{ref:n,className:te("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}));Vf.displayName=Es.displayName;const Kf=v.forwardRef(({className:e,children:t,...n},r)=>{const o=v.useMemo(()=>{let s=!1;function i(a){v.Children.forEach(a,l=>{if(s||!v.isValidElement(l))return;const c=l.type;if(c===nr||(c==null?void 0:c.displayName)===nr.displayName||(c==null?void 0:c.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return u.jsxs(eS,{children:[u.jsx(Vf,{}),u.jsxs(Is,{ref:r,className:te("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&u.jsx(nr,{className:"sr-only",children:"Dialog"}),t,u.jsxs(Wf,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[u.jsx(ae.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Kf.displayName=Is.displayName;const qf=({className:e,...t})=>u.jsx("div",{className:te("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});qf.displayName="DialogHeader";const Gf=v.forwardRef(({className:e,...t},n)=>u.jsx(nr,{ref:n,className:te("text-lg font-semibold leading-none tracking-tight",e),...t}));Gf.displayName=nr.displayName;const tS=v.forwardRef(({className:e,...t},n)=>u.jsx(Ns,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));tS.displayName=Ns.displayName;function nS({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=b.useState(!1),[a,l]=b.useState(null),[c,d]=b.useState(null),{toast:f}=ba(),h=b.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const g=await Tf(n);l(g)}catch(g){console.error("Failed to load file:",g),d(g instanceof Error?g.message:"Failed to load file")}finally{i(!1)}}},[n]);b.useEffect(()=>{e&&n&&h()},[e,n,h]);const p=async()=>{if(n)try{await F0(n),f({title:"Download started",description:`Downloading ${r}`})}catch(g){console.error("Failed to download file:",g),f({title:"Download failed",description:String(g),variant:"destructive"})}},m=async()=>{if(n)try{const g=await Tf(n),w=new Blob([g],{type:o}),S=URL.createObjectURL(w);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(g){console.error("Failed to open file externally:",g),f({title:"Failed to open file",description:String(g),variant:"destructive"})}},x=()=>s?u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(ae.Loader,{className:"h-8 w-8 animate-spin mr-3"}),u.jsx("span",{children:"Loading file..."})]}):c?u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),u.jsx("p",{className:"text-red-600 mb-4",children:c}),u.jsx(rt,{onClick:h,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?u.jsx("div",{className:"flex justify-center",children:u.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?u.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:u.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?u.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:u.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx(ae.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),u.jsx("p",{className:"text-lg font-medium mb-2",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):u.jsx("div",{className:"flex items-center justify-center py-12",children:u.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),y=()=>o.startsWith("image/")?u.jsx(ae.Image,{className:"h-5 w-5"}):u.jsx(ae.FileText,{className:"h-5 w-5"});return u.jsx(Q0,{open:e,onOpenChange:t,children:u.jsxs(Kf,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(qf,{children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[y(),u.jsxs("div",{children:[u.jsx(Gf,{className:"text-left",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(rt,{variant:"outline",size:"sm",onClick:m,className:"flex items-center gap-2",children:[u.jsx(ae.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(rt,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[u.jsx(ae.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:x()})]})})}function Yf(){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 rr=Yf();function rS(e){rr=e}const Xf=/[&<>"']/,oS=new RegExp(Xf.source,"g"),Jf=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,sS=new RegExp(Jf.source,"g"),iS={"&":"&","<":"<",">":">",'"':""","'":"'"},Zf=e=>iS[e];function Mt(e,t){if(t){if(Xf.test(e))return e.replace(oS,Zf)}else if(Jf.test(e))return e.replace(sS,Zf);return e}const aS=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Qf(e){return e.replace(aS,(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 lS=/(^|[^\[])\^/g;function lt(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(lS,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const cS=/[^\w:]/g,uS=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function eh(e,t,n){if(e){let r;try{r=decodeURIComponent(Qf(n)).replace(cS,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!uS.test(n)&&(n=pS(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const As={},dS=/^[^:]+:\/*[^/]*$/,fS=/^([^:]+:)[\s\S]*$/,hS=/^([^:]+:\/*[^/]*)[\s\S]*$/;function pS(e,t){As[" "+e]||(dS.test(e)?As[" "+e]=e+"/":As[" "+e]=_s(e,"/",!0)),e=As[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(fS,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(hS,"$1")+t:e+t}const js={exec:function(){}};function th(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,c=i;for(;--c>=0&&a[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function _s(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 mS(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 gS(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 nh(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function rh(e,t,n,r){const o=t.href,s=t.title?Mt(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:Mt(i)}}function xS(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
91
91
|
`).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(`
|
|
92
|
-
`)}class Ea{constructor(t){this.options=t||
|
|
93
|
-
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=xS(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=
|
|
92
|
+
`)}class Ea{constructor(t){this.options=t||rr}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:_s(r,`
|
|
93
|
+
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=xS(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=_s(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,l,c,d,f,h,p,m,x=n[1].trim();const y=x.length>1,g={type:"list",raw:"",ordered:y,start:y?+x.slice(0,-1):"",loose:!1,items:[]};x=y?`\\d{1,9}\\${x.slice(-1)}`:`\\${x}`,this.options.pedantic&&(x=y?x:"[*+-]");const w=new RegExp(`^( {0,3}${x})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(m=!1,!(!(n=w.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
|
|
94
94
|
`,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),f=t.split(`
|
|
95
95
|
`,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+`
|
|
96
96
|
`,t=t.substring(f.length+1),m=!0),!m){const k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),C=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),E=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(h=t.split(`
|
|
97
97
|
`,1)[0],f=h,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(C.test(f)||E.test(f)||k.test(f)||T.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())p+=`
|
|
98
98
|
`+f.slice(i);else{if(l||d.search(/[^ ]/)>=4||C.test(d)||E.test(d)||T.test(d))break;p+=`
|
|
99
99
|
`+f}!l&&!f.trim()&&(l=!0),r+=h+`
|
|
100
|
-
`,t=t.substring(h.length+1),d=f.slice(i)}}g.loose||(c?g.loose=!0:/\n *\n *$/.test(r)&&(c=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),g.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),g.raw+=r}g.items[g.items.length-1].raw=r.trimRight(),g.items[g.items.length-1].text=p.trimRight(),g.raw=g.raw.trimRight();const S=g.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,g.items[a].tokens=this.lexer.blockTokens(g.items[a].text,[]),!g.loose){const k=g.items[a].tokens.filter(C=>C.type==="space"),T=k.length>0&&k.some(C=>/\n.*\n/.test(C.raw));g.loose=T}if(g.loose)for(a=0;a<S;a++)g.items[a].loose=!0;return g}}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]):
|
|
100
|
+
`,t=t.substring(h.length+1),d=f.slice(i)}}g.loose||(c?g.loose=!0:/\n *\n *$/.test(r)&&(c=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),g.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),g.raw+=r}g.items[g.items.length-1].raw=r.trimRight(),g.items[g.items.length-1].text=p.trimRight(),g.raw=g.raw.trimRight();const S=g.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,g.items[a].tokens=this.lexer.blockTokens(g.items[a].text,[]),!g.loose){const k=g.items[a].tokens.filter(C=>C.type==="space"),T=k.length>0&&k.some(C=>/\n.*\n/.test(C.raw));g.loose=T}if(g.loose)for(a=0;a<S;a++)g.items[a].loose=!0;return g}}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]):Mt(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:th(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
|
|
101
101
|
`):[]};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]=th(r.rows[s],r.header.length).map(c=>({text:c}));for(o=r.header.length,i=0;i<o;i++)r.header[i].tokens=this.lexer.inline(r.header[i].text);for(o=r.rows.length,i=0;i<o;i++)for(l=r.rows[i],a=0;a<l.length;a++)l[a].tokens=this.lexer.inline(l[a].text);return r}}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const r=n[1].charAt(n[1].length-1)===`
|
|
102
|
-
`?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:
|
|
103
|
-
]`).replace("lheading",be.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ue={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:
|
|
102
|
+
`?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:Mt(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]):Mt(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=_s(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=mS(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)),rh(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 rh(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,l,c=i,d=0;const f=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*t.length+i);(o=f.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(l=a.length,o[3]||o[4]){c+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c+d);const h=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const m=h.slice(1,-1);return{type:"em",raw:h,text:m,tokens:this.lexer.inlineTokens(m)}}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=Mt(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=Mt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Mt(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=Mt(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=Mt(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]):Mt(r[0]):r[0]:o=Mt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const be={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:js,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};be._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,be._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,be.def=lt(be.def).replace("label",be._label).replace("title",be._title).getRegex(),be.bullet=/(?:[*+-]|\d{1,9}[.)])/,be.listItemStart=lt(/^( *)(bull) */).replace("bull",be.bullet).getRegex(),be.list=lt(be.list).replace(/bull/g,be.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+be.def.source+")").getRegex(),be._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",be._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,be.html=lt(be.html,"i").replace("comment",be._comment).replace("tag",be._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),be.paragraph=lt(be._paragraph).replace("hr",be.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",be._tag).getRegex(),be.blockquote=lt(be.blockquote).replace("paragraph",be.paragraph).getRegex(),be.normal={...be},be.gfm={...be.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},be.gfm.table=lt(be.gfm.table).replace("hr",be.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",be._tag).getRegex(),be.gfm.paragraph=lt(be._paragraph).replace("hr",be.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",be.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",be._tag).getRegex(),be.pedantic={...be.normal,html:lt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",be._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:js,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:lt(be.normal._paragraph).replace("hr",be.hr).replace("heading",` *#{1,6} *[^
|
|
103
|
+
]`).replace("lheading",be.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ue={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:js,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:js,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};ue._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",ue.punctuation=lt(ue.punctuation).replace(/punctuation/g,ue._punctuation).getRegex(),ue.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,ue.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,ue._comment=lt(be._comment).replace("(?:-->|$)","-->").getRegex(),ue.emStrong.lDelim=lt(ue.emStrong.lDelim).replace(/punct/g,ue._punctuation).getRegex(),ue.emStrong.rDelimAst=lt(ue.emStrong.rDelimAst,"g").replace(/punct/g,ue._punctuation).getRegex(),ue.emStrong.rDelimUnd=lt(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=lt(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=lt(ue.tag).replace("comment",ue._comment).replace("attribute",ue._attribute).getRegex(),ue._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ue._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,ue._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ue.link=lt(ue.link).replace("label",ue._label).replace("href",ue._href).replace("title",ue._title).getRegex(),ue.reflink=lt(ue.reflink).replace("label",ue._label).replace("ref",be._label).getRegex(),ue.nolink=lt(ue.nolink).replace("ref",be._label).getRegex(),ue.reflinkSearch=lt(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:lt(/^!?\[(label)\]\((.*?)\)/).replace("label",ue._label).getRegex(),reflink:lt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ue._label).getRegex()},ue.gfm={...ue.normal,escape:lt(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=lt(ue.gfm.url,"i").replace("email",ue.gfm._extended_email).getRegex(),ue.breaks={...ue.gfm,br:lt(ue.br).replace("{2,}","*").getRegex(),text:lt(ue.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function yS(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 oh(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 Fn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||rr,this.options.tokenizer=this.options.tokenizer||new Ea,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:be.normal,inline:ue.normal};this.options.pedantic?(n.block=be.pedantic,n.inline=ue.pedantic):this.options.gfm&&(n.block=be.gfm,this.options.breaks?n.inline=ue.breaks:n.inline=ue.gfm),this.tokenizer.rules=n}static get rules(){return{block:be,inline:ue}}static lex(t,n){return new Fn(n).lex(t)}static lexInline(t,n){return new Fn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
|
|
104
104
|
`),this.blockTokens(t,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(t,n=[]){this.options.pedantic?t=t.replace(/\t/g," ").replace(/^ +$/gm,""):t=t.replace(/^( *)(\t+)/gm,(a,l,c)=>l+" ".repeat(c.length));let r,o,s,i;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(r=a.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=`
|
|
105
105
|
`: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+=`
|
|
106
106
|
`+r.raw,o.text+=`
|
|
@@ -110,9 +110,9 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
110
110
|
`+r.raw,o.text+=`
|
|
111
111
|
`+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+=`
|
|
112
112
|
`+r.raw,o.text+=`
|
|
113
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,l,c;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+nh("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)+"["+nh("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.escapedEmSt.exec(i))!=null;)i=i.slice(0,a.index+a[0].length-2)+"++"+i.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;t;)if(l||(c=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(t,i,c)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(t,oh)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,oh))){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,yS)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(c=r.raw.slice(-1)),l=!0,o=n[n.length-1],o&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(t){const d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return n}}class Ia{constructor(t){this.options=t||
|
|
114
|
-
`,o?'<pre><code class="'+this.options.langPrefix+
|
|
115
|
-
`:"<pre><code>"+(r?t:
|
|
113
|
+
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,l,c;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+nh("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)+"["+nh("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.escapedEmSt.exec(i))!=null;)i=i.slice(0,a.index+a[0].length-2)+"++"+i.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;t;)if(l||(c=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(t,i,c)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(t,oh)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,oh))){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,yS)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(c=r.raw.slice(-1)),l=!0,o=n[n.length-1],o&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(t){const d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return n}}class Ia{constructor(t){this.options=t||rr}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$/,"")+`
|
|
114
|
+
`,o?'<pre><code class="'+this.options.langPrefix+Mt(o)+'">'+(r?t:Mt(t,!0))+`</code></pre>
|
|
115
|
+
`:"<pre><code>"+(r?t:Mt(t,!0))+`</code></pre>
|
|
116
116
|
`}blockquote(t){return`<blockquote>
|
|
117
117
|
${t}</blockquote>
|
|
118
118
|
`}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}>
|
|
@@ -130,8 +130,8 @@ ${t}</blockquote>
|
|
|
130
130
|
`}tablerow(t){return`<tr>
|
|
131
131
|
${t}</tr>
|
|
132
132
|
`}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
|
|
133
|
-
`}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=eh(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=eh(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 sh{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 ih{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
|
|
134
|
-
`+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const N='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(N);return}else throw new Error(N)}}}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
|
|
135
|
-
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+
|
|
136
|
-
`)):r=t(e),r||""}function CS(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function ch(e){if("type"in e&&e.type==="default_message")return`default:${e.content.length}`;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"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function TS({className:e}){const[t,n]=b.useState(0);return b.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:te("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const Na=b.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:f=!0,customStyles:h={},onEdit:p,onRegenerate:m,onCancelEdit:x,onCopy:y,activeInterrupt:g,disableInterruptActions:w=!1,onInterruptActionStart:S,onInterruptActionEnd:k,checkpointCandidates:T=[],activeCheckpointId:C=null,onSelectCheckpoint:E,defaultCheckpointId:N=null,messageParentCheckpointId:j=null}){const[D,P]=b.useState(!1),[M,F]=b.useState("preview"),[A,z]=b.useState(!1),{currentThreadId:_}=
|
|
137
|
-
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[je[B]?u.jsx(ie.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[de,je[B]?" (processing)":""]})]},B)}if(W.type==="interrupt"){const H=W,de=Rs((H==null?void 0:H.id)??(H==null?void 0:H.interrupt_id)),we=!!(oe&&de&&de===oe),Se=we?le??(H==null?void 0:H.value):H==null?void 0:H.value,ye=de?{...H,id:de,interrupt_id:de}:H;return u.jsx(kS,{interruptPart:ye,onApprove:nt,onReject:kt,disabled:w,isActive:we,payload:Se},B)}return null},[G,je,nt,kt,R,c,d,A,$,oe,le,g,w,qe]),mt=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(ie.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),gt=b.useCallback(()=>{const W=K.trim().length>0||re.length>0||Oe.length>0||qe.length>0;if(!Z&&Oe.length>0&&!r)return mt();if(!Z&&!W&&!r)return null;if(Z)return u.jsx(NS,{message:t,viewMode:M},t.id);if(!Z&&!Y){const B=t,H=u.jsx("div",{className:"space-y-2",children:B.content.map((de,we)=>u.jsx(pt,{part:de,i:we},we))});return r?u.jsxs("div",{"aria-busy":"true",role:"status",children:[H,u.jsx(TS,{className:U})]}):H}},[K,re.length,Oe.length,qe.length,r,Z,M,mt,U]),Ze=b.useMemo(()=>Y?"Assistant":CS(t),[Y,t]),He=b.useMemo(()=>Y?[]:Array.isArray(T)?T:[],[T,Y]),Nt=b.useMemo(()=>{var W;return He.length?N&&He.some(B=>B.id===N)?N:((W=He[0])==null?void 0:W.id)??null:null},[N,He]),nn=b.useMemo(()=>!He.length||!C?null:He.some(W=>W.id===C)?C:null,[C,He])??Nt,rn=R==="user"&&He.length>0&&typeof E=="function",Ke=b.useCallback(W=>{if(!E)return;const B=(W==null?void 0:W.id)??null,H=(W==null?void 0:W.parentId)??j??null;E(B,H)},[j,E]),Ne=b.useMemo(()=>nn?He.findIndex(W=>W.id===nn):-1,[nn,He]),Mt=b.useMemo(()=>Ne<0?null:He[Ne]??null,[Ne,He]),Ht=b.useCallback(W=>{const B=[];if(W.step!==null&&B.push(`Step ${W.step}`),W.source&&B.push(W.source),!W.createdAt)return B.length?B.join(" • "):W.id.slice(0,8);let H="";try{const de=new Date(W.createdAt);Number.isNaN(de.getTime())||(H=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(de))}catch{H=""}return`${H}`},[]);return Z&&!f?null:u.jsxs(u.Fragment,{children:[u.jsx("div",{className:te(Fe(),h.container),children:u.jsxs("div",{className:te(Je(),h.content),children:[(i||a||Z)&&u.jsxs("div",{className:te("flex items-center justify-between mb-2 pb-2 border-b border-current/10",$&&"mb-1 pb-1",U,h.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[Le(),a&&Ze&&u.jsx("span",{className:te("font-medium",$?"text-xs":"text-sm"),children:Ze}),Z&&u.jsxs(vf,{variant:"outline",className:te("text-xs flex items-center gap-1 cursor-pointer select-none",U,"border border-current/40",$&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":M==="expanded",onClick:()=>F(W=>W==="expanded"?"preview":"expanded"),onKeyDown:W=>{(W.key==="Enter"||W.key===" ")&&(W.preventDefault(),F(B=>B==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:se.name??"Tool Output"}),se.toolCallId&&u.jsx("span",{className:"opacity-70",children:se.toolCallId.slice(0,8)}),M==="expanded"?u.jsx(ie.ChevronUp,{className:"h-3 w-3"}):u.jsx(ie.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[rn&&Mt&&Ne>=0&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:te("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ne>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(Ne<=0)return;const W=He[Ne-1];W&&Ke(W)},"aria-label":"Previous checkpoint",disabled:Ne<=0,children:u.jsx(ie.ChevronLeft,{className:"h-3 w-3"})}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("span",{className:"whitespace-nowrap",children:[Ne+1," / ",He.length]}),u.jsx("span",{className:"text-muted-foreground",children:Ht(Mt)})]}),u.jsx("button",{type:"button",className:te("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ne<He.length-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(Ne>=He.length-1)return;const W=He[Ne+1];W&&Ke(W)},"aria-label":"Next checkpoint",disabled:Ne>=He.length-1,children:u.jsx(ie.ChevronRight,{className:"h-3 w-3"})})]}),i&&t.createdAt&&u.jsx("time",{className:te("text-xs opacity-60",U,$&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&u.jsxs("div",{className:te("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",h.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(rt,{variant:"ghost",size:"sm",onClick:()=>Be(),className:te("h-6 w-6 p-0 hover:bg-foreground/10",U,$&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(ie.Copy,{className:te(D?"text-success":U,$?"h-3 w-3":"h-4 w-4")})})}),R==="user"&&p&&u.jsx(rt,{variant:"ghost",size:"sm",onClick:Ye,className:te("h-6 w-6 p-0 hover:bg-foreground/10",U,$&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(ie.Edit,{className:te(U,$?"h-3 w-3":"h-4 w-4")})}),R==="assistant"&&m&&u.jsx(rt,{variant:"ghost",size:"sm",onClick:Xe,className:te("h-6 w-6 p-0 hover:bg-foreground/10",U,$&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(ie.RotateCcw,{className:te(U,$?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsx("div",{className:"relative",children:gt()}),Z&&M==="expanded"&&(se.toolCallId||se.name)&&u.jsxs("div",{className:te("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",$&&"text-xs"),children:[se.name&&u.jsxs("div",{children:["Function: ",se.name]}),se.toolCallId&&u.jsxs("div",{children:["Call ID: ",se.toolCallId]})]}),!(i||a||Z)&&s&&!o&&u.jsxs("div",{className:te("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",h.actions),children:[u.jsx(rt,{variant:"ghost",size:"sm",onClick:()=>Be(),className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",$&&"h-5 w-5"),children:u.jsx(ie.Copy,{className:te(D?"text-success":"text-current",$?"h-3 w-3":"h-4 w-4")})}),R==="user"&&p&&u.jsx(rt,{variant:"ghost",size:"sm",onClick:Ye,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",$&&"h-5 w-5"),children:u.jsx(ie.Edit,{className:te("text-current",$?"h-3 w-3":"h-4 w-4")})}),R==="assistant"&&m&&u.jsx(rt,{variant:"ghost",size:"sm",onClick:Xe,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",$&&"h-5 w-5"),children:u.jsx(ie.RotateCcw,{className:te("text-current",$?"h-3 w-3":"h-4 w-4")})})]})]})}),X&&u.jsx(nS,{isOpen:ne,onClose:L,fileId:X.id,fileName:X.name,mimeType:X.mimeType})]})},(e,t)=>{var i,a,l,c,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&ch(e.message)===ch(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(m=>e[m]===t[m]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((l=e.customStyles)==null?void 0:l.content)===((c=t.customStyles)==null?void 0:c.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((h=e.customStyles)==null?void 0:h.header)===((p=t.customStyles)==null?void 0:p.header);return o&&s});function uh({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:wS,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:so(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:so(e)})}function kS({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=so(s);a=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(Qr,{className:te("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(eo,{className:"pb-3",children:[u.jsx(to,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(wf,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(no,{className:"pt-0 pb-3",children:a}),u.jsx(bf,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(rt,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(rt,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}function ES(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=ba(),[o,s]=b.useState({}),[i,a]=b.useState(null),[l,c]=b.useState(!1),d=b.useCallback(()=>{c(!1),a(null)},[]),f=b.useCallback(p=>{a(p),c(!0)},[]),h=b.useCallback(async(p,m,x)=>{var y,g;if(!t){p.preventDefault();return}if(o[x]){p.preventDefault();return}try{const w=String(m.url??""),S=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){p.preventDefault();const k=S[1],T=m.name||`file_${k}`,C=m.mimeType||"application/octet-stream";f({id:k,name:T,mimeType:C});return}if(w.startsWith("data:")){p.preventDefault(),s(T=>({...T,[x]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const T=await z0(n??void 0);if(!T||!Array.isArray(T))throw new Error("Invalid file list response");const C=T.find(E=>!E||typeof E!="object"||!((E.filename??"")===(m.name??""))?!1:typeof m.size=="number"&&typeof E.size=="number"?E.size===m.size:!0);if(!(C!=null&&C.id))throw new Error(`File "${m.name}" is not yet available on the server`);if(!C.id||!C.filename)throw new Error("Invalid file data received from server");f({id:C.id,name:m.name||C.filename||`file_${C.id}`,mimeType:m.mimeType||C.mime_type||"application/octet-stream"}),(y=k.update)==null||y.call(k,{id:k.id,title:"Success",description:`Opened ${m.name}`,open:!0})}catch(T){console.error("Failed to fetch server file:",T);const C=T instanceof Error?T.message:"Unknown error occurred";(g=k.update)==null||g.call(k,{id:k.id,title:"Failed",description:C}),r({title:"Failed to fetch file",description:C,open:!0})}finally{s(T=>({...T,[x]:!1}))}}}catch(w){console.error("File click error:",w),s(S=>({...S,[x]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:h,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function IS({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("div",{className:te("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(io,{content:e,allowHtml:!1}):u.jsxs("pre",{className:te("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(rt,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(ie.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(ie.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function NS({message:e,viewMode:t}){const r=lh(e).name||"tool",o=c=>{if(c==null)return null;const d=typeof c=="string"?Sa(c)??c:c;if(d&&typeof d=="object")return u.jsx(uh,{data:d});const f=typeof d=="string"?d:(()=>{try{return so(d)}catch{return String(d??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:f})},s=c=>{if(c==null)return null;const{content:d,isMarkdown:f}=H0(c);return f?u.jsx(io,{content:d,className:"text-current"}):o(c)};if(t==="preview")return null;const i=e.content.find(c=>c.type!=="tool_call");if(!i)return u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ie.Loader,{className:"h-4 w-4 animate-spin"}),u.jsxs("span",{children:["Waiting for ",r," output…"]})]});if(i.type==="text"){const d=(i.text??"").trim();if(!d)return null;const f=Ss(d);return s(f)}const a=oo(i),l=Ss(a);return s(l)}const AS=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r})=>{const o=e??[],s=o.length>0,i=b.useMemo(()=>s?[...o].reverse():[],[o,s]),a=t??(o.length?o[o.length-1].id:null);return b.useEffect(()=>{console.debug("[TimelineColumn] entries:",o.length)},[o.length]),s?u.jsxs("div",{className:"w-32 flex-shrink-0 flex-col border-r border-border/40 pr-2 flex",children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-4 pb-2 pr-1",children:[u.jsxs("div",{className:"absolute left-0 right-0 top-1 flex items-center justify-between px-2 pb-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:"Timeline"}),u.jsxs("div",{className:"group relative z-50",children:[u.jsx(ie.Info,{className:"h-3 w-3 text-muted-foreground cursor-help"}),u.jsx("div",{className:"pointer-events-auto fixed hidden w-56 rounded-md border bg-background p-3 text-[10px] font-normal text-muted-foreground shadow-lg group-hover:block whitespace-normal leading-relaxed",style:{zIndex:9999},children:"Backend pre-selects user inputs + latest loop checkpoint. Click a dot to jump, or use “Latest” to return to the newest messages."})]})]}),u.jsx("div",{className:"pointer-events-none absolute left-3 top-0 bottom-0 w-px bg-border/40"}),u.jsx("div",{className:"flex flex-col gap-3 pt-6 pr-2",children:i.map(l=>{const c=a===l.id,d=l.messageId?(r==null?void 0:r.get(l.messageId))??null:null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(l.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${c?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${c?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${c?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium leading-tight",children:l.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[l.step!==null?`STEP ${l.step}`:"STEP —",l.next?` - ${l.next}`:""]}),d&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:d,children:d})]})]},l.id)})})]}),n&&u.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]}):null},dh=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,jS=e=>{const t=e.additionalKwargs??{},n=e.responseMetadata??{},r=t.originalMessageId??n.originalMessageId??t.original_message_id??n.original_message_id;return typeof r=="string"&&r.trim()?r.trim():e.id},Aa=b.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:m=!0,isNavigatingCheckpoint:x=!1,onScrollAway:y,onAtBottom:g,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:T,showToolMessages:C=!0,checkpointMetaById:E,checkpointIndexByKey:N,activeCheckpointId:j,onSelectCheckpoint:D,timelineCheckpoints:P,messagePreviews:M,createSyntheticThinkingMessage:F=!1},A)=>{const z=b.useRef(null),_=b.useRef(null),J=b.useRef(!1),[$,R]=b.useState(!0),Z=b.useMemo(()=>w?e.some(oe=>"type"in oe&&oe.type==="default_message"?!1:Array.isArray(oe==null?void 0:oe.content)&&oe.content.some(le=>le&&le.type==="interrupt"&&(le.id??le.interrupt_id)===w.id)):!1,[w,e]),Y=b.useMemo(()=>{if(!w||Z)return null;const oe=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let le;const De=w.value;if(De&&typeof De=="object"&&!Array.isArray(De)){const Be=De.title;typeof Be=="string"&&Be.trim()&&(le=Be.trim())}return{id:`interrupt-${oe}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:oe,value:De,title:le}]}},[w,Z]),me=b.useMemo(()=>Y?[...e,Y]:e,[e,Y]),Te=b.useMemo(()=>!F||!t?me:!me.some(le=>le.role==="assistant")&&me.length>0?[...me,{id:"thinking-assistant",role:"assistant",content:[],createdAt:new Date().toISOString()}]:me,[me,t,F]),je=b.useMemo(()=>C?Te:Te.filter(oe=>(oe==null?void 0:oe.role)!=="tool"),[Te,C]),G=b.useMemo(()=>{const oe=new Set,le=[];for(let De=je.length-1;De>=0;De--){const Be=je[De];if(!Be)continue;if("type"in Be&&Be.type==="default_message"){le.push(Be);continue}const Ye=Be,Xe=jS(Ye);oe.has(Xe)||(oe.add(Xe),le.push(Ye))}return le.reverse()},[je]),ne=b.useCallback(oe=>{R(oe),y&&y(!oe),g&&g(oe)},[y,g]),X=b.useMemo(()=>{if(a)return async()=>{if(!J.current){J.current=!0;try{await a()}finally{J.current=!1}}}},[a]),L=b.useMemo(()=>!m||x?!1:$?"auto":!1,[$,m,x]),U=P??[],K=U.length>0,se=b.useMemo(()=>{if(typeof p!="string")return null;const oe=p.trim();return oe?{id:"default-message",role:"assistant",type:"default_message",content:oe,createdAt:new Date().toISOString()}:null},[p]),re=K?u.jsx(AS,{timelineEntries:U,activeCheckpointId:j??null,onSelectCheckpoint:D,messagePreviews:M}):null,Oe=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),qe=()=>se?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Na,{message:se,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{}})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:p??"No messages yet. Start a conversation!"}),Ge=G.length>0;return b.useImperativeHandle(A,()=>({scrollToLatest:()=>{var oe,le;if(z.current&&G.length>0){const De=G.length-1;(le=(oe=z.current).scrollToIndex)==null||le.call(oe,{index:De,align:"end",behavior:"auto"})}else _.current&&(_.current.scrollTop=_.current.scrollHeight)},scrollToTop:()=>{var oe,le;z.current&&G.length>0?(le=(oe=z.current).scrollToIndex)==null||le.call(oe,{index:0,align:"start",behavior:"auto"}):_.current&&(_.current.scrollTop=0)}}),[G]),u.jsxs("div",{className:Oe,style:h,children:[re,u.jsx("div",{className:"relative flex-1 min-h-0",children:Ge?u.jsx(y0,{ref:oe=>{z.current=oe},scrollerRef:oe=>{_.current=oe instanceof HTMLDivElement?oe:null},data:G,followOutput:L,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!0,startReached:()=>{X&&X()},atBottomStateChange:ne,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(oe,le)=>dh(le,oe),itemContent:(oe,le)=>{var pt;const De=dh(le,oe),Be="type"in le&&le.type==="default_message";let Ye=[],Xe=null,Le={},Fe={},Je=null,nt=null;if(!Be){const mt=le,gt=mt.checkpointId??null;Le=mt.additionalKwargs??{},Fe=mt.responseMetadata??{};const Ze=gt&&E?E.get(gt)??null:null;Je=typeof Le.step=="number"?Le.step:typeof Fe.step=="number"?Fe.step:(Ze==null?void 0:Ze.step)??null;const He=typeof Le.source=="string"?Le.source:typeof Fe.source=="string"?Fe.source:(Ze==null?void 0:Ze.source)??null;nt=He?String(He):null;const Nt=Je!==null&&nt?`${Je}:${nt}`:null;Nt&&(N!=null&&N.has(Nt))?Ye=N.get(Nt)??[]:gt&&Ze&&(Ye=[Ze]),Xe=gt??((pt=Ye[0])==null?void 0:pt.id)??null}const kt=(()=>{if(typeof Le.parentCheckpointId=="string")return Le.parentCheckpointId;if(typeof Fe.parentCheckpointId=="string")return Fe.parentCheckpointId})();return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":De,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Na,{message:le,messageIndex:oe,isStreamingMessage:t&&n===le.id,streamingDebounceMs:r,isEditing:i===le.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:l,onRegenerate:()=>c(oe),onCancelEdit:d,activeInterrupt:w,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:T,showToolMessages:C,checkpointCandidates:Ye,activeCheckpointId:j??null,onSelectCheckpoint:D,defaultCheckpointId:Xe,messageParentCheckpointId:kt})})}}):qe()})]})});Aa.displayName="MessageList";const fh={value:""};function Ps({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,customStyles:f={},onMessageSent:h,onExcelUploadSuccess:p,onError:m}){const{api:x}=ai(),{currentThreadId:y}=No(),{threadId:g,messages:w,isHistoryLoading:S,isLoading:k,navigateToCheckpoint:T,returnToLatest:C,checkpoint:E,checkpoints:N,interrupt:j,metadata:D,timelineCheckpoints:P,messagePreviews:M}=Ao(),{isStreaming:F,error:A,connectionState:z,submit:_,stop:J}=lc(),$=g??y??null,R=(E==null?void 0:E.id)??null,Z=(E==null?void 0:E.namespace)??null,Y=(D==null?void 0:D.assemblingMessageId)??null,me=j,[Te,je]=b.useState(!1);b.useEffect(()=>{me||je(!1)},[me]);const G=b.useCallback(()=>{je(!0)},[]),ne=b.useCallback(()=>{je(!1)},[]),X=!!me||Te,[L,U]=b.useState(null),[K,se]=b.useState(""),[re,Oe]=b.useState(null),[qe,Ge]=b.useState(null),[oe,le]=b.useState([]),[De,Be]=b.useState(0),[Ye,Xe]=b.useState(0),[Le,Fe]=b.useState(!1),[Je,nt]=b.useState(null),[kt,pt]=b.useState(null),[mt,gt]=b.useState(!1),[Ze,He]=b.useState(null),Nt=b.useRef(!1),[At,nn]=b.useState(()=>fh.value),rn=b.useRef(At),Ke=b.useRef(null),Ne=b.useCallback(ee=>{fh.value=ee,nn(ee)},[]),[Mt,Ht]=b.useState(!1),W=b.useRef(null),B=b.useCallback((ee,fe)=>{if(!ee||typeof ee!="object")return null;const he=ee[fe];return typeof he=="number"?he:null},[]),H=b.useCallback((ee,fe)=>{if(!ee||typeof ee!="object")return null;const he=ee[fe];return typeof he=="string"&&he.trim()?he:null},[]),de=b.useMemo(()=>{const ee=ve=>{if(!Array.isArray(ve)||ve.length===0)return null;const ct=ve.map(xt=>{if(typeof xt=="string")return xt.trim();if(xt&&typeof xt=="object"&&"type"in xt){const fn=xt;if(typeof fn.type=="string")return fn.type}return null}).filter(xt=>!!(xt&&xt.length));return ct.length?ct.join(", "):null},fe=Array.isArray(N)?N.map(ve=>{const ct=ee(ve.next);return ct?{...ve,metadata:{...ve.metadata??{},next:ct}}:ve}):[];return fe.some(ve=>B(ve.metadata,"step")!==null)&&fe.sort((ve,ct)=>{const xt=B(ve.metadata,"step"),fn=B(ct.metadata,"step");if(xt!==null||fn!==null)return(fn??Number.NEGATIVE_INFINITY)-(xt??Number.NEGATIVE_INFINITY);const lo=Date.parse(ve.createdAt??""),co=Date.parse(ct.createdAt??"");return Number.isNaN(lo)||Number.isNaN(co)?0:co-lo}),fe},[N,B]),{checkpointMetaById:we,checkpointIndexByKey:Se}=b.useMemo(()=>{const ee=new Map,fe=new Map;for(const he of de){const ve=he.checkpointId??null;if(!ve)continue;const ct=B(he.metadata,"step"),xt=H(he.metadata,"source"),fn={id:ve,step:ct,source:xt,createdAt:he.createdAt??null,namespace:he.checkpointNs??null,parentId:he.parentId??null};if(ee.set(ve,fn),ct!==null&&xt){const lo=`${ct}:${xt}`,co=fe.get(lo)??[];co.push(fn),fe.set(lo,co)}}for(const he of fe.values())he.sort((ve,ct)=>{const xt=ve.createdAt??"";return(ct.createdAt??"").localeCompare(xt)});return{checkpointMetaById:ee,checkpointIndexByKey:fe}},[de,B,H]),ye=P??[],st=b.useRef(null),Ae=b.useRef(null),et=b.useCallback(()=>{st.current&&(st.current.value=""),Ae.current&&(Ae.current.value=""),Be(ee=>ee+1),Xe(ee=>ee+1)},[]),yt=b.useCallback(ee=>{Ne(ee)},[Ne]),Cn=b.useRef(!1);b.useEffect(()=>{Cn.current&&!F&&(le([]),et()),Cn.current=F},[F,et]);const[Ws,Wa]=b.useState("desktop");b.useEffect(()=>{const ee=()=>{const fe=window.innerWidth;Wa(fe<640?"phone":fe<1024?"tablet":"desktop")};return ee(),window.addEventListener("resize",ee),()=>window.removeEventListener("resize",ee)},[]),b.useEffect(()=>{Nt.current=!1},[$]),b.useEffect(()=>{rn.current=At},[At]),b.useEffect(()=>{if(!L){Ke.current=null;return}Ke.current===null&&(Ke.current=rn.current),Ne(K??"")},[K,L,Ne]),b.useEffect(()=>{(async()=>{if(!x.baseUrl){He(null);return}try{const he=(await x.getAgent("default")).uiDefaultMessage||"";He(he||null)}catch(fe){console.warn("Failed to fetch default message:",fe),He(null)}})()},[x.baseUrl]),b.useEffect(()=>{A&&!mt&&(m==null||m(A))},[A,mt,m]);const Va=ee=>{if(ee.length>is)return`Message too long (${ee.length}/${is} characters)`;try{return lb(ee),null}catch(fe){return(fe==null?void 0:fe.message)||"Invalid message"}},Ka=async ee=>{const fe=ee.trim();if(!(!fe&&oe.length===0)){if(fe){const he=Va(fe);if(he){Ge(he);return}}try{const he=R??void 0,ve=Z??void 0,ct=L?{edit:!0,originalMessageId:L,...re!=null&&re.checkpointId?{originalCheckpointId:re.checkpointId}:{},...re!=null&&re.checkpointNs?{originalCheckpointNs:re.checkpointNs}:{}}:void 0;await _({text:fe||"",attachments:oe,messageAdditionalKwargs:ct},{checkpointId:he,checkpointNs:ve}),h==null||h(fe),Ne(""),Ge(null),le([]),et(),U(null),se(""),Oe(null)}catch(he){const ve=(he==null?void 0:he.message)||"Failed to send message";Ge(ve),m==null||m(ve)}}},Vs=b.useCallback((ee,fe,he)=>{c&&(Ke.current=At,U(ee),se(fe),Ne(fe),Ge(null),Oe({checkpointId:(he==null?void 0:he.checkpointId)??null,checkpointNs:(he==null?void 0:he.checkpointNs)??null}))},[At,c,Ne]),I=b.useCallback(()=>{U(null),se(""),Oe(null),Ge(null),Ne(Ke.current??At),Ke.current=null},[At,Ne]),q=b.useCallback((ee,fe,he)=>{Vs(ee,fe,he)},[Vs]),ae=b.useCallback(ee=>{for(let fe=ee-1;fe>=0;fe--)if(w[fe].role==="user"){const he=w[fe].content||[],ct=he.filter(xt=>xt.type==="text").map(xt=>xt.text).join("")||(()=>{try{return JSON.stringify(he,null,2)}catch{return String(he)}})();ct&&_({text:ct},{checkpointId:R??void 0,checkpointNs:Z??void 0});break}},[w,_,R,Z]),ke=ee=>{const fe=Array.from(ee.target.files||[]);le(he=>[...he,...fe]),ee.target.value=""},tt=ee=>{le(fe=>{const he=fe.filter((ve,ct)=>ee!==ct);return he.length===0&&et(),he})},it=async ee=>{const fe=(ee.target.files||[])[0];if(fe){nt(null),pt(null),Fe(!0);try{await _({attachments:[fe]},{checkpointId:R??void 0,checkpointNs:Z??void 0});const he=`Uploaded ${fe.name} - processing through chat stream`;pt(he)}catch(he){const ve=he instanceof Error?he.message:"Failed to upload Excel file";console.error("Excel upload failed",he),nt(ve),m==null||m(ve)}finally{Fe(!1),ee.target.value="",et()}}},Ue=async ee=>{if(y){Ht(!0);try{if(!ee){await C(),requestAnimationFrame(()=>{var ve;(ve=W.current)==null||ve.scrollToLatest()});return}const fe=de.find(ve=>ve.checkpointId===ee),he=(fe==null?void 0:fe.checkpointNs)??null;await T(ee,he),requestAnimationFrame(()=>{var ve;(ve=W.current)==null||ve.scrollToTop()})}finally{Ht(!1)}}},ze=b.useCallback(async ee=>{await Ue(ee)},[Ue]),jt=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${f.container||""}`,vt=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${f.messagesArea||""}`,wt=`flex-shrink-0 w-full border-t p-4 bg-transparent ${f.inputArea||""}`;return b.useCallback(ee=>{if(!ee)return"Latest";const fe=[];ee.step!==null&&fe.push(`Step ${ee.step}`),ee.source&&fe.push(ee.source);const he=ee.createdAt?new Date(ee.createdAt):null,ve=he&&!Number.isNaN(he.getTime())?he.toLocaleString():ee.createdAt??ee.id,ct=fe.length?` — ${fe.join(" • ")}`:"";return`${ve}${ct}`},[]),u.jsxs("div",{className:jt,children:[!!A&&!mt&&u.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[u.jsx("span",{children:A}),u.jsx(rt,{variant:"ghost",size:"sm",onClick:()=>gt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(ie.X,{size:16})})]}),u.jsxs("div",{className:`relative ${vt}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(Aa,{ref:W,className:"h-full",style:{height:"100%"},messages:w,isStreaming:F,streamingAssistantId:Y,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Ws,enableMessageEditing:c,editingMessageId:L,onEdit:q,onRegenerate:ae,onCancelEdit:I,emptyMessage:Ze??void 0,isNavigatingCheckpoint:Mt,activeInterrupt:me,disableInterruptActions:Te,onInterruptActionStart:G,onInterruptActionEnd:ne,showToolMessages:d,checkpointMetaById:we,checkpointIndexByKey:Se,activeCheckpointId:R,onSelectCheckpoint:ze,timelineCheckpoints:ye,messagePreviews:M}),(z==="reconnecting"||z==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(ie.Loader2,{className:"h-3 w-3 animate-spin"}),z==="reconnecting"?"Reconnecting…":"Connecting…"]})}),z==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),k&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ie.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(S||Mt)&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ie.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),u.jsxs("div",{className:wt,children:[L&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(ie.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(rt,{variant:"ghost",size:"sm",onClick:I,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(ie.X,{size:16})})]})}),(a||l)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[a&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:st,type:"file",multiple:!0,onChange:ee=>ke(ee),className:"hidden"},De),oe.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:oe.map((ee,fe)=>u.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[u.jsx(ie.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:ee.name}),u.jsx(rt,{variant:"ghost",size:"sm",onClick:()=>tt(fe),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 ${ee.name}`,children:u.jsx(ie.X,{size:12})})]},fe))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:Ae,type:"file",accept:".xls,.xlsx,.xlsm",onChange:it,className:"hidden"},Ye),Le&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ie.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),kt&&!Le&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:kt}),Je&&!Le&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Je})]})]}),qe&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:qe}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(Zw,{children:[u.jsx(Qw,{asChild:!0,children:u.jsx(rt,{type:"button",size:"icon",variant:"outline",disabled:F||X,title:"More input actions",className:f.moreButton||"",children:u.jsx(ie.Plus,{size:16})})}),u.jsxs(vd,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(Yi,{onClick:()=>{var ee;return(ee=st.current)==null?void 0:ee.click()},className:"cursor-pointer",children:[u.jsx(ie.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(Yi,{onClick:()=>{var ee;Le||(ee=Ae.current)==null||ee.click()},className:`cursor-pointer ${Le?"opacity-60 pointer-events-none":""}`,children:[u.jsx(ie.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(Qg,{initialValue:K,editingMessageId:L,value:At,onValueChange:yt,placeholder:L?"Edit your message...":t,isStreaming:F,disabled:X,maxLength:is,onSend:Ka,onCancelEdit:I,onStop:J,allowEmptySend:oe.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${L?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${qe?"border-red-400":""} ${f.textarea||""}`})})]})]})]})}const Os=v.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:te("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}));Os.displayName="Input";function ja(e,[t,n]){return Math.min(n,Math.max(t,e))}function _S(e,t){return v.useReducer((n,r)=>t[n][r]??n,e)}var _a="ScrollArea",[hh,vT]=kn(_a),[RS,en]=hh(_a),ph=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=v.useState(null),[c,d]=v.useState(null),[f,h]=v.useState(null),[p,m]=v.useState(null),[x,y]=v.useState(null),[g,w]=v.useState(0),[S,k]=v.useState(0),[T,C]=v.useState(!1),[E,N]=v.useState(!1),j=We(t,P=>l(P)),D=_o(o);return u.jsx(RS,{scope:n,type:r,dir:D,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:T,onScrollbarXEnabledChange:C,scrollbarY:x,onScrollbarYChange:y,scrollbarYEnabled:E,onScrollbarYEnabledChange:N,onCornerWidthChange:w,onCornerHeightChange:k,children:u.jsx(Re.div,{dir:D,...i,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":g+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});ph.displayName=_a;var mh="ScrollAreaViewport",gh=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=en(mh,n),a=v.useRef(null),l=We(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),u.jsx(Re.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});gh.displayName=mh;var Sn="ScrollAreaScrollbar",Ra=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=en(Sn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return v.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(PS,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(OS,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(xh,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Pa,{...r,ref:t}):null});Ra.displayName=Sn;var PS=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=en(Sn,e.__scopeScrollArea),[s,i]=v.useState(!1);return v.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Xt,{present:n||s,children:u.jsx(xh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),OS=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=en(Sn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=$s(()=>l("SCROLL_END"),100),[a,l]=_S("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 v.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),v.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let f=c[d];const h=()=>{const p=c[d];f!==p&&(l("SCROLL"),i()),f=p};return c.addEventListener("scroll",h),()=>c.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),u.jsx(Xt,{present:n||a!=="hidden",children:u.jsx(Pa,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:pe(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:pe(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),xh=v.forwardRef((e,t)=>{const n=en(Sn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=v.useState(!1),a=e.orientation==="horizontal",l=$s(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Cr(n.viewport,l),Cr(n.content,l),u.jsx(Xt,{present:r||s,children:u.jsx(Pa,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Pa=v.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=en(Sn,e.__scopeScrollArea),s=v.useRef(null),i=v.useRef(0),[a,l]=v.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=Sh(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return zS(h,i.current,a,p)}return n==="horizontal"?u.jsx(MS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=Ch(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?u.jsx(DS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=Ch(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),MS=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=en(Sn,e.__scopeScrollArea),[i,a]=v.useState(),l=v.useRef(null),c=We(t,l,s.onScrollbarXChange);return v.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(vh,{"data-orientation":"horizontal",...o,ref:c,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Ls(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),kh(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:Ds(i.paddingLeft),paddingEnd:Ds(i.paddingRight)}})}})}),DS=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=en(Sn,e.__scopeScrollArea),[i,a]=v.useState(),l=v.useRef(null),c=We(t,l,s.onScrollbarYChange);return v.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(vh,{"data-orientation":"vertical",...o,ref:c,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Ls(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),kh(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:Ds(i.paddingTop),paddingEnd:Ds(i.paddingBottom)}})}})}),[LS,yh]=hh(Sn),vh=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:f,...h}=e,p=en(Sn,n),[m,x]=v.useState(null),y=We(t,j=>x(j)),g=v.useRef(null),w=v.useRef(""),S=p.viewport,k=r.content-r.viewport,T=It(d),C=It(l),E=$s(f,10);function N(j){if(g.current){const D=j.clientX-g.current.left,P=j.clientY-g.current.top;c({x:D,y:P})}}return v.useEffect(()=>{const j=D=>{const P=D.target;(m==null?void 0:m.contains(P))&&T(D,k)};return document.addEventListener("wheel",j,{passive:!1}),()=>document.removeEventListener("wheel",j,{passive:!1})},[S,m,k,T]),v.useEffect(C,[r,C]),Cr(m,E),Cr(p.content,E),u.jsx(LS,{scope:n,scrollbar:m,hasThumb:o,onThumbChange:It(s),onThumbPointerUp:It(i),onThumbPositionChange:C,onThumbPointerDown:It(a),children:u.jsx(Re.div,{...h,ref:y,style:{position:"absolute",...h.style},onPointerDown:pe(e.onPointerDown,j=>{j.button===0&&(j.target.setPointerCapture(j.pointerId),g.current=m.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),N(j))}),onPointerMove:pe(e.onPointerMove,N),onPointerUp:pe(e.onPointerUp,j=>{const D=j.target;D.hasPointerCapture(j.pointerId)&&D.releasePointerCapture(j.pointerId),document.body.style.webkitUserSelect=w.current,p.viewport&&(p.viewport.style.scrollBehavior=""),g.current=null})})})}),Ms="ScrollAreaThumb",wh=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=yh(Ms,e.__scopeScrollArea);return u.jsx(Xt,{present:n||o.hasThumb,children:u.jsx($S,{ref:t,...r})})}),$S=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=en(Ms,n),i=yh(Ms,n),{onThumbPositionChange:a}=i,l=We(t,f=>i.onThumbChange(f)),c=v.useRef(void 0),d=$s(()=>{c.current&&(c.current(),c.current=void 0)},100);return v.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!c.current){const p=BS(f,a);c.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),u.jsx(Re.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:pe(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),m=f.clientX-p.left,x=f.clientY-p.top;i.onThumbPointerDown({x:m,y:x})}),onPointerUp:pe(e.onPointerUp,i.onThumbPointerUp)})});wh.displayName=Ms;var Oa="ScrollAreaCorner",bh=v.forwardRef((e,t)=>{const n=en(Oa,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(FS,{...e,ref:t}):null});bh.displayName=Oa;var FS=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=en(Oa,n),[s,i]=v.useState(0),[a,l]=v.useState(0),c=!!(s&&a);return Cr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Cr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(Re.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 Ds(e){return e?parseInt(e,10):0}function Sh(e,t){const n=e/t;return isNaN(n)?0:n}function Ls(e){const t=Sh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function zS(e,t,n,r="ltr"){const o=Ls(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return Th([l,c],f)(e)}function Ch(e,t,n="ltr"){const r=Ls(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=ja(e,l);return Th([0,i],[0,a])(c)}function Th(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 kh(e,t){return e>0&&e<t}var BS=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function $s(e,t){const n=It(e),r=v.useRef(0);return v.useEffect(()=>()=>window.clearTimeout(r.current),[]),v.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Cr(e,t){const n=It(t);Et(()=>{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 Eh=ph,HS=gh,US=bh;const Ih=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Eh,{ref:r,className:te("relative overflow-hidden",e),...n,children:[u.jsx(HS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(Nh,{}),u.jsx(US,{})]}));Ih.displayName=Eh.displayName;const Nh=v.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Ra,{ref:r,orientation:t,className:te("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:u.jsx(wh,{className:"relative flex-1 rounded-full bg-border"})}));Nh.displayName=Ra.displayName;const Ah=25;function Ma({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d}){const{threads:f,currentThreadId:h,setCurrentThreadId:p,isLoading:m,actions:x}=No(),{loadThread:y}=Ao(),{createThread:g,deleteThread:w,renameThread:S}=x,[k,T]=b.useState(Array.isArray(f)?f:[]),C=b.useRef(k.length>0),E=b.useRef(null),N=b.useRef(0),[j,D]=b.useState(null),[P,M]=b.useState(""),[F,A]=b.useState(!1);b.useEffect(()=>{const G=Array.isArray(f)?f:[];if(G.length>0){C.current=!0,T(G);return}m||(C.current=!1,T(G))},[f,m]),b.useEffect(()=>{if(!E.current)return;const G=E.current.querySelector("[data-radix-scroll-area-viewport]");if(!G)return;let ne=null,X=null;return ne=requestAnimationFrame(()=>{X=requestAnimationFrame(()=>{G.scrollTop=N.current})}),()=>{ne!==null&&cancelAnimationFrame(ne),X!==null&&cancelAnimationFrame(X)}},[k]);const z=async G=>{try{p(G),await y(G),a==null||a(G),l==null||l(G)}catch(ne){console.error("Failed to select thread:",ne)}},_=async()=>{try{A(!0);const G=await g();G&&(c==null||c(G),a==null||a(G))}catch(G){console.error("Failed to create thread:",G)}finally{A(!1)}},J=async(G,ne)=>{if(ne.stopPropagation(),!!confirm("Delete this thread?")){if(E.current){const X=E.current.querySelector("[data-radix-scroll-area-viewport]");X&&(N.current=X.scrollTop)}try{await w(G),d==null||d(G)}catch(X){console.error("Failed to delete thread:",X)}}},$=(G,ne)=>{ne.stopPropagation(),D(G.threadId),M(G.title||`Thread ${G.threadId.slice(0,8)}`)},R=async G=>{if(P.trim())try{await S(G,P.trim()),D(null),M("")}catch(ne){console.error("Failed to update title:",ne)}},Z=()=>{D(null),M("")},Y=(G,ne)=>{G.key==="Enter"?R(ne):G.key==="Escape"&&Z()},me=G=>{if(!G)return"";try{const ne=new Date(G),L=new Date().getTime()-ne.getTime(),U=Math.floor(L/(1e3*60*60*24));return U===0?ne.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):U===1?"Yesterday":U<7?`${U} days ago`:ne.toLocaleDateString()}catch{return""}},Te=G=>G.title||`Thread ${G.threadId.slice(0,8)}`,je=G=>{const ne=Te(G);return ne.length<=Ah?ne:`${ne.slice(0,Ah)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&u.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:u.jsx(rt,{onClick:_,disabled:F||m,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:F?"Creating...":"New Chat",children:u.jsx(ie.MessageSquarePlus,{size:20})})}),u.jsx(Ih,{ref:E,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children:m?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(ie.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):k.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(ie.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):k.slice().sort((G,ne)=>new Date(ne.updatedAt||ne.createdAt||"").getTime()-new Date(G.updatedAt||G.createdAt||"").getTime()).map(G=>u.jsxs("div",{onClick:()=>z(G.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??h)===G.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:j===G.threadId?u.jsxs("div",{className:"flex items-center gap-2",onClick:ne=>ne.stopPropagation(),children:[u.jsx(Os,{value:P,onChange:ne=>M(ne.target.value),onKeyDown:ne=>Y(ne,G.threadId),className:"h-6 text-sm",autoFocus:!0}),u.jsx(rt,{variant:"ghost",size:"sm",onClick:()=>R(G.threadId),className:"h-6 w-6 p-0",children:u.jsx(ie.Check,{size:12})}),u.jsx(rt,{variant:"ghost",size:"sm",onClick:Z,className:"h-6 w-6 p-0",children:u.jsx(ie.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:je(G)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(ie.Calendar,{size:10}),u.jsx("span",{children:me(G.updatedAt||G.createdAt)})]})]})}),u.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&j!==G.threadId&&u.jsx(rt,{variant:"ghost",size:"sm",onClick:ne=>$(G,ne),className:"h-6 w-6 p-0",title:"Edit title",children:u.jsx(ie.Edit3,{size:12})}),n&&u.jsx(rt,{variant:"ghost",size:"sm",onClick:ne=>J(G.threadId,ne),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:u.jsx(ie.Trash2,{size:12})})]})]}),i===G.threadId&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},G.threadId))})})]})}function Tr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function WS(e){if(typeof e!="string")return;const t=e.trim();if(t)return Tn(t)}function jh(){const e=[Tr("__API_BASE_URL__"),Tr("__CHAT_API_BASE_URL__"),Tr("__CHAT_API_URL__")];for(const t of e){const n=WS(t);if(n)return n}}function _h(){const e=[Tr("__API_AUTH_TOKEN__"),Tr("__CHAT_API_KEY__"),Tr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Rh(...e){for(const t of e)if(typeof t=="string"&&t.trim())return Tn(t);return Tn()}function Ph(){const e={},t=jh(),n=_h();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Oh(){const e=Ph(),t=jn.getAuthToken(),n=jh();return{apiBaseUrl:Rh(e.baseUrl,jn.baseUrl,n),apiKey:t||e.apiKey||_h()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Mh="chat-settings";function VS(){try{const e=localStorage.getItem(Mh);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function KS(e){try{const t={...e,apiBaseUrl:Tn(e.apiBaseUrl)};localStorage.setItem(Mh,JSON.stringify(t)),t.apiKey&&jn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function qS(){const e=Oh(),t=VS(),n=jn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Rh(jn.baseUrl,r,e.apiBaseUrl)}}function GS(e){jn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),KS(e)}var YS="Label",Dh=v.forwardRef((e,t)=>u.jsx(Re.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())}}));Dh.displayName=YS;var Lh=Dh;const XS=uo.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),tn=v.forwardRef(({className:e,...t},n)=>u.jsx(Lh,{ref:n,className:te(XS(),e),...t}));tn.displayName=Lh.displayName;function $h(e){const t=v.useRef({value:e,previous:e});return v.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Fs="Switch",[JS,wT]=kn(Fs),[ZS,QS]=JS(Fs),Fh=v.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...f}=e,[h,p]=v.useState(null),m=We(t,S=>p(S)),x=v.useRef(!1),y=h?d||!!h.closest("form"):!0,[g,w]=dr({prop:o,defaultProp:s??!1,onChange:c,caller:Fs});return u.jsxs(ZS,{scope:n,checked:g,disabled:a,children:[u.jsx(Re.button,{type:"button",role:"switch","aria-checked":g,"aria-required":i,"data-state":Uh(g),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:m,onClick:pe(e.onClick,S=>{w(k=>!k),y&&(x.current=S.isPropagationStopped(),x.current||S.stopPropagation())})}),y&&u.jsx(Hh,{control:h,bubbles:!x.current,name:r,value:l,checked:g,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Fh.displayName=Fs;var zh="SwitchThumb",Bh=v.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=QS(zh,n);return u.jsx(Re.span,{"data-state":Uh(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Bh.displayName=zh;var eC="SwitchBubbleInput",Hh=v.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=v.useRef(null),a=We(i,s),l=$h(n),c=Kc(t);return v.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const m=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(m)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Hh.displayName=eC;function Uh(e){return e?"checked":"unchecked"}var Wh=Fh,tC=Bh;const zn=v.forwardRef(({className:e,...t},n)=>u.jsx(Wh,{className:te("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:u.jsx(tC,{className:te("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));zn.displayName=Wh.displayName;var Vh=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"}),nC="VisuallyHidden",rC=v.forwardRef((e,t)=>u.jsx(Re.span,{...e,ref:t,style:{...Vh,...e.style}}));rC.displayName=nC;var oC=[" ","Enter","ArrowUp","ArrowDown"],sC=[" ","Enter"],rr="Select",[zs,Bs,iC]=pi(rr),[kr,bT]=kn(rr,[iC,Wo]),Hs=Wo(),[aC,Bn]=kr(rr),[lC,cC]=kr(rr),Kh=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:f,disabled:h,required:p,form:m}=e,x=Hs(t),[y,g]=v.useState(null),[w,S]=v.useState(null),[k,T]=v.useState(!1),C=_o(c),[E,N]=dr({prop:r,defaultProp:o??!1,onChange:s,caller:rr}),[j,D]=dr({prop:i,defaultProp:a,onChange:l,caller:rr}),P=v.useRef(null),M=y?m||!!y.closest("form"):!0,[F,A]=v.useState(new Set),z=Array.from(F).map(_=>_.props.value).join(";");return u.jsx(nu,{...x,children:u.jsxs(aC,{required:p,scope:t,trigger:y,onTriggerChange:g,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:T,contentId:En(),value:j,onValueChange:D,open:E,onOpenChange:N,dir:C,triggerPointerDownPosRef:P,disabled:h,children:[u.jsx(zs.Provider,{scope:t,children:u.jsx(lC,{scope:e.__scopeSelect,onNativeOptionAdd:v.useCallback(_=>{A(J=>new Set(J).add(_))},[]),onNativeOptionRemove:v.useCallback(_=>{A(J=>{const $=new Set(J);return $.delete(_),$})},[]),children:n})}),M?u.jsxs(gp,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:j,onChange:_=>D(_.target.value),disabled:h,form:m,children:[j===void 0?u.jsx("option",{value:""}):null,Array.from(F)]},z):null]})})};Kh.displayName=rr;var qh="SelectTrigger",Gh=v.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Hs(n),i=Bn(qh,n),a=i.disabled||r,l=We(t,i.onTriggerChange),c=Bs(n),d=v.useRef("touch"),[f,h,p]=yp(x=>{const y=c().filter(S=>!S.disabled),g=y.find(S=>S.value===i.value),w=vp(y,x,g);w!==void 0&&i.onValueChange(w.value)}),m=x=>{a||(i.onOpenChange(!0),p()),x&&(i.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return u.jsx(ru,{asChild:!0,...s,children:u.jsx(Re.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":xp(i.value)?"":void 0,...o,ref:l,onClick:pe(o.onClick,x=>{x.currentTarget.focus(),d.current!=="mouse"&&m(x)}),onPointerDown:pe(o.onPointerDown,x=>{d.current=x.pointerType;const y=x.target;y.hasPointerCapture(x.pointerId)&&y.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(m(x),x.preventDefault())}),onKeyDown:pe(o.onKeyDown,x=>{const y=f.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&h(x.key),!(y&&x.key===" ")&&oC.includes(x.key)&&(m(),x.preventDefault())})})})});Gh.displayName=qh;var Yh="SelectValue",Xh=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Bn(Yh,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,f=We(t,l.onValueNodeChange);return Et(()=>{c(d)},[c,d]),u.jsx(Re.span,{...a,ref:f,style:{pointerEvents:"none"},children:xp(l.value)?u.jsx(u.Fragment,{children:i}):s})});Xh.displayName=Yh;var uC="SelectIcon",Jh=v.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(Re.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Jh.displayName=uC;var dC="SelectPortal",Zh=e=>u.jsx(Vo,{asChild:!0,...e});Zh.displayName=dC;var or="SelectContent",Qh=v.forwardRef((e,t)=>{const n=Bn(or,e.__scopeSelect),[r,o]=v.useState();if(Et(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?fo.createPortal(u.jsx(ep,{scope:e.__scopeSelect,children:u.jsx(zs.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(tp,{...e,ref:t})});Qh.displayName=or;var dn=10,[ep,Hn]=kr(or),fC="SelectContentImpl",hC=Un.createSlot("SelectContent.RemoveScroll"),tp=v.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:m,hideWhenDetached:x,avoidCollisions:y,...g}=e,w=Bn(or,n),[S,k]=v.useState(null),[T,C]=v.useState(null),E=We(t,X=>k(X)),[N,j]=v.useState(null),[D,P]=v.useState(null),M=Bs(n),[F,A]=v.useState(!1),z=v.useRef(!1);v.useEffect(()=>{if(S)return Di(S)},[S]),xi();const _=v.useCallback(X=>{const[L,...U]=M().map(re=>re.ref.current),[K]=U.slice(-1),se=document.activeElement;for(const re of X)if(re===se||(re==null||re.scrollIntoView({block:"nearest"}),re===L&&T&&(T.scrollTop=0),re===K&&T&&(T.scrollTop=T.scrollHeight),re==null||re.focus(),document.activeElement!==se))return},[M,T]),J=v.useCallback(()=>_([N,S]),[_,N,S]);v.useEffect(()=>{F&&J()},[F,J]);const{onOpenChange:$,triggerPointerDownPosRef:R}=w;v.useEffect(()=>{if(S){let X={x:0,y:0};const L=K=>{var se,re;X={x:Math.abs(Math.round(K.pageX)-(((se=R.current)==null?void 0:se.x)??0)),y:Math.abs(Math.round(K.pageY)-(((re=R.current)==null?void 0:re.y)??0))}},U=K=>{X.x<=10&&X.y<=10?K.preventDefault():S.contains(K.target)||$(!1),document.removeEventListener("pointermove",L),R.current=null};return R.current!==null&&(document.addEventListener("pointermove",L),document.addEventListener("pointerup",U,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",U,{capture:!0})}}},[S,$,R]),v.useEffect(()=>{const X=()=>$(!1);return window.addEventListener("blur",X),window.addEventListener("resize",X),()=>{window.removeEventListener("blur",X),window.removeEventListener("resize",X)}},[$]);const[Z,Y]=yp(X=>{const L=M().filter(se=>!se.disabled),U=L.find(se=>se.ref.current===document.activeElement),K=vp(L,X,U);K&&setTimeout(()=>K.ref.current.focus())}),me=v.useCallback((X,L,U)=>{const K=!z.current&&!U;(w.value!==void 0&&w.value===L||K)&&(j(X),K&&(z.current=!0))},[w.value]),Te=v.useCallback(()=>S==null?void 0:S.focus(),[S]),je=v.useCallback((X,L,U)=>{const K=!z.current&&!U;(w.value!==void 0&&w.value===L||K)&&P(X)},[w.value]),G=r==="popper"?Da:np,ne=G===Da?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:m,hideWhenDetached:x,avoidCollisions:y}:{};return u.jsx(ep,{scope:n,content:S,viewport:T,onViewportChange:C,itemRefCallback:me,selectedItem:N,onItemLeave:Te,itemTextRefCallback:je,focusSelectedItem:J,selectedItemText:D,position:r,isPositioned:F,searchRef:Z,children:u.jsx(es,{as:hC,allowPinchZoom:!0,children:u.jsx(Po,{asChild:!0,trapped:w.open,onMountAutoFocus:X=>{X.preventDefault()},onUnmountAutoFocus:pe(o,X=>{var L;(L=w.trigger)==null||L.focus({preventScroll:!0}),X.preventDefault()}),children:u.jsx(Ro,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:X=>X.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(G,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:X=>X.preventDefault(),...g,...ne,onPlaced:()=>A(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...g.style},onKeyDown:pe(g.onKeyDown,X=>{const L=X.ctrlKey||X.altKey||X.metaKey;if(X.key==="Tab"&&X.preventDefault(),!L&&X.key.length===1&&Y(X.key),["ArrowUp","ArrowDown","Home","End"].includes(X.key)){let K=M().filter(se=>!se.disabled).map(se=>se.ref.current);if(["ArrowUp","End"].includes(X.key)&&(K=K.slice().reverse()),["ArrowUp","ArrowDown"].includes(X.key)){const se=X.target,re=K.indexOf(se);K=K.slice(re+1)}setTimeout(()=>_(K)),X.preventDefault()}})})})})})})});tp.displayName=fC;var pC="SelectItemAlignedPosition",np=v.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Bn(or,n),i=Hn(or,n),[a,l]=v.useState(null),[c,d]=v.useState(null),f=We(t,E=>d(E)),h=Bs(n),p=v.useRef(!1),m=v.useRef(!0),{viewport:x,selectedItem:y,selectedItemText:g,focusSelectedItem:w}=i,S=v.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&x&&y&&g){const E=s.trigger.getBoundingClientRect(),N=c.getBoundingClientRect(),j=s.valueNode.getBoundingClientRect(),D=g.getBoundingClientRect();if(s.dir!=="rtl"){const se=D.left-N.left,re=j.left-se,Oe=E.left-re,qe=E.width+Oe,Ge=Math.max(qe,N.width),oe=window.innerWidth-dn,le=ja(re,[dn,Math.max(dn,oe-Ge)]);a.style.minWidth=qe+"px",a.style.left=le+"px"}else{const se=N.right-D.right,re=window.innerWidth-j.right-se,Oe=window.innerWidth-E.right-re,qe=E.width+Oe,Ge=Math.max(qe,N.width),oe=window.innerWidth-dn,le=ja(re,[dn,Math.max(dn,oe-Ge)]);a.style.minWidth=qe+"px",a.style.right=le+"px"}const P=h(),M=window.innerHeight-dn*2,F=x.scrollHeight,A=window.getComputedStyle(c),z=parseInt(A.borderTopWidth,10),_=parseInt(A.paddingTop,10),J=parseInt(A.borderBottomWidth,10),$=parseInt(A.paddingBottom,10),R=z+_+F+$+J,Z=Math.min(y.offsetHeight*5,R),Y=window.getComputedStyle(x),me=parseInt(Y.paddingTop,10),Te=parseInt(Y.paddingBottom,10),je=E.top+E.height/2-dn,G=M-je,ne=y.offsetHeight/2,X=y.offsetTop+ne,L=z+_+X,U=R-L;if(L<=je){const se=P.length>0&&y===P[P.length-1].ref.current;a.style.bottom="0px";const re=c.clientHeight-x.offsetTop-x.offsetHeight,Oe=Math.max(G,ne+(se?Te:0)+re+J),qe=L+Oe;a.style.height=qe+"px"}else{const se=P.length>0&&y===P[0].ref.current;a.style.top="0px";const Oe=Math.max(je,z+x.offsetTop+(se?me:0)+ne)+U;a.style.height=Oe+"px",x.scrollTop=L-je+x.offsetTop}a.style.margin=`${dn}px 0`,a.style.minHeight=Z+"px",a.style.maxHeight=M+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,c,x,y,g,s.dir,r]);Et(()=>S(),[S]);const[k,T]=v.useState();Et(()=>{c&&T(window.getComputedStyle(c).zIndex)},[c]);const C=v.useCallback(E=>{E&&m.current===!0&&(S(),w==null||w(),m.current=!1)},[S,w]);return u.jsx(gC,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:C,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(Re.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});np.displayName=pC;var mC="SelectPopperPosition",Da=v.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=dn,...s}=e,i=Hs(n);return u.jsx(ou,{...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)"}})});Da.displayName=mC;var[gC,La]=kr(or,{}),$a="SelectViewport",rp=v.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Hn($a,n),i=La($a,n),a=We(t,s.onViewportChange),l=v.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(zs.Slot,{scope:n,children:u.jsx(Re.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:pe(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const m=window.innerHeight-dn*2,x=parseFloat(f.style.minHeight),y=parseFloat(f.style.height),g=Math.max(x,y);if(g<m){const w=g+p,S=Math.min(m,w),k=w-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})})})]})});rp.displayName=$a;var op="SelectGroup",[xC,yC]=kr(op),vC=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=En();return u.jsx(xC,{scope:n,id:o,children:u.jsx(Re.div,{role:"group","aria-labelledby":o,...r,ref:t})})});vC.displayName=op;var sp="SelectLabel",ip=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=yC(sp,n);return u.jsx(Re.div,{id:o.id,...r,ref:t})});ip.displayName=sp;var Us="SelectItem",[wC,ap]=kr(Us),lp=v.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Bn(Us,n),l=Hn(Us,n),c=a.value===r,[d,f]=v.useState(s??""),[h,p]=v.useState(!1),m=We(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),x=En(),y=v.useRef("touch"),g=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(wC,{scope:n,value:r,disabled:o,textId:x,isSelected:c,onItemTextChange:v.useCallback(w=>{f(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(zs.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(Re.div,{role:"option","aria-labelledby":x,"data-highlighted":h?"":void 0,"aria-selected":c&&h,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:m,onFocus:pe(i.onFocus,()=>p(!0)),onBlur:pe(i.onBlur,()=>p(!1)),onClick:pe(i.onClick,()=>{y.current!=="mouse"&&g()}),onPointerUp:pe(i.onPointerUp,()=>{y.current==="mouse"&&g()}),onPointerDown:pe(i.onPointerDown,w=>{y.current=w.pointerType}),onPointerMove:pe(i.onPointerMove,w=>{var S;y.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):y.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:pe(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:pe(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(sC.includes(w.key)&&g(),w.key===" "&&w.preventDefault())})})})})});lp.displayName=Us;var ao="SelectItemText",cp=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Bn(ao,n),a=Hn(ao,n),l=ap(ao,n),c=cC(ao,n),[d,f]=v.useState(null),h=We(t,g=>f(g),l.onItemTextChange,g=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,g,l.value,l.disabled)}),p=d==null?void 0:d.textContent,m=v.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:x,onNativeOptionRemove:y}=c;return Et(()=>(x(m),()=>y(m)),[x,y,m]),u.jsxs(u.Fragment,{children:[u.jsx(Re.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?fo.createPortal(s.children,i.valueNode):null]})});cp.displayName=ao;var up="SelectItemIndicator",dp=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return ap(up,n).isSelected?u.jsx(Re.span,{"aria-hidden":!0,...r,ref:t}):null});dp.displayName=up;var Fa="SelectScrollUpButton",fp=v.forwardRef((e,t)=>{const n=Hn(Fa,e.__scopeSelect),r=La(Fa,e.__scopeSelect),[o,s]=v.useState(!1),i=We(t,r.onScrollButtonChange);return Et(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(pp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});fp.displayName=Fa;var za="SelectScrollDownButton",hp=v.forwardRef((e,t)=>{const n=Hn(za,e.__scopeSelect),r=La(za,e.__scopeSelect),[o,s]=v.useState(!1),i=We(t,r.onScrollButtonChange);return Et(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(pp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});hp.displayName=za;var pp=v.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Hn("SelectScrollButton",n),i=v.useRef(null),a=Bs(n),l=v.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return v.useEffect(()=>()=>l(),[l]),Et(()=>{var d;const c=a().find(f=>f.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(Re.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:pe(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:pe(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:pe(o.onPointerLeave,()=>{l()})})}),bC="SelectSeparator",mp=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(Re.div,{"aria-hidden":!0,...r,ref:t})});mp.displayName=bC;var Ba="SelectArrow",SC=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Hs(n),s=Bn(Ba,n),i=Hn(Ba,n);return s.open&&i.position==="popper"?u.jsx(su,{...o,...r,ref:t}):null});SC.displayName=Ba;var CC="SelectBubbleInput",gp=v.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=v.useRef(null),s=We(r,o),i=$h(t);return v.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),u.jsx(Re.select,{...n,style:{...Vh,...n.style},ref:s,defaultValue:t})});gp.displayName=CC;function xp(e){return e===""||e===void 0}function yp(e){const t=It(e),n=v.useRef(""),r=v.useRef(0),o=v.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=v.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return v.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function vp(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=TC(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function TC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var kC=Kh,wp=Gh,EC=Xh,IC=Jh,NC=Zh,bp=Qh,AC=rp,Sp=ip,Cp=lp,jC=cp,_C=dp,Tp=fp,kp=hp,Ep=mp;const Ip=kC,Np=EC,Ha=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(wp,{ref:r,className:te("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,u.jsx(IC,{asChild:!0,children:u.jsx(ie.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Ha.displayName=wp.displayName;const Ap=v.forwardRef(({className:e,...t},n)=>u.jsx(Tp,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ie.ChevronUp,{className:"h-4 w-4"})}));Ap.displayName=Tp.displayName;const jp=v.forwardRef(({className:e,...t},n)=>u.jsx(kp,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ie.ChevronDown,{className:"h-4 w-4"})}));jp.displayName=kp.displayName;const Ua=v.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(NC,{children:u.jsxs(bp,{ref:o,className:te("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(Ap,{}),u.jsx(AC,{className:te("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(jp,{})]})}));Ua.displayName=bp.displayName;const RC=v.forwardRef(({className:e,...t},n)=>u.jsx(Sp,{ref:n,className:te("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));RC.displayName=Sp.displayName;const sr=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Cp,{ref:r,className:te("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(_C,{children:u.jsx(ie.Check,{className:"h-4 w-4"})})}),u.jsx(jC,{children:t})]}));sr.displayName=Cp.displayName;const PC=v.forwardRef(({className:e,...t},n)=>u.jsx(Ep,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));PC.displayName=Ep.displayName;var OC="Separator",_p="horizontal",MC=["horizontal","vertical"],Rp=v.forwardRef((e,t)=>{const{decorative:n,orientation:r=_p,...o}=e,s=DC(r)?r:_p,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(Re.div,{"data-orientation":s,...a,...o,ref:t})});Rp.displayName=OC;function DC(e){return MC.includes(e)}var Pp=Rp;const Op=v.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(Pp,{ref:o,decorative:n,orientation:t,className:te("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Op.displayName=Pp.displayName;const LC=Hf,$C=Z0,FC=Uf,Mp=v.forwardRef(({className:e,...t},n)=>u.jsx(ks,{className:te("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}));Mp.displayName=ks.displayName;const zC=uo.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"}}),Dp=v.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(FC,{children:[u.jsx(Mp,{}),u.jsxs(Es,{ref:o,className:te(zC({side:e}),t),...r,children:[n,u.jsxs(Wf,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[u.jsx(ie.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Dp.displayName=Es.displayName;const Lp=({className:e,...t})=>u.jsx("div",{className:te("flex flex-col space-y-2 text-center sm:text-left",e),...t});Lp.displayName="SheetHeader";const $p=v.forwardRef(({className:e,...t},n)=>u.jsx(tr,{ref:n,className:te("text-lg font-semibold text-foreground",e),...t}));$p.displayName=tr.displayName;const Fp=v.forwardRef(({className:e,...t},n)=>u.jsx(Is,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));Fp.displayName=Is.displayName;const BC={api:{baseUrl:"http://localhost:8000/api",authToken:"",enableAuth:!1},ui:{layout:"sidebar",theme:"light",showTimestamps:!0,showAgentNames:!0,compactMessages:!1},behavior:{autoSave:!0,enableStreaming:!0,showTypingIndicator:!0}};function HC({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=b.useState(!1),[s,i]=b.useState(!1),[a,l]=b.useState(e),[c,d]=b.useState(!1),{toast:f}=ba();b.useEffect(()=>{const y=JSON.stringify(a)!==JSON.stringify(e);d(y)},[a,e]),b.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(BC),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},m=()=>{l(e),d(!1),o(!1)},x=async()=>{try{const g=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${g.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return u.jsxs(LC,{open:r,onOpenChange:o,children:[u.jsx($C,{asChild:!0,children:u.jsxs(rt,{variant:"outline",size:"sm",className:n,children:[u.jsx(ie.Settings,{className:"h-4 w-4 mr-2"}),"Settings",c&&u.jsx(vf,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),u.jsxs(Dp,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[u.jsxs(Lp,{children:[u.jsx($p,{children:"Chat Settings"}),u.jsx(Fp,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),u.jsxs("div",{className:"space-y-6 py-6",children:[u.jsxs(Qr,{children:[u.jsx(eo,{className:"pb-3",children:u.jsxs(to,{className:"text-lg flex items-center gap-2",children:[u.jsx(ie.Server,{className:"h-5 w-5"}),"API Configuration"]})}),u.jsxs(no,{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(tn,{htmlFor:"api-url",children:"API Base URL"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(Os,{id:"api-url",value:a.api.baseUrl,onChange:y=>l(g=>({...g,api:{...g.api,baseUrl:y.target.value}})),placeholder:"http://localhost:8000/api"}),u.jsx(rt,{variant:"outline",onClick:x,children:"Test"})]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(tn,{htmlFor:"enable-auth",children:"Enable Authentication"}),u.jsx(zn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:y=>l(g=>({...g,api:{...g.api,enableAuth:y}}))})]}),a.api.enableAuth&&u.jsxs("div",{className:"space-y-2",children:[u.jsx(tn,{htmlFor:"auth-token",children:"Authentication Token"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(Os,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:y=>l(g=>({...g,api:{...g.api,authToken:y.target.value}})),placeholder:"Enter your Bearer token"}),u.jsx(rt,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?u.jsx(ie.EyeOff,{className:"h-4 w-4"}):u.jsx(ie.Eye,{className:"h-4 w-4"})})]})]})]})]}),u.jsxs(Qr,{children:[u.jsx(eo,{className:"pb-3",children:u.jsxs(to,{className:"text-lg flex items-center gap-2",children:[u.jsx(ie.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),u.jsxs(no,{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(tn,{htmlFor:"layout",children:"Layout Style"}),u.jsxs(Ip,{value:a.ui.layout,onValueChange:y=>l(g=>({...g,ui:{...g.ui,layout:y}})),children:[u.jsx(Ha,{children:u.jsx(Np,{})}),u.jsxs(Ua,{children:[u.jsx(sr,{value:"sidebar",children:"Sidebar Layout"}),u.jsx(sr,{value:"fullscreen",children:"Fullscreen"}),u.jsx(sr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(tn,{htmlFor:"theme",children:"Theme"}),u.jsxs(Ip,{value:a.ui.theme,onValueChange:y=>l(g=>({...g,ui:{...g.ui,theme:y}})),children:[u.jsx(Ha,{children:u.jsx(Np,{})}),u.jsxs(Ua,{children:[u.jsx(sr,{value:"light",children:"Light"}),u.jsx(sr,{value:"dark",children:"Dark"}),u.jsx(sr,{value:"system",children:"System"})]})]})]}),u.jsx(Op,{}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(tn,{htmlFor:"show-timestamps",children:"Show Timestamps"}),u.jsx(zn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:y=>l(g=>({...g,ui:{...g.ui,showTimestamps:y}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(tn,{htmlFor:"show-agent-names",children:"Show Agent Names"}),u.jsx(zn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:y=>l(g=>({...g,ui:{...g.ui,showAgentNames:y}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(tn,{htmlFor:"compact-messages",children:"Compact Messages"}),u.jsx(zn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:y=>l(g=>({...g,ui:{...g.ui,compactMessages:y}}))})]})]})]})]}),u.jsxs(Qr,{children:[u.jsx(eo,{className:"pb-3",children:u.jsxs(to,{className:"text-lg flex items-center gap-2",children:[u.jsx(ie.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),u.jsxs(no,{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(tn,{htmlFor:"auto-save",children:"Auto-save Conversations"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),u.jsx(zn,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:y=>l(g=>({...g,behavior:{...g.behavior,autoSave:y}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(tn,{htmlFor:"enable-streaming",children:"Enable Streaming"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),u.jsx(zn,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:y=>l(g=>({...g,behavior:{...g.behavior,enableStreaming:y}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(tn,{htmlFor:"typing-indicator",children:"Typing Indicator"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),u.jsx(zn,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:y=>l(g=>({...g,behavior:{...g.behavior,showTypingIndicator:y}}))})]})]})]})]}),u.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[u.jsxs(rt,{variant:"outline",onClick:p,children:[u.jsx(ie.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(rt,{variant:"outline",onClick:m,children:"Cancel"}),u.jsxs(rt,{onClick:h,disabled:!c,children:[u.jsx(ie.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function UC({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const d="h-full";switch(c){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=b.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(jo,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Ps,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(jo,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(Ma,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Ps,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(jo,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(Ma,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Ps,{onError:s.onError,enableFileUpload:!0})})]})})}Ee.ChatApi=Bl,Ee.ChatInput=uc,Ee.ChatInterface=Ps,Ee.ChatProviders=jo,Ee.ChatSettings=HC,Ee.MarkdownContent=io,Ee.MessageComponent=Na,Ee.MessageList=Aa,Ee.ThreadManager=Ma,Ee.applySettings=GS,Ee.buildMessagePreviewMap=Gl,Ee.chatApiClient=jn,Ee.default=UC,Ee.del=zl,Ee.get=Gt,Ee.getChatToken=Ll,Ee.getCurrentSettings=qS,Ee.getDefaultApiConfig=Ph,Ee.getDefaultChatSettings=Oh,Ee.onChatTokenChanged=$l,Ee.post=ii,Ee.put=Fl,Ee.setChatToken=To,Ee.useApi=ai,Ee.useChatStream=Yl,Ee.useMessagesReducer=Xl,Ee.useStream=lc,Ee.useThreadState=Ao,Ee.useThreads=No,Object.defineProperties(Ee,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
133
|
+
`}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=eh(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=eh(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 sh{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 ih{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 zn{constructor(t){this.options=t||rr,this.options.renderer=this.options.renderer||new Ia,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new sh,this.slugger=new ih}static parse(t,n){return new zn(n).parse(t)}static parseInline(t,n){return new zn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,f,h,p,m,x,y,g,w,S,k,T,C;const E=t.length;for(o=0;o<E;o++){if(p=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[p.type]&&(C=this.options.extensions.renderers[p.type].call({parser:this},p),C!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type))){r+=C||"";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,Qf(this.parseInline(p.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(p.text,p.lang,p.escaped);continue}case"table":{for(f="",d="",a=p.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(p.header[s].tokens),{header:!0,align:p.align[s]});for(f+=this.renderer.tablerow(d),h="",a=p.rows.length,s=0;s<a;s++){for(c=p.rows[s],d="",l=c.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(c[i].tokens),{header:!1,align:p.align[i]});h+=this.renderer.tablerow(d)}r+=this.renderer.table(f,h);continue}case"blockquote":{h=this.parse(p.tokens),r+=this.renderer.blockquote(h);continue}case"list":{for(m=p.ordered,x=p.start,y=p.loose,a=p.items.length,h="",s=0;s<a;s++)w=p.items[s],S=w.checked,k=w.task,g="",w.task&&(T=this.renderer.checkbox(S),y?w.tokens.length>0&&w.tokens[0].type==="paragraph"?(w.tokens[0].text=T+" "+w.tokens[0].text,w.tokens[0].tokens&&w.tokens[0].tokens.length>0&&w.tokens[0].tokens[0].type==="text"&&(w.tokens[0].tokens[0].text=T+" "+w.tokens[0].tokens[0].text)):w.tokens.unshift({type:"text",text:T}):g+=T),g+=this.parse(w.tokens,y),h+=this.renderer.listitem(g,k,S);r+=this.renderer.list(h,m,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<E&&t[o+1].type==="text";)p=t[++o],h+=`
|
|
134
|
+
`+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const N='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(N);return}else throw new Error(N)}}}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 Rs{constructor(t){this.options=t||rr}preprocess(t){return t}postprocess(t){return t}}zp(Rs,"passThroughHooks",new Set(["preprocess","postprocess"]));function vS(e,t,n){return r=>{if(r.message+=`
|
|
135
|
+
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Mt(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 ah(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...xe.defaults,...s};const i=vS(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(gS(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(f){return i(f)}const c=function(f){let h;if(!f)try{r.walkTokens&&xe.walkTokens(l,r.walkTokens),h=t(l,r),r.hooks&&(h=r.hooks.postprocess(h))}catch(p){f=p}return r.highlight=a,f?i(f):o(null,h)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;xe.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(h,p){if(h)return c(h);p!=null&&p!==f.text&&(f.text=p,f.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(xe.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&&xe.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function xe(e,t,n){return ah(Fn.lex,zn.parse)(e,t,n)}xe.options=xe.setOptions=function(e){return xe.defaults={...xe.defaults,...e},rS(xe.defaults),xe},xe.getDefaults=Yf,xe.defaults=rr,xe.use=function(...e){const t=xe.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=xe.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=xe.defaults.renderer||new Ia;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=xe.defaults.tokenizer||new Ea;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=xe.defaults.hooks||new Rs;for(const s in n.hooks){const i=o[s];Rs.passThroughHooks.has(s)?o[s]=a=>{if(xe.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=xe.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}}xe.setOptions(r)})},xe.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(xe,r)),r.type){case"table":{for(const o of r.header)n=n.concat(xe.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(xe.walkTokens(s.tokens,t));break}case"list":{n=n.concat(xe.walkTokens(r.items,t));break}default:xe.defaults.extensions&&xe.defaults.extensions.childTokens&&xe.defaults.extensions.childTokens[r.type]?xe.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(xe.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(xe.walkTokens(r.tokens,t)))}return n},xe.parseInline=ah(Fn.lexInline,zn.parseInline),xe.Parser=zn,xe.parser=zn.parse,xe.Renderer=Ia,xe.TextRenderer=sh,xe.Lexer=Fn,xe.lexer=Fn.lex,xe.Tokenizer=Ea,xe.Slugger=ih,xe.Hooks=Rs,xe.parse=xe,xe.options,xe.setOptions,xe.use,xe.walkTokens,xe.parseInline,zn.parse,Fn.lex;function ao({content:e,className:t="",allowHtml:n=!1,style:r}){const o=b.useMemo(()=>{try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof xe.parse=="function"?xe.parse(i):xe(i)}return typeof xe.parse=="function"?xe.parse(e):xe(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=b.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return u.jsx("div",{className:te("markdown prose prose-sm max-w-none break-words","dark:prose-invert","text-current","prose-headings:text-current prose-p:text-current prose-li:text-current prose-a:text-current prose-strong:text-current","prose-em:text-current prose-blockquote:text-current prose-table:text-current prose-td:text-current prose-th:text-current","prose-pre:font-mono prose-pre:text-xs prose-pre:bg-background/50 prose-pre:border prose-pre:rounded prose-pre:p-3 prose-pre:whitespace-pre prose-pre:overflow-x-auto","prose-code:font-mono prose-code:text-sm prose-code:bg-background/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-current",t),style:s,dangerouslySetInnerHTML:{__html:o}})}const wS="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";function bS(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function lh(e){const t=e.content.find(s=>s.type==="tool_call"),n=e.additionalKwargs??{},r=typeof(t==null?void 0:t.id)=="string"&&t.id||typeof n.toolCallId=="string"&&n.toolCallId||(e.id.startsWith("tool-")?e.id.slice(5):void 0);return{name:(typeof(t==null?void 0:t.name)=="string"&&t.name||typeof n.toolName=="string"&&n.toolName||e.name&&String(e.name))??void 0,toolCallId:r??void 0}}function Ps(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function SS(e){const t=o=>{try{const s=so(o);return typeof s=="string"?s:JSON.stringify(s??"")}catch{return""}},n=e.filter(o=>o.type==="text");let r="";return n.length?r=t(n.map(o=>o.text).join(`
|
|
136
|
+
`)):r=t(e),r||""}function CS(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function ch(e){if("type"in e&&e.type==="default_message")return`default:${e.content.length}`;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"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function TS({className:e}){const[t,n]=b.useState(0);return b.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:te("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const Na=b.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:f=!0,customStyles:h={},onEdit:p,onRegenerate:m,onCancelEdit:x,onCopy:y,activeInterrupt:g,disableInterruptActions:w=!1,onInterruptActionStart:S,onInterruptActionEnd:k,checkpointCandidates:T=[],activeCheckpointId:C=null,onSelectCheckpoint:E,defaultCheckpointId:N=null,messageParentCheckpointId:j=null}){const[D,P]=b.useState(!1),[M,F]=b.useState("preview"),[A,z]=b.useState(!1),{currentThreadId:_}=Ao(),{respondToInterrupt:X}=jo(),$=l==="phone"||l==="half-screen",R=t.role,J=R==="tool",G=b.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),pe=!!G,Ce=!(r&&R!=="user"),{uploadingFiles:Ae,handleFileClick:q,fileViewerOpen:ne,currentFileInfo:Y,closeFileViewer:L}=ES({allowFileOpen:Ce,currentThreadId:_}),H=b.useMemo(()=>{switch(R){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))]"}},[R]),V=b.useMemo(()=>G?"":bS(t.content),[G,t]),ie=b.useMemo(()=>G?{}:lh(t),[G,t]),re=b.useMemo(()=>G?[]:t.content.filter(U=>U.type==="image_url"),[G,t]),ze=b.useMemo(()=>G?[]:t.content.filter(U=>U.type==="file"),[G,t]),We=b.useMemo(()=>G?[]:t.content.filter(U=>U.type==="interrupt"),[G,t]),Ze=(g==null?void 0:g.id)??(g==null?void 0:g.interrupt_id),oe=Ps(Ze),me=g==null?void 0:g.value,Te=b.useMemo(()=>G?"":SS(t.content),[G,t]),Be=b.useCallback(async()=>{const U=J?Te:V;async function ve(B){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(B);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const ee=new Blob([B],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":ee})]);return}throw new Error("Clipboard API not supported in this context.")}try{await ve(U),P(!0),setTimeout(()=>P(!1),2e3),y==null||y(U)}catch(B){console.error("Failed to copy:",B)}},[J,Te,V,y]),Je=b.useCallback(()=>{if(!p)return;const U=J?Te:V,ve="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};p(t.id,U,ve)},[p,t.id,J,Te,V,t]),tt=b.useCallback(()=>{m==null||m(n)},[m,n]),$e=b.useCallback(()=>{const ve=te($?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",H);switch(R){case"user":return u.jsx(ae.User,{className:ve});case"assistant":return u.jsx(ae.Bot,{className:ve});case"tool":return u.jsx(ae.Wrench,{className:ve});default:return u.jsx(ae.Bot,{className:ve})}},[$,H,R]),He=b.useCallback(()=>{const U="group relative mb-4 flex w-full";switch(R){case"user":return te(U,"justify-end");case"assistant":case"tool":case"system":return te(U,"justify-start");default:return U}},[R]),Ve=b.useCallback(()=>{const U=te("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",$&&"px-3 py-2 text-sm");if(pe)return te(U,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(R){case"user":return te(U,"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 te(U,"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 te(U,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return te(U,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return te(U,"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")}},[$,pe,R]);if(pe&&G)return u.jsx("div",{className:te(He(),h.container),children:u.jsxs("div",{className:te(Ve(),h.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(ae.Bot,{className:te("h-4 w-4",H)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(ao,{content:G.content,className:"text-current"})]})});const nt=b.useCallback(async U=>{if(w)return;const ve=Ps((U==null?void 0:U.id)??(U==null?void 0:U.interrupt_id));if(!ve){console.warn("Interrupt part missing id",U);return}try{S==null||S(),await X(ve,!0)}catch(B){console.error("Failed to approve interrupt:",B)}finally{k==null||k()}},[w,k,S,X]),kt=b.useCallback(async U=>{if(w)return;const ve=Ps((U==null?void 0:U.id)??(U==null?void 0:U.interrupt_id));if(!ve){console.warn("Interrupt part missing id",U);return}try{S==null||S(),await X(ve,!1)}catch(B){console.error("Failed to reject interrupt:",B)}finally{k==null||k()}},[w,k,S,X]),ft=b.useCallback(({part:U,i:ve})=>{if(U.type==="text"){const B=U.text??"",ee=B.trim(),ye=Sa(ee);return ye&&R!=="tool"?u.jsx(uh,{data:ye},ve):R==="user"&&c&&ee.length>d?u.jsx(IS,{text:ee,expanded:A,onExpandedChange:z,previewLength:d,isCompact:$},ve):u.jsx(ao,{content:B,allowHtml:!1},ve)}if(U.type==="image_url"){const B=U;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:B.url,alt:B.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},ve)}if(U.type==="file"){const B=U,ee=B.name||"file";return u.jsxs("a",{href:B.url,onClick:ye=>q(ye,B,ve),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
137
|
+
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[Ae[ve]?u.jsx(ae.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[ee,Ae[ve]?" (processing)":""]})]},ve)}if(U.type==="interrupt"){const B=U,ee=Ps((B==null?void 0:B.id)??(B==null?void 0:B.interrupt_id)),ye=!!(oe&&ee&&ee===oe),Ne=ye?me??(B==null?void 0:B.value):B==null?void 0:B.value,se=ee?{...B,id:ee,interrupt_id:ee}:B;return u.jsx(kS,{interruptPart:se,onApprove:nt,onReject:kt,disabled:w,isActive:ye,payload:Ne},ve)}return null},[q,Ae,nt,kt,R,c,d,A,$,oe,me,g,w,We]),mt=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(ae.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),gt=b.useCallback(()=>{const U=V.trim().length>0||re.length>0||ze.length>0||We.length>0;if(!J&&ze.length>0&&!r)return mt();if(!J&&!U&&!r)return null;if(J)return u.jsx(NS,{message:t,viewMode:M},t.id);if(!J&&!G){const ve=t,B=u.jsx("div",{className:"space-y-2",children:ve.content.map((ee,ye)=>u.jsx(ft,{part:ee,i:ye},ye))});return r?u.jsxs("div",{"aria-busy":"true",role:"status",children:[B,u.jsx(TS,{className:H})]}):B}},[V,re.length,ze.length,We.length,r,J,M,mt,H]),st=b.useMemo(()=>G?"Assistant":CS(t),[G,t]),De=b.useMemo(()=>G?[]:Array.isArray(T)?T:[],[T,G]),At=b.useMemo(()=>{var U;return De.length?N&&De.some(ve=>ve.id===N)?N:((U=De[0])==null?void 0:U.id)??null:null},[N,De]),nn=b.useMemo(()=>!De.length||!C?null:De.some(U=>U.id===C)?C:null,[C,De])??At,fn=R==="user"&&De.length>0&&typeof E=="function",qe=b.useCallback(U=>{if(!E)return;const ve=(U==null?void 0:U.id)??null,B=(U==null?void 0:U.parentId)??j??null;E(ve,B)},[j,E]),je=b.useMemo(()=>nn?De.findIndex(U=>U.id===nn):-1,[nn,De]),Et=b.useMemo(()=>je<0?null:De[je]??null,[je,De]),Ht=b.useCallback(U=>{const ve=[];if(U.step!==null&&ve.push(`Step ${U.step}`),U.source&&ve.push(U.source),!U.createdAt)return ve.length?ve.join(" • "):U.id.slice(0,8);let B="";try{const ee=new Date(U.createdAt);Number.isNaN(ee.getTime())||(B=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(ee))}catch{B=""}return`${B}`},[]);return J&&!f?null:u.jsxs(u.Fragment,{children:[u.jsx("div",{className:te(He(),h.container),children:u.jsxs("div",{className:te(Ve(),h.content),children:[(i||a||J)&&u.jsxs("div",{className:te("flex items-center justify-between mb-2 pb-2 border-b border-current/10",$&&"mb-1 pb-1",H,h.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[$e(),a&&st&&u.jsx("span",{className:te("font-medium",$?"text-xs":"text-sm"),children:st}),J&&u.jsxs(vf,{variant:"outline",className:te("text-xs flex items-center gap-1 cursor-pointer select-none",H,"border border-current/40",$&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":M==="expanded",onClick:()=>F(U=>U==="expanded"?"preview":"expanded"),onKeyDown:U=>{(U.key==="Enter"||U.key===" ")&&(U.preventDefault(),F(ve=>ve==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:ie.name??"Tool Output"}),ie.toolCallId&&u.jsx("span",{className:"opacity-70",children:ie.toolCallId.slice(0,8)}),M==="expanded"?u.jsx(ae.ChevronUp,{className:"h-3 w-3"}):u.jsx(ae.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[fn&&Et&&je>=0&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:te("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",je>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(je<=0)return;const U=De[je-1];U&&qe(U)},"aria-label":"Previous checkpoint",disabled:je<=0,children:u.jsx(ae.ChevronLeft,{className:"h-3 w-3"})}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("span",{className:"whitespace-nowrap",children:[je+1," / ",De.length]}),u.jsx("span",{className:"text-muted-foreground",children:Ht(Et)})]}),u.jsx("button",{type:"button",className:te("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",je<De.length-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(je>=De.length-1)return;const U=De[je+1];U&&qe(U)},"aria-label":"Next checkpoint",disabled:je>=De.length-1,children:u.jsx(ae.ChevronRight,{className:"h-3 w-3"})})]}),i&&t.createdAt&&u.jsx("time",{className:te("text-xs opacity-60",H,$&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&u.jsxs("div",{className:te("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",h.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(rt,{variant:"ghost",size:"sm",onClick:()=>Be(),className:te("h-6 w-6 p-0 hover:bg-foreground/10",H,$&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(ae.Copy,{className:te(D?"text-success":H,$?"h-3 w-3":"h-4 w-4")})})}),R==="user"&&p&&u.jsx(rt,{variant:"ghost",size:"sm",onClick:Je,className:te("h-6 w-6 p-0 hover:bg-foreground/10",H,$&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(ae.Edit,{className:te(H,$?"h-3 w-3":"h-4 w-4")})}),R==="assistant"&&m&&u.jsx(rt,{variant:"ghost",size:"sm",onClick:tt,className:te("h-6 w-6 p-0 hover:bg-foreground/10",H,$&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(ae.RotateCcw,{className:te(H,$?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsx("div",{className:"relative",children:gt()}),J&&M==="expanded"&&(ie.toolCallId||ie.name)&&u.jsxs("div",{className:te("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",$&&"text-xs"),children:[ie.name&&u.jsxs("div",{children:["Function: ",ie.name]}),ie.toolCallId&&u.jsxs("div",{children:["Call ID: ",ie.toolCallId]})]}),!(i||a||J)&&s&&!o&&u.jsxs("div",{className:te("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",h.actions),children:[u.jsx(rt,{variant:"ghost",size:"sm",onClick:()=>Be(),className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",$&&"h-5 w-5"),children:u.jsx(ae.Copy,{className:te(D?"text-success":"text-current",$?"h-3 w-3":"h-4 w-4")})}),R==="user"&&p&&u.jsx(rt,{variant:"ghost",size:"sm",onClick:Je,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",$&&"h-5 w-5"),children:u.jsx(ae.Edit,{className:te("text-current",$?"h-3 w-3":"h-4 w-4")})}),R==="assistant"&&m&&u.jsx(rt,{variant:"ghost",size:"sm",onClick:tt,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",$&&"h-5 w-5"),children:u.jsx(ae.RotateCcw,{className:te("text-current",$?"h-3 w-3":"h-4 w-4")})})]})]})}),Y&&u.jsx(nS,{isOpen:ne,onClose:L,fileId:Y.id,fileName:Y.name,mimeType:Y.mimeType})]})},(e,t)=>{var i,a,l,c,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&ch(e.message)===ch(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(m=>e[m]===t[m]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((l=e.customStyles)==null?void 0:l.content)===((c=t.customStyles)==null?void 0:c.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((h=e.customStyles)==null?void 0:h.header)===((p=t.customStyles)==null?void 0:p.header);return o&&s});function uh({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:wS,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:io(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:io(e)})}function kS({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=io(s);a=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(eo,{className:te("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(to,{className:"pb-3",children:[u.jsx(no,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(wf,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(ro,{className:"pt-0 pb-3",children:a}),u.jsx(bf,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(rt,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(rt,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}function ES(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=ba(),[o,s]=b.useState({}),[i,a]=b.useState(null),[l,c]=b.useState(!1),d=b.useCallback(()=>{c(!1),a(null)},[]),f=b.useCallback(p=>{a(p),c(!0)},[]),h=b.useCallback(async(p,m,x)=>{var y,g;if(!t){p.preventDefault();return}if(o[x]){p.preventDefault();return}try{const w=String(m.url??""),S=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){p.preventDefault();const k=S[1],T=m.name||`file_${k}`,C=m.mimeType||"application/octet-stream";f({id:k,name:T,mimeType:C});return}if(w.startsWith("data:")){p.preventDefault(),s(T=>({...T,[x]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const T=await z0(n??void 0);if(!T||!Array.isArray(T))throw new Error("Invalid file list response");const C=T.find(E=>!E||typeof E!="object"||!((E.filename??"")===(m.name??""))?!1:typeof m.size=="number"&&typeof E.size=="number"?E.size===m.size:!0);if(!(C!=null&&C.id))throw new Error(`File "${m.name}" is not yet available on the server`);if(!C.id||!C.filename)throw new Error("Invalid file data received from server");f({id:C.id,name:m.name||C.filename||`file_${C.id}`,mimeType:m.mimeType||C.mime_type||"application/octet-stream"}),(y=k.update)==null||y.call(k,{id:k.id,title:"Success",description:`Opened ${m.name}`,open:!0})}catch(T){console.error("Failed to fetch server file:",T);const C=T instanceof Error?T.message:"Unknown error occurred";(g=k.update)==null||g.call(k,{id:k.id,title:"Failed",description:C}),r({title:"Failed to fetch file",description:C,open:!0})}finally{s(T=>({...T,[x]:!1}))}}}catch(w){console.error("File click error:",w),s(S=>({...S,[x]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:h,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function IS({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("div",{className:te("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(ao,{content:e,allowHtml:!1}):u.jsxs("pre",{className:te("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(rt,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(ae.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(ae.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function NS({message:e,viewMode:t}){const r=lh(e).name||"tool",o=c=>{if(c==null)return null;const d=typeof c=="string"?Sa(c)??c:c;if(d&&typeof d=="object")return u.jsx(uh,{data:d});const f=typeof d=="string"?d:(()=>{try{return io(d)}catch{return String(d??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:f})},s=c=>{if(c==null)return null;const{content:d,isMarkdown:f}=H0(c);return f?u.jsx(ao,{content:d,className:"text-current"}):o(c)};if(t==="preview")return null;const i=e.content.find(c=>c.type!=="tool_call");if(!i)return u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ae.Loader,{className:"h-4 w-4 animate-spin"}),u.jsxs("span",{children:["Waiting for ",r," output…"]})]});if(i.type==="text"){const d=(i.text??"").trim();if(!d)return null;const f=Cs(d);return s(f)}const a=so(i),l=Cs(a);return s(l)}const AS=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r})=>{const o=e??[],s=o.length>0,i=b.useMemo(()=>s?[...o].reverse():[],[o,s]),a=t??(o.length?o[o.length-1].id:null);return b.useEffect(()=>{console.debug("[TimelineColumn] entries:",o.length)},[o.length]),s?u.jsxs("div",{className:"w-32 flex-shrink-0 flex-col border-r border-border/40 pr-2 flex",children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-4 pb-2 pr-1",children:[u.jsxs("div",{className:"absolute left-0 right-0 top-1 flex items-center justify-between px-2 pb-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:"Timeline"}),u.jsxs("div",{className:"group relative z-50",children:[u.jsx(ae.Info,{className:"h-3 w-3 text-muted-foreground cursor-help"}),u.jsx("div",{className:"pointer-events-auto fixed hidden w-56 rounded-md border bg-background p-3 text-[10px] font-normal text-muted-foreground shadow-lg group-hover:block whitespace-normal leading-relaxed",style:{zIndex:9999},children:"Backend pre-selects user inputs + latest loop checkpoint. Click a dot to jump, or use “Latest” to return to the newest messages."})]})]}),u.jsx("div",{className:"pointer-events-none absolute left-3 top-0 bottom-0 w-px bg-border/40"}),u.jsx("div",{className:"flex flex-col gap-3 pt-6 pr-2",children:i.map(l=>{const c=a===l.id,d=l.messageId?(r==null?void 0:r.get(l.messageId))??null:null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(l.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${c?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${c?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${c?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium leading-tight",children:l.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[l.step!==null?`STEP ${l.step}`:"STEP —",l.next?` - ${l.next}`:""]}),d&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:d,children:d})]})]},l.id)})})]}),n&&u.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]}):null},dh=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,jS=e=>{const t=e.additionalKwargs??{},n=e.responseMetadata??{},r=t.originalMessageId??n.originalMessageId??t.original_message_id??n.original_message_id;return typeof r=="string"&&r.trim()?r.trim():e.id},Aa=b.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:m=!0,isNavigatingCheckpoint:x=!1,onScrollAway:y,onAtBottom:g,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:T,showToolMessages:C=!0,checkpointMetaById:E,checkpointIndexByKey:N,activeCheckpointId:j,onSelectCheckpoint:D,timelineCheckpoints:P,messagePreviews:M,createSyntheticThinkingMessage:F=!1},A)=>{const z=b.useRef(null),_=b.useRef(null),X=b.useRef(!1),[$,R]=b.useState(!0),J=b.useMemo(()=>w?e.some(oe=>"type"in oe&&oe.type==="default_message"?!1:Array.isArray(oe==null?void 0:oe.content)&&oe.content.some(me=>me&&me.type==="interrupt"&&(me.id??me.interrupt_id)===w.id)):!1,[w,e]),G=b.useMemo(()=>{if(!w||J)return null;const oe=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let me;const Te=w.value;if(Te&&typeof Te=="object"&&!Array.isArray(Te)){const Be=Te.title;typeof Be=="string"&&Be.trim()&&(me=Be.trim())}return{id:`interrupt-${oe}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:oe,value:Te,title:me}]}},[w,J]),pe=b.useMemo(()=>G?[...e,G]:e,[e,G]),Ce=b.useMemo(()=>!F||!t?pe:!pe.some(me=>me.role==="assistant")&&pe.length>0?[...pe,{id:"thinking-assistant",role:"assistant",content:[],createdAt:new Date().toISOString()}]:pe,[pe,t,F]),Ae=b.useMemo(()=>C?Ce:Ce.filter(oe=>(oe==null?void 0:oe.role)!=="tool"),[Ce,C]),q=b.useMemo(()=>{const oe=new Set,me=[];for(let Te=Ae.length-1;Te>=0;Te--){const Be=Ae[Te];if(!Be)continue;if("type"in Be&&Be.type==="default_message"){me.push(Be);continue}const Je=Be,tt=jS(Je);oe.has(tt)||(oe.add(tt),me.push(Je))}return me.reverse()},[Ae]),ne=b.useCallback(oe=>{R(oe),y&&y(!oe),g&&g(oe)},[y,g]),Y=b.useMemo(()=>{if(a)return async()=>{if(!X.current){X.current=!0;try{await a()}finally{X.current=!1}}}},[a]),L=b.useMemo(()=>!m||x?!1:$?"auto":!1,[$,m,x]),H=P??[],V=H.length>0,ie=b.useMemo(()=>{if(typeof p!="string")return null;const oe=p.trim();return oe?{id:"default-message",role:"assistant",type:"default_message",content:oe,createdAt:new Date().toISOString()}:null},[p]),re=V?u.jsx(AS,{timelineEntries:H,activeCheckpointId:j??null,onSelectCheckpoint:D,messagePreviews:M}):null,ze=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),We=()=>ie?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Na,{message:ie,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{}})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:p??"No messages yet. Start a conversation!"}),Ze=q.length>0;return b.useImperativeHandle(A,()=>({scrollToLatest:()=>{var oe,me;if(z.current&&q.length>0){const Te=q.length-1;(me=(oe=z.current).scrollToIndex)==null||me.call(oe,{index:Te,align:"end",behavior:"auto"})}else _.current&&(_.current.scrollTop=_.current.scrollHeight)},scrollToTop:()=>{var oe,me;z.current&&q.length>0?(me=(oe=z.current).scrollToIndex)==null||me.call(oe,{index:0,align:"start",behavior:"auto"}):_.current&&(_.current.scrollTop=0)}}),[q]),u.jsxs("div",{className:ze,style:h,children:[re,u.jsx("div",{className:"relative flex-1 min-h-0",children:Ze?u.jsx(y0,{ref:oe=>{z.current=oe},scrollerRef:oe=>{_.current=oe instanceof HTMLDivElement?oe:null},data:q,followOutput:L,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!0,startReached:()=>{Y&&Y()},atBottomStateChange:ne,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(oe,me)=>dh(me,oe),itemContent:(oe,me)=>{var ft;const Te=dh(me,oe),Be="type"in me&&me.type==="default_message";let Je=[],tt=null,$e={},He={},Ve=null,nt=null;if(!Be){const mt=me,gt=mt.checkpointId??null;$e=mt.additionalKwargs??{},He=mt.responseMetadata??{};const st=gt&&E?E.get(gt)??null:null;Ve=typeof $e.step=="number"?$e.step:typeof He.step=="number"?He.step:(st==null?void 0:st.step)??null;const De=typeof $e.source=="string"?$e.source:typeof He.source=="string"?He.source:(st==null?void 0:st.source)??null;nt=De?String(De):null;const At=Ve!==null&&nt?`${Ve}:${nt}`:null;At&&(N!=null&&N.has(At))?Je=N.get(At)??[]:gt&&st&&(Je=[st]),tt=gt??((ft=Je[0])==null?void 0:ft.id)??null}const kt=(()=>{if(typeof $e.parentCheckpointId=="string")return $e.parentCheckpointId;if(typeof He.parentCheckpointId=="string")return He.parentCheckpointId})();return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":Te,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Na,{message:me,messageIndex:oe,isStreamingMessage:t&&n===me.id,streamingDebounceMs:r,isEditing:i===me.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:l,onRegenerate:()=>c(oe),onCancelEdit:d,activeInterrupt:w,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:T,showToolMessages:C,checkpointCandidates:Je,activeCheckpointId:j??null,onSelectCheckpoint:D,defaultCheckpointId:tt,messageParentCheckpointId:kt})})}}):We()})]})});Aa.displayName="MessageList";const fh={value:""};function Os({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,customStyles:f={},onMessageSent:h,onExcelUploadSuccess:p,onError:m}){const{api:x}=ai(),{currentThreadId:y}=Ao(),{threadId:g,messages:w,isHistoryLoading:S,isLoading:k,navigateToCheckpoint:T,returnToLatest:C,checkpoint:E,checkpoints:N,interrupt:j,metadata:D,timelineCheckpoints:P,messagePreviews:M}=jo(),{isStreaming:F,error:A,connectionState:z,submit:_,stop:X}=lc(),$=g??y??null,R=(E==null?void 0:E.id)??null,J=(E==null?void 0:E.namespace)??null,G=(D==null?void 0:D.assemblingMessageId)??null,pe=j,[Ce,Ae]=b.useState(!1);b.useEffect(()=>{pe||Ae(!1)},[pe]);const q=b.useCallback(()=>{Ae(!0)},[]),ne=b.useCallback(()=>{Ae(!1)},[]),Y=!!pe||Ce,[L,H]=b.useState(null),[V,ie]=b.useState(""),[re,ze]=b.useState(null),[We,Ze]=b.useState(null),[oe,me]=b.useState([]),[Te,Be]=b.useState(0),[Je,tt]=b.useState(0),[$e,He]=b.useState(!1),[Ve,nt]=b.useState(null),[kt,ft]=b.useState(null),[mt,gt]=b.useState(!1),[st,De]=b.useState(null),At=b.useRef(!1),[jt,nn]=b.useState(()=>fh.value),fn=b.useRef(jt),qe=b.useRef(null),je=b.useCallback(Q=>{fh.value=Q,nn(Q)},[]),[Et,Ht]=b.useState(!1),U=b.useRef(null),ve=b.useCallback((Q,de)=>{if(!Q||typeof Q!="object")return null;const fe=Q[de];return typeof fe=="number"?fe:null},[]),B=b.useCallback((Q,de)=>{if(!Q||typeof Q!="object")return null;const fe=Q[de];return typeof fe=="string"&&fe.trim()?fe:null},[]),ee=b.useMemo(()=>{const Q=we=>{if(!Array.isArray(we)||we.length===0)return null;const ct=we.map(xt=>{if(typeof xt=="string")return xt.trim();if(xt&&typeof xt=="object"&&"type"in xt){const hn=xt;if(typeof hn.type=="string")return hn.type}return null}).filter(xt=>!!(xt&&xt.length));return ct.length?ct.join(", "):null},de=Array.isArray(N)?N.map(we=>{const ct=Q(we.next);return ct?{...we,metadata:{...we.metadata??{},next:ct}}:we}):[];return de.some(we=>ve(we.metadata,"step")!==null)&&de.sort((we,ct)=>{const xt=ve(we.metadata,"step"),hn=ve(ct.metadata,"step");if(xt!==null||hn!==null)return(hn??Number.NEGATIVE_INFINITY)-(xt??Number.NEGATIVE_INFINITY);const co=Date.parse(we.createdAt??""),uo=Date.parse(ct.createdAt??"");return Number.isNaN(co)||Number.isNaN(uo)?0:uo-co}),de},[N,ve]),{checkpointMetaById:ye,checkpointIndexByKey:Ne}=b.useMemo(()=>{const Q=new Map,de=new Map;for(const fe of ee){const we=fe.checkpointId??null;if(!we)continue;const ct=ve(fe.metadata,"step"),xt=B(fe.metadata,"source"),hn={id:we,step:ct,source:xt,createdAt:fe.createdAt??null,namespace:fe.checkpointNs??null,parentId:fe.parentId??null};if(Q.set(we,hn),ct!==null&&xt){const co=`${ct}:${xt}`,uo=de.get(co)??[];uo.push(hn),de.set(co,uo)}}for(const fe of de.values())fe.sort((we,ct)=>{const xt=we.createdAt??"";return(ct.createdAt??"").localeCompare(xt)});return{checkpointMetaById:Q,checkpointIndexByKey:de}},[ee,ve,B]),se=P??[],Ge=b.useRef(null),_e=b.useRef(null),Le=b.useCallback(()=>{Ge.current&&(Ge.current.value=""),_e.current&&(_e.current.value=""),Be(Q=>Q+1),tt(Q=>Q+1)},[]),rn=b.useCallback(Q=>{je(Q)},[je]),yt=b.useRef(!1);b.useEffect(()=>{yt.current&&!F&&(me([]),Le()),yt.current=F},[F,Le]);const[jn,Wa]=b.useState("desktop");b.useEffect(()=>{const Q=()=>{const de=window.innerWidth;Wa(de<640?"phone":de<1024?"tablet":"desktop")};return Q(),window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[]),b.useEffect(()=>{At.current=!1},[$]),b.useEffect(()=>{fn.current=jt},[jt]),b.useEffect(()=>{if(!L){qe.current=null;return}qe.current===null&&(qe.current=fn.current),je(V??"")},[V,L,je]),b.useEffect(()=>{(async()=>{if(!x.baseUrl){De(null);return}try{const fe=(await x.getAgent("default")).uiDefaultMessage||"";De(fe||null)}catch(de){console.warn("Failed to fetch default message:",de),De(null)}})()},[x.baseUrl]),b.useEffect(()=>{A&&!mt&&(m==null||m(A))},[A,mt,m]);const Va=Q=>{if(Q.length>as)return`Message too long (${Q.length}/${as} characters)`;try{return lb(Q),null}catch(de){return(de==null?void 0:de.message)||"Invalid message"}},Ka=async Q=>{const de=Q.trim();if(!(!de&&oe.length===0)){if(de){const fe=Va(de);if(fe){Ze(fe);return}}try{const fe=R??void 0,we=J??void 0,ct=L?{edit:!0,originalMessageId:L,...re!=null&&re.checkpointId?{originalCheckpointId:re.checkpointId}:{},...re!=null&&re.checkpointNs?{originalCheckpointNs:re.checkpointNs}:{}}:void 0;await _({text:de||"",attachments:oe,messageAdditionalKwargs:ct},{checkpointId:fe,checkpointNs:we}),h==null||h(de),je(""),Ze(null),me([]),Le(),H(null),ie(""),ze(null)}catch(fe){const we=(fe==null?void 0:fe.message)||"Failed to send message";Ze(we),m==null||m(we)}}},Vs=b.useCallback((Q,de,fe)=>{c&&(qe.current=jt,H(Q),ie(de),je(de),Ze(null),ze({checkpointId:(fe==null?void 0:fe.checkpointId)??null,checkpointNs:(fe==null?void 0:fe.checkpointNs)??null}))},[jt,c,je]),I=b.useCallback(()=>{H(null),ie(""),ze(null),Ze(null),je(qe.current??jt),qe.current=null},[jt,je]),K=b.useCallback((Q,de,fe)=>{Vs(Q,de,fe)},[Vs]),le=b.useCallback(Q=>{for(let de=Q-1;de>=0;de--)if(w[de].role==="user"){const fe=w[de].content||[],ct=fe.filter(xt=>xt.type==="text").map(xt=>xt.text).join("")||(()=>{try{return JSON.stringify(fe,null,2)}catch{return String(fe)}})();ct&&_({text:ct},{checkpointId:R??void 0,checkpointNs:J??void 0});break}},[w,_,R,J]),ke=Q=>{const de=Array.from(Q.target.files||[]);me(fe=>[...fe,...de]),Q.target.value=""},et=Q=>{me(de=>{const fe=de.filter((we,ct)=>Q!==ct);return fe.length===0&&Le(),fe})},it=async Q=>{const de=(Q.target.files||[])[0];if(de){nt(null),ft(null),He(!0);try{await _({attachments:[de]},{checkpointId:R??void 0,checkpointNs:J??void 0});const fe=`Uploaded ${de.name} - processing through chat stream`;ft(fe)}catch(fe){const we=fe instanceof Error?fe.message:"Failed to upload Excel file";console.error("Excel upload failed",fe),nt(we),m==null||m(we)}finally{He(!1),Q.target.value="",Le()}}},Ke=async Q=>{if(y){Ht(!0);try{if(!Q){await C(),requestAnimationFrame(()=>{var we;(we=U.current)==null||we.scrollToLatest()});return}const de=ee.find(we=>we.checkpointId===Q),fe=(de==null?void 0:de.checkpointNs)??null;await T(Q,fe),requestAnimationFrame(()=>{var we;(we=U.current)==null||we.scrollToTop()})}finally{Ht(!1)}}},Ue=b.useCallback(async Q=>{await Ke(Q)},[Ke]),_t=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${f.container||""}`,vt=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${f.messagesArea||""}`,wt=`flex-shrink-0 w-full border-t p-4 bg-transparent ${f.inputArea||""}`;return b.useCallback(Q=>{if(!Q)return"Latest";const de=[];Q.step!==null&&de.push(`Step ${Q.step}`),Q.source&&de.push(Q.source);const fe=Q.createdAt?new Date(Q.createdAt):null,we=fe&&!Number.isNaN(fe.getTime())?fe.toLocaleString():Q.createdAt??Q.id,ct=de.length?` — ${de.join(" • ")}`:"";return`${we}${ct}`},[]),u.jsxs("div",{className:_t,children:[!!A&&!mt&&u.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[u.jsx("span",{children:A}),u.jsx(rt,{variant:"ghost",size:"sm",onClick:()=>gt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(ae.X,{size:16})})]}),u.jsxs("div",{className:`relative ${vt}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(Aa,{ref:U,className:"h-full",style:{height:"100%"},messages:w,isStreaming:F,streamingAssistantId:G,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:jn,enableMessageEditing:c,editingMessageId:L,onEdit:K,onRegenerate:le,onCancelEdit:I,emptyMessage:st??void 0,isNavigatingCheckpoint:Et,activeInterrupt:pe,disableInterruptActions:Ce,onInterruptActionStart:q,onInterruptActionEnd:ne,showToolMessages:d,checkpointMetaById:ye,checkpointIndexByKey:Ne,activeCheckpointId:R,onSelectCheckpoint:Ue,timelineCheckpoints:se,messagePreviews:M}),(z==="reconnecting"||z==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(ae.Loader2,{className:"h-3 w-3 animate-spin"}),z==="reconnecting"?"Reconnecting…":"Connecting…"]})}),z==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),k&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ae.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(S||Et)&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ae.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),u.jsxs("div",{className:wt,children:[L&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(ae.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(rt,{variant:"ghost",size:"sm",onClick:I,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(ae.X,{size:16})})]})}),(a||l)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[a&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:Ge,type:"file",multiple:!0,onChange:Q=>ke(Q),className:"hidden"},Te),oe.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:oe.map((Q,de)=>u.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[u.jsx(ae.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:Q.name}),u.jsx(rt,{variant:"ghost",size:"sm",onClick:()=>et(de),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 ${Q.name}`,children:u.jsx(ae.X,{size:12})})]},de))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:_e,type:"file",accept:".xls,.xlsx,.xlsm",onChange:it,className:"hidden"},Je),$e&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ae.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),kt&&!$e&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:kt}),Ve&&!$e&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Ve})]})]}),We&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:We}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(Zw,{children:[u.jsx(Qw,{asChild:!0,children:u.jsx(rt,{type:"button",size:"icon",variant:"outline",disabled:F||Y,title:"More input actions",className:f.moreButton||"",children:u.jsx(ae.Plus,{size:16})})}),u.jsxs(vd,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(Yi,{onClick:()=>{var Q;return(Q=Ge.current)==null?void 0:Q.click()},className:"cursor-pointer",children:[u.jsx(ae.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(Yi,{onClick:()=>{var Q;$e||(Q=_e.current)==null||Q.click()},className:`cursor-pointer ${$e?"opacity-60 pointer-events-none":""}`,children:[u.jsx(ae.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(Qg,{initialValue:V,editingMessageId:L,value:jt,onValueChange:rn,placeholder:L?"Edit your message...":t,isStreaming:F,disabled:Y,maxLength:as,onSend:Ka,onCancelEdit:I,onStop:X,allowEmptySend:oe.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${L?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${We?"border-red-400":""} ${f.textarea||""}`})})]})]})]})}const Ms=v.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:te("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}));Ms.displayName="Input";function ja(e,[t,n]){return Math.min(n,Math.max(t,e))}function _S(e,t){return v.useReducer((n,r)=>t[n][r]??n,e)}var _a="ScrollArea",[hh,vT]=kn(_a),[RS,en]=hh(_a),ph=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=v.useState(null),[c,d]=v.useState(null),[f,h]=v.useState(null),[p,m]=v.useState(null),[x,y]=v.useState(null),[g,w]=v.useState(0),[S,k]=v.useState(0),[T,C]=v.useState(!1),[E,N]=v.useState(!1),j=Ye(t,P=>l(P)),D=Ro(o);return u.jsx(RS,{scope:n,type:r,dir:D,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:T,onScrollbarXEnabledChange:C,scrollbarY:x,onScrollbarYChange:y,scrollbarYEnabled:E,onScrollbarYEnabledChange:N,onCornerWidthChange:w,onCornerHeightChange:k,children:u.jsx(Pe.div,{dir:D,...i,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":g+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});ph.displayName=_a;var mh="ScrollAreaViewport",gh=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=en(mh,n),a=v.useRef(null),l=Ye(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),u.jsx(Pe.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});gh.displayName=mh;var Cn="ScrollAreaScrollbar",Ra=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=en(Cn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return v.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(PS,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(OS,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(xh,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Pa,{...r,ref:t}):null});Ra.displayName=Cn;var PS=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=en(Cn,e.__scopeScrollArea),[s,i]=v.useState(!1);return v.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Xt,{present:n||s,children:u.jsx(xh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),OS=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=en(Cn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Fs(()=>l("SCROLL_END"),100),[a,l]=_S("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 v.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),v.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let f=c[d];const h=()=>{const p=c[d];f!==p&&(l("SCROLL"),i()),f=p};return c.addEventListener("scroll",h),()=>c.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),u.jsx(Xt,{present:n||a!=="hidden",children:u.jsx(Pa,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:he(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:he(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),xh=v.forwardRef((e,t)=>{const n=en(Cn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=v.useState(!1),a=e.orientation==="horizontal",l=Fs(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Tr(n.viewport,l),Tr(n.content,l),u.jsx(Xt,{present:r||s,children:u.jsx(Pa,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Pa=v.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=en(Cn,e.__scopeScrollArea),s=v.useRef(null),i=v.useRef(0),[a,l]=v.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=Sh(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return zS(h,i.current,a,p)}return n==="horizontal"?u.jsx(MS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=Ch(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?u.jsx(DS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=Ch(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),MS=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=en(Cn,e.__scopeScrollArea),[i,a]=v.useState(),l=v.useRef(null),c=Ye(t,l,s.onScrollbarXChange);return v.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(vh,{"data-orientation":"horizontal",...o,ref:c,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":$s(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),kh(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:Ls(i.paddingLeft),paddingEnd:Ls(i.paddingRight)}})}})}),DS=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=en(Cn,e.__scopeScrollArea),[i,a]=v.useState(),l=v.useRef(null),c=Ye(t,l,s.onScrollbarYChange);return v.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(vh,{"data-orientation":"vertical",...o,ref:c,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":$s(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),kh(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:Ls(i.paddingTop),paddingEnd:Ls(i.paddingBottom)}})}})}),[LS,yh]=hh(Cn),vh=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:f,...h}=e,p=en(Cn,n),[m,x]=v.useState(null),y=Ye(t,j=>x(j)),g=v.useRef(null),w=v.useRef(""),S=p.viewport,k=r.content-r.viewport,T=Nt(d),C=Nt(l),E=Fs(f,10);function N(j){if(g.current){const D=j.clientX-g.current.left,P=j.clientY-g.current.top;c({x:D,y:P})}}return v.useEffect(()=>{const j=D=>{const P=D.target;(m==null?void 0:m.contains(P))&&T(D,k)};return document.addEventListener("wheel",j,{passive:!1}),()=>document.removeEventListener("wheel",j,{passive:!1})},[S,m,k,T]),v.useEffect(C,[r,C]),Tr(m,E),Tr(p.content,E),u.jsx(LS,{scope:n,scrollbar:m,hasThumb:o,onThumbChange:Nt(s),onThumbPointerUp:Nt(i),onThumbPositionChange:C,onThumbPointerDown:Nt(a),children:u.jsx(Pe.div,{...h,ref:y,style:{position:"absolute",...h.style},onPointerDown:he(e.onPointerDown,j=>{j.button===0&&(j.target.setPointerCapture(j.pointerId),g.current=m.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),N(j))}),onPointerMove:he(e.onPointerMove,N),onPointerUp:he(e.onPointerUp,j=>{const D=j.target;D.hasPointerCapture(j.pointerId)&&D.releasePointerCapture(j.pointerId),document.body.style.webkitUserSelect=w.current,p.viewport&&(p.viewport.style.scrollBehavior=""),g.current=null})})})}),Ds="ScrollAreaThumb",wh=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=yh(Ds,e.__scopeScrollArea);return u.jsx(Xt,{present:n||o.hasThumb,children:u.jsx($S,{ref:t,...r})})}),$S=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=en(Ds,n),i=yh(Ds,n),{onThumbPositionChange:a}=i,l=Ye(t,f=>i.onThumbChange(f)),c=v.useRef(void 0),d=Fs(()=>{c.current&&(c.current(),c.current=void 0)},100);return v.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!c.current){const p=BS(f,a);c.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),u.jsx(Pe.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:he(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),m=f.clientX-p.left,x=f.clientY-p.top;i.onThumbPointerDown({x:m,y:x})}),onPointerUp:he(e.onPointerUp,i.onThumbPointerUp)})});wh.displayName=Ds;var Oa="ScrollAreaCorner",bh=v.forwardRef((e,t)=>{const n=en(Oa,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(FS,{...e,ref:t}):null});bh.displayName=Oa;var FS=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=en(Oa,n),[s,i]=v.useState(0),[a,l]=v.useState(0),c=!!(s&&a);return Tr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Tr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(Pe.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 Ls(e){return e?parseInt(e,10):0}function Sh(e,t){const n=e/t;return isNaN(n)?0:n}function $s(e){const t=Sh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function zS(e,t,n,r="ltr"){const o=$s(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return Th([l,c],f)(e)}function Ch(e,t,n="ltr"){const r=$s(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=ja(e,l);return Th([0,i],[0,a])(c)}function Th(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 kh(e,t){return e>0&&e<t}var BS=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function Fs(e,t){const n=Nt(e),r=v.useRef(0);return v.useEffect(()=>()=>window.clearTimeout(r.current),[]),v.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Tr(e,t){const n=Nt(t);It(()=>{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 Eh=ph,HS=gh,US=bh;const Ih=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Eh,{ref:r,className:te("relative overflow-hidden",e),...n,children:[u.jsx(HS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(Nh,{}),u.jsx(US,{})]}));Ih.displayName=Eh.displayName;const Nh=v.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Ra,{ref:r,orientation:t,className:te("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:u.jsx(wh,{className:"relative flex-1 rounded-full bg-border"})}));Nh.displayName=Ra.displayName;const Ah=25;function Ma({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d}){const{threads:f,currentThreadId:h,setCurrentThreadId:p,isLoading:m,actions:x}=Ao(),{loadThread:y}=jo(),{createThread:g,deleteThread:w,renameThread:S}=x,[k,T]=b.useState(Array.isArray(f)?f:[]),C=b.useRef(k.length>0),E=b.useRef(null),N=b.useRef(0),[j,D]=b.useState(null),[P,M]=b.useState(""),[F,A]=b.useState(!1);b.useEffect(()=>{const q=Array.isArray(f)?f:[];if(q.length>0){C.current=!0,T(q);return}m||(C.current=!1,T(q))},[f,m]),b.useEffect(()=>{if(!E.current)return;const q=E.current.querySelector("[data-radix-scroll-area-viewport]");if(!q)return;let ne=null,Y=null;return ne=requestAnimationFrame(()=>{Y=requestAnimationFrame(()=>{q.scrollTop=N.current})}),()=>{ne!==null&&cancelAnimationFrame(ne),Y!==null&&cancelAnimationFrame(Y)}},[k]);const z=async q=>{try{p(q),await y(q),a==null||a(q),l==null||l(q)}catch(ne){console.error("Failed to select thread:",ne)}},_=async()=>{try{A(!0);const q=await g();q&&(c==null||c(q),a==null||a(q))}catch(q){console.error("Failed to create thread:",q)}finally{A(!1)}},X=async(q,ne)=>{if(ne.stopPropagation(),!!confirm("Delete this thread?")){if(E.current){const Y=E.current.querySelector("[data-radix-scroll-area-viewport]");Y&&(N.current=Y.scrollTop)}try{await w(q),d==null||d(q)}catch(Y){console.error("Failed to delete thread:",Y)}}},$=(q,ne)=>{ne.stopPropagation(),D(q.threadId),M(q.title||`Thread ${q.threadId.slice(0,8)}`)},R=async q=>{if(P.trim())try{await S(q,P.trim()),D(null),M("")}catch(ne){console.error("Failed to update title:",ne)}},J=()=>{D(null),M("")},G=(q,ne)=>{q.key==="Enter"?R(ne):q.key==="Escape"&&J()},pe=q=>{if(!q)return"";try{const ne=new Date(q),L=new Date().getTime()-ne.getTime(),H=Math.floor(L/(1e3*60*60*24));return H===0?ne.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):H===1?"Yesterday":H<7?`${H} days ago`:ne.toLocaleDateString()}catch{return""}},Ce=q=>q.title||`Thread ${q.threadId.slice(0,8)}`,Ae=q=>{const ne=Ce(q);return ne.length<=Ah?ne:`${ne.slice(0,Ah)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&u.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:u.jsx(rt,{onClick:_,disabled:F||m,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:F?"Creating...":"New Chat",children:u.jsx(ae.MessageSquarePlus,{size:20})})}),u.jsx(Ih,{ref:E,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children:m?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(ae.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):k.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(ae.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):k.slice().sort((q,ne)=>new Date(ne.updatedAt||ne.createdAt||"").getTime()-new Date(q.updatedAt||q.createdAt||"").getTime()).map(q=>u.jsxs("div",{onClick:()=>z(q.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??h)===q.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:j===q.threadId?u.jsxs("div",{className:"flex items-center gap-2",onClick:ne=>ne.stopPropagation(),children:[u.jsx(Ms,{value:P,onChange:ne=>M(ne.target.value),onKeyDown:ne=>G(ne,q.threadId),className:"h-6 text-sm",autoFocus:!0}),u.jsx(rt,{variant:"ghost",size:"sm",onClick:()=>R(q.threadId),className:"h-6 w-6 p-0",children:u.jsx(ae.Check,{size:12})}),u.jsx(rt,{variant:"ghost",size:"sm",onClick:J,className:"h-6 w-6 p-0",children:u.jsx(ae.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:Ae(q)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(ae.Calendar,{size:10}),u.jsx("span",{children:pe(q.updatedAt||q.createdAt)})]})]})}),u.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&j!==q.threadId&&u.jsx(rt,{variant:"ghost",size:"sm",onClick:ne=>$(q,ne),className:"h-6 w-6 p-0",title:"Edit title",children:u.jsx(ae.Edit3,{size:12})}),n&&u.jsx(rt,{variant:"ghost",size:"sm",onClick:ne=>X(q.threadId,ne),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:u.jsx(ae.Trash2,{size:12})})]})]}),i===q.threadId&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},q.threadId))})})]})}function kr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function WS(e){if(typeof e!="string")return;const t=e.trim();if(t)return Tn(t)}function jh(){const e=[kr("__API_BASE_URL__"),kr("__CHAT_API_BASE_URL__"),kr("__CHAT_API_URL__")];for(const t of e){const n=WS(t);if(n)return n}}function _h(){const e=[kr("__API_AUTH_TOKEN__"),kr("__CHAT_API_KEY__"),kr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Rh(...e){for(const t of e)if(typeof t=="string"&&t.trim())return Tn(t);return Tn()}function Ph(){const e={},t=jh(),n=_h();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Oh(){const e=Ph(),t=_n.getAuthToken(),n=jh();return{apiBaseUrl:Rh(e.baseUrl,_n.baseUrl,n),apiKey:t||e.apiKey||_h()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Mh="chat-settings";function VS(){try{const e=localStorage.getItem(Mh);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function KS(e){try{const t={...e,apiBaseUrl:Tn(e.apiBaseUrl)};localStorage.setItem(Mh,JSON.stringify(t)),t.apiKey&&_n.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function qS(){const e=Oh(),t=VS(),n=_n.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Rh(_n.baseUrl,r,e.apiBaseUrl)}}function GS(e){_n.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),KS(e)}var YS="Label",Dh=v.forwardRef((e,t)=>u.jsx(Pe.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())}}));Dh.displayName=YS;var Lh=Dh;const XS=fo.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),tn=v.forwardRef(({className:e,...t},n)=>u.jsx(Lh,{ref:n,className:te(XS(),e),...t}));tn.displayName=Lh.displayName;function $h(e){const t=v.useRef({value:e,previous:e});return v.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var zs="Switch",[JS,wT]=kn(zs),[ZS,QS]=JS(zs),Fh=v.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...f}=e,[h,p]=v.useState(null),m=Ye(t,S=>p(S)),x=v.useRef(!1),y=h?d||!!h.closest("form"):!0,[g,w]=fr({prop:o,defaultProp:s??!1,onChange:c,caller:zs});return u.jsxs(ZS,{scope:n,checked:g,disabled:a,children:[u.jsx(Pe.button,{type:"button",role:"switch","aria-checked":g,"aria-required":i,"data-state":Uh(g),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:m,onClick:he(e.onClick,S=>{w(k=>!k),y&&(x.current=S.isPropagationStopped(),x.current||S.stopPropagation())})}),y&&u.jsx(Hh,{control:h,bubbles:!x.current,name:r,value:l,checked:g,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Fh.displayName=zs;var zh="SwitchThumb",Bh=v.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=QS(zh,n);return u.jsx(Pe.span,{"data-state":Uh(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Bh.displayName=zh;var eC="SwitchBubbleInput",Hh=v.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=v.useRef(null),a=Ye(i,s),l=$h(n),c=Kc(t);return v.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const m=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(m)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Hh.displayName=eC;function Uh(e){return e?"checked":"unchecked"}var Wh=Fh,tC=Bh;const Bn=v.forwardRef(({className:e,...t},n)=>u.jsx(Wh,{className:te("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:u.jsx(tC,{className:te("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")})}));Bn.displayName=Wh.displayName;var Vh=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"}),nC="VisuallyHidden",rC=v.forwardRef((e,t)=>u.jsx(Pe.span,{...e,ref:t,style:{...Vh,...e.style}}));rC.displayName=nC;var oC=[" ","Enter","ArrowUp","ArrowDown"],sC=[" ","Enter"],or="Select",[Bs,Hs,iC]=pi(or),[Er,bT]=kn(or,[iC,Vo]),Us=Vo(),[aC,Hn]=Er(or),[lC,cC]=Er(or),Kh=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:f,disabled:h,required:p,form:m}=e,x=Us(t),[y,g]=v.useState(null),[w,S]=v.useState(null),[k,T]=v.useState(!1),C=Ro(c),[E,N]=fr({prop:r,defaultProp:o??!1,onChange:s,caller:or}),[j,D]=fr({prop:i,defaultProp:a,onChange:l,caller:or}),P=v.useRef(null),M=y?m||!!y.closest("form"):!0,[F,A]=v.useState(new Set),z=Array.from(F).map(_=>_.props.value).join(";");return u.jsx(nu,{...x,children:u.jsxs(aC,{required:p,scope:t,trigger:y,onTriggerChange:g,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:T,contentId:En(),value:j,onValueChange:D,open:E,onOpenChange:N,dir:C,triggerPointerDownPosRef:P,disabled:h,children:[u.jsx(Bs.Provider,{scope:t,children:u.jsx(lC,{scope:e.__scopeSelect,onNativeOptionAdd:v.useCallback(_=>{A(X=>new Set(X).add(_))},[]),onNativeOptionRemove:v.useCallback(_=>{A(X=>{const $=new Set(X);return $.delete(_),$})},[]),children:n})}),M?u.jsxs(gp,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:j,onChange:_=>D(_.target.value),disabled:h,form:m,children:[j===void 0?u.jsx("option",{value:""}):null,Array.from(F)]},z):null]})})};Kh.displayName=or;var qh="SelectTrigger",Gh=v.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Us(n),i=Hn(qh,n),a=i.disabled||r,l=Ye(t,i.onTriggerChange),c=Hs(n),d=v.useRef("touch"),[f,h,p]=yp(x=>{const y=c().filter(S=>!S.disabled),g=y.find(S=>S.value===i.value),w=vp(y,x,g);w!==void 0&&i.onValueChange(w.value)}),m=x=>{a||(i.onOpenChange(!0),p()),x&&(i.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return u.jsx(ru,{asChild:!0,...s,children:u.jsx(Pe.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":xp(i.value)?"":void 0,...o,ref:l,onClick:he(o.onClick,x=>{x.currentTarget.focus(),d.current!=="mouse"&&m(x)}),onPointerDown:he(o.onPointerDown,x=>{d.current=x.pointerType;const y=x.target;y.hasPointerCapture(x.pointerId)&&y.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(m(x),x.preventDefault())}),onKeyDown:he(o.onKeyDown,x=>{const y=f.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&h(x.key),!(y&&x.key===" ")&&oC.includes(x.key)&&(m(),x.preventDefault())})})})});Gh.displayName=qh;var Yh="SelectValue",Xh=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Hn(Yh,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,f=Ye(t,l.onValueNodeChange);return It(()=>{c(d)},[c,d]),u.jsx(Pe.span,{...a,ref:f,style:{pointerEvents:"none"},children:xp(l.value)?u.jsx(u.Fragment,{children:i}):s})});Xh.displayName=Yh;var uC="SelectIcon",Jh=v.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(Pe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Jh.displayName=uC;var dC="SelectPortal",Zh=e=>u.jsx(Ko,{asChild:!0,...e});Zh.displayName=dC;var sr="SelectContent",Qh=v.forwardRef((e,t)=>{const n=Hn(sr,e.__scopeSelect),[r,o]=v.useState();if(It(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?ho.createPortal(u.jsx(ep,{scope:e.__scopeSelect,children:u.jsx(Bs.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(tp,{...e,ref:t})});Qh.displayName=sr;var dn=10,[ep,Un]=Er(sr),fC="SelectContentImpl",hC=Wn.createSlot("SelectContent.RemoveScroll"),tp=v.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:m,hideWhenDetached:x,avoidCollisions:y,...g}=e,w=Hn(sr,n),[S,k]=v.useState(null),[T,C]=v.useState(null),E=Ye(t,Y=>k(Y)),[N,j]=v.useState(null),[D,P]=v.useState(null),M=Hs(n),[F,A]=v.useState(!1),z=v.useRef(!1);v.useEffect(()=>{if(S)return Di(S)},[S]),xi();const _=v.useCallback(Y=>{const[L,...H]=M().map(re=>re.ref.current),[V]=H.slice(-1),ie=document.activeElement;for(const re of Y)if(re===ie||(re==null||re.scrollIntoView({block:"nearest"}),re===L&&T&&(T.scrollTop=0),re===V&&T&&(T.scrollTop=T.scrollHeight),re==null||re.focus(),document.activeElement!==ie))return},[M,T]),X=v.useCallback(()=>_([N,S]),[_,N,S]);v.useEffect(()=>{F&&X()},[F,X]);const{onOpenChange:$,triggerPointerDownPosRef:R}=w;v.useEffect(()=>{if(S){let Y={x:0,y:0};const L=V=>{var ie,re;Y={x:Math.abs(Math.round(V.pageX)-(((ie=R.current)==null?void 0:ie.x)??0)),y:Math.abs(Math.round(V.pageY)-(((re=R.current)==null?void 0:re.y)??0))}},H=V=>{Y.x<=10&&Y.y<=10?V.preventDefault():S.contains(V.target)||$(!1),document.removeEventListener("pointermove",L),R.current=null};return R.current!==null&&(document.addEventListener("pointermove",L),document.addEventListener("pointerup",H,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",H,{capture:!0})}}},[S,$,R]),v.useEffect(()=>{const Y=()=>$(!1);return window.addEventListener("blur",Y),window.addEventListener("resize",Y),()=>{window.removeEventListener("blur",Y),window.removeEventListener("resize",Y)}},[$]);const[J,G]=yp(Y=>{const L=M().filter(ie=>!ie.disabled),H=L.find(ie=>ie.ref.current===document.activeElement),V=vp(L,Y,H);V&&setTimeout(()=>V.ref.current.focus())}),pe=v.useCallback((Y,L,H)=>{const V=!z.current&&!H;(w.value!==void 0&&w.value===L||V)&&(j(Y),V&&(z.current=!0))},[w.value]),Ce=v.useCallback(()=>S==null?void 0:S.focus(),[S]),Ae=v.useCallback((Y,L,H)=>{const V=!z.current&&!H;(w.value!==void 0&&w.value===L||V)&&P(Y)},[w.value]),q=r==="popper"?Da:np,ne=q===Da?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:m,hideWhenDetached:x,avoidCollisions:y}:{};return u.jsx(ep,{scope:n,content:S,viewport:T,onViewportChange:C,itemRefCallback:pe,selectedItem:N,onItemLeave:Ce,itemTextRefCallback:Ae,focusSelectedItem:X,selectedItemText:D,position:r,isPositioned:F,searchRef:J,children:u.jsx(ts,{as:hC,allowPinchZoom:!0,children:u.jsx(Oo,{asChild:!0,trapped:w.open,onMountAutoFocus:Y=>{Y.preventDefault()},onUnmountAutoFocus:he(o,Y=>{var L;(L=w.trigger)==null||L.focus({preventScroll:!0}),Y.preventDefault()}),children:u.jsx(Po,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:Y=>Y.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(q,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:Y=>Y.preventDefault(),...g,...ne,onPlaced:()=>A(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...g.style},onKeyDown:he(g.onKeyDown,Y=>{const L=Y.ctrlKey||Y.altKey||Y.metaKey;if(Y.key==="Tab"&&Y.preventDefault(),!L&&Y.key.length===1&&G(Y.key),["ArrowUp","ArrowDown","Home","End"].includes(Y.key)){let V=M().filter(ie=>!ie.disabled).map(ie=>ie.ref.current);if(["ArrowUp","End"].includes(Y.key)&&(V=V.slice().reverse()),["ArrowUp","ArrowDown"].includes(Y.key)){const ie=Y.target,re=V.indexOf(ie);V=V.slice(re+1)}setTimeout(()=>_(V)),Y.preventDefault()}})})})})})})});tp.displayName=fC;var pC="SelectItemAlignedPosition",np=v.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Hn(sr,n),i=Un(sr,n),[a,l]=v.useState(null),[c,d]=v.useState(null),f=Ye(t,E=>d(E)),h=Hs(n),p=v.useRef(!1),m=v.useRef(!0),{viewport:x,selectedItem:y,selectedItemText:g,focusSelectedItem:w}=i,S=v.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&x&&y&&g){const E=s.trigger.getBoundingClientRect(),N=c.getBoundingClientRect(),j=s.valueNode.getBoundingClientRect(),D=g.getBoundingClientRect();if(s.dir!=="rtl"){const ie=D.left-N.left,re=j.left-ie,ze=E.left-re,We=E.width+ze,Ze=Math.max(We,N.width),oe=window.innerWidth-dn,me=ja(re,[dn,Math.max(dn,oe-Ze)]);a.style.minWidth=We+"px",a.style.left=me+"px"}else{const ie=N.right-D.right,re=window.innerWidth-j.right-ie,ze=window.innerWidth-E.right-re,We=E.width+ze,Ze=Math.max(We,N.width),oe=window.innerWidth-dn,me=ja(re,[dn,Math.max(dn,oe-Ze)]);a.style.minWidth=We+"px",a.style.right=me+"px"}const P=h(),M=window.innerHeight-dn*2,F=x.scrollHeight,A=window.getComputedStyle(c),z=parseInt(A.borderTopWidth,10),_=parseInt(A.paddingTop,10),X=parseInt(A.borderBottomWidth,10),$=parseInt(A.paddingBottom,10),R=z+_+F+$+X,J=Math.min(y.offsetHeight*5,R),G=window.getComputedStyle(x),pe=parseInt(G.paddingTop,10),Ce=parseInt(G.paddingBottom,10),Ae=E.top+E.height/2-dn,q=M-Ae,ne=y.offsetHeight/2,Y=y.offsetTop+ne,L=z+_+Y,H=R-L;if(L<=Ae){const ie=P.length>0&&y===P[P.length-1].ref.current;a.style.bottom="0px";const re=c.clientHeight-x.offsetTop-x.offsetHeight,ze=Math.max(q,ne+(ie?Ce:0)+re+X),We=L+ze;a.style.height=We+"px"}else{const ie=P.length>0&&y===P[0].ref.current;a.style.top="0px";const ze=Math.max(Ae,z+x.offsetTop+(ie?pe:0)+ne)+H;a.style.height=ze+"px",x.scrollTop=L-Ae+x.offsetTop}a.style.margin=`${dn}px 0`,a.style.minHeight=J+"px",a.style.maxHeight=M+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,c,x,y,g,s.dir,r]);It(()=>S(),[S]);const[k,T]=v.useState();It(()=>{c&&T(window.getComputedStyle(c).zIndex)},[c]);const C=v.useCallback(E=>{E&&m.current===!0&&(S(),w==null||w(),m.current=!1)},[S,w]);return u.jsx(gC,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:C,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(Pe.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});np.displayName=pC;var mC="SelectPopperPosition",Da=v.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=dn,...s}=e,i=Us(n);return u.jsx(ou,{...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)"}})});Da.displayName=mC;var[gC,La]=Er(sr,{}),$a="SelectViewport",rp=v.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Un($a,n),i=La($a,n),a=Ye(t,s.onViewportChange),l=v.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(Bs.Slot,{scope:n,children:u.jsx(Pe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:he(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const m=window.innerHeight-dn*2,x=parseFloat(f.style.minHeight),y=parseFloat(f.style.height),g=Math.max(x,y);if(g<m){const w=g+p,S=Math.min(m,w),k=w-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})})})]})});rp.displayName=$a;var op="SelectGroup",[xC,yC]=Er(op),vC=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=En();return u.jsx(xC,{scope:n,id:o,children:u.jsx(Pe.div,{role:"group","aria-labelledby":o,...r,ref:t})})});vC.displayName=op;var sp="SelectLabel",ip=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=yC(sp,n);return u.jsx(Pe.div,{id:o.id,...r,ref:t})});ip.displayName=sp;var Ws="SelectItem",[wC,ap]=Er(Ws),lp=v.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Hn(Ws,n),l=Un(Ws,n),c=a.value===r,[d,f]=v.useState(s??""),[h,p]=v.useState(!1),m=Ye(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),x=En(),y=v.useRef("touch"),g=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(wC,{scope:n,value:r,disabled:o,textId:x,isSelected:c,onItemTextChange:v.useCallback(w=>{f(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(Bs.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(Pe.div,{role:"option","aria-labelledby":x,"data-highlighted":h?"":void 0,"aria-selected":c&&h,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:m,onFocus:he(i.onFocus,()=>p(!0)),onBlur:he(i.onBlur,()=>p(!1)),onClick:he(i.onClick,()=>{y.current!=="mouse"&&g()}),onPointerUp:he(i.onPointerUp,()=>{y.current==="mouse"&&g()}),onPointerDown:he(i.onPointerDown,w=>{y.current=w.pointerType}),onPointerMove:he(i.onPointerMove,w=>{var S;y.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):y.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:he(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:he(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(sC.includes(w.key)&&g(),w.key===" "&&w.preventDefault())})})})})});lp.displayName=Ws;var lo="SelectItemText",cp=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Hn(lo,n),a=Un(lo,n),l=ap(lo,n),c=cC(lo,n),[d,f]=v.useState(null),h=Ye(t,g=>f(g),l.onItemTextChange,g=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,g,l.value,l.disabled)}),p=d==null?void 0:d.textContent,m=v.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:x,onNativeOptionRemove:y}=c;return It(()=>(x(m),()=>y(m)),[x,y,m]),u.jsxs(u.Fragment,{children:[u.jsx(Pe.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?ho.createPortal(s.children,i.valueNode):null]})});cp.displayName=lo;var up="SelectItemIndicator",dp=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return ap(up,n).isSelected?u.jsx(Pe.span,{"aria-hidden":!0,...r,ref:t}):null});dp.displayName=up;var Fa="SelectScrollUpButton",fp=v.forwardRef((e,t)=>{const n=Un(Fa,e.__scopeSelect),r=La(Fa,e.__scopeSelect),[o,s]=v.useState(!1),i=Ye(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(pp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});fp.displayName=Fa;var za="SelectScrollDownButton",hp=v.forwardRef((e,t)=>{const n=Un(za,e.__scopeSelect),r=La(za,e.__scopeSelect),[o,s]=v.useState(!1),i=Ye(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(pp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});hp.displayName=za;var pp=v.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Un("SelectScrollButton",n),i=v.useRef(null),a=Hs(n),l=v.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return v.useEffect(()=>()=>l(),[l]),It(()=>{var d;const c=a().find(f=>f.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(Pe.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:he(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:he(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:he(o.onPointerLeave,()=>{l()})})}),bC="SelectSeparator",mp=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(Pe.div,{"aria-hidden":!0,...r,ref:t})});mp.displayName=bC;var Ba="SelectArrow",SC=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Us(n),s=Hn(Ba,n),i=Un(Ba,n);return s.open&&i.position==="popper"?u.jsx(su,{...o,...r,ref:t}):null});SC.displayName=Ba;var CC="SelectBubbleInput",gp=v.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=v.useRef(null),s=Ye(r,o),i=$h(t);return v.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),u.jsx(Pe.select,{...n,style:{...Vh,...n.style},ref:s,defaultValue:t})});gp.displayName=CC;function xp(e){return e===""||e===void 0}function yp(e){const t=Nt(e),n=v.useRef(""),r=v.useRef(0),o=v.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=v.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return v.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function vp(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=TC(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function TC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var kC=Kh,wp=Gh,EC=Xh,IC=Jh,NC=Zh,bp=Qh,AC=rp,Sp=ip,Cp=lp,jC=cp,_C=dp,Tp=fp,kp=hp,Ep=mp;const Ip=kC,Np=EC,Ha=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(wp,{ref:r,className:te("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,u.jsx(IC,{asChild:!0,children:u.jsx(ae.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Ha.displayName=wp.displayName;const Ap=v.forwardRef(({className:e,...t},n)=>u.jsx(Tp,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ae.ChevronUp,{className:"h-4 w-4"})}));Ap.displayName=Tp.displayName;const jp=v.forwardRef(({className:e,...t},n)=>u.jsx(kp,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ae.ChevronDown,{className:"h-4 w-4"})}));jp.displayName=kp.displayName;const Ua=v.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(NC,{children:u.jsxs(bp,{ref:o,className:te("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(Ap,{}),u.jsx(AC,{className:te("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(jp,{})]})}));Ua.displayName=bp.displayName;const RC=v.forwardRef(({className:e,...t},n)=>u.jsx(Sp,{ref:n,className:te("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));RC.displayName=Sp.displayName;const ir=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Cp,{ref:r,className:te("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(_C,{children:u.jsx(ae.Check,{className:"h-4 w-4"})})}),u.jsx(jC,{children:t})]}));ir.displayName=Cp.displayName;const PC=v.forwardRef(({className:e,...t},n)=>u.jsx(Ep,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));PC.displayName=Ep.displayName;var OC="Separator",_p="horizontal",MC=["horizontal","vertical"],Rp=v.forwardRef((e,t)=>{const{decorative:n,orientation:r=_p,...o}=e,s=DC(r)?r:_p,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(Pe.div,{"data-orientation":s,...a,...o,ref:t})});Rp.displayName=OC;function DC(e){return MC.includes(e)}var Pp=Rp;const Op=v.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(Pp,{ref:o,decorative:n,orientation:t,className:te("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Op.displayName=Pp.displayName;const LC=Hf,$C=Z0,FC=Uf,Mp=v.forwardRef(({className:e,...t},n)=>u.jsx(Es,{className:te("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}));Mp.displayName=Es.displayName;const zC=fo.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"}}),Dp=v.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(FC,{children:[u.jsx(Mp,{}),u.jsxs(Is,{ref:o,className:te(zC({side:e}),t),...r,children:[n,u.jsxs(Wf,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[u.jsx(ae.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Dp.displayName=Is.displayName;const Lp=({className:e,...t})=>u.jsx("div",{className:te("flex flex-col space-y-2 text-center sm:text-left",e),...t});Lp.displayName="SheetHeader";const $p=v.forwardRef(({className:e,...t},n)=>u.jsx(nr,{ref:n,className:te("text-lg font-semibold text-foreground",e),...t}));$p.displayName=nr.displayName;const Fp=v.forwardRef(({className:e,...t},n)=>u.jsx(Ns,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));Fp.displayName=Ns.displayName;const BC={api:{baseUrl:"http://localhost:8000/api",authToken:"",enableAuth:!1},ui:{layout:"sidebar",theme:"light",showTimestamps:!0,showAgentNames:!0,compactMessages:!1},behavior:{autoSave:!0,enableStreaming:!0,showTypingIndicator:!0}};function HC({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=b.useState(!1),[s,i]=b.useState(!1),[a,l]=b.useState(e),[c,d]=b.useState(!1),{toast:f}=ba();b.useEffect(()=>{const y=JSON.stringify(a)!==JSON.stringify(e);d(y)},[a,e]),b.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(BC),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},m=()=>{l(e),d(!1),o(!1)},x=async()=>{try{const g=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${g.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return u.jsxs(LC,{open:r,onOpenChange:o,children:[u.jsx($C,{asChild:!0,children:u.jsxs(rt,{variant:"outline",size:"sm",className:n,children:[u.jsx(ae.Settings,{className:"h-4 w-4 mr-2"}),"Settings",c&&u.jsx(vf,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),u.jsxs(Dp,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[u.jsxs(Lp,{children:[u.jsx($p,{children:"Chat Settings"}),u.jsx(Fp,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),u.jsxs("div",{className:"space-y-6 py-6",children:[u.jsxs(eo,{children:[u.jsx(to,{className:"pb-3",children:u.jsxs(no,{className:"text-lg flex items-center gap-2",children:[u.jsx(ae.Server,{className:"h-5 w-5"}),"API Configuration"]})}),u.jsxs(ro,{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(tn,{htmlFor:"api-url",children:"API Base URL"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(Ms,{id:"api-url",value:a.api.baseUrl,onChange:y=>l(g=>({...g,api:{...g.api,baseUrl:y.target.value}})),placeholder:"http://localhost:8000/api"}),u.jsx(rt,{variant:"outline",onClick:x,children:"Test"})]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(tn,{htmlFor:"enable-auth",children:"Enable Authentication"}),u.jsx(Bn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:y=>l(g=>({...g,api:{...g.api,enableAuth:y}}))})]}),a.api.enableAuth&&u.jsxs("div",{className:"space-y-2",children:[u.jsx(tn,{htmlFor:"auth-token",children:"Authentication Token"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(Ms,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:y=>l(g=>({...g,api:{...g.api,authToken:y.target.value}})),placeholder:"Enter your Bearer token"}),u.jsx(rt,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?u.jsx(ae.EyeOff,{className:"h-4 w-4"}):u.jsx(ae.Eye,{className:"h-4 w-4"})})]})]})]})]}),u.jsxs(eo,{children:[u.jsx(to,{className:"pb-3",children:u.jsxs(no,{className:"text-lg flex items-center gap-2",children:[u.jsx(ae.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),u.jsxs(ro,{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(tn,{htmlFor:"layout",children:"Layout Style"}),u.jsxs(Ip,{value:a.ui.layout,onValueChange:y=>l(g=>({...g,ui:{...g.ui,layout:y}})),children:[u.jsx(Ha,{children:u.jsx(Np,{})}),u.jsxs(Ua,{children:[u.jsx(ir,{value:"sidebar",children:"Sidebar Layout"}),u.jsx(ir,{value:"fullscreen",children:"Fullscreen"}),u.jsx(ir,{value:"tabs",children:"Tabbed Interface"})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(tn,{htmlFor:"theme",children:"Theme"}),u.jsxs(Ip,{value:a.ui.theme,onValueChange:y=>l(g=>({...g,ui:{...g.ui,theme:y}})),children:[u.jsx(Ha,{children:u.jsx(Np,{})}),u.jsxs(Ua,{children:[u.jsx(ir,{value:"light",children:"Light"}),u.jsx(ir,{value:"dark",children:"Dark"}),u.jsx(ir,{value:"system",children:"System"})]})]})]}),u.jsx(Op,{}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(tn,{htmlFor:"show-timestamps",children:"Show Timestamps"}),u.jsx(Bn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:y=>l(g=>({...g,ui:{...g.ui,showTimestamps:y}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(tn,{htmlFor:"show-agent-names",children:"Show Agent Names"}),u.jsx(Bn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:y=>l(g=>({...g,ui:{...g.ui,showAgentNames:y}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(tn,{htmlFor:"compact-messages",children:"Compact Messages"}),u.jsx(Bn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:y=>l(g=>({...g,ui:{...g.ui,compactMessages:y}}))})]})]})]})]}),u.jsxs(eo,{children:[u.jsx(to,{className:"pb-3",children:u.jsxs(no,{className:"text-lg flex items-center gap-2",children:[u.jsx(ae.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),u.jsxs(ro,{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(tn,{htmlFor:"auto-save",children:"Auto-save Conversations"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),u.jsx(Bn,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:y=>l(g=>({...g,behavior:{...g.behavior,autoSave:y}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(tn,{htmlFor:"enable-streaming",children:"Enable Streaming"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),u.jsx(Bn,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:y=>l(g=>({...g,behavior:{...g.behavior,enableStreaming:y}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(tn,{htmlFor:"typing-indicator",children:"Typing Indicator"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),u.jsx(Bn,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:y=>l(g=>({...g,behavior:{...g.behavior,showTypingIndicator:y}}))})]})]})]})]}),u.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[u.jsxs(rt,{variant:"outline",onClick:p,children:[u.jsx(ae.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(rt,{variant:"outline",onClick:m,children:"Cancel"}),u.jsxs(rt,{onClick:h,disabled:!c,children:[u.jsx(ae.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function UC({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const d="h-full";switch(c){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=b.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(_o,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Os,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(_o,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(Ma,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Os,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(_o,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(Ma,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Os,{onError:s.onError,enableFileUpload:!0})})]})})}Ee.ChatApi=Bl,Ee.ChatInput=uc,Ee.ChatInterface=Os,Ee.ChatProviders=_o,Ee.ChatSettings=HC,Ee.MarkdownContent=ao,Ee.MessageComponent=Na,Ee.MessageList=Aa,Ee.ThreadManager=Ma,Ee.applySettings=GS,Ee.buildMessagePreviewMap=Gl,Ee.chatApiClient=_n,Ee.default=UC,Ee.del=zl,Ee.get=Gt,Ee.getChatToken=Ll,Ee.getCurrentSettings=qS,Ee.getDefaultApiConfig=Ph,Ee.getDefaultChatSettings=Oh,Ee.onChatTokenChanged=$l,Ee.post=ii,Ee.put=Fl,Ee.setChatToken=ko,Ee.useApi=ai,Ee.useChatStream=Yl,Ee.useMessagesReducer=Xl,Ee.useStream=lc,Ee.useThreadState=jo,Ee.useThreads=Ao,Object.defineProperties(Ee,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|