teodor-new-chat-ui 4.3.199 → 4.3.201
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 +1048 -1039
- package/dist/index.umd.js +20 -20
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(Ie,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom"],w):(Ie=typeof globalThis<"u"?globalThis:Ie||self,w(Ie.NewChatUI={},Ie.React,Ie.LucideReact,Ie.reactSlot,Ie.classVarianceAuthority,Ie.clsx,Ie.tailwindMerge,Ie.ReactDOM))})(this,function(Ie,w,se,Yn,xo,Gh,Yh,Js){"use strict";var KC=Object.defineProperty;var qC=(Ie,w,se)=>w in Ie?KC(Ie,w,{enumerable:!0,configurable:!0,writable:!0,value:se}):Ie[w]=se;var Kh=(Ie,w,se)=>qC(Ie,typeof w!="symbol"?w+"":w,se);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(w),yo=Qa(Js);var Zs={exports:{}},Rr={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -14,28 +14,28 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var tl;function Jh(){return tl||(tl=1,process.env.NODE_ENV!=="production"&&function(){var e=w,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),h=Symbol.for("react.offscreen"),x=Symbol.iterator,y="@@iterator";function m(I){if(I===null||typeof I!="object")return null;var K=x&&I[x]||I[y];return typeof K=="function"?K:null}var g=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(I){{for(var K=arguments.length,le=new Array(K>1?K-1:0),
|
|
18
|
-
`+W+I}}var H=!1,te;{var ae=typeof WeakMap=="function"?WeakMap:Map;te=new ae}function ne(I,K){if(!I||H)return"";{var le=te.get(I);if(le!==void 0)return le}var
|
|
19
|
-
`),Pt=
|
|
20
|
-
`),bt
|
|
21
|
-
|
|
17
|
+
*/var tl;function Jh(){return tl||(tl=1,process.env.NODE_ENV!=="production"&&function(){var e=w,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),h=Symbol.for("react.offscreen"),x=Symbol.iterator,y="@@iterator";function m(I){if(I===null||typeof I!="object")return null;var K=x&&I[x]||I[y];return typeof K=="function"?K:null}var g=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(I){{for(var K=arguments.length,le=new Array(K>1?K-1:0),Se=1;Se<K;Se++)le[Se-1]=arguments[Se];S("error",I,le)}}function S(I,K,le){{var Se=g.ReactDebugCurrentFrame,Ye=Se.getStackAddendum();Ye!==""&&(K+="%s",le=le.concat([Ye]));var st=le.map(function(Ue){return String(Ue)});st.unshift("Warning: "+K),Function.prototype.apply.call(console[I],console,st)}}var k=!1,T=!1,C=!1,E=!1,j=!1,A;A=Symbol.for("react.module.reference");function N(I){return!!(typeof I=="string"||typeof I=="function"||I===r||I===s||j||I===o||I===c||I===d||E||I===h||k||T||C||typeof I=="object"&&I!==null&&(I.$$typeof===p||I.$$typeof===f||I.$$typeof===i||I.$$typeof===a||I.$$typeof===l||I.$$typeof===A||I.getModuleId!==void 0))}function P(I,K,le){var Se=I.displayName;if(Se)return Se;var Ye=K.displayName||K.name||"";return Ye!==""?le+"("+Ye+")":le}function F(I){return I.displayName||"Context"}function $(I){if(I==null)return null;if(typeof I.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof I=="function")return I.displayName||I.name||null;if(typeof I=="string")return I;switch(I){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case c:return"Suspense";case d:return"SuspenseList"}if(typeof I=="object")switch(I.$$typeof){case a:var K=I;return F(K)+".Consumer";case i:var le=I;return F(le._context)+".Provider";case l:return P(I,I.render,"ForwardRef");case f:var Se=I.displayName||null;return Se!==null?Se:$(I.type)||"Memo";case p:{var Ye=I,st=Ye._payload,Ue=Ye._init;try{return $(Ue(st))}catch{return null}}}return null}var R=Object.assign,z=0,_,B,L,M,J,X,pe;function Ne(){}Ne.__reactDisabledLog=!0;function je(){{if(z===0){_=console.log,B=console.info,L=console.warn,M=console.error,J=console.group,X=console.groupCollapsed,pe=console.groupEnd;var I={configurable:!0,enumerable:!0,value:Ne,writable:!0};Object.defineProperties(console,{info:I,log:I,warn:I,error:I,group:I,groupCollapsed:I,groupEnd:I})}z++}}function G(){{if(z--,z===0){var I={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:R({},I,{value:_}),info:R({},I,{value:B}),warn:R({},I,{value:L}),error:R({},I,{value:M}),group:R({},I,{value:J}),groupCollapsed:R({},I,{value:X}),groupEnd:R({},I,{value:pe})})}z<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ee=g.ReactCurrentDispatcher,W;function D(I,K,le){{if(W===void 0)try{throw Error()}catch(Ye){var Se=Ye.stack.trim().match(/\n( *(at )?)/);W=Se&&Se[1]||""}return`
|
|
18
|
+
`+W+I}}var H=!1,te;{var ae=typeof WeakMap=="function"?WeakMap:Map;te=new ae}function ne(I,K){if(!I||H)return"";{var le=te.get(I);if(le!==void 0)return le}var Se;H=!0;var Ye=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var st;st=ee.current,ee.current=null,je();try{if(K){var Ue=function(){throw Error()};if(Object.defineProperty(Ue.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ue,[])}catch($t){Se=$t}Reflect.construct(I,[],Ue)}else{try{Ue.call()}catch($t){Se=$t}I.call(Ue.prototype)}}else{try{throw Error()}catch($t){Se=$t}I()}}catch($t){if($t&&Se&&typeof $t.stack=="string"){for(var Fe=$t.stack.split(`
|
|
19
|
+
`),Pt=Se.stack.split(`
|
|
20
|
+
`),bt=Fe.length-1,yt=Pt.length-1;bt>=1&&yt>=0&&Fe[bt]!==Pt[yt];)yt--;for(;bt>=1&&yt>=0;bt--,yt--)if(Fe[bt]!==Pt[yt]){if(bt!==1||yt!==1)do if(bt--,yt--,yt<0||Fe[bt]!==Pt[yt]){var qt=`
|
|
21
|
+
`+Fe[bt].replace(" at new "," at ");return I.displayName&&qt.includes("<anonymous>")&&(qt=qt.replace("<anonymous>",I.displayName)),typeof I=="function"&&te.set(I,qt),qt}while(bt>=1&&yt>=0);break}}}finally{H=!1,ee.current=st,G(),Error.prepareStackTrace=Ye}var Gn=I?I.displayName||I.name:"",Rn=Gn?D(Gn):"";return typeof I=="function"&&te.set(I,Rn),Rn}function Le(I,K,le){return ne(I,!1)}function Q(I){var K=I.prototype;return!!(K&&K.isReactComponent)}function ie(I,K,le){if(I==null)return"";if(typeof I=="function")return ne(I,Q(I));if(typeof I=="string")return D(I);switch(I){case c:return D("Suspense");case d:return D("SuspenseList")}if(typeof I=="object")switch(I.$$typeof){case l:return Le(I.render);case f:return ie(I.type,K,le);case p:{var Se=I,Ye=Se._payload,st=Se._init;try{return ie(st(Ye),K,le)}catch{}}}return""}var ke=Object.prototype.hasOwnProperty,Re={},Ke=g.ReactDebugCurrentFrame;function ze(I){if(I){var K=I._owner,le=ie(I.type,I._source,K?K.type:null);Ke.setExtraStackFrame(le)}else Ke.setExtraStackFrame(null)}function $e(I,K,le,Se,Ye){{var st=Function.call.bind(ke);for(var Ue in I)if(st(I,Ue)){var Fe=void 0;try{if(typeof I[Ue]!="function"){var Pt=Error((Se||"React class")+": "+le+" type `"+Ue+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof I[Ue]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Pt.name="Invariant Violation",Pt}Fe=I[Ue](K,Ue,Se,le,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(bt){Fe=bt}Fe&&!(Fe instanceof Error)&&(ze(Ye),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Se||"React class",le,Ue,typeof Fe),ze(null)),Fe instanceof Error&&!(Fe.message in Re)&&(Re[Fe.message]=!0,ze(Ye),b("Failed %s type: %s",le,Fe.message),ze(null))}}}var qe=Array.isArray;function Ge(I){return qe(I)}function Qe(I){{var K=typeof Symbol=="function"&&Symbol.toStringTag,le=K&&I[Symbol.toStringTag]||I.constructor.name||"Object";return le}}function Je(I){try{return rt(I),!1}catch{return!0}}function rt(I){return""+I}function At(I){if(Je(I))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Qe(I)),rt(I)}var ut=g.ReactCurrentOwner,it={key:!0,ref:!0,__self:!0,__source:!0},Ct,vt;function re(I){if(ke.call(I,"ref")){var K=Object.getOwnPropertyDescriptor(I,"ref").get;if(K&&K.isReactWarning)return!1}return I.ref!==void 0}function be(I){if(ke.call(I,"key")){var K=Object.getOwnPropertyDescriptor(I,"key").get;if(K&&K.isReactWarning)return!1}return I.key!==void 0}function Be(I,K){typeof I.ref=="string"&&ut.current}function He(I,K){{var le=function(){Ct||(Ct=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",K))};le.isReactWarning=!0,Object.defineProperty(I,"key",{get:le,configurable:!0})}}function mt(I,K){{var le=function(){vt||(vt=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",K))};le.isReactWarning=!0,Object.defineProperty(I,"ref",{get:le,configurable:!0})}}var xe=function(I,K,le,Se,Ye,st,Ue){var Fe={$$typeof:t,type:I,key:K,ref:le,props:Ue,_owner:st};return Fe._store={},Object.defineProperty(Fe._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Fe,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Se}),Object.defineProperty(Fe,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Ye}),Object.freeze&&(Object.freeze(Fe.props),Object.freeze(Fe)),Fe};function he(I,K,le,Se,Ye){{var st,Ue={},Fe=null,Pt=null;le!==void 0&&(At(le),Fe=""+le),be(K)&&(At(K.key),Fe=""+K.key),re(K)&&(Pt=K.ref,Be(K,Ye));for(st in K)ke.call(K,st)&&!it.hasOwnProperty(st)&&(Ue[st]=K[st]);if(I&&I.defaultProps){var bt=I.defaultProps;for(st in bt)Ue[st]===void 0&&(Ue[st]=bt[st])}if(Fe||Pt){var yt=typeof I=="function"?I.displayName||I.name||"Unknown":I;Fe&&He(Ue,yt),Pt&&mt(Ue,yt)}return xe(I,Fe,Pt,Ye,Se,ut.current,Ue)}}var ot=g.ReactCurrentOwner,jt=g.ReactDebugCurrentFrame;function V(I){if(I){var K=I._owner,le=ie(I.type,I._source,K?K.type:null);jt.setExtraStackFrame(le)}else jt.setExtraStackFrame(null)}var we;we=!1;function ye(I){return typeof I=="object"&&I!==null&&I.$$typeof===t}function ft(){{if(ot.current){var I=$(ot.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 gt(I){return""}var Tt={};function Oe(I){{var K=ft();if(!K){var le=typeof I=="string"?I:I.displayName||I.name;le&&(K=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+le+">.")}return K}}function Kt(I,K){{if(!I._store||I._store.validated||I.key!=null)return;I._store.validated=!0;var le=
|
|
25
|
+
Check the top-level render call using <`+le+">.")}return K}}function Kt(I,K){{if(!I._store||I._store.validated||I.key!=null)return;I._store.validated=!0;var le=Oe(K);if(Tt[le])return;Tt[le]=!0;var Se="";I&&I._owner&&I._owner!==ot.current&&(Se=" It was passed a child from "+$(I._owner.type)+"."),V(I),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',le,Se),V(null)}}function at(I,K){{if(typeof I!="object")return;if(Ge(I))for(var le=0;le<I.length;le++){var Se=I[le];ye(Se)&&Kt(Se,K)}else if(ye(I))I._store&&(I._store.validated=!0);else if(I){var Ye=m(I);if(typeof Ye=="function"&&Ye!==I.entries)for(var st=Ye.call(I),Ue;!(Ue=st.next()).done;)ye(Ue.value)&&Kt(Ue.value,K)}}}function kt(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 Se=$(K);$e(le,I.props,"prop",Se,I)}else if(K.PropTypes!==void 0&&!we){we=!0;var Ye=$(K);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ye||"Unknown")}typeof K.getDefaultProps=="function"&&!K.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Kn(I){{for(var K=Object.keys(I.props),le=0;le<K.length;le++){var Se=K[le];if(Se!=="children"&&Se!=="key"){V(I),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Se),V(null);break}}I.ref!==null&&(V(I),b("Invalid attribute `ref` supplied to `React.Fragment`."),V(null))}}var fr={};function qn(I,K,le,Se,Ye,st){{var Ue=N(I);if(!Ue){var Fe="";(I===void 0||typeof I=="object"&&I!==null&&Object.keys(I).length===0)&&(Fe+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Pt=gt();Pt?Fe+=Pt:Fe+=ft();var bt;I===null?bt="null":Ge(I)?bt="array":I!==void 0&&I.$$typeof===t?(bt="<"+($(I.type)||"Unknown")+" />",Fe=" Did you accidentally export a JSX literal instead of a component?"):bt=typeof I,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",bt,Fe)}var yt=he(I,K,le,Ye,st);if(yt==null)return yt;if(Ue){var qt=K.children;if(qt!==void 0)if(Se)if(Ge(qt)){for(var Gn=0;Gn<qt.length;Gn++)at(qt[Gn],I);Object.freeze&&Object.freeze(qt)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else at(qt,I)}if(ke.call(K,"key")){var Rn=$(I),$t=Object.keys(K).filter(function(oe){return oe!=="key"}),go=$t.length>0?"{key: someKey, "+$t.join(": ..., ")+": ...}":"{key: someKey}";if(!fr[Rn+go]){var q=$t.length>0?"{"+$t.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,go,Rn,q,Rn),fr[Rn+go]=!0}}return I===r?Kn(xt):Et(xt),xt}}function Ya(I,K,le){return qn(I,K,le,!0)}function Xs(I,K,le){return qn(I,K,le,!1)}var Xa=Xs,Ja=Ya;Pr.Fragment=r,Pr.jsx=Xa,Pr.jsxs=Ja}()),Pr}process.env.NODE_ENV==="production"?Zs.exports=Xh():Zs.exports=Jh();var u=Zs.exports;function nl(e,t){return function(){return e.apply(t,arguments)}}const{toString:Zh}=Object.prototype,{getPrototypeOf:Qs}=Object,{iterator:vo,toStringTag:rl}=Symbol,bo=(e=>t=>{const n=Zh.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),cn=e=>(e=e.toLowerCase(),t=>bo(t)===e),wo=e=>t=>typeof t===e,{isArray:hr}=Array,mr=wo("undefined");function Or(e){return e!==null&&!mr(e)&&e.constructor!==null&&!mr(e.constructor)&&Ht(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const ol=cn("ArrayBuffer");function Qh(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&ol(e.buffer),t}const em=wo("string"),Ht=wo("function"),sl=wo("number"),Mr=e=>e!==null&&typeof e=="object",tm=e=>e===!0||e===!1,So=e=>{if(bo(e)!=="object")return!1;const t=Qs(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(rl in e)&&!(vo in e)},nm=e=>{if(!Mr(e)||Or(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},rm=cn("Date"),om=cn("File"),sm=cn("Blob"),im=cn("FileList"),am=e=>Mr(e)&&Ht(e.pipe),lm=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ht(e.append)&&((t=bo(e))==="formdata"||t==="object"&&Ht(e.toString)&&e.toString()==="[object FormData]"))},cm=cn("URLSearchParams"),[um,dm,fm,pm]=["ReadableStream","Request","Response","Headers"].map(cn),hm=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Dr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),hr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Or(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 il(e,t){if(Or(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 Xn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,al=e=>!mr(e)&&e!==Xn;function ei(){const{caseless:e,skipUndefined:t}=al(this)&&this||{},n={},r=(o,s)=>{const i=e&&il(n,s)||s;So(n[i])&&So(o)?n[i]=ei(n[i],o):So(o)?n[i]=ei({},o):hr(o)?n[i]=o.slice():(!t||!mr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Dr(arguments[o],r);return n}const mm=(e,t,n,{allOwnKeys:r}={})=>(Dr(t,(o,s)=>{n&&Ht(o)?e[s]=nl(o,n):e[s]=o},{allOwnKeys:r}),e),gm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),xm=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},ym=(e,t,n,r)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!r||r(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=n!==!1&&Qs(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},vm=(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},bm=e=>{if(!e)return null;if(hr(e))return e;let t=e.length;if(!sl(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},wm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Qs(Uint8Array)),Sm=(e,t)=>{const r=(e&&e[vo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Cm=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Tm=cn("HTMLFormElement"),km=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),ll=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Em=cn("RegExp"),cl=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Dr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Im=e=>{cl(e,(t,n)=>{if(Ht(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ht(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Nm=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return hr(e)?r(e):r(String(e).split(t)),n},Am=()=>{},jm=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function _m(e){return!!(e&&Ht(e.append)&&e[rl]==="FormData"&&e[vo])}const Rm=e=>{const t=new Array(10),n=(r,o)=>{if(Mr(r)){if(t.indexOf(r)>=0)return;if(Or(r))return r;if(!("toJSON"in r)){t[o]=r;const s=hr(r)?[]:{};return Dr(r,(i,a)=>{const l=n(i,o+1);!mr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},Pm=cn("AsyncFunction"),Om=e=>e&&(Mr(e)||Ht(e))&&Ht(e.then)&&Ht(e.catch),ul=((e,t)=>e?setImmediate:t?((n,r)=>(Xn.addEventListener("message",({source:o,data:s})=>{o===Xn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Xn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ht(Xn.postMessage)),Mm=typeof queueMicrotask<"u"?queueMicrotask.bind(Xn):typeof process<"u"&&process.nextTick||ul,O={isArray:hr,isArrayBuffer:ol,isBuffer:Or,isFormData:lm,isArrayBufferView:Qh,isString:em,isNumber:sl,isBoolean:tm,isObject:Mr,isPlainObject:So,isEmptyObject:nm,isReadableStream:um,isRequest:dm,isResponse:fm,isHeaders:pm,isUndefined:mr,isDate:rm,isFile:om,isBlob:sm,isRegExp:Em,isFunction:Ht,isStream:am,isURLSearchParams:cm,isTypedArray:wm,isFileList:im,forEach:Dr,merge:ei,extend:mm,trim:hm,stripBOM:gm,inherits:xm,toFlatObject:ym,kindOf:bo,kindOfTest:cn,endsWith:vm,toArray:bm,forEachEntry:Sm,matchAll:Cm,isHTMLForm:Tm,hasOwnProperty:ll,hasOwnProp:ll,reduceDescriptors:cl,freezeMethods:Im,toObjectSet:Nm,toCamelCase:km,noop:Am,toFiniteNumber:jm,findKey:il,global:Xn,isContextDefined:al,isSpecCompliantForm:_m,toJSONObject:Rm,isAsyncFn:Pm,isThenable:Om,setImmediate:ul,asap:Mm,isIterable:e=>e!=null&&Ht(e[vo])};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 dl=Pe.prototype,fl={};["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=>{fl[e]={value:e}}),Object.defineProperties(Pe,fl),Object.defineProperty(dl,"isAxiosError",{value:!0}),Pe.from=(e,t,n,r,o,s)=>{const i=Object.create(dl);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 Dm=null;function ti(e){return O.isPlainObject(e)||O.isArray(e)}function pl(e){return O.endsWith(e,"[]")?e.slice(0,-2):e}function hl(e,t,n){return e?e.concat(t).map(function(o,s){return o=pl(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function Lm(e){return O.isArray(e)&&!e.some(ti)}const Fm=O.toFlatObject(O,{},null,function(t){return/^is[A-Z]/.test(t)});function Co(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(y,m){return!O.isUndefined(m[y])});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(x){if(x===null)return"";if(O.isDate(x))return x.toISOString();if(O.isBoolean(x))return x.toString();if(!l&&O.isBlob(x))throw new Pe("Blob is not supported. Use a Buffer instead.");return O.isArrayBuffer(x)||O.isTypedArray(x)?l&&typeof Blob=="function"?new Blob([x]):Buffer.from(x):x}function d(x,y,m){let g=x;if(x&&!m&&typeof x=="object"){if(O.endsWith(y,"{}"))y=r?y:y.slice(0,-2),x=JSON.stringify(x);else if(O.isArray(x)&&Lm(x)||(O.isFileList(x)||O.endsWith(y,"[]"))&&(g=O.toArray(x)))return y=pl(y),g.forEach(function(S,k){!(O.isUndefined(S)||S===null)&&t.append(i===!0?hl([y],k,s):i===null?y:y+"[]",c(S))}),!1}return ti(x)?!0:(t.append(hl(m,y,s),c(x)),!1)}const f=[],p=Object.assign(Fm,{defaultVisitor:d,convertValue:c,isVisitable:ti});function h(x,y){if(!O.isUndefined(x)){if(f.indexOf(x)!==-1)throw Error("Circular reference detected in "+y.join("."));f.push(x),O.forEach(x,function(g,b){(!(O.isUndefined(g)||g===null)&&o.call(t,g,O.isString(b)?b.trim():b,y,p))===!0&&h(g,y?y.concat(b):[b])}),f.pop()}}if(!O.isObject(e))throw new TypeError("data must be an object");return h(e),t}function ml(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function ni(e,t){this._pairs=[],e&&Co(e,this,t)}const gl=ni.prototype;gl.append=function(t,n){this._pairs.push([t,n])},gl.toString=function(t){const n=t?function(r){return t.call(this,r,ml)}:ml;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function $m(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function xl(e,t,n){if(!t)return e;const r=n&&n.encode||$m;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 ni(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class yl{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 vl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},zm={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:ni,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},ri=typeof window<"u"&&typeof document<"u",oi=typeof navigator=="object"&&navigator||void 0,Bm=ri&&(!oi||["ReactNative","NativeScript","NS"].indexOf(oi.product)<0),Hm=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Um=ri&&window.location.href||"http://localhost",Mt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ri,hasStandardBrowserEnv:Bm,hasStandardBrowserWebWorkerEnv:Hm,navigator:oi,origin:Um},Symbol.toStringTag,{value:"Module"})),...zm};function Wm(e,t){return Co(e,new Mt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Mt.isNode&&O.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Vm(e){return O.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Km(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 bl(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]=Km(o[i])),!a)}if(O.isFormData(e)&&O.isFunction(e.entries)){const n={};return O.forEachEntry(e,(r,o)=>{t(Vm(r),o,n,0)}),n}return null}function qm(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 Lr={transitional:vl,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(bl(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 Wm(t,this.formSerializer).toString();if((a=O.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Co(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),qm(t)):t}],transformResponse:[function(t){const n=this.transitional||Lr.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:Mt.classes.FormData,Blob:Mt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};O.forEach(["delete","get","head","post","put","patch"],e=>{Lr.headers[e]={}});const Gm=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"]),Ym=e=>{const t={};let n,r,o;return e&&e.split(`
|
|
30
|
+
<%s key={someKey} {...props} />`,go,Rn,q,Rn),fr[Rn+go]=!0}}return I===r?Kn(yt):kt(yt),yt}}function Ya(I,K,le){return qn(I,K,le,!0)}function Xs(I,K,le){return qn(I,K,le,!1)}var Xa=Xs,Ja=Ya;Pr.Fragment=r,Pr.jsx=Xa,Pr.jsxs=Ja}()),Pr}process.env.NODE_ENV==="production"?Zs.exports=Xh():Zs.exports=Jh();var u=Zs.exports;function nl(e,t){return function(){return e.apply(t,arguments)}}const{toString:Zh}=Object.prototype,{getPrototypeOf:Qs}=Object,{iterator:vo,toStringTag:rl}=Symbol,bo=(e=>t=>{const n=Zh.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),cn=e=>(e=e.toLowerCase(),t=>bo(t)===e),wo=e=>t=>typeof t===e,{isArray:hr}=Array,mr=wo("undefined");function Or(e){return e!==null&&!mr(e)&&e.constructor!==null&&!mr(e.constructor)&&Ht(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const ol=cn("ArrayBuffer");function Qh(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&ol(e.buffer),t}const em=wo("string"),Ht=wo("function"),sl=wo("number"),Mr=e=>e!==null&&typeof e=="object",tm=e=>e===!0||e===!1,So=e=>{if(bo(e)!=="object")return!1;const t=Qs(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(rl in e)&&!(vo in e)},nm=e=>{if(!Mr(e)||Or(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},rm=cn("Date"),om=cn("File"),sm=cn("Blob"),im=cn("FileList"),am=e=>Mr(e)&&Ht(e.pipe),lm=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ht(e.append)&&((t=bo(e))==="formdata"||t==="object"&&Ht(e.toString)&&e.toString()==="[object FormData]"))},cm=cn("URLSearchParams"),[um,dm,fm,pm]=["ReadableStream","Request","Response","Headers"].map(cn),hm=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Dr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),hr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Or(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 il(e,t){if(Or(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 Xn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,al=e=>!mr(e)&&e!==Xn;function ei(){const{caseless:e,skipUndefined:t}=al(this)&&this||{},n={},r=(o,s)=>{const i=e&&il(n,s)||s;So(n[i])&&So(o)?n[i]=ei(n[i],o):So(o)?n[i]=ei({},o):hr(o)?n[i]=o.slice():(!t||!mr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Dr(arguments[o],r);return n}const mm=(e,t,n,{allOwnKeys:r}={})=>(Dr(t,(o,s)=>{n&&Ht(o)?e[s]=nl(o,n):e[s]=o},{allOwnKeys:r}),e),gm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),xm=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},ym=(e,t,n,r)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!r||r(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=n!==!1&&Qs(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},vm=(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},bm=e=>{if(!e)return null;if(hr(e))return e;let t=e.length;if(!sl(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},wm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Qs(Uint8Array)),Sm=(e,t)=>{const r=(e&&e[vo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Cm=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Tm=cn("HTMLFormElement"),km=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),ll=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Em=cn("RegExp"),cl=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Dr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Im=e=>{cl(e,(t,n)=>{if(Ht(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ht(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Nm=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return hr(e)?r(e):r(String(e).split(t)),n},Am=()=>{},jm=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function _m(e){return!!(e&&Ht(e.append)&&e[rl]==="FormData"&&e[vo])}const Rm=e=>{const t=new Array(10),n=(r,o)=>{if(Mr(r)){if(t.indexOf(r)>=0)return;if(Or(r))return r;if(!("toJSON"in r)){t[o]=r;const s=hr(r)?[]:{};return Dr(r,(i,a)=>{const l=n(i,o+1);!mr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},Pm=cn("AsyncFunction"),Om=e=>e&&(Mr(e)||Ht(e))&&Ht(e.then)&&Ht(e.catch),ul=((e,t)=>e?setImmediate:t?((n,r)=>(Xn.addEventListener("message",({source:o,data:s})=>{o===Xn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Xn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ht(Xn.postMessage)),Mm=typeof queueMicrotask<"u"?queueMicrotask.bind(Xn):typeof process<"u"&&process.nextTick||ul,O={isArray:hr,isArrayBuffer:ol,isBuffer:Or,isFormData:lm,isArrayBufferView:Qh,isString:em,isNumber:sl,isBoolean:tm,isObject:Mr,isPlainObject:So,isEmptyObject:nm,isReadableStream:um,isRequest:dm,isResponse:fm,isHeaders:pm,isUndefined:mr,isDate:rm,isFile:om,isBlob:sm,isRegExp:Em,isFunction:Ht,isStream:am,isURLSearchParams:cm,isTypedArray:wm,isFileList:im,forEach:Dr,merge:ei,extend:mm,trim:hm,stripBOM:gm,inherits:xm,toFlatObject:ym,kindOf:bo,kindOfTest:cn,endsWith:vm,toArray:bm,forEachEntry:Sm,matchAll:Cm,isHTMLForm:Tm,hasOwnProperty:ll,hasOwnProp:ll,reduceDescriptors:cl,freezeMethods:Im,toObjectSet:Nm,toCamelCase:km,noop:Am,toFiniteNumber:jm,findKey:il,global:Xn,isContextDefined:al,isSpecCompliantForm:_m,toJSONObject:Rm,isAsyncFn:Pm,isThenable:Om,setImmediate:ul,asap:Mm,isIterable:e=>e!=null&&Ht(e[vo])};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 dl=Pe.prototype,fl={};["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=>{fl[e]={value:e}}),Object.defineProperties(Pe,fl),Object.defineProperty(dl,"isAxiosError",{value:!0}),Pe.from=(e,t,n,r,o,s)=>{const i=Object.create(dl);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 Dm=null;function ti(e){return O.isPlainObject(e)||O.isArray(e)}function pl(e){return O.endsWith(e,"[]")?e.slice(0,-2):e}function hl(e,t,n){return e?e.concat(t).map(function(o,s){return o=pl(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function Lm(e){return O.isArray(e)&&!e.some(ti)}const Fm=O.toFlatObject(O,{},null,function(t){return/^is[A-Z]/.test(t)});function Co(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(y,m){return!O.isUndefined(m[y])});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(x){if(x===null)return"";if(O.isDate(x))return x.toISOString();if(O.isBoolean(x))return x.toString();if(!l&&O.isBlob(x))throw new Pe("Blob is not supported. Use a Buffer instead.");return O.isArrayBuffer(x)||O.isTypedArray(x)?l&&typeof Blob=="function"?new Blob([x]):Buffer.from(x):x}function d(x,y,m){let g=x;if(x&&!m&&typeof x=="object"){if(O.endsWith(y,"{}"))y=r?y:y.slice(0,-2),x=JSON.stringify(x);else if(O.isArray(x)&&Lm(x)||(O.isFileList(x)||O.endsWith(y,"[]"))&&(g=O.toArray(x)))return y=pl(y),g.forEach(function(S,k){!(O.isUndefined(S)||S===null)&&t.append(i===!0?hl([y],k,s):i===null?y:y+"[]",c(S))}),!1}return ti(x)?!0:(t.append(hl(m,y,s),c(x)),!1)}const f=[],p=Object.assign(Fm,{defaultVisitor:d,convertValue:c,isVisitable:ti});function h(x,y){if(!O.isUndefined(x)){if(f.indexOf(x)!==-1)throw Error("Circular reference detected in "+y.join("."));f.push(x),O.forEach(x,function(g,b){(!(O.isUndefined(g)||g===null)&&o.call(t,g,O.isString(b)?b.trim():b,y,p))===!0&&h(g,y?y.concat(b):[b])}),f.pop()}}if(!O.isObject(e))throw new TypeError("data must be an object");return h(e),t}function ml(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function ni(e,t){this._pairs=[],e&&Co(e,this,t)}const gl=ni.prototype;gl.append=function(t,n){this._pairs.push([t,n])},gl.toString=function(t){const n=t?function(r){return t.call(this,r,ml)}:ml;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function $m(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function xl(e,t,n){if(!t)return e;const r=n&&n.encode||$m;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 ni(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class yl{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 vl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},zm={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:ni,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},ri=typeof window<"u"&&typeof document<"u",oi=typeof navigator=="object"&&navigator||void 0,Bm=ri&&(!oi||["ReactNative","NativeScript","NS"].indexOf(oi.product)<0),Hm=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Um=ri&&window.location.href||"http://localhost",Mt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ri,hasStandardBrowserEnv:Bm,hasStandardBrowserWebWorkerEnv:Hm,navigator:oi,origin:Um},Symbol.toStringTag,{value:"Module"})),...zm};function Wm(e,t){return Co(e,new Mt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Mt.isNode&&O.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Vm(e){return O.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Km(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 bl(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]=Km(o[i])),!a)}if(O.isFormData(e)&&O.isFunction(e.entries)){const n={};return O.forEachEntry(e,(r,o)=>{t(Vm(r),o,n,0)}),n}return null}function qm(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 Lr={transitional:vl,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(bl(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 Wm(t,this.formSerializer).toString();if((a=O.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Co(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),qm(t)):t}],transformResponse:[function(t){const n=this.transitional||Lr.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:Mt.classes.FormData,Blob:Mt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};O.forEach(["delete","get","head","post","put","patch"],e=>{Lr.headers[e]={}});const Gm=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"]),Ym=e=>{const t={};let n,r,o;return e&&e.split(`
|
|
31
31
|
`).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&Gm[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},wl=Symbol("internals");function Fr(e){return e&&String(e).trim().toLowerCase()}function To(e){return e===!1||e==null?e:O.isArray(e)?e.map(To):String(e)}function Xm(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const Jm=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function si(e,t,n,r,o){if(O.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!O.isString(t)){if(O.isString(r))return t.indexOf(r)!==-1;if(O.isRegExp(r))return r.test(t)}}function Zm(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 Ut=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=Fr(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]=To(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())&&!Jm(t))i(Ym(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=Fr(t),t){const r=O.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Xm(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=Fr(t),t){const r=O.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||si(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Fr(i),i){const a=O.findKey(r,i);a&&(!n||si(r,r[a],a,n))&&(delete r[a],o=!0)}}return O.isArray(t)?t.forEach(s):s(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const s=n[r];(!t||si(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return O.forEach(this,(o,s)=>{const i=O.findKey(r,s);if(i){n[i]=To(o),delete n[s];return}const a=t?Zm(s):String(s).trim();a!==s&&delete n[s],n[a]=To(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[wl]=this[wl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Fr(i);r[a]||(Qm(o,i),r[a]=!0)}return O.isArray(t)?t.forEach(s):s(t),this}};Ut.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),O.reduceDescriptors(Ut.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),O.freezeMethods(Ut);function ii(e,t){const n=this||Lr,r=t||n,o=Ut.from(r.headers);let s=r.data;return O.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Sl(e){return!!(e&&e.__CANCEL__)}function gr(e,t,n){Pe.call(this,e??"canceled",Pe.ERR_CANCELED,t,n),this.name="CanceledError"}O.inherits(gr,Pe,{__CANCEL__:!0});function Cl(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 eg(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function tg(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,p=0;for(;f!==o;)p+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const h=d&&c-d;return h?Math.round(p*1e3/h):void 0}}function ng(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 ko=(e,t,n=3)=>{let r=0;const o=tg(50,250);return ng(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)},Tl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},kl=e=>(...t)=>O.asap(()=>e(...t)),rg=Mt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Mt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Mt.origin),Mt.navigator&&/(msie|trident)/i.test(Mt.navigator.userAgent)):()=>!0,og=Mt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];O.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),O.isString(r)&&i.push("path="+r),O.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function sg(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function ig(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function El(e,t,n){let r=!sg(t);return e&&(r||n==!1)?ig(e,t):t}const Il=e=>e instanceof Ut?{...e}:e;function Jn(e,t){t=t||{};const n={};function r(c,d,f,p){return O.isPlainObject(c)&&O.isPlainObject(d)?O.merge.call({caseless:p},c,d):O.isPlainObject(d)?O.merge({},d):O.isArray(d)?d.slice():d}function o(c,d,f,p){if(O.isUndefined(d)){if(!O.isUndefined(c))return r(void 0,c,f,p)}else return r(c,d,f,p)}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(Il(c),Il(d),f,!0)};return O.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,p=f(e[d],t[d],d);O.isUndefined(p)&&f!==a||(n[d]=p)}),n}const Nl=e=>{const t=Jn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ut.from(i),t.url=xl(El(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),O.isFormData(n)){if(Mt.hasStandardBrowserEnv||Mt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(O.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{c.includes(d.toLowerCase())&&i.set(d,f)})}}if(Mt.hasStandardBrowserEnv&&(r&&O.isFunction(r)&&(r=r(t)),r||r!==!1&&rg(t.url))){const l=o&&s&&og.read(s);l&&i.set(o,l)}return t},ag=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Nl(e);let s=o.data;const i=Ut.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,f,p,h,x;function y(){h&&h(),x&&x(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let m=new XMLHttpRequest;m.open(o.method.toUpperCase(),o.url,!0),m.timeout=o.timeout;function g(){if(!m)return;const S=Ut.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),T={data:!a||a==="text"||a==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:S,config:e,request:m};Cl(function(E){n(E),y()},function(E){r(E),y()},T),m=null}"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(g)},m.onabort=function(){m&&(r(new Pe("Request aborted",Pe.ECONNABORTED,e,m)),m=null)},m.onerror=function(k){const T=k&&k.message?k.message:"Network Error",C=new Pe(T,Pe.ERR_NETWORK,e,m);C.event=k||null,r(C),m=null},m.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const T=o.transitional||vl;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Pe(k,T.clarifyTimeoutError?Pe.ETIMEDOUT:Pe.ECONNABORTED,e,m)),m=null},s===void 0&&i.setContentType(null),"setRequestHeader"in m&&O.forEach(i.toJSON(),function(k,T){m.setRequestHeader(T,k)}),O.isUndefined(o.withCredentials)||(m.withCredentials=!!o.withCredentials),a&&a!=="json"&&(m.responseType=o.responseType),c&&([p,x]=ko(c,!0),m.addEventListener("progress",p)),l&&m.upload&&([f,h]=ko(l),m.upload.addEventListener("progress",f),m.upload.addEventListener("loadend",h)),(o.cancelToken||o.signal)&&(d=S=>{m&&(r(!S||S.type?new gr(null,e,m):S),m.abort(),m=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=eg(o.url);if(b&&Mt.protocols.indexOf(b)===-1){r(new Pe("Unsupported protocol "+b+":",Pe.ERR_BAD_REQUEST,e));return}m.send(s||null)})},lg=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,a();const d=c instanceof Error?c:this.reason;r.abort(d instanceof Pe?d:new gr(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}},cg=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},ug=async function*(e,t){for await(const n of dg(e))yield*cg(n,t)},dg=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()}},Al=(e,t,n,r)=>{const o=ug(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 p=s+=f;n(p)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},jl=64*1024,{isFunction:Eo}=O,fg=(({Request:e,Response:t})=>({Request:e,Response:t}))(O.global),{ReadableStream:_l,TextEncoder:Rl}=O.global,Pl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},pg=e=>{e=O.merge.call({skipUndefined:!0},fg,e);const{fetch:t,Request:n,Response:r}=e,o=t?Eo(t):typeof fetch=="function",s=Eo(n),i=Eo(r);if(!o)return!1;const a=o&&Eo(_l),l=o&&(typeof Rl=="function"?(x=>y=>x.encode(y))(new Rl):async x=>new Uint8Array(await new n(x).arrayBuffer())),c=s&&a&&Pl(()=>{let x=!1;const y=new n(Mt.origin,{body:new _l,method:"POST",get duplex(){return x=!0,"half"}}).headers.has("Content-Type");return x&&!y}),d=i&&a&&Pl(()=>O.isReadableStream(new r("").body)),f={stream:d&&(x=>x.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(x=>{!f[x]&&(f[x]=(y,m)=>{let g=y&&y[x];if(g)return g.call(y);throw new Pe(`Response type '${x}' is not supported`,Pe.ERR_NOT_SUPPORT,m)})});const p=async x=>{if(x==null)return 0;if(O.isBlob(x))return x.size;if(O.isSpecCompliantForm(x))return(await new n(Mt.origin,{method:"POST",body:x}).arrayBuffer()).byteLength;if(O.isArrayBufferView(x)||O.isArrayBuffer(x))return x.byteLength;if(O.isURLSearchParams(x)&&(x=x+""),O.isString(x))return(await l(x)).byteLength},h=async(x,y)=>{const m=O.toFiniteNumber(x.getContentLength());return m??p(y)};return async x=>{let{url:y,method:m,data:g,signal:b,cancelToken:S,timeout:k,onDownloadProgress:T,onUploadProgress:C,responseType:E,headers:j,withCredentials:A="same-origin",fetchOptions:N}=Nl(x),P=t||fetch;E=E?(E+"").toLowerCase():"text";let F=lg([b,S&&S.toAbortSignal()],k),$=null;const R=F&&F.unsubscribe&&(()=>{F.unsubscribe()});let z;try{if(C&&c&&m!=="get"&&m!=="head"&&(z=await h(j,g))!==0){let X=new n(y,{method:"POST",body:g,duplex:"half"}),pe;if(O.isFormData(g)&&(pe=X.headers.get("content-type"))&&j.setContentType(pe),X.body){const[Ie,je]=Tl(z,ko(kl(C)));g=Al(X.body,jl,Ie,je)}}O.isString(A)||(A=A?"include":"omit");const _=s&&"credentials"in n.prototype,B={...N,signal:F,method:m.toUpperCase(),headers:j.normalize().toJSON(),body:g,duplex:"half",credentials:_?A:void 0};$=s&&new n(y,B);let L=await(s?P($,N):P(y,B));const M=d&&(E==="stream"||E==="response");if(d&&(T||M&&R)){const X={};["status","statusText","headers"].forEach(G=>{X[G]=L[G]});const pe=O.toFiniteNumber(L.headers.get("content-length")),[Ie,je]=T&&Tl(pe,ko(kl(T),!0))||[];L=new r(Al(L.body,jl,Ie,()=>{je&&je(),R&&R()}),X)}E=E||"text";let J=await f[O.findKey(f,E)||"text"](L,x);return!M&&R&&R(),await new Promise((X,pe)=>{Cl(X,pe,{data:J,headers:Ut.from(L.headers),status:L.status,statusText:L.statusText,config:x,request:$})})}catch(_){throw R&&R(),_&&_.name==="TypeError"&&/Load failed|fetch/i.test(_.message)?Object.assign(new Pe("Network Error",Pe.ERR_NETWORK,x,$),{cause:_.cause||_}):Pe.from(_,_&&_.code,x,$)}}},hg=new Map,Ol=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=hg;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:pg(t)),d=c;return c};Ol();const ai={http:Dm,xhr:ag,fetch:{get:Ol}};O.forEach(ai,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Ml=e=>`- ${e}`,mg=e=>O.isFunction(e)||e===null||e===!1,Dl={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,!mg(r)&&(o=ai[(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 :
|
|
32
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[wl]=this[wl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Fr(i);r[a]||(Qm(o,i),r[a]=!0)}return O.isArray(t)?t.forEach(s):s(t),this}};Ut.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),O.reduceDescriptors(Ut.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),O.freezeMethods(Ut);function ii(e,t){const n=this||Lr,r=t||n,o=Ut.from(r.headers);let s=r.data;return O.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Sl(e){return!!(e&&e.__CANCEL__)}function gr(e,t,n){Pe.call(this,e??"canceled",Pe.ERR_CANCELED,t,n),this.name="CanceledError"}O.inherits(gr,Pe,{__CANCEL__:!0});function Cl(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 eg(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function tg(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,p=0;for(;f!==o;)p+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const h=d&&c-d;return h?Math.round(p*1e3/h):void 0}}function ng(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 ko=(e,t,n=3)=>{let r=0;const o=tg(50,250);return ng(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)},Tl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},kl=e=>(...t)=>O.asap(()=>e(...t)),rg=Mt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Mt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Mt.origin),Mt.navigator&&/(msie|trident)/i.test(Mt.navigator.userAgent)):()=>!0,og=Mt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];O.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),O.isString(r)&&i.push("path="+r),O.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function sg(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function ig(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function El(e,t,n){let r=!sg(t);return e&&(r||n==!1)?ig(e,t):t}const Il=e=>e instanceof Ut?{...e}:e;function Jn(e,t){t=t||{};const n={};function r(c,d,f,p){return O.isPlainObject(c)&&O.isPlainObject(d)?O.merge.call({caseless:p},c,d):O.isPlainObject(d)?O.merge({},d):O.isArray(d)?d.slice():d}function o(c,d,f,p){if(O.isUndefined(d)){if(!O.isUndefined(c))return r(void 0,c,f,p)}else return r(c,d,f,p)}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(Il(c),Il(d),f,!0)};return O.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,p=f(e[d],t[d],d);O.isUndefined(p)&&f!==a||(n[d]=p)}),n}const Nl=e=>{const t=Jn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ut.from(i),t.url=xl(El(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),O.isFormData(n)){if(Mt.hasStandardBrowserEnv||Mt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(O.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{c.includes(d.toLowerCase())&&i.set(d,f)})}}if(Mt.hasStandardBrowserEnv&&(r&&O.isFunction(r)&&(r=r(t)),r||r!==!1&&rg(t.url))){const l=o&&s&&og.read(s);l&&i.set(o,l)}return t},ag=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Nl(e);let s=o.data;const i=Ut.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,f,p,h,x;function y(){h&&h(),x&&x(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let m=new XMLHttpRequest;m.open(o.method.toUpperCase(),o.url,!0),m.timeout=o.timeout;function g(){if(!m)return;const S=Ut.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),T={data:!a||a==="text"||a==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:S,config:e,request:m};Cl(function(E){n(E),y()},function(E){r(E),y()},T),m=null}"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(g)},m.onabort=function(){m&&(r(new Pe("Request aborted",Pe.ECONNABORTED,e,m)),m=null)},m.onerror=function(k){const T=k&&k.message?k.message:"Network Error",C=new Pe(T,Pe.ERR_NETWORK,e,m);C.event=k||null,r(C),m=null},m.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const T=o.transitional||vl;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Pe(k,T.clarifyTimeoutError?Pe.ETIMEDOUT:Pe.ECONNABORTED,e,m)),m=null},s===void 0&&i.setContentType(null),"setRequestHeader"in m&&O.forEach(i.toJSON(),function(k,T){m.setRequestHeader(T,k)}),O.isUndefined(o.withCredentials)||(m.withCredentials=!!o.withCredentials),a&&a!=="json"&&(m.responseType=o.responseType),c&&([p,x]=ko(c,!0),m.addEventListener("progress",p)),l&&m.upload&&([f,h]=ko(l),m.upload.addEventListener("progress",f),m.upload.addEventListener("loadend",h)),(o.cancelToken||o.signal)&&(d=S=>{m&&(r(!S||S.type?new gr(null,e,m):S),m.abort(),m=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=eg(o.url);if(b&&Mt.protocols.indexOf(b)===-1){r(new Pe("Unsupported protocol "+b+":",Pe.ERR_BAD_REQUEST,e));return}m.send(s||null)})},lg=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,a();const d=c instanceof Error?c:this.reason;r.abort(d instanceof Pe?d:new gr(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}},cg=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},ug=async function*(e,t){for await(const n of dg(e))yield*cg(n,t)},dg=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()}},Al=(e,t,n,r)=>{const o=ug(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 p=s+=f;n(p)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},jl=64*1024,{isFunction:Eo}=O,fg=(({Request:e,Response:t})=>({Request:e,Response:t}))(O.global),{ReadableStream:_l,TextEncoder:Rl}=O.global,Pl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},pg=e=>{e=O.merge.call({skipUndefined:!0},fg,e);const{fetch:t,Request:n,Response:r}=e,o=t?Eo(t):typeof fetch=="function",s=Eo(n),i=Eo(r);if(!o)return!1;const a=o&&Eo(_l),l=o&&(typeof Rl=="function"?(x=>y=>x.encode(y))(new Rl):async x=>new Uint8Array(await new n(x).arrayBuffer())),c=s&&a&&Pl(()=>{let x=!1;const y=new n(Mt.origin,{body:new _l,method:"POST",get duplex(){return x=!0,"half"}}).headers.has("Content-Type");return x&&!y}),d=i&&a&&Pl(()=>O.isReadableStream(new r("").body)),f={stream:d&&(x=>x.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(x=>{!f[x]&&(f[x]=(y,m)=>{let g=y&&y[x];if(g)return g.call(y);throw new Pe(`Response type '${x}' is not supported`,Pe.ERR_NOT_SUPPORT,m)})});const p=async x=>{if(x==null)return 0;if(O.isBlob(x))return x.size;if(O.isSpecCompliantForm(x))return(await new n(Mt.origin,{method:"POST",body:x}).arrayBuffer()).byteLength;if(O.isArrayBufferView(x)||O.isArrayBuffer(x))return x.byteLength;if(O.isURLSearchParams(x)&&(x=x+""),O.isString(x))return(await l(x)).byteLength},h=async(x,y)=>{const m=O.toFiniteNumber(x.getContentLength());return m??p(y)};return async x=>{let{url:y,method:m,data:g,signal:b,cancelToken:S,timeout:k,onDownloadProgress:T,onUploadProgress:C,responseType:E,headers:j,withCredentials:A="same-origin",fetchOptions:N}=Nl(x),P=t||fetch;E=E?(E+"").toLowerCase():"text";let F=lg([b,S&&S.toAbortSignal()],k),$=null;const R=F&&F.unsubscribe&&(()=>{F.unsubscribe()});let z;try{if(C&&c&&m!=="get"&&m!=="head"&&(z=await h(j,g))!==0){let X=new n(y,{method:"POST",body:g,duplex:"half"}),pe;if(O.isFormData(g)&&(pe=X.headers.get("content-type"))&&j.setContentType(pe),X.body){const[Ne,je]=Tl(z,ko(kl(C)));g=Al(X.body,jl,Ne,je)}}O.isString(A)||(A=A?"include":"omit");const _=s&&"credentials"in n.prototype,B={...N,signal:F,method:m.toUpperCase(),headers:j.normalize().toJSON(),body:g,duplex:"half",credentials:_?A:void 0};$=s&&new n(y,B);let L=await(s?P($,N):P(y,B));const M=d&&(E==="stream"||E==="response");if(d&&(T||M&&R)){const X={};["status","statusText","headers"].forEach(G=>{X[G]=L[G]});const pe=O.toFiniteNumber(L.headers.get("content-length")),[Ne,je]=T&&Tl(pe,ko(kl(T),!0))||[];L=new r(Al(L.body,jl,Ne,()=>{je&&je(),R&&R()}),X)}E=E||"text";let J=await f[O.findKey(f,E)||"text"](L,x);return!M&&R&&R(),await new Promise((X,pe)=>{Cl(X,pe,{data:J,headers:Ut.from(L.headers),status:L.status,statusText:L.statusText,config:x,request:$})})}catch(_){throw R&&R(),_&&_.name==="TypeError"&&/Load failed|fetch/i.test(_.message)?Object.assign(new Pe("Network Error",Pe.ERR_NETWORK,x,$),{cause:_.cause||_}):Pe.from(_,_&&_.code,x,$)}}},hg=new Map,Ol=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=hg;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:pg(t)),d=c;return c};Ol();const ai={http:Dm,xhr:ag,fetch:{get:Ol}};O.forEach(ai,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Ml=e=>`- ${e}`,mg=e=>O.isFunction(e)||e===null||e===!1,Dl={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,!mg(r)&&(o=ai[(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 :
|
|
33
33
|
`+i.map(Ml).join(`
|
|
34
34
|
`):" "+Ml(i[0]):"as no adapter specified";throw new Pe("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:ai};function li(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new gr(null,e)}function Ll(e){return li(e),e.headers=Ut.from(e.headers),e.data=ii.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Dl.getAdapter(e.adapter||Lr.adapter,e)(e).then(function(r){return li(e),r.data=ii.call(e,e.transformResponse,r),r.headers=Ut.from(r.headers),r},function(r){return Sl(r)||(li(e),r&&r.response&&(r.response.data=ii.call(e,e.transformResponse,r.response),r.response.headers=Ut.from(r.response.headers))),Promise.reject(r)})}const Fl="1.12.2",Io={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Io[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const $l={};Io.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Fl+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Pe(o(i," has been removed"+(n?" in "+n:"")),Pe.ERR_DEPRECATED);return n&&!$l[i]&&($l[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}},Io.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function gg(e,t,n){if(typeof e!="object")throw new Pe("options must be an object",Pe.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 Pe("option "+s+" must be "+l,Pe.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Pe("Unknown option "+s,Pe.ERR_BAD_OPTION)}}const No={assertOptions:gg,validators:Io},gn=No.validators;let Zn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new yl,response:new yl}}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=Jn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&No.assertOptions(r,{silentJSONParsing:gn.transitional(gn.boolean),forcedJSONParsing:gn.transitional(gn.boolean),clarifyTimeoutError:gn.transitional(gn.boolean)},!1),o!=null&&(O.isFunction(o)?n.paramsSerializer={serialize:o}:No.assertOptions(o,{encode:gn.function,serialize:gn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),No.assertOptions(n,{baseUrl:gn.spelling("baseURL"),withXsrfToken:gn.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"],x=>{delete s[x]}),n.headers=Ut.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(n)===!1||(l=l&&y.synchronous,a.unshift(y.fulfilled,y.rejected))});const c=[];this.interceptors.response.forEach(function(y){c.push(y.fulfilled,y.rejected)});let d,f=0,p;if(!l){const x=[Ll.bind(this),void 0];for(x.unshift(...a),x.push(...c),p=x.length,d=Promise.resolve(n);f<p;)d=d.then(x[f++],x[f++]);return d}p=a.length;let h=n;for(;f<p;){const x=a[f++],y=a[f++];try{h=x(h)}catch(m){y.call(this,m);break}}try{d=Ll.call(this,h)}catch(x){return Promise.reject(x)}for(f=0,p=c.length;f<p;)d=d.then(c[f++],c[f++]);return d}getUri(t){t=Jn(this.defaults,t);const n=El(t.baseURL,t.url,t.allowAbsoluteUrls);return xl(n,t.params,t.paramsSerializer)}};O.forEach(["delete","get","head","options"],function(t){Zn.prototype[t]=function(n,r){return this.request(Jn(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(Jn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Zn.prototype[t]=n(),Zn.prototype[t+"Form"]=n(!0)});let xg=class qh{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 gr(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 qh(function(o){t=o}),cancel:t}}};function yg(e){return function(n){return e.apply(null,n)}}function vg(e){return O.isObject(e)&&e.isAxiosError===!0}const ci={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(ci).forEach(([e,t])=>{ci[t]=e});function zl(e){const t=new Zn(e),n=nl(Zn.prototype.request,t);return O.extend(n,Zn.prototype,t,{allOwnKeys:!0}),O.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return zl(Jn(e,o))},n}const St=zl(Lr);St.Axios=Zn,St.CanceledError=gr,St.CancelToken=xg,St.isCancel=Sl,St.VERSION=Fl,St.toFormData=Co,St.AxiosError=Pe,St.Cancel=St.CanceledError,St.all=function(t){return Promise.all(t)},St.spread=yg,St.isAxiosError=vg,St.mergeConfig=Jn,St.AxiosHeaders=Ut,St.formToJSON=e=>bl(O.isHTMLForm(e)?new FormData(e):e),St.getAdapter=Dl.getAdapter,St.HttpStatusCode=ci,St.default=St;const{Axios:eT,AxiosError:tT,CanceledError:nT,isCancel:rT,CancelToken:oT,VERSION:sT,all:iT,Cancel:aT,isAxiosError:lT,spread:cT,toFormData:uT,AxiosHeaders:dT,HttpStatusCode:fT,formToJSON:pT,getAdapter:hT,mergeConfig:mT}=St,Bl=typeof window<"u"?window.__API_BASE_URL__:void 0,Hl=Bl?En(Bl):void 0;function En(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Ao=null;const ui=new Set;function Ul(){return Ao}function jo(e){Ao=e,ui.forEach(t=>t(e))}function Wl(e){return ui.add(e),()=>ui.delete(e)}const bg=3e4,wg=9e4,Zt=St.create({...Hl?{baseURL:Hl}:{},timeout:bg,withCredentials:!0});Zt.interceptors.request.use(e=>(Ao&&(e.headers.Authorization=`Bearer ${Ao}`),e)),Zt.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),jo(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 Qt(e,t){return Zt.defaults.baseURL?(await Zt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function di(e,t,n){return Zt.defaults.baseURL?(await Zt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Vl(e,t,n){return Zt.defaults.baseURL?(await Zt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Kl(e,t){return Zt.defaults.baseURL?(await Zt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function en(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class ql{get baseUrl(){const t=Zt.defaults.baseURL;return t?En(String(t)):""}updateConfig(t){t.baseUrl&&(Zt.defaults.baseURL=En(String(t.baseUrl))),t.authToken!==void 0&&jo(t.authToken)}getAuthToken(){return Ul()}setAuthToken(t){jo(t)}onTokenChange(t){return Wl(t)}async listThreads(){const t=await Qt("/threads"),n=en(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await di("/threads",t?{title:t}:void 0);return en(r)}async updateThread(t,n){const r=await Vl(`/threads/${t}`,{title:n});return en(r)}async deleteThread(t){const n=await Kl(`/threads/${t}`);return en(n)}async threadInfo(t){const n=await Qt(`/threads/${t}/info`);return en(n)}async listAgents(){const t=await Qt("/agents"),n=en(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Qt(`/agents/${t}`);return en(n)}async getAgentSchema(t){const n=await Qt(`/agents/${t}/schema`);return en(n)}async getState(t){const n=await Qt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return en(n)}async getStateHistory(t){const n=await Qt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:wg});return en(n)}async cancelRun(t){const n=await di("/runs/cancel",{threadId:t});return en(n)}async listCheckpointSummaries(t){const n=await Qt(`/threads/${t}/state/checkpoints`,{params:{thread_id:t}}),r=en(n);return(r==null?void 0:r.items)??[]}}const Pn=new ql,Gl=w.createContext(null);function Sg({children:e,apiConfig:t}){const n=Pn;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(Gl.Provider,{value:r,children:e})}function fi(){const e=w.useContext(Gl);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function Cg(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 Tg(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const c=await Cg(l);a.push({filename:l.name,data:c,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const kg={human:"user",user:"user",ai:"assistant",assistant:"assistant",tool:"tool",function:"tool",system:"system"};function pi(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 Eg(e,t){return`${e??""}::${t??""}`}function $r(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(!pi(r))return{threadId:n,latest:null,checkpoints:[],interrupt:null,snapshots:{}};const{orderedSnapshots:o,snapshotMap:s}=Ng(t),i=Yl(r,0);return{threadId:n,latest:i,checkpoints:o,interrupt:(i==null?void 0:i.interrupt)??null,snapshots:s}}function Yl(e,t){if(!pi(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(A=>!!A&&typeof A=="object").map(A=>({...A})):a===null?null:void 0,c=r.map((A,N)=>Mg(A,N)).filter(A=>!!A),d=Wt(e.config),f=Wt(d==null?void 0:d.configurable),p=It(f,["checkpoint_id","checkpointId"]),h=It(f,["checkpoint_ns","checkpointNs"]),x=Wt(e==null?void 0:e.parentConfig),y=Wt(x==null?void 0:x.configurable),m=It(y,["checkpoint_id","checkpointId"])??null,g=It(y,["checkpoint_ns","checkpointNs"])??null,b=e==null?void 0:e.createdAt,S=typeof b=="string"&&b.trim()?b:new Date(Date.now()-t).toISOString(),k=c[c.length-1]??null,T=Wt(e==null?void 0:e.metadata),C=It(T,["branch_label","branchLabel"]),E=It(y,["checkpoint_id","checkpointId"]),j=Array.isArray(e.next)?[...e.next]:(e==null?void 0:e.next)===null?null:void 0;return{messages:c,checkpointId:p??null,checkpointNs:h??null,nextCursor:m,nextCursorNs:g,interrupt:Ig(a,c,t),createdAt:S,parentId:E??null,branchLabel:C??null,lastMessageId:(k==null?void 0:k.id)??null,hasMessages:c.length>0,messagesLen:c.length,metadata:T??null,config:d??null,parentConfig:x??null,next:j??null,tasks:l??null,values:i??null}}function Ig(e,t,n){const r=Pg(e,n);return r||Rg(t,n)}function Ng(e){const t=new Map;e.forEach((o,s)=>{if(!pi(o))return;const i=Yl(o,s);if(!(i!=null&&i.checkpointId))return;const a=Eg(i.checkpointId,i.checkpointNs??null),l=t.get(a);if(!l){t.set(a,i);return}t.set(a,Ag(l,i))});const n=Array.from(t.values());n.sort((o,s)=>Jl(s.createdAt??"")-Jl(o.createdAt??""));const r={};for(const[o,s]of t.entries())r[o]=s;return{orderedSnapshots:n,snapshotMap:r}}function Ag(e,t){return{...e,metadata:_o(e.metadata,t.metadata)??null,config:_o(e.config,t.config)??null,parentConfig:_o(e.parentConfig,t.parentConfig)??null,next:jg(e.next,t.next)??null,tasks:_g(e.tasks,t.tasks)??null,values:_o(e.values,t.values)??null}}function _o(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 jg(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 _g(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 Rg(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 Pg(e,t){if(!Array.isArray(e)||!e.length)return null;for(let n=e.length-1;n>=0;n--){const r=Og(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=zr(r.interrupts[s],`${o}-interrupt-${s}`);if(i)return i}if(r.state!==void 0&&r.state!==null){const s=zr(r.state,`${o}-state`);if(s)return s}}return null}function Og(e,t){if(!e)return null;if(Array.isArray(e)){const[a,l,c,,d,,f,...p]=e,h=typeof a=="string"&&a.trim()?a:t,x=typeof l=="string"&&l.trim()?l:Array.isArray(c)&&typeof c[0]=="string"?String(c[0]):"task",y=Array.isArray(d)?d:void 0,m=p.length?p[p.length-1]:void 0;return{id:h,name:x,interrupts:y,state:m!==void 0?m:f}}const n=Wt(e);if(!n)return null;const r=It(n,["id","task_id","taskId"])??t,o=It(n,["name"])??"task",s=Array.isArray(n.interrupts)?n.interrupts:void 0,i=Object.prototype.hasOwnProperty.call(n,"state")?n.state:void 0;return{id:r,name:o,interrupts:s,state:i}}function zr(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=Xl(e,t);if(o)return o;if(Array.isArray(e)){for(let s=e.length-1;s>=0;s--){const i=zr(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=zr(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=zr(l,t,n+1,r);if(c)return c}}return null}function Xl(e,t){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){const n=e,r=It(n,["type","event","kind"]),o=It(n,["id","interrupt_id","interruptId","value_id"])??(r&&r.toLowerCase().includes("interrupt")?t:void 0);if(!(Object.prototype.hasOwnProperty.call(n,"value")||Object.prototype.hasOwnProperty.call(n,"data")||Object.prototype.hasOwnProperty.call(n,"payload"))&&!(r&&r.toLowerCase().includes("interrupt")))return null;const i=Object.prototype.hasOwnProperty.call(n,"value")?n.value:Object.prototype.hasOwnProperty.call(n,"data")?n.data:Object.prototype.hasOwnProperty.call(n,"payload")?n.payload:n,a=o&&o.trim()?o:t;return a?{id:a,value:i}:null}if(Array.isArray(e)){for(let n=e.length-1;n>=0;n--){const r=Xl(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 Jl(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function Mg(e,t){if(!e||typeof e!="object")return null;const n=e,r=Wt(e)??{},o=Wt(n.data)??r,s=String(n.type??o.type??o.role??"").toLowerCase(),i=kg[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=Wt(o.additional_kwargs)??Wt(o.additionalKwargs),d=Wt(o.response_metadata)??Wt(o.responseMetadata),f=It(c,["createdAt","created_at"])??It(o,["created_at","createdAt"]),p=It(c,["checkpointId","checkpoint_id"]),h=It(c,["checkpointNs","checkpoint_ns"]),x=Dg(o.content),y={id:l,role:i,content:x};f&&(y.createdAt=f),typeof o.name=="string"&&o.name.trim()&&(y.name=o.name),typeof(d==null?void 0:d.model_name)=="string"&&(y.model=String(d.model_name)),!y.model&&typeof o.model=="string"&&(y.model=o.model),p&&(y.checkpointId=p),h&&(y.checkpointNs=h);const m=zg(c,["createdAt","created_at","checkpointId","checkpoint_id","checkpointNs","checkpoint_ns","tool_calls"]),g=d?{...d}:void 0;m&&Object.keys(m).length&&(y.additionalKwargs=m),g&&Object.keys(g).length&&(y.responseMetadata=g);const b=Lg((c==null?void 0:c.tool_calls)??o.tool_calls);if(b.length&&(y.content=[...y.content,...b]),i==="tool"){const S=Fg(o,y.content);S&&(y.content=S)}return y}function Dg(e){if(!e)return[];if(Array.isArray(e))return e.map(t=>Zl(t)).filter(t=>!!t);if(typeof e=="string")return e.trim()?[{type:"text",text:e.trim()}]:[];if(typeof e=="object"){const t=Zl(e);return t?[t]:[]}return[]}function Zl(e){if(!e||typeof e!="object")return typeof e=="string"&&e.trim()?{type:"text",text:e}:null;const t=e,n=String(t.type??"").toLowerCase();if(!n||n==="text"){const o=typeof t.text=="string"?t.text:typeof t.value=="string"?t.value:"";return o.trim()?{type:"text",text:o}:null}if(n==="image"||n==="image_url"){const o=It(t,["url","src"]);if(!o)return null;const s={type:"image_url",url:o};return typeof t.mimeType=="string"&&(s.mimeType=t.mimeType),typeof t.alt=="string"&&(s.alt=t.alt),s}if(n==="file"){const o=It(t,["url"]);if(!o)return null;const s={type:"file",url:o};return typeof t.mimeType=="string"&&(s.mimeType=t.mimeType),typeof t.name=="string"&&(s.name=t.name),typeof t.size=="number"&&(s.size=t.size),typeof t.sourceType=="string"&&(s.sourceType=t.sourceType),s}if(n==="tool_call")return 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=It(t,["text","content"]);if(o)return{type:"text",text:o}}const r=typeof t.content=="string"?t.content:typeof t.value=="string"?t.value:JSON.stringify(t);return r?{type:"text",text:r}:null}function Ql(e,t){var s;const n=It(e,["id","call_id"])??t,r=It(e,["name"])??It(Wt(e.function),["name"]);if(!n||!r)return null;const o=$g(e.args??e.arguments??((s=Wt(e.function))==null?void 0:s.arguments));return{type:"tool_call",id:n,name:r,args:o}}function Lg(e){return Array.isArray(e)?e.map((t,n)=>Ql(t,`tool_call_${n}`)).filter(t=>!!t):[]}function Fg(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 $g(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 Wt(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function It(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r}}function zg(e,t){if(!e)return;const n={};let r=!1;for(const[o,s]of Object.entries(e)){if(t.includes(o)){r=!0;continue}s!==void 0&&(n[o]=s)}return r?Object.keys(n).length?n:void 0:e}function Bg(){const e=w.useRef(new Map),t=w.useCallback((a,l)=>{e.current.set(a,l)},[]),n=w.useCallback((a,l)=>{const c=e.current.get(a);return c==null?void 0:c.find(d=>d.checkpointId===l)},[]),r=w.useCallback((a,l)=>{const c=e.current.get(a);return(c==null?void 0:c.some(d=>d.checkpointId===l))??!1},[]),o=w.useCallback(a=>e.current.get(a),[]),s=w.useCallback(a=>{e.current.delete(a)},[]),i=w.useCallback(()=>{e.current.clear()},[]);return{cache:e.current,setCacheForThread:t,getCachedMetadata:n,checkpointExists:r,getThreadMetadata:o,clearThreadCache:s,clearAllCache:i}}function Hg(e){return e.type!=="thread_info"&&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:hi(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,pendingInterrupt:null};case"seed":{const r=hi(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=hi(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 tc(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>tc(o,s),e):e}case"interrupt_response":return{...e,messages:nc(e.messages),pendingInterrupt:null};default:return e}}function ec(e=[]){const[t,n]=w.useReducer(Wg,{...Ug,messages:e}),r=w.useRef([]),o=w.useRef(null),s=w.useRef(null),i=w.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=w.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=w.useCallback(d=>{r.current.push(d),a()},[a]);w.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=w.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:d=>n({type:"user_message",payload:{message:d}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function tc(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??{},p={...f,[a]:f[a]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:a,messagesStreamMeta:p}}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??rc(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??{},p=f[a]??{lastSeq:null,lastText:ic(d.content)},h=t.seq??null;if(h!==null&&typeof h=="number"&&typeof p.lastSeq=="number"&&h<=p.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:h,lastSeq:p.lastSeq}),e;const{newParts:x,newMeta:y,changed:m}=Vg(d.content,t.delta,p,h);if(!m)return e;const g={...d,content:x},b=Ro(l,c,g),S={...f,[a]:y};return{...e,messages:b,messagesStreamMeta:S}}if(t.type==="message_end"){const a=e.assemblingId??rc(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(p=>{var h;return(p==null?void 0:p.type)==="text"&&((h=p.text)==null?void 0:h.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:d.id,contentTypes:(r=d.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=d.content)==null?void 0:o.map(h=>(h==null?void 0:h.type)==="text"?String(h.text).slice(0,100):h==null?void 0:h.type)});const p=[...l.slice(0,c),...l.slice(c+1)];return{...e,assemblingId:null,messages:p}}}return e}if(t.type==="tool_start"){const a=oc(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=sc(e,d,c),p=f>=0?e.messages[f]:null,h=l??d[0]??`${c}-${Date.now()}`,x=(p==null?void 0:p.id)??`tool-${h}`,y=d[0]??h,m={type:"tool_call",id:y,name:c,args:t.args};if(p){const S=gi(p,d,c,t.args),k={...p,name:p.name??c,additionalKwargs:S},T=f,C=T>=0?Ro(e.messages,T,k):e.messages,E=Po(k,d),j=xi(e.toolIndex,x,E);return{...e,messages:C,toolIndex:j}}const g={id:x,role:"tool",name:c,createdAt:new Date().toISOString(),content:[m],additionalKwargs:gi(void 0,d.length?d:[y],c,t.args)},b=Po(g,d.length?d:[y]);return{...e,messages:[...e.messages,g],toolIndex:xi(e.toolIndex,x,b)}}if(t.type==="tool_end"){const a=oc(t);if(!a.length&&!(typeof t.id=="string"&&t.id))return e;const l=t.name??null,c=sc(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",p=a[0]??((i=d==null?void 0:d.id)==null?void 0:i.replace(/^tool-/,""))??`${f}-${Date.now()}`,h=(d==null?void 0:d.id)??`tool-${p}`,x=Po(d,a);let y=t.output;if(typeof t.output=="string")try{const C=t.output.trim();(C.startsWith("{")||C.startsWith("["))&&(y=JSON.parse(C))}catch{y=t.output}const m={type:"text",text:typeof y=="string"?y:JSON.stringify(y)},g=(d==null?void 0:d.createdAt)??new Date().toISOString(),b=gi(d??void 0,x.length?x:a,f),S={id:h,role:"tool",name:f??(d==null?void 0:d.name)??"tool",content:[m],createdAt:g,additionalKwargs:b},k=c>=0?Ro(e.messages,c,S):[...e.messages,S],T=Po(S,a.length?a:x);return{...e,messages:k,toolIndex:xi(e.toolIndex,h,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=$r(t),l=a.interrupt,c=a.latest,d=l===null?nc(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 e}function hi(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 Ro(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function nc(e){let t=!1;const n=e.map(r=>{const o=(r.content??[]).filter(s=>s.type!=="interrupt");return o.length!==r.content.length?(t=!0,{...r,content:o}):r});return t?n:e}function rc(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function oc(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 mi(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 gi(e,t,n,r){const o=new Set,s=l=>{typeof l=="string"&&l.trim()&&o.add(l.trim())};if(e){const l=mi(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 Po(e,t){const n=new Set;for(const o of t)typeof o=="string"&&o.trim()&&n.add(o.trim());const r=mi(e);for(const o of r)n.add(o);return Array.from(n)}function xi(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 sc(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(mi(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 ic(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??ic(e);let l="",c=e.slice();if(s){const f=Kg(a,s);if(f===""?l="":f===s?l=s:l=f,l){const p=c[c.length-1];if((p==null?void 0:p.type)==="text"){const h=p.text??"",x={...p,text:h+l};c=[...c.slice(0,c.length-1),x]}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 ac(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=ac(e),o=ac(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 Ro(e,r,s)}return e}function Gg(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function lc(e={}){const t=w.useMemo(()=>En(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=w.useState(e.token??null),s=w.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=w.useState(!1),[c,d]=w.useState(null),[f,p]=w.useState(""),[h,x]=w.useState(null),[y,m]=w.useState(0),[g,b]=w.useState(!1),S=w.useRef(null),k=w.useRef(!0),T=w.useRef(0),C=w.useRef(null),E=w.useRef(null),j=w.useRef(null),A=w.useRef(null),N=w.useCallback(R=>{o(R)},[]),P=w.useCallback(()=>{p(""),x(null),d(null),E.current=null,j.current=null,A.current=null},[]),F=w.useCallback(()=>{var R;console.debug("[use-chat] stop() invoked - aborting stream"),(R=S.current)==null||R.abort(),S.current=null,C.current=null,l(!1),b(!1),T.current=0,m(0)},[]),$=w.useCallback((R,z,_)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&p(""),x(null),E.current=null,j.current=null,A.current=null;const B=new AbortController;S.current=B;let L=null,M=null,J=!1;return C.current={threadId:R.threadId??null,headers:{}},(async()=>{var pe,Ie,je,G,ee,W,D,H,te,ae,ne,Fe,Q,ie,Ce,Re,Ke,Be;const X=ze=>{var qe;try{const Ge=JSON.parse(JSON.stringify(ze));return(qe=Ge==null?void 0:Ge.payload)!=null&&qe.files_info&&Array.isArray(Ge.payload.files_info)&&(Ge.payload.files_info=Ge.payload.files_info.map(Qe=>({...Qe,data:Qe!=null&&Qe.data?`<base64 ${String(Qe.data).length} chars>`:Qe==null?void 0:Qe.data}))),Ge}catch{return ze}};try{let ze={};try{if(r)ze={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const ye=window.__AUTH_TOKEN__,vt=((pe=window.localStorage)==null?void 0:pe.getItem("authToken"))||null;let jt=null;try{const ve=(Ie=window.localStorage)==null?void 0:Ie.getItem("chat-settings");ve&&(jt=((je=JSON.parse(ve))==null?void 0:je.apiKey)||null)}catch{}const V=ye||vt||jt||null;V&&(ze={Authorization:`Bearer ${V}`})}}catch{}console.debug("[use-chat] POST",t+n,X(R));let qe={};if(typeof window<"u")try{const Ne=(G=window.localStorage)==null?void 0:G.getItem("authSessionId");Ne&&(qe={"X-Session-Id":Ne})}catch{}const Ge={...ze,...qe,...s.current},Qe={"Content-Type":"application/json",Accept:"text/event-stream",...Ge},Je=await fetch(t+n,{method:"POST",headers:Qe,body:JSON.stringify(R),signal:B.signal,credentials:i});if(C.current&&(C.current.headers=Ge),!Je.ok||!Je.body){const Ne=await Je.text().catch(()=>"");console.debug("[use-chat] non-OK response",Je.status,Ne==null?void 0:Ne.slice(0,500));const ye=`stream ${Je.status}${Ne?": "+Ne:""}`;throw(ee=_==null?void 0:_.onConnectionError)==null||ee.call(_,ye),J=!0,L="error",M=ye,new Error(ye)}b(!0);const rt=Je.body.getReader(),wt=new TextDecoder;let ut="",it=[];T.current=0,m(0);let Tt=0,yt=null;const re=()=>{if(it.length){const Ne=it.join("");it=[],k.current&&p(ye=>ye+Ne)}yt=null},Te=()=>{typeof window<"u"&&yt==null&&(yt=requestAnimationFrame(re))};let Ve=Date.now();const Oe=setInterval(()=>{var Ne;if(Date.now()-Ve>18e5){const ye="Stream idle timeout";d(ye),L="error",M=ye,B.abort(),(Ne=_==null?void 0:_.onError)==null||Ne.call(_,ye)}},5e3),ot=1024*1024;try{const Ne=Je.headers.get("X-Thread-Id")||Je.headers.get("x-thread-id"),ye=Je.headers.get("X-Thread-Created")||Je.headers.get("x-thread-created"),vt=Ne??null,jt=String(ye??"").toLowerCase()==="true";for(C.current&&!C.current.threadId&&(C.current={...C.current,threadId:vt}),(W=_==null?void 0:_.onOpen)==null||W.call(_,{threadId:vt,created:jt});;){const{value:V,done:ve}=await rt.read();if(ve)break;ut+=wt.decode(V,{stream:!0}),ut.length>ot&&(ut="",console.warn("Stream buffer reset: exceeded 1MB"));let ge;for(;(ge=ut.indexOf(`
|
|
35
|
+
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Jn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&No.assertOptions(r,{silentJSONParsing:gn.transitional(gn.boolean),forcedJSONParsing:gn.transitional(gn.boolean),clarifyTimeoutError:gn.transitional(gn.boolean)},!1),o!=null&&(O.isFunction(o)?n.paramsSerializer={serialize:o}:No.assertOptions(o,{encode:gn.function,serialize:gn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),No.assertOptions(n,{baseUrl:gn.spelling("baseURL"),withXsrfToken:gn.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"],x=>{delete s[x]}),n.headers=Ut.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(n)===!1||(l=l&&y.synchronous,a.unshift(y.fulfilled,y.rejected))});const c=[];this.interceptors.response.forEach(function(y){c.push(y.fulfilled,y.rejected)});let d,f=0,p;if(!l){const x=[Ll.bind(this),void 0];for(x.unshift(...a),x.push(...c),p=x.length,d=Promise.resolve(n);f<p;)d=d.then(x[f++],x[f++]);return d}p=a.length;let h=n;for(;f<p;){const x=a[f++],y=a[f++];try{h=x(h)}catch(m){y.call(this,m);break}}try{d=Ll.call(this,h)}catch(x){return Promise.reject(x)}for(f=0,p=c.length;f<p;)d=d.then(c[f++],c[f++]);return d}getUri(t){t=Jn(this.defaults,t);const n=El(t.baseURL,t.url,t.allowAbsoluteUrls);return xl(n,t.params,t.paramsSerializer)}};O.forEach(["delete","get","head","options"],function(t){Zn.prototype[t]=function(n,r){return this.request(Jn(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(Jn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Zn.prototype[t]=n(),Zn.prototype[t+"Form"]=n(!0)});let xg=class qh{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 gr(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 qh(function(o){t=o}),cancel:t}}};function yg(e){return function(n){return e.apply(null,n)}}function vg(e){return O.isObject(e)&&e.isAxiosError===!0}const ci={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(ci).forEach(([e,t])=>{ci[t]=e});function zl(e){const t=new Zn(e),n=nl(Zn.prototype.request,t);return O.extend(n,Zn.prototype,t,{allOwnKeys:!0}),O.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return zl(Jn(e,o))},n}const wt=zl(Lr);wt.Axios=Zn,wt.CanceledError=gr,wt.CancelToken=xg,wt.isCancel=Sl,wt.VERSION=Fl,wt.toFormData=Co,wt.AxiosError=Pe,wt.Cancel=wt.CanceledError,wt.all=function(t){return Promise.all(t)},wt.spread=yg,wt.isAxiosError=vg,wt.mergeConfig=Jn,wt.AxiosHeaders=Ut,wt.formToJSON=e=>bl(O.isHTMLForm(e)?new FormData(e):e),wt.getAdapter=Dl.getAdapter,wt.HttpStatusCode=ci,wt.default=wt;const{Axios:eT,AxiosError:tT,CanceledError:nT,isCancel:rT,CancelToken:oT,VERSION:sT,all:iT,Cancel:aT,isAxiosError:lT,spread:cT,toFormData:uT,AxiosHeaders:dT,HttpStatusCode:fT,formToJSON:pT,getAdapter:hT,mergeConfig:mT}=wt,Bl=typeof window<"u"?window.__API_BASE_URL__:void 0,Hl=Bl?En(Bl):void 0;function En(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Ao=null;const ui=new Set;function Ul(){return Ao}function jo(e){Ao=e,ui.forEach(t=>t(e))}function Wl(e){return ui.add(e),()=>ui.delete(e)}const bg=3e4,wg=9e4,Zt=wt.create({...Hl?{baseURL:Hl}:{},timeout:bg,withCredentials:!0});Zt.interceptors.request.use(e=>(Ao&&(e.headers.Authorization=`Bearer ${Ao}`),e)),Zt.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),jo(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 Qt(e,t){return Zt.defaults.baseURL?(await Zt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function di(e,t,n){return Zt.defaults.baseURL?(await Zt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Vl(e,t,n){return Zt.defaults.baseURL?(await Zt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Kl(e,t){return Zt.defaults.baseURL?(await Zt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function en(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class ql{get baseUrl(){const t=Zt.defaults.baseURL;return t?En(String(t)):""}updateConfig(t){t.baseUrl&&(Zt.defaults.baseURL=En(String(t.baseUrl))),t.authToken!==void 0&&jo(t.authToken)}getAuthToken(){return Ul()}setAuthToken(t){jo(t)}onTokenChange(t){return Wl(t)}async listThreads(){const t=await Qt("/threads"),n=en(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await di("/threads",t?{title:t}:void 0);return en(r)}async updateThread(t,n){const r=await Vl(`/threads/${t}`,{title:n});return en(r)}async deleteThread(t){const n=await Kl(`/threads/${t}`);return en(n)}async threadInfo(t){const n=await Qt(`/threads/${t}/info`);return en(n)}async listAgents(){const t=await Qt("/agents"),n=en(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Qt(`/agents/${t}`);return en(n)}async getAgentSchema(t){const n=await Qt(`/agents/${t}/schema`);return en(n)}async getState(t){const n=await Qt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return en(n)}async getStateHistory(t){const n=await Qt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:wg});return en(n)}async cancelRun(t){const n=await di("/runs/cancel",{threadId:t});return en(n)}async listCheckpointSummaries(t){const n=await Qt(`/threads/${t}/state/checkpoints`,{params:{thread_id:t}}),r=en(n);return(r==null?void 0:r.items)??[]}}const Pn=new ql,Gl=w.createContext(null);function Sg({children:e,apiConfig:t}){const n=Pn;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(Gl.Provider,{value:r,children:e})}function fi(){const e=w.useContext(Gl);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function Cg(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 Tg(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const c=await Cg(l);a.push({filename:l.name,data:c,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const kg={human:"user",user:"user",ai:"assistant",assistant:"assistant",tool:"tool",function:"tool",system:"system"};function pi(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 Eg(e,t){return`${e??""}::${t??""}`}function $r(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(!pi(r))return{threadId:n,latest:null,checkpoints:[],interrupt:null,snapshots:{}};const{orderedSnapshots:o,snapshotMap:s}=Ng(t),i=Yl(r,0);return{threadId:n,latest:i,checkpoints:o,interrupt:(i==null?void 0:i.interrupt)??null,snapshots:s}}function Yl(e,t){if(!pi(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(A=>!!A&&typeof A=="object").map(A=>({...A})):a===null?null:void 0,c=r.map((A,N)=>Mg(A,N)).filter(A=>!!A),d=Wt(e.config),f=Wt(d==null?void 0:d.configurable),p=Et(f,["checkpoint_id","checkpointId"]),h=Et(f,["checkpoint_ns","checkpointNs"]),x=Wt(e==null?void 0:e.parentConfig),y=Wt(x==null?void 0:x.configurable),m=Et(y,["checkpoint_id","checkpointId"])??null,g=Et(y,["checkpoint_ns","checkpointNs"])??null,b=e==null?void 0:e.createdAt,S=typeof b=="string"&&b.trim()?b:new Date(Date.now()-t).toISOString(),k=c[c.length-1]??null,T=Wt(e==null?void 0:e.metadata),C=Et(T,["branch_label","branchLabel"]),E=Et(y,["checkpoint_id","checkpointId"]),j=Array.isArray(e.next)?[...e.next]:(e==null?void 0:e.next)===null?null:void 0;return{messages:c,checkpointId:p??null,checkpointNs:h??null,nextCursor:m,nextCursorNs:g,interrupt:Ig(a,c,t),createdAt:S,parentId:E??null,branchLabel:C??null,lastMessageId:(k==null?void 0:k.id)??null,hasMessages:c.length>0,messagesLen:c.length,metadata:T??null,config:d??null,parentConfig:x??null,next:j??null,tasks:l??null,values:i??null}}function Ig(e,t,n){const r=Pg(e,n);return r||Rg(t,n)}function Ng(e){const t=new Map;e.forEach((o,s)=>{if(!pi(o))return;const i=Yl(o,s);if(!(i!=null&&i.checkpointId))return;const a=Eg(i.checkpointId,i.checkpointNs??null),l=t.get(a);if(!l){t.set(a,i);return}t.set(a,Ag(l,i))});const n=Array.from(t.values());n.sort((o,s)=>Jl(s.createdAt??"")-Jl(o.createdAt??""));const r={};for(const[o,s]of t.entries())r[o]=s;return{orderedSnapshots:n,snapshotMap:r}}function Ag(e,t){return{...e,metadata:_o(e.metadata,t.metadata)??null,config:_o(e.config,t.config)??null,parentConfig:_o(e.parentConfig,t.parentConfig)??null,next:jg(e.next,t.next)??null,tasks:_g(e.tasks,t.tasks)??null,values:_o(e.values,t.values)??null}}function _o(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 jg(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 _g(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 Rg(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 Pg(e,t){if(!Array.isArray(e)||!e.length)return null;for(let n=e.length-1;n>=0;n--){const r=Og(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=zr(r.interrupts[s],`${o}-interrupt-${s}`);if(i)return i}if(r.state!==void 0&&r.state!==null){const s=zr(r.state,`${o}-state`);if(s)return s}}return null}function Og(e,t){if(!e)return null;if(Array.isArray(e)){const[a,l,c,,d,,f,...p]=e,h=typeof a=="string"&&a.trim()?a:t,x=typeof l=="string"&&l.trim()?l:Array.isArray(c)&&typeof c[0]=="string"?String(c[0]):"task",y=Array.isArray(d)?d:void 0,m=p.length?p[p.length-1]:void 0;return{id:h,name:x,interrupts:y,state:m!==void 0?m:f}}const n=Wt(e);if(!n)return null;const r=Et(n,["id","task_id","taskId"])??t,o=Et(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 zr(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=Xl(e,t);if(o)return o;if(Array.isArray(e)){for(let s=e.length-1;s>=0;s--){const i=zr(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=zr(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=zr(l,t,n+1,r);if(c)return c}}return null}function Xl(e,t){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){const n=e,r=Et(n,["type","event","kind"]),o=Et(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=Xl(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 Jl(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function Mg(e,t){if(!e||typeof e!="object")return null;const n=e,r=Wt(e)??{},o=Wt(n.data)??r,s=String(n.type??o.type??o.role??"").toLowerCase(),i=kg[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=Wt(o.additional_kwargs)??Wt(o.additionalKwargs),d=Wt(o.response_metadata)??Wt(o.responseMetadata),f=Et(c,["createdAt","created_at"])??Et(o,["created_at","createdAt"]),p=Et(c,["checkpointId","checkpoint_id"]),h=Et(c,["checkpointNs","checkpoint_ns"]),x=Dg(o.content),y={id:l,role:i,content:x};f&&(y.createdAt=f),typeof o.name=="string"&&o.name.trim()&&(y.name=o.name),typeof(d==null?void 0:d.model_name)=="string"&&(y.model=String(d.model_name)),!y.model&&typeof o.model=="string"&&(y.model=o.model),p&&(y.checkpointId=p),h&&(y.checkpointNs=h);const m=zg(c,["createdAt","created_at","checkpointId","checkpoint_id","checkpointNs","checkpoint_ns","tool_calls"]),g=d?{...d}:void 0;m&&Object.keys(m).length&&(y.additionalKwargs=m),g&&Object.keys(g).length&&(y.responseMetadata=g);const b=Lg((c==null?void 0:c.tool_calls)??o.tool_calls);if(b.length&&(y.content=[...y.content,...b]),i==="tool"){const S=Fg(o,y.content);S&&(y.content=S)}return y}function Dg(e){if(!e)return[];if(Array.isArray(e))return e.map(t=>Zl(t)).filter(t=>!!t);if(typeof e=="string")return e.trim()?[{type:"text",text:e.trim()}]:[];if(typeof e=="object"){const t=Zl(e);return t?[t]:[]}return[]}function Zl(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=Et(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=Et(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=Et(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=Et(e,["id","call_id"])??t,r=Et(e,["name"])??Et(Wt(e.function),["name"]);if(!n||!r)return null;const o=$g(e.args??e.arguments??((s=Wt(e.function))==null?void 0:s.arguments));return{type:"tool_call",id:n,name:r,args:o}}function Lg(e){return Array.isArray(e)?e.map((t,n)=>Ql(t,`tool_call_${n}`)).filter(t=>!!t):[]}function Fg(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 $g(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 Wt(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function Et(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r}}function zg(e,t){if(!e)return;const n={};let r=!1;for(const[o,s]of Object.entries(e)){if(t.includes(o)){r=!0;continue}s!==void 0&&(n[o]=s)}return r?Object.keys(n).length?n:void 0:e}function Bg(){const e=w.useRef(new Map),t=w.useCallback((a,l)=>{e.current.set(a,l)},[]),n=w.useCallback((a,l)=>{const c=e.current.get(a);return c==null?void 0:c.find(d=>d.checkpointId===l)},[]),r=w.useCallback((a,l)=>{const c=e.current.get(a);return(c==null?void 0:c.some(d=>d.checkpointId===l))??!1},[]),o=w.useCallback(a=>e.current.get(a),[]),s=w.useCallback(a=>{e.current.delete(a)},[]),i=w.useCallback(()=>{e.current.clear()},[]);return{cache:e.current,setCacheForThread:t,getCachedMetadata:n,checkpointExists:r,getThreadMetadata:o,clearThreadCache:s,clearAllCache:i}}function Hg(e){return e.type!=="thread_info"&&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:hi(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,pendingInterrupt:null};case"seed":{const r=hi(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=hi(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 tc(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>tc(o,s),e):e}case"interrupt_response":return{...e,messages:nc(e.messages),pendingInterrupt:null};default:return e}}function ec(e=[]){const[t,n]=w.useReducer(Wg,{...Ug,messages:e}),r=w.useRef([]),o=w.useRef(null),s=w.useRef(null),i=w.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=w.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=w.useCallback(d=>{r.current.push(d),a()},[a]);w.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=w.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:d=>n({type:"user_message",payload:{message:d}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function tc(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??{},p={...f,[a]:f[a]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:a,messagesStreamMeta:p}}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??rc(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??{},p=f[a]??{lastSeq:null,lastText:ic(d.content)},h=t.seq??null;if(h!==null&&typeof h=="number"&&typeof p.lastSeq=="number"&&h<=p.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:h,lastSeq:p.lastSeq}),e;const{newParts:x,newMeta:y,changed:m}=Vg(d.content,t.delta,p,h);if(!m)return e;const g={...d,content:x},b=Ro(l,c,g),S={...f,[a]:y};return{...e,messages:b,messagesStreamMeta:S}}if(t.type==="message_end"){const a=e.assemblingId??rc(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(p=>{var h;return(p==null?void 0:p.type)==="text"&&((h=p.text)==null?void 0:h.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:d.id,contentTypes:(r=d.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=d.content)==null?void 0:o.map(h=>(h==null?void 0:h.type)==="text"?String(h.text).slice(0,100):h==null?void 0:h.type)});const p=[...l.slice(0,c),...l.slice(c+1)];return{...e,assemblingId:null,messages:p}}}return e}if(t.type==="tool_start"){const a=oc(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=sc(e,d,c),p=f>=0?e.messages[f]:null,h=l??d[0]??`${c}-${Date.now()}`,x=(p==null?void 0:p.id)??`tool-${h}`,y=d[0]??h,m={type:"tool_call",id:y,name:c,args:t.args};if(p){const S=gi(p,d,c,t.args),k={...p,name:p.name??c,additionalKwargs:S},T=f,C=T>=0?Ro(e.messages,T,k):e.messages,E=Po(k,d),j=xi(e.toolIndex,x,E);return{...e,messages:C,toolIndex:j}}const g={id:x,role:"tool",name:c,createdAt:new Date().toISOString(),content:[m],additionalKwargs:gi(void 0,d.length?d:[y],c,t.args)},b=Po(g,d.length?d:[y]);return{...e,messages:[...e.messages,g],toolIndex:xi(e.toolIndex,x,b)}}if(t.type==="tool_end"){const a=oc(t);if(!a.length&&!(typeof t.id=="string"&&t.id))return e;const l=t.name??null,c=sc(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",p=a[0]??((i=d==null?void 0:d.id)==null?void 0:i.replace(/^tool-/,""))??`${f}-${Date.now()}`,h=(d==null?void 0:d.id)??`tool-${p}`,x=Po(d,a);let y=t.output;if(typeof t.output=="string")try{const C=t.output.trim();(C.startsWith("{")||C.startsWith("["))&&(y=JSON.parse(C))}catch{y=t.output}const m={type:"text",text:typeof y=="string"?y:JSON.stringify(y)},g=(d==null?void 0:d.createdAt)??new Date().toISOString(),b=gi(d??void 0,x.length?x:a,f),S={id:h,role:"tool",name:f??(d==null?void 0:d.name)??"tool",content:[m],createdAt:g,additionalKwargs:b},k=c>=0?Ro(e.messages,c,S):[...e.messages,S],T=Po(S,a.length?a:x);return{...e,messages:k,toolIndex:xi(e.toolIndex,h,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=$r(t),l=a.interrupt,c=a.latest,d=l===null?nc(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 e}function hi(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 Ro(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function nc(e){let t=!1;const n=e.map(r=>{const o=(r.content??[]).filter(s=>s.type!=="interrupt");return o.length!==r.content.length?(t=!0,{...r,content:o}):r});return t?n:e}function rc(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function oc(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 mi(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 gi(e,t,n,r){const o=new Set,s=l=>{typeof l=="string"&&l.trim()&&o.add(l.trim())};if(e){const l=mi(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 Po(e,t){const n=new Set;for(const o of t)typeof o=="string"&&o.trim()&&n.add(o.trim());const r=mi(e);for(const o of r)n.add(o);return Array.from(n)}function xi(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 sc(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(mi(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 ic(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??ic(e);let l="",c=e.slice();if(s){const f=Kg(a,s);if(f===""?l="":f===s?l=s:l=f,l){const p=c[c.length-1];if((p==null?void 0:p.type)==="text"){const h=p.text??"",x={...p,text:h+l};c=[...c.slice(0,c.length-1),x]}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 ac(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=ac(e),o=ac(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 Ro(e,r,s)}return e}function Gg(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function lc(e={}){const t=w.useMemo(()=>En(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=w.useState(e.token??null),s=w.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=w.useState(!1),[c,d]=w.useState(null),[f,p]=w.useState(""),[h,x]=w.useState(null),[y,m]=w.useState(0),[g,b]=w.useState(!1),S=w.useRef(null),k=w.useRef(!0),T=w.useRef(0),C=w.useRef(null),E=w.useRef(null),j=w.useRef(null),A=w.useRef(null),N=w.useCallback(R=>{o(R)},[]),P=w.useCallback(()=>{p(""),x(null),d(null),E.current=null,j.current=null,A.current=null},[]),F=w.useCallback(()=>{var R;console.debug("[use-chat] stop() invoked - aborting stream"),(R=S.current)==null||R.abort(),S.current=null,C.current=null,l(!1),b(!1),T.current=0,m(0)},[]),$=w.useCallback((R,z,_)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&p(""),x(null),E.current=null,j.current=null,A.current=null;const B=new AbortController;S.current=B;let L=null,M=null,J=!1;return C.current={threadId:R.threadId??null,headers:{}},(async()=>{var pe,Ne,je,G,ee,W,D,H,te,ae,ne,Le,Q,ie,ke,Re,Ke,ze;const X=$e=>{var qe;try{const Ge=JSON.parse(JSON.stringify($e));return(qe=Ge==null?void 0:Ge.payload)!=null&&qe.files_info&&Array.isArray(Ge.payload.files_info)&&(Ge.payload.files_info=Ge.payload.files_info.map(Qe=>({...Qe,data:Qe!=null&&Qe.data?`<base64 ${String(Qe.data).length} chars>`:Qe==null?void 0:Qe.data}))),Ge}catch{return $e}};try{let $e={};try{if(r)$e={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const he=window.__AUTH_TOKEN__,ot=((pe=window.localStorage)==null?void 0:pe.getItem("authToken"))||null;let jt=null;try{const we=(Ne=window.localStorage)==null?void 0:Ne.getItem("chat-settings");we&&(jt=((je=JSON.parse(we))==null?void 0:je.apiKey)||null)}catch{}const V=he||ot||jt||null;V&&($e={Authorization:`Bearer ${V}`})}}catch{}console.debug("[use-chat] POST",t+n,X(R));let qe={};if(typeof window<"u")try{const xe=(G=window.localStorage)==null?void 0:G.getItem("authSessionId");xe&&(qe={"X-Session-Id":xe})}catch{}const Ge={...$e,...qe,...s.current},Qe={"Content-Type":"application/json",Accept:"text/event-stream",...Ge},Je=await fetch(t+n,{method:"POST",headers:Qe,body:JSON.stringify(R),signal:B.signal,credentials:i});if(C.current&&(C.current.headers=Ge),!Je.ok||!Je.body){const xe=await Je.text().catch(()=>"");console.debug("[use-chat] non-OK response",Je.status,xe==null?void 0:xe.slice(0,500));const he=`stream ${Je.status}${xe?": "+xe:""}`;throw(ee=_==null?void 0:_.onConnectionError)==null||ee.call(_,he),J=!0,L="error",M=he,new Error(he)}b(!0);const rt=Je.body.getReader(),At=new TextDecoder;let ut="",it=[];T.current=0,m(0);let Ct=0,vt=null;const re=()=>{if(it.length){const xe=it.join("");it=[],k.current&&p(he=>he+xe)}vt=null},be=()=>{typeof window<"u"&&vt==null&&(vt=requestAnimationFrame(re))};let Be=Date.now();const He=setInterval(()=>{var xe;if(Date.now()-Be>18e5){const he="Stream idle timeout";d(he),L="error",M=he,B.abort(),(xe=_==null?void 0:_.onError)==null||xe.call(_,he)}},5e3),mt=1024*1024;try{const xe=Je.headers.get("X-Thread-Id")||Je.headers.get("x-thread-id"),he=Je.headers.get("X-Thread-Created")||Je.headers.get("x-thread-created"),ot=xe??null,jt=String(he??"").toLowerCase()==="true";for(C.current&&!C.current.threadId&&(C.current={...C.current,threadId:ot}),(W=_==null?void 0:_.onOpen)==null||W.call(_,{threadId:ot,created:jt});;){const{value:V,done:we}=await rt.read();if(we)break;ut+=At.decode(V,{stream:!0}),ut.length>mt&&(ut="",console.warn("Stream buffer reset: exceeded 1MB"));let ye;for(;(ye=ut.indexOf(`
|
|
36
36
|
|
|
37
|
-
`))>=0;){const ft=ut.slice(0,
|
|
38
|
-
`)}const cc=200;function Jg({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onUnhandledEvent:r,onSequenceGap:o,onStreamClosed:s,onConnectionError:i,onAuthError:a,onHeartbeat:l}){const c=w.useRef(null),d=w.useRef(null),f=w.useRef(new Map),p=w.useRef(null),h=w.useCallback(A=>{try{const N=globalThis.structuredClone;if(typeof N=="function")return N(A)}catch{}try{return JSON.parse(JSON.stringify(A))}catch{return A}},[]),x=w.useCallback((A,N)=>{if(!A)return;const P=f.current.get(A)??[],F=h(N),$=P.length>=cc?[...P.slice(P.length-cc+1),F]:[...P,F];f.current.set(A,$)},[h]),y=w.useCallback(A=>{A&&f.current.set(A,[])},[]),m=w.useCallback(A=>{const N=A??d.current;if(!N)return;const P=f.current.get(N);P!=null&&P.length&&P.forEach(F=>{try{n(F)}catch($){console.error("[useChatStreamingService] Failed to replay buffered event",$)}})},[n]),g=w.useCallback(A=>{var F,$,R,z,_;const N=A.seq??null;if(N!==null){const B=c.current;if(B!==null){if(N<=B)return;N>B+1&&(o==null||o({from:B,to:N}))}c.current=N}if(A.type==="thread_info"){d.current=A.threadId,p.current&&(p.current.threadIdGuess=A.threadId),y(A.threadId),console.log("[useChatStreamingService] 🎯 Received thread_info event:",A);try{t(A)}catch(B){console.error("[useChatStreamingService] Error in onThreadInfo handler:",B)}return}if(A.type==="heartbeat"){try{l==null||l(A)}catch(B){console.error("[useChatStreamingService] Error in onHeartbeat handler:",B)}return}if(A.type==="error"){const B=A;if(B.error_type==="auth_error"||B.code==="TOKEN_EXPIRED"||((F=B.message)==null?void 0:F.includes("token"))||(($=B.message)==null?void 0:$.includes("401"))||((R=B.message)==null?void 0:R.includes("unauthorized"))||((z=B.message)==null?void 0:z.includes("Unauthorized"))){console.error("[useChatStreamingService] Auth error event detected:",B.message);try{a==null||a(B.message)}catch(M){console.warn("[useChatStreamingService] onAuthError handler failed",M)}}}const P=A.threadId??(A.type==="state_history"?A.threadId:void 0)??d.current??((_=p.current)==null?void 0:_.threadIdGuess)??null;if(A.type==="state_history"&&(d.current=P??d.current),Hg(A)){A.type==="checkpoint"||A.type==="state_history"?y(P??null):x(P??null,A);try{n(A)}catch(B){console.error("[useChatStreamingService] Error in onMessageEvent handler:",B)}return}try{r==null||r(A)}catch(B){console.error("[useChatStreamingService] Error in onUnhandledEvent handler:",B)}},[x,y,n,o,t,r]),{stream:b,stop:S,isStreaming:k,error:T,setToken:C}=lc({baseUrl:e,token:void 0}),E=w.useCallback((A,N)=>{c.current=null,d.current=A.threadId??null,p.current={request:A,callbacks:N,manualStop:!1,threadIdGuess:A.threadId??null},b(A,g,{onOpen:N==null?void 0:N.onOpen,onError:P=>{var F;(F=N==null?void 0:N.onError)==null||F.call(N,P)},onGap:(N==null?void 0:N.onGap)??o,onConnectionError:P=>{var F;i==null||i(P),(F=N==null?void 0:N.onConnectionError)==null||F.call(N,P)},onAuthError:P=>{var F;a==null||a(P),(F=N==null?void 0:N.onAuthError)==null||F.call(N,P)},onHeartbeat:P=>{var F;try{l==null||l(P)}catch($){console.warn("[useChatStreamingService] onHeartbeat handler failed",$)}try{(F=N==null?void 0:N.onHeartbeat)==null||F.call(N,P)}catch($){console.warn("[useChatStreamingService] downstream onHeartbeat handler failed",$)}},onClosed:P=>{var z,_,B,L;const F=((z=p.current)==null?void 0:z.manualStop)??!1,$=d.current??((_=p.current)==null?void 0:_.threadIdGuess)??((B=P.lastStateHistory)==null?void 0:B.threadId)??null;(P.reason==="complete"||P.reason==="aborted"&&F)&&y($);const R={...P,threadId:$,manualStop:F};try{s==null||s(R)}catch(M){console.warn("[useChatStreamingService] onStreamClosed handler failed",M)}try{(L=N==null?void 0:N.onClosed)==null||L.call(N,R)}catch(M){console.warn("[useChatStreamingService] downstream onClosed handler failed",M)}p.current&&(p.current=null)}})},[y,g,a,i,l,o,s,b]),j=w.useCallback(()=>{p.current&&(p.current.manualStop=!0),S()},[S]);return w.useMemo(()=>({startStream:E,stop:j,isStreaming:k,error:T,setAuthToken:C,replayBufferedEvents:m}),[E,j,k,T,C,m])}const uc=w.createContext(null),dc=w.createContext(null),fc=w.createContext(null);w.createContext(!1);function Zg({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,disableAutoRestore:s=!1,enableFileAgentRouting:i=!1,fileAgentId:a="invoice_reader",onError:l,onAuthError:c,onThreadChange:d}){const{api:f,baseUrl:p}=fi(),h=w.useMemo(()=>En(p),[p]),[x,y]=w.useState([]),[m,g]=w.useState(t),[b,S]=w.useState(!1),[k,T]=w.useState(null),[C,E]=w.useState(!1),[j,A]=w.useState(null),{state:N,seed:P,prepend:F,pushUser:$,onEvent:R}=ec(),[z,_]=w.useState(!1),[B,L]=w.useState(!1),[M,J]=w.useState(null),[X,pe]=w.useState([]),[Ie,je]=w.useState(!1),{setCacheForThread:G,checkpointExists:ee}=Bg(),W=w.useRef(m),D=w.useRef(null);w.useEffect(()=>{W.current=m},[m]);const H=w.useRef(),{startStream:te,stop:ae,isStreaming:ne,error:Fe,setAuthToken:Q}=Jg({baseUrl:h,onThreadInfo:re=>{console.log("[ChatSessionProvider] Thread info:",re.threadId),W.current!==re.threadId&&g(re.threadId)},onMessageEvent:R,onUnhandledEvent:re=>{console.warn("[ChatSessionProvider] Unhandled event:",re.type)},onAuthError:c}),ie=w.useCallback(async()=>{S(!0),T(null);try{const re=await f.listThreads();y(re??[])}catch(re){const Te=String(re);T(Te),l==null||l(Te)}finally{S(!1)}},[f,l]),Ce=w.useCallback(async re=>{try{const Te=await f.createThread(re);return g(Te.threadId),await ie(),Te.threadId}catch(Te){return l==null||l(String(Te)),null}},[f,ie,l]),Re=w.useCallback(async re=>{try{await f.deleteThread(re),W.current===re&&(g(null),P([],{})),await ie()}catch(Te){l==null||l(String(Te))}},[f,ie,P,l]),Ke=w.useCallback(async(re,Te)=>{try{await f.updateThread(re,Te),await ie()}catch(Ve){l==null||l(String(Ve))}},[f,ie,l]),Be=w.useCallback(async(re,Te)=>{if(re){E(!0),A(null);try{const Ve=await f.getStateHistory({threadId:re,checkpointId:Te}),{latest:Oe,checkpoints:ot}=$r(Ve),Ne=ot.filter(ye=>ye.checkpointId).map(ye=>({checkpointId:ye.checkpointId,checkpointNs:ye.checkpointNs??void 0,createdAt:ye.createdAt??""}));G(re,Ne),P((Oe==null?void 0:Oe.messages)??[],{checkpointId:(Oe==null?void 0:Oe.checkpointId)??null,checkpointNs:(Oe==null?void 0:Oe.checkpointNs)??null}),pe(ot),_(!!(Oe!=null&&Oe.nextCursor)),J((Oe==null?void 0:Oe.nextCursor)??null)}catch(Ve){const Oe=String(Ve);A(Oe),l==null||l(Oe)}finally{E(!1)}}},[f,P,l,G]);w.useEffect(()=>{H.current=Be},[Be]);const ze=w.useCallback(async(re,Te)=>{const Ve=W.current;if(Ve){je(!0);try{const Oe=await f.getStateHistory({threadId:Ve,checkpointId:re,checkpointNs:Te??void 0}),{checkpoints:ot}=$r(Oe),Ne=ot.find(ye=>ye.checkpointId===re&&(Te?ye.checkpointNs===Te:!0));if(!Ne){console.warn("[ChatSessionProvider] Requested checkpoint not found in response:",{checkpointId:re,checkpointNs:Te});return}P((Ne==null?void 0:Ne.messages)??[],{checkpointId:(Ne==null?void 0:Ne.checkpointId)??null,checkpointNs:(Ne==null?void 0:Ne.checkpointNs)??null})}catch(Oe){l==null||l(String(Oe))}finally{je(!1)}}},[f,P,l]),qe=w.useCallback((re,Te)=>{P(N.messages,{checkpointId:re??null,checkpointNs:Te??null})},[P,N.messages]),Ge=w.useCallback(async()=>{W.current&&await Be(W.current)},[Be]),Qe=w.useCallback(async()=>{if(!(!W.current||!M)){L(!0);try{const re=await f.getStateHistory({threadId:W.current,checkpointId:M}),{checkpoints:Te}=$r(re);if(Te.length>0){const Ve=Te[Te.length-1];F((Ve==null?void 0:Ve.messages)??[]),_(!!(Ve!=null&&Ve.nextCursor)),J((Ve==null?void 0:Ve.nextCursor)??null)}}catch(re){l==null||l(String(re))}finally{L(!1)}}},[f,M,F,l]),Je=w.useCallback(async()=>{P([],{}),pe([]),_(!1),J(null)},[P]),rt=w.useCallback(async(re,Te)=>{console.log("[ChatSessionProvider] Interrupt:",re,Te)},[]);w.useEffect(()=>{ie()},[ie]);const wt=w.useRef();w.useEffect(()=>{wt.current=ze},[ze]),w.useEffect(()=>{var Ne;if(!o||!m||C===!0||D.current===m)return;D.current=m;const re=localStorage.getItem("lastCheckpointId"),Te=localStorage.getItem("lastCheckpointNs"),Ve=n,Oe=r;(Ne=H.current)==null||Ne.call(H,m);let ot={id:re,ns:Te};if(ot.id||(ot={id:Ve,ns:Oe}),ot.id&&ee(m,ot.id)){const ye=setTimeout(()=>{var vt;ee(m,ot.id)&&((vt=wt.current)==null||vt.call(wt,ot.id,ot.ns??void 0))},50);return()=>clearTimeout(ye)}},[o,m,C,ee,n,r]),w.useEffect(()=>{d==null||d(m)},[m,d]),w.useEffect(()=>{N.lastCheckpointId&&(localStorage.setItem("lastCheckpointId",N.lastCheckpointId),N.lastCheckpointNs&&localStorage.setItem("lastCheckpointNs",N.lastCheckpointNs))},[N.lastCheckpointId,N.lastCheckpointNs]);const ut=w.useCallback(async(re,Te)=>{const Ve=W.current,Oe=(re==null?void 0:re.text)??"";if(!Ve&&!Oe)return;if(!Ve){await Ce("New Chat");return}const{contentParts:ot}=await Tg(f,(re==null?void 0:re.attachments)??[]),Ne=[...ot];Oe!=null&&Oe.trim()&&Ne.push({type:"text",text:Oe});const ye={id:`msg-${Date.now()}`,role:"user",content:Ne,createdAt:new Date().toISOString()};$(ye);const vt={threadId:Ve,checkpointId:(Te==null?void 0:Te.checkpointId)??N.lastCheckpointId??void 0,checkpointNs:(Te==null?void 0:Te.checkpointNs)??N.lastCheckpointNs??void 0};te(vt)},[f,Ce,$,N,te]),it=w.useMemo(()=>({threads:x,currentThreadId:m,setCurrentThreadId:g,isLoading:b,error:k,actions:{createThread:Ce,deleteThread:Re,renameThread:Ke,refreshThreads:ie}}),[x,m,b,k,Ce,Re,Ke,ie]),Tt=w.useMemo(()=>({threadId:m,messages:N.messages,interrupt:null,checkpoint:{id:N.lastCheckpointId??null,namespace:N.lastCheckpointNs??null},checkpoints:X,metadata:null,isLoading:C,isHistoryLoading:B,isLoadingCheckpoint:Ie,error:j,hasMore:z,loadOlder:Qe,clearState:Je,navigateToCheckpoint:ze,setCurrentCheckpointId:qe,returnToLatest:Ge,loadThread:Be,clearThread:Je,respondToInterrupt:rt}),[m,N,X,C,B,Ie,j,z,Qe,Je,ze,qe,Ge,Be,rt]),yt=w.useMemo(()=>({isStreaming:ne,error:Fe,connectionState:ne?"connected":"idle",submit:ut,send:ut,stop:ae,setAuthToken:Q}),[ne,Fe,ut,ae,Q]);return u.jsx(uc.Provider,{value:it,children:u.jsx(dc.Provider,{value:Tt,children:u.jsx(fc.Provider,{value:yt,children:e})})})}function Oo(){const e=w.useContext(uc);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Mo(){const e=w.useContext(dc);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function pc(){const e=w.useContext(fc);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function Do({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onError:i,onAuthError:a,onThreadChange:l}){return u.jsx(Sg,{apiConfig:t,children:u.jsx(Zg,{initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:i,onAuthError:a,onThreadChange:l,children:e})})}function Z(...e){return Yh.twMerge(Gh.clsx(e))}const Qg=xo.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"}}),tt=v.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Yn.Slot:"button";return u.jsx(i,{className:Z(Qg({variant:t,size:n,className:e})),ref:s,...o})});tt.displayName="Button";const hc=v.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:Z("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}));hc.displayName="Textarea";function mc({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:p="",allowEmptySend:h=!1}){const x=i!==void 0,[y,m]=w.useState(e),g=(x?i:y)??"",[b,S]=w.useTransition(),k=w.useRef(null),T=w.useRef(0),C=w.useRef(null);w.useEffect(()=>{x||(m(e??""),C.current=null,k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`))},[e,t,x]);const E=w.useCallback(()=>{const z=k.current;z&&(z.style.height="auto",z.style.height=`${z.scrollHeight}px`)},[]);w.useEffect(()=>{E()},[E,g]);const j=w.useCallback((z,{fromUser:_})=>{x||m(z),_&&(a==null||a(z))},[x,a]),A=w.useCallback(async z=>{z&&z.preventDefault();const _=(g??"").trim();if(!_&&!h)return;const B=++T.current;C.current={id:B,shouldClear:!0},S(()=>{var L,M,J;try{const X=l(_);X&&typeof X.then=="function"?X.then(()=>{var pe,Ie;((pe=C.current)==null?void 0:pe.id)===B&&C.current.shouldClear&&(x||(m(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((Ie=C.current)==null?void 0:Ie.id)===B&&(C.current=null)}).catch(()=>{var pe;((pe=C.current)==null?void 0:pe.id)===B&&(C.current=null)}):(((L=C.current)==null?void 0:L.id)===B&&C.current.shouldClear&&(x||(m(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((M=C.current)==null?void 0:M.id)===B&&(C.current=null))}catch{((J=C.current)==null?void 0:J.id)===B&&(C.current=null)}})},[g,l,h,x,a]),N=w.useCallback(z=>{const _=z.target.value;j(_,{fromUser:!0}),C.current&&(C.current.shouldClear=!1),k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`)},[j]),P=w.useCallback(z=>{z.key==="Enter"&&!z.shiftKey?(z.preventDefault(),A()):z.key==="Escape"&&t&&(z.preventDefault(),c==null||c())},[A,t,c]),R=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${p}`;return u.jsx("form",{onSubmit:z=>void A(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(hc,{ref:k,value:g,onChange:N,onKeyDown:P,placeholder:t?"Edit your message...":n,className:R,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),u.jsx("div",{children:r?u.jsx(tt,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(se.Square,{size:16})}):u.jsx(tt,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!g.trim()&&!h||b,children:u.jsx(se.Send,{size:16})})})]})})}const ex=w.memo(mc);function fe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function gc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function yi(...e){return t=>{let n=!1;const r=e.map(o=>{const s=gc(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():gc(e[o],null)}}}}function Ue(...e){return v.useCallback(yi(...e),e)}function tx(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 In(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:p,children:h,...x}=f,y=((g=p==null?void 0:p[e])==null?void 0:g[l])||a,m=v.useMemo(()=>x,Object.values(x));return u.jsx(y.Provider,{value:m,children:h})};c.displayName=s+"Provider";function d(f,p){var y;const h=((y=p==null?void 0:p[e])==null?void 0:y[l])||a,x=v.useContext(h);if(x)return x;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,nx(o,...t)]}function nx(...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 _t=globalThis!=null&&globalThis.document?v.useLayoutEffect:()=>{},rx=v[" useInsertionEffect ".trim().toString()]||_t;function xr({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=ox({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 p=sx(d)?d(e):d;p!==e&&((f=i.current)==null||f.call(i,p))}else s(d)},[a,e,s,i]);return[l,c]}function ox({defaultProp:e,onChange:t}){const[n,r]=v.useState(e),o=v.useRef(n),s=v.useRef(t);return rx(()=>{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 sx(e){return typeof e=="function"}var ix=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],_e=ix.reduce((e,t)=>{const n=Yn.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 xc(e,t){e&&yo.flushSync(()=>e.dispatchEvent(t))}function vi(e){const t=e+"CollectionProvider",[n,r]=In(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=y=>{const{scope:m,children:g}=y,b=w.useRef(null),S=w.useRef(new Map).current;return u.jsx(o,{scope:m,itemMap:S,collectionRef:b,children:g})};i.displayName=t;const a=e+"CollectionSlot",l=Yn.createSlot(a),c=w.forwardRef((y,m)=>{const{scope:g,children:b}=y,S=s(a,g),k=Ue(m,S.collectionRef);return u.jsx(l,{ref:k,children:b})});c.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",p=Yn.createSlot(d),h=w.forwardRef((y,m)=>{const{scope:g,children:b,...S}=y,k=w.useRef(null),T=Ue(m,k),C=s(d,g);return w.useEffect(()=>(C.itemMap.set(k,{ref:k,...S}),()=>void C.itemMap.delete(k))),u.jsx(p,{[f]:"",ref:T,children:b})});h.displayName=d;function x(y){const m=s(e+"CollectionConsumer",y);return w.useCallback(()=>{const b=m.collectionRef.current;if(!b)return[];const S=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(m.itemMap.values()).sort((C,E)=>S.indexOf(C.ref.current)-S.indexOf(E.ref.current))},[m.collectionRef,m.itemMap])}return[{Provider:i,Slot:c,ItemSlot:h},x,r]}var ax=v.createContext(void 0);function Lo(e){const t=v.useContext(ax);return e||t||"ltr"}function Rt(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 lx(e,t=globalThis==null?void 0:globalThis.document){const n=Rt(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 cx="DismissableLayer",bi="dismissableLayer.update",ux="dismissableLayer.pointerDownOutside",dx="dismissableLayer.focusOutside",yc,vc=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Fo=v.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=v.useContext(vc),[d,f]=v.useState(null),p=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,h]=v.useState({}),x=Ue(t,E=>f(E)),y=Array.from(c.layers),[m]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),g=y.indexOf(m),b=d?y.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=b>=g,T=hx(E=>{const j=E.target,A=[...c.branches].some(N=>N.contains(j));!k||A||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},p),C=mx(E=>{const j=E.target;[...c.branches].some(N=>N.contains(j))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},p);return lx(E=>{b===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},p),v.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(yc=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),bc(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=yc)}},[d,p,n,c]),v.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),bc())},[d,c]),v.useEffect(()=>{const E=()=>h({});return document.addEventListener(bi,E),()=>document.removeEventListener(bi,E)},[]),u.jsx(_e.div,{...l,ref:x,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:fe(e.onFocusCapture,C.onFocusCapture),onBlurCapture:fe(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:fe(e.onPointerDownCapture,T.onPointerDownCapture)})});Fo.displayName=cx;var fx="DismissableLayerBranch",px=v.forwardRef((e,t)=>{const n=v.useContext(vc),r=v.useRef(null),o=Ue(t,r);return v.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(_e.div,{...e,ref:o})});px.displayName=fx;function hx(e,t=globalThis==null?void 0:globalThis.document){const n=Rt(e),r=v.useRef(!1),o=v.useRef(()=>{});return v.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){wc(ux,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 mx(e,t=globalThis==null?void 0:globalThis.document){const n=Rt(e),r=v.useRef(!1);return v.useEffect(()=>{const o=s=>{s.target&&!r.current&&wc(dx,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 bc(){const e=new CustomEvent(bi);document.dispatchEvent(e)}function wc(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?xc(o,s):o.dispatchEvent(s)}var wi=0;function Si(){v.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Sc()),document.body.insertAdjacentElement("beforeend",e[1]??Sc()),wi++,()=>{wi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),wi--}},[])}function Sc(){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 Ci="focusScope.autoFocusOnMount",Ti="focusScope.autoFocusOnUnmount",Cc={bubbles:!1,cancelable:!0},gx="FocusScope",$o=v.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=v.useState(null),c=Rt(o),d=Rt(s),f=v.useRef(null),p=Ue(t,y=>l(y)),h=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(r){let y=function(S){if(h.paused||!a)return;const k=S.target;a.contains(k)?f.current=k:On(f.current,{select:!0})},m=function(S){if(h.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||On(f.current,{select:!0}))},g=function(S){if(document.activeElement===document.body)for(const T of S)T.removedNodes.length>0&&On(a)};document.addEventListener("focusin",y),document.addEventListener("focusout",m);const b=new MutationObserver(g);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",m),b.disconnect()}}},[r,a,h.paused]),v.useEffect(()=>{if(a){Ec.add(h);const y=document.activeElement;if(!a.contains(y)){const g=new CustomEvent(Ci,Cc);a.addEventListener(Ci,c),a.dispatchEvent(g),g.defaultPrevented||(xx(Sx(Tc(a)),{select:!0}),document.activeElement===y&&On(a))}return()=>{a.removeEventListener(Ci,c),setTimeout(()=>{const g=new CustomEvent(Ti,Cc);a.addEventListener(Ti,d),a.dispatchEvent(g),g.defaultPrevented||On(y??document.body,{select:!0}),a.removeEventListener(Ti,d),Ec.remove(h)},0)}}},[a,c,d,h]);const x=v.useCallback(y=>{if(!n&&!r||h.paused)return;const m=y.key==="Tab"&&!y.altKey&&!y.ctrlKey&&!y.metaKey,g=document.activeElement;if(m&&g){const b=y.currentTarget,[S,k]=yx(b);S&&k?!y.shiftKey&&g===k?(y.preventDefault(),n&&On(S,{select:!0})):y.shiftKey&&g===S&&(y.preventDefault(),n&&On(k,{select:!0})):g===b&&y.preventDefault()}},[n,r,h.paused]);return u.jsx(_e.div,{tabIndex:-1,...i,ref:p,onKeyDown:x})});$o.displayName=gx;function xx(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(On(r,{select:t}),document.activeElement!==n)return}function yx(e){const t=Tc(e),n=kc(t,e),r=kc(t.reverse(),e);return[n,r]}function Tc(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 kc(e,t){for(const n of e)if(!vx(n,{upTo:t}))return n}function vx(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 bx(e){return e instanceof HTMLInputElement&&"select"in e}function On(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&bx(e)&&t&&e.select()}}var Ec=wx();function wx(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Ic(e,t),e.unshift(t)},remove(t){var n;e=Ic(e,t),(n=e[0])==null||n.resume()}}}function Ic(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Sx(e){return e.filter(t=>t.tagName!=="A")}var Cx=v[" useId ".trim().toString()]||(()=>{}),Tx=0;function Nn(e){const[t,n]=v.useState(Cx());return _t(()=>{n(r=>r??String(Tx++))},[e]),t?`radix-${t}`:""}const kx=["top","right","bottom","left"],Mn=Math.min,Gt=Math.max,zo=Math.round,Bo=Math.floor,xn=e=>({x:e,y:e}),Ex={left:"right",right:"left",bottom:"top",top:"bottom"},Ix={start:"end",end:"start"};function ki(e,t,n){return Gt(e,Mn(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function jn(e){return e.split("-")[0]}function yr(e){return e.split("-")[1]}function Ei(e){return e==="x"?"y":"x"}function Ii(e){return e==="y"?"height":"width"}const Nx=new Set(["top","bottom"]);function yn(e){return Nx.has(jn(e))?"y":"x"}function Ni(e){return Ei(yn(e))}function Ax(e,t,n){n===void 0&&(n=!1);const r=yr(e),o=Ni(e),s=Ii(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Ho(i)),[i,Ho(i)]}function jx(e){const t=Ho(e);return[Ai(e),t,Ai(t)]}function Ai(e){return e.replace(/start|end/g,t=>Ix[t])}const Nc=["left","right"],Ac=["right","left"],_x=["top","bottom"],Rx=["bottom","top"];function Px(e,t,n){switch(e){case"top":case"bottom":return n?t?Ac:Nc:t?Nc:Ac;case"left":case"right":return t?_x:Rx;default:return[]}}function Ox(e,t,n,r){const o=yr(e);let s=Px(jn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ai)))),s}function Ho(e){return e.replace(/left|right|bottom|top/g,t=>Ex[t])}function Mx(e){return{top:0,right:0,bottom:0,left:0,...e}}function jc(e){return typeof e!="number"?Mx(e):{top:e,right:e,bottom:e,left:e}}function Uo(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 _c(e,t,n){let{reference:r,floating:o}=e;const s=yn(t),i=Ni(t),a=Ii(i),l=jn(t),c=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,p=r[a]/2-o[a]/2;let h;switch(l){case"top":h={x:d,y:r.y-o.height};break;case"bottom":h={x:d,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-o.width,y:f};break;default:h={x:r.x,y:r.y}}switch(yr(t)){case"start":h[i]-=p*(n&&c?-1:1);break;case"end":h[i]+=p*(n&&c?-1:1);break}return h}const Dx=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}=_c(c,r,l),p=r,h={},x=0;for(let y=0;y<a.length;y++){const{name:m,fn:g}=a[y],{x:b,y:S,data:k,reset:T}=await g({x:d,y:f,initialPlacement:r,placement:p,strategy:o,middlewareData:h,rects:c,platform:i,elements:{reference:e,floating:t}});d=b??d,f=S??f,h={...h,[m]:{...h[m],...k}},T&&x<=50&&(x++,typeof T=="object"&&(T.placement&&(p=T.placement),T.rects&&(c=T.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:d,y:f}=_c(c,p,l)),y=-1)}return{x:d,y:f,placement:p,strategy:o,middlewareData:h}};async function Br(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:p=!1,padding:h=0}=An(t,e),x=jc(h),m=a[p?f==="floating"?"reference":"floating":f],g=Uo(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(m)))==null||n?m:m.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},T=Uo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(g.top-T.top+x.top)/k.y,bottom:(T.bottom-g.bottom+x.bottom)/k.y,left:(g.left-T.left+x.left)/k.x,right:(T.right-g.right+x.right)/k.x}}const Lx=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}=An(e,t)||{};if(c==null)return{};const f=jc(d),p={x:n,y:r},h=Ni(o),x=Ii(h),y=await i.getDimensions(c),m=h==="y",g=m?"top":"left",b=m?"bottom":"right",S=m?"clientHeight":"clientWidth",k=s.reference[x]+s.reference[h]-p[h]-s.floating[x],T=p[h]-s.reference[h],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[x]);const j=k/2-T/2,A=E/2-y[x]/2-1,N=Mn(f[g],A),P=Mn(f[b],A),F=N,$=E-y[x]-P,R=E/2-y[x]/2+j,z=ki(F,R,$),_=!l.arrow&&yr(o)!=null&&R!==z&&s.reference[x]/2-(R<F?N:P)-y[x]/2<0,B=_?R<F?R-F:R-$:0;return{[h]:p[h]+B,data:{[h]:z,centerOffset:R-z-B,..._&&{alignmentOffset:B}},reset:_}}}),Fx=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:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:y=!0,...m}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const g=jn(o),b=yn(a),S=jn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),T=p||(S||!y?[Ho(a)]:jx(a)),C=x!=="none";!p&&C&&T.push(...Ox(a,y,x,k));const E=[a,...T],j=await Br(t,m),A=[];let N=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&A.push(j[g]),f){const R=Ax(o,i,k);A.push(j[R[0]],j[R[1]])}if(N=[...N,{placement:o,overflows:A}],!A.every(R=>R<=0)){var P,F;const R=(((P=s.flip)==null?void 0:P.index)||0)+1,z=E[R];if(z&&(!(f==="alignment"?b!==yn(z):!1)||N.every(L=>yn(L.placement)===b?L.overflows[0]>0:!0)))return{data:{index:R,overflows:N},reset:{placement:z}};let _=(F=N.filter(B=>B.overflows[0]<=0).sort((B,L)=>B.overflows[1]-L.overflows[1])[0])==null?void 0:F.placement;if(!_)switch(h){case"bestFit":{var $;const B=($=N.filter(L=>{if(C){const M=yn(L.placement);return M===b||M==="y"}return!0}).map(L=>[L.placement,L.overflows.filter(M=>M>0).reduce((M,J)=>M+J,0)]).sort((L,M)=>L[1]-M[1])[0])==null?void 0:$[0];B&&(_=B);break}case"initialPlacement":_=a;break}if(o!==_)return{reset:{placement:_}}}return{}}}};function Rc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Pc(e){return kx.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}=An(e,t);switch(r){case"referenceHidden":{const s=await Br(t,{...o,elementContext:"reference"}),i=Rc(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Pc(i)}}}case"escaped":{const s=await Br(t,{...o,altBoundary:!0}),i=Rc(s,n.floating);return{data:{escapedOffsets:i,escaped:Pc(i)}}}default:return{}}}}},Oc=new Set(["left","top"]);async function zx(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=jn(n),a=yr(n),l=yn(n)==="y",c=Oc.has(i)?-1:1,d=s&&l?-1:1,f=An(t,e);let{mainAxis:p,crossAxis:h,alignmentAxis:x}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof x=="number"&&(h=a==="end"?x*-1:x),l?{x:h*d,y:p*c}:{x:p*c,y:h*d}}const Bx=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 zx(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}}}}},Hx=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:m=>{let{x:g,y:b}=m;return{x:g,y:b}}},...l}=An(e,t),c={x:n,y:r},d=await Br(t,l),f=yn(jn(o)),p=Ei(f);let h=c[p],x=c[f];if(s){const m=p==="y"?"top":"left",g=p==="y"?"bottom":"right",b=h+d[m],S=h-d[g];h=ki(b,h,S)}if(i){const m=f==="y"?"top":"left",g=f==="y"?"bottom":"right",b=x+d[m],S=x-d[g];x=ki(b,x,S)}const y=a.fn({...t,[p]:h,[f]:x});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[p]:s,[f]:i}}}}}},Ux=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}=An(e,t),d={x:n,y:r},f=yn(o),p=Ei(f);let h=d[p],x=d[f];const y=An(a,t),m=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(l){const S=p==="y"?"height":"width",k=s.reference[p]-s.floating[S]+m.mainAxis,T=s.reference[p]+s.reference[S]-m.mainAxis;h<k?h=k:h>T&&(h=T)}if(c){var g,b;const S=p==="y"?"width":"height",k=Oc.has(jn(o)),T=s.reference[f]-s.floating[S]+(k&&((g=i.offset)==null?void 0:g[f])||0)+(k?0:m.crossAxis),C=s.reference[f]+s.reference[S]+(k?0:((b=i.offset)==null?void 0:b[f])||0)-(k?m.crossAxis:0);x<T?x=T:x>C&&(x=C)}return{[p]:h,[f]:x}}}},Wx=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}=An(e,t),d=await Br(t,c),f=jn(o),p=yr(o),h=yn(o)==="y",{width:x,height:y}=s.floating;let m,g;f==="top"||f==="bottom"?(m=f,g=p===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(g=f,m=p==="end"?"top":"bottom");const b=y-d.top-d.bottom,S=x-d.left-d.right,k=Mn(y-d[m],b),T=Mn(x-d[g],S),C=!t.middlewareData.shift;let E=k,j=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),C&&!p){const N=Gt(d.left,0),P=Gt(d.right,0),F=Gt(d.top,0),$=Gt(d.bottom,0);h?j=x-2*(N!==0||P!==0?N+P:Gt(d.left,d.right)):E=y-2*(F!==0||$!==0?F+$:Gt(d.top,d.bottom))}await l({...t,availableWidth:j,availableHeight:E});const A=await i.getDimensions(a.floating);return x!==A.width||y!==A.height?{reset:{rects:!0}}:{}}}};function Wo(){return typeof window<"u"}function vr(e){return Mc(e)?(e.nodeName||"").toLowerCase():"#document"}function Yt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function vn(e){var t;return(t=(Mc(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Mc(e){return Wo()?e instanceof Node||e instanceof Yt(e).Node:!1}function un(e){return Wo()?e instanceof Element||e instanceof Yt(e).Element:!1}function bn(e){return Wo()?e instanceof HTMLElement||e instanceof Yt(e).HTMLElement:!1}function Dc(e){return!Wo()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Yt(e).ShadowRoot}const Vx=new Set(["inline","contents"]);function Hr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=dn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Vx.has(o)}const Kx=new Set(["table","td","th"]);function qx(e){return Kx.has(vr(e))}const Gx=[":popover-open",":modal"];function Vo(e){return Gx.some(t=>{try{return e.matches(t)}catch{return!1}})}const Yx=["transform","translate","scale","rotate","perspective"],Xx=["transform","translate","scale","rotate","perspective","filter"],Jx=["paint","layout","strict","content"];function ji(e){const t=_i(),n=un(e)?dn(e):e;return Yx.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)||Xx.some(r=>(n.willChange||"").includes(r))||Jx.some(r=>(n.contain||"").includes(r))}function Zx(e){let t=Dn(e);for(;bn(t)&&!br(t);){if(ji(t))return t;if(Vo(t))return null;t=Dn(t)}return null}function _i(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Qx=new Set(["html","body","#document"]);function br(e){return Qx.has(vr(e))}function dn(e){return Yt(e).getComputedStyle(e)}function Ko(e){return un(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Dn(e){if(vr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Dc(e)&&e.host||vn(e);return Dc(t)?t.host:t}function Lc(e){const t=Dn(e);return br(t)?e.ownerDocument?e.ownerDocument.body:e.body:bn(t)&&Hr(t)?t:Lc(t)}function Ur(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Lc(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Yt(o);if(s){const a=Ri(i);return t.concat(i,i.visualViewport||[],Hr(o)?o:[],a&&n?Ur(a):[])}return t.concat(o,Ur(o,[],n))}function Ri(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Fc(e){const t=dn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=bn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=zo(n)!==s||zo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Pi(e){return un(e)?e:e.contextElement}function wr(e){const t=Pi(e);if(!bn(t))return xn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Fc(t);let i=(s?zo(n.width):n.width)/r,a=(s?zo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const ey=xn(0);function $c(e){const t=Yt(e);return!_i()||!t.visualViewport?ey:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function ty(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Yt(e)?!1:t}function Qn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Pi(e);let i=xn(1);t&&(r?un(r)&&(i=wr(r)):i=wr(e));const a=ty(s,n,r)?$c(s):xn(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 p=Yt(s),h=r&&un(r)?Yt(r):r;let x=p,y=Ri(x);for(;y&&r&&h!==x;){const m=wr(y),g=y.getBoundingClientRect(),b=dn(y),S=g.left+(y.clientLeft+parseFloat(b.paddingLeft))*m.x,k=g.top+(y.clientTop+parseFloat(b.paddingTop))*m.y;l*=m.x,c*=m.y,d*=m.x,f*=m.y,l+=S,c+=k,x=Yt(y),y=Ri(x)}}return Uo({width:d,height:f,x:l,y:c})}function qo(e,t){const n=Ko(e).scrollLeft;return t?t.left+n:Qn(vn(e)).left+n}function zc(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-qo(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function ny(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=vn(r),a=t?Vo(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=xn(1);const d=xn(0),f=bn(r);if((f||!f&&!s)&&((vr(r)!=="body"||Hr(i))&&(l=Ko(r)),bn(r))){const h=Qn(r);c=wr(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}const p=i&&!f&&!s?zc(i,l):xn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+p.x,y:n.y*c.y-l.scrollTop*c.y+d.y+p.y}}function ry(e){return Array.from(e.getClientRects())}function oy(e){const t=vn(e),n=Ko(e),r=e.ownerDocument.body,o=Gt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Gt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+qo(e);const a=-n.scrollTop;return dn(r).direction==="rtl"&&(i+=Gt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Bc=25;function sy(e,t){const n=Yt(e),r=vn(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=_i();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=qo(r);if(c<=0){const d=r.ownerDocument,f=d.body,p=getComputedStyle(f),h=d.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,x=Math.abs(r.clientWidth-f.clientWidth-h);x<=Bc&&(s-=x)}else c<=Bc&&(s+=c);return{width:s,height:i,x:a,y:l}}const iy=new Set(["absolute","fixed"]);function ay(e,t){const n=Qn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=bn(e)?wr(e):xn(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 Hc(e,t,n){let r;if(t==="viewport")r=sy(e,n);else if(t==="document")r=oy(vn(e));else if(un(t))r=ay(t,n);else{const o=$c(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Uo(r)}function Uc(e,t){const n=Dn(e);return n===t||!un(n)||br(n)?!1:dn(n).position==="fixed"||Uc(n,t)}function ly(e,t){const n=t.get(e);if(n)return n;let r=Ur(e,[],!1).filter(a=>un(a)&&vr(a)!=="body"),o=null;const s=dn(e).position==="fixed";let i=s?Dn(e):e;for(;un(i)&&!br(i);){const a=dn(i),l=ji(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&iy.has(o.position)||Hr(i)&&!l&&Uc(e,i))?r=r.filter(d=>d!==i):o=a,i=Dn(i)}return t.set(e,r),r}function cy(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Vo(t)?[]:ly(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const f=Hc(t,d,o);return c.top=Gt(f.top,c.top),c.right=Mn(f.right,c.right),c.bottom=Mn(f.bottom,c.bottom),c.left=Gt(f.left,c.left),c},Hc(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function uy(e){const{width:t,height:n}=Fc(e);return{width:t,height:n}}function dy(e,t,n){const r=bn(t),o=vn(t),s=n==="fixed",i=Qn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=xn(0);function c(){l.x=qo(o)}if(r||!r&&!s)if((vr(t)!=="body"||Hr(o))&&(a=Ko(t)),r){const h=Qn(t,!0,s,t);l.x=h.x+t.clientLeft,l.y=h.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?zc(o,a):xn(0),f=i.left+a.scrollLeft-l.x-d.x,p=i.top+a.scrollTop-l.y-d.y;return{x:f,y:p,width:i.width,height:i.height}}function Oi(e){return dn(e).position==="static"}function Wc(e,t){if(!bn(e)||dn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return vn(e)===n&&(n=n.ownerDocument.body),n}function Vc(e,t){const n=Yt(e);if(Vo(e))return n;if(!bn(e)){let o=Dn(e);for(;o&&!br(o);){if(un(o)&&!Oi(o))return o;o=Dn(o)}return n}let r=Wc(e,t);for(;r&&qx(r)&&Oi(r);)r=Wc(r,t);return r&&br(r)&&Oi(r)&&!ji(r)?n:r||Zx(e)||n}const fy=async function(e){const t=this.getOffsetParent||Vc,n=this.getDimensions,r=await n(e.floating);return{reference:dy(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function py(e){return dn(e).direction==="rtl"}const hy={convertOffsetParentRelativeRectToViewportRelativeRect:ny,getDocumentElement:vn,getClippingRect:cy,getOffsetParent:Vc,getElementRects:fy,getClientRects:ry,getDimensions:uy,getScale:wr,isElement:un,isRTL:py};function Kc(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function my(e,t){let n=null,r;const o=vn(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:p,height:h}=c;if(a||t(),!p||!h)return;const x=Bo(f),y=Bo(o.clientWidth-(d+p)),m=Bo(o.clientHeight-(f+h)),g=Bo(d),S={rootMargin:-x+"px "+-y+"px "+-m+"px "+-g+"px",threshold:Gt(0,Mn(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&&!Kc(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 gy(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=Pi(e),d=o||s?[...c?Ur(c):[],...Ur(t)]:[];d.forEach(g=>{o&&g.addEventListener("scroll",n,{passive:!0}),s&&g.addEventListener("resize",n)});const f=c&&a?my(c,n):null;let p=-1,h=null;i&&(h=new ResizeObserver(g=>{let[b]=g;b&&b.target===c&&h&&(h.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var S;(S=h)==null||S.observe(t)})),n()}),c&&!l&&h.observe(c),h.observe(t));let x,y=l?Qn(e):null;l&&m();function m(){const g=Qn(e);y&&!Kc(y,g)&&n(),y=g,x=requestAnimationFrame(m)}return n(),()=>{var g;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(g=h)==null||g.disconnect(),h=null,l&&cancelAnimationFrame(x)}}const xy=Bx,yy=Hx,vy=Fx,by=Wx,wy=$x,qc=Lx,Sy=Ux,Cy=(e,t,n)=>{const r=new Map,o={platform:hy,...n},s={...o.platform,_c:r};return Dx(e,t,{...o,platform:s})};var Ty=typeof document<"u",ky=function(){},Go=Ty?w.useLayoutEffect:ky;function Yo(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(!Yo(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)&&!Yo(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Gc(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Yc(e,t){const n=Gc(e);return Math.round(t*n)/n}function Mi(e){const t=v.useRef(e);return Go(()=>{t.current=e}),t}function Ey(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}),[p,h]=v.useState(r);Yo(p,r)||h(r);const[x,y]=v.useState(null),[m,g]=v.useState(null),b=v.useCallback(L=>{L!==C.current&&(C.current=L,y(L))},[]),S=v.useCallback(L=>{L!==E.current&&(E.current=L,g(L))},[]),k=s||x,T=i||m,C=v.useRef(null),E=v.useRef(null),j=v.useRef(d),A=l!=null,N=Mi(l),P=Mi(o),F=Mi(c),$=v.useCallback(()=>{if(!C.current||!E.current)return;const L={placement:t,strategy:n,middleware:p};P.current&&(L.platform=P.current),Cy(C.current,E.current,L).then(M=>{const J={...M,isPositioned:F.current!==!1};R.current&&!Yo(j.current,J)&&(j.current=J,yo.flushSync(()=>{f(J)}))})},[p,t,n,P,F]);Go(()=>{c===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,f(L=>({...L,isPositioned:!1})))},[c]);const R=v.useRef(!1);Go(()=>(R.current=!0,()=>{R.current=!1}),[]),Go(()=>{if(k&&(C.current=k),T&&(E.current=T),k&&T){if(N.current)return N.current(k,T,$);$()}},[k,T,$,N,A]);const z=v.useMemo(()=>({reference:C,floating:E,setReference:b,setFloating:S}),[b,S]),_=v.useMemo(()=>({reference:k,floating:T}),[k,T]),B=v.useMemo(()=>{const L={position:n,left:0,top:0};if(!_.floating)return L;const M=Yc(_.floating,d.x),J=Yc(_.floating,d.y);return a?{...L,transform:"translate("+M+"px, "+J+"px)",...Gc(_.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:M,top:J}},[n,a,_.floating,d.x,d.y]);return v.useMemo(()=>({...d,update:$,refs:z,elements:_,floatingStyles:B}),[d,$,z,_,B])}const Iy=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?qc({element:r.current,padding:o}).fn(n):{}:r?qc({element:r,padding:o}).fn(n):{}}}},Ny=(e,t)=>({...xy(e),options:[e,t]}),Ay=(e,t)=>({...yy(e),options:[e,t]}),jy=(e,t)=>({...Sy(e),options:[e,t]}),_y=(e,t)=>({...vy(e),options:[e,t]}),Ry=(e,t)=>({...by(e),options:[e,t]}),Py=(e,t)=>({...wy(e),options:[e,t]}),Oy=(e,t)=>({...Iy(e),options:[e,t]});var My="Arrow",Xc=v.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(_e.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"})})});Xc.displayName=My;var Dy=Xc;function Jc(e){const[t,n]=v.useState(void 0);return _t(()=>{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 Di="Popper",[Zc,Xo]=In(Di),[Ly,Qc]=Zc(Di),eu=e=>{const{__scopePopper:t,children:n}=e,[r,o]=v.useState(null);return u.jsx(Ly,{scope:t,anchor:r,onAnchorChange:o,children:n})};eu.displayName=Di;var tu="PopperAnchor",nu=v.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Qc(tu,n),i=v.useRef(null),a=Ue(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(_e.div,{...o,ref:a})});nu.displayName=tu;var Li="PopperContent",[Fy,$y]=Zc(Li),ru=v.forwardRef((e,t)=>{var W,D,H,te,ae,ne;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:p=!1,updatePositionStrategy:h="optimized",onPlaced:x,...y}=e,m=Qc(Li,n),[g,b]=v.useState(null),S=Ue(t,Fe=>b(Fe)),[k,T]=v.useState(null),C=Jc(k),E=(C==null?void 0:C.width)??0,j=(C==null?void 0:C.height)??0,A=r+(s!=="center"?"-"+s:""),N=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},P=Array.isArray(c)?c:[c],F=P.length>0,$={padding:N,boundary:P.filter(By),altBoundary:F},{refs:R,floatingStyles:z,placement:_,isPositioned:B,middlewareData:L}=Ey({strategy:"fixed",placement:A,whileElementsMounted:(...Fe)=>gy(...Fe,{animationFrame:h==="always"}),elements:{reference:m.anchor},middleware:[Ny({mainAxis:o+j,alignmentAxis:i}),l&&Ay({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?jy():void 0,...$}),l&&_y({...$}),Ry({...$,apply:({elements:Fe,rects:Q,availableWidth:ie,availableHeight:Ce})=>{const{width:Re,height:Ke}=Q.reference,Be=Fe.floating.style;Be.setProperty("--radix-popper-available-width",`${ie}px`),Be.setProperty("--radix-popper-available-height",`${Ce}px`),Be.setProperty("--radix-popper-anchor-width",`${Re}px`),Be.setProperty("--radix-popper-anchor-height",`${Ke}px`)}}),k&&Oy({element:k,padding:a}),Hy({arrowWidth:E,arrowHeight:j}),p&&Py({strategy:"referenceHidden",...$})]}),[M,J]=iu(_),X=Rt(x);_t(()=>{B&&(X==null||X())},[B,X]);const pe=(W=L.arrow)==null?void 0:W.x,Ie=(D=L.arrow)==null?void 0:D.y,je=((H=L.arrow)==null?void 0:H.centerOffset)!==0,[G,ee]=v.useState();return _t(()=>{g&&ee(window.getComputedStyle(g).zIndex)},[g]),u.jsx("div",{ref:R.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:B?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:G,"--radix-popper-transform-origin":[(te=L.transformOrigin)==null?void 0:te.x,(ae=L.transformOrigin)==null?void 0:ae.y].join(" "),...((ne=L.hide)==null?void 0:ne.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(Fy,{scope:n,placedSide:M,onArrowChange:T,arrowX:pe,arrowY:Ie,shouldHideArrow:je,children:u.jsx(_e.div,{"data-side":M,"data-align":J,...y,ref:S,style:{...y.style,animation:B?void 0:"none"}})})})});ru.displayName=Li;var ou="PopperArrow",zy={top:"bottom",right:"left",bottom:"top",left:"right"},su=v.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=$y(ou,r),i=zy[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(Dy,{...o,ref:n,style:{...o.style,display:"block"}})})});su.displayName=ou;function By(e){return e!==null}var Hy=e=>({name:"transformOrigin",options:e,fn(t){var m,g,b;const{placement:n,rects:r,middlewareData:o}=t,i=((m=o.arrow)==null?void 0:m.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,d]=iu(n),f={start:"0%",center:"50%",end:"100%"}[d],p=(((g=o.arrow)==null?void 0:g.x)??0)+a/2,h=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let x="",y="";return c==="bottom"?(x=i?f:`${p}px`,y=`${-l}px`):c==="top"?(x=i?f:`${p}px`,y=`${r.floating.height+l}px`):c==="right"?(x=`${-l}px`,y=i?f:`${h}px`):c==="left"&&(x=`${r.floating.width+l}px`,y=i?f:`${h}px`),{data:{x,y}}}});function iu(e){const[t,n="center"]=e.split("-");return[t,n]}var au=eu,lu=nu,cu=ru,uu=su,Uy="Portal",Jo=v.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=v.useState(!1);_t(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Js.createPortal(u.jsx(_e.div,{...r,ref:t}),i):null});Jo.displayName=Uy;function Wy(e,t){return v.useReducer((n,r)=>t[n][r]??n,e)}var tn=e=>{const{present:t,children:n}=e,r=Vy(t),o=typeof n=="function"?n({present:r.isPresent}):v.Children.only(n),s=Ue(r.ref,Ky(o));return typeof n=="function"||r.isPresent?v.cloneElement(o,{ref:s}):null};tn.displayName="Presence";function Vy(e){const[t,n]=v.useState(),r=v.useRef(null),o=v.useRef(e),s=v.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Wy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const c=Zo(r.current);s.current=a==="mounted"?c:"none"},[a]),_t(()=>{const c=r.current,d=o.current;if(d!==e){const p=s.current,h=Zo(c);e?l("MOUNT"):h==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&p!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),_t(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,f=h=>{const y=Zo(r.current).includes(CSS.escape(h.animationName));if(h.target===t&&y&&(l("ANIMATION_END"),!o.current)){const m=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=m)})}},p=h=>{h.target===t&&(s.current=Zo(r.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",p),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 Zo(e){return(e==null?void 0:e.animationName)||"none"}function Ky(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 Fi="rovingFocusGroup.onEntryFocus",qy={bubbles:!1,cancelable:!0},Wr="RovingFocusGroup",[$i,du,Gy]=vi(Wr),[Yy,fu]=In(Wr,[Gy]),[Xy,Jy]=Yy(Wr),pu=v.forwardRef((e,t)=>u.jsx($i.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx($i.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Zy,{...e,ref:t})})}));pu.displayName=Wr;var Zy=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,p=v.useRef(null),h=Ue(t,p),x=Lo(s),[y,m]=xr({prop:i,defaultProp:a??null,onChange:l,caller:Wr}),[g,b]=v.useState(!1),S=Rt(c),k=du(n),T=v.useRef(!1),[C,E]=v.useState(0);return v.useEffect(()=>{const j=p.current;if(j)return j.addEventListener(Fi,S),()=>j.removeEventListener(Fi,S)},[S]),u.jsx(Xy,{scope:n,orientation:r,dir:x,loop:o,currentTabStopId:y,onItemFocus:v.useCallback(j=>m(j),[m]),onItemShiftTab:v.useCallback(()=>b(!0),[]),onFocusableItemAdd:v.useCallback(()=>E(j=>j+1),[]),onFocusableItemRemove:v.useCallback(()=>E(j=>j-1),[]),children:u.jsx(_e.div,{tabIndex:g||C===0?-1:0,"data-orientation":r,...f,ref:h,style:{outline:"none",...e.style},onMouseDown:fe(e.onMouseDown,()=>{T.current=!0}),onFocus:fe(e.onFocus,j=>{const A=!T.current;if(j.target===j.currentTarget&&A&&!g){const N=new CustomEvent(Fi,qy);if(j.currentTarget.dispatchEvent(N),!N.defaultPrevented){const P=k().filter(_=>_.focusable),F=P.find(_=>_.active),$=P.find(_=>_.id===y),z=[F,$,...P].filter(Boolean).map(_=>_.ref.current);gu(z,d)}}T.current=!1}),onBlur:fe(e.onBlur,()=>b(!1))})})}),hu="RovingFocusGroupItem",mu=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Nn(),c=s||l,d=Jy(hu,n),f=d.currentTabStopId===c,p=du(n),{onFocusableItemAdd:h,onFocusableItemRemove:x,currentTabStopId:y}=d;return v.useEffect(()=>{if(r)return h(),()=>x()},[r,h,x]),u.jsx($i.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(_e.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:fe(e.onMouseDown,m=>{r?d.onItemFocus(c):m.preventDefault()}),onFocus:fe(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:fe(e.onKeyDown,m=>{if(m.key==="Tab"&&m.shiftKey){d.onItemShiftTab();return}if(m.target!==m.currentTarget)return;const g=tv(m,d.orientation,d.dir);if(g!==void 0){if(m.metaKey||m.ctrlKey||m.altKey||m.shiftKey)return;m.preventDefault();let S=p().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(m.currentTarget);S=d.loop?nv(S,k+1):S.slice(k+1)}setTimeout(()=>gu(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:y!=null}):i})})});mu.displayName=hu;var Qy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ev(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function tv(e,t,n){const r=ev(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Qy[r]}function gu(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function nv(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var rv=pu,ov=mu,sv=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Sr=new WeakMap,Qo=new WeakMap,es={},zi=0,xu=function(e){return e&&(e.host||xu(e.parentNode))},iv=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=xu(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})},av=function(e,t,n,r){var o=iv(t,Array.isArray(e)?e:[e]);es[n]||(es[n]=new WeakMap);var s=es[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(p){if(a.has(p))d(p);else try{var h=p.getAttribute(r),x=h!==null&&h!=="false",y=(Sr.get(p)||0)+1,m=(s.get(p)||0)+1;Sr.set(p,y),s.set(p,m),i.push(p),y===1&&x&&Qo.set(p,!0),m===1&&p.setAttribute(n,"true"),x||p.setAttribute(r,"true")}catch(g){console.error("aria-hidden: cannot operate on ",p,g)}})};return d(t),a.clear(),zi++,function(){i.forEach(function(f){var p=Sr.get(f)-1,h=s.get(f)-1;Sr.set(f,p),s.set(f,h),p||(Qo.has(f)||f.removeAttribute(r),Qo.delete(f)),h||f.removeAttribute(n)}),zi--,zi||(Sr=new WeakMap,Sr=new WeakMap,Qo=new WeakMap,es={})}},Bi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=sv(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),av(r,o,n,"aria-hidden")):function(){return null}},wn=function(){return wn=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},wn.apply(this,arguments)};function yu(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 lv(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 ts="right-scroll-bar-position",ns="width-before-scroll-bar",cv="with-scroll-bars-hidden",uv="--removed-body-scroll-bar-size";function Hi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function dv(e,t){var n=w.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var fv=typeof window<"u"?v.useLayoutEffect:v.useEffect,vu=new WeakMap;function pv(e,t){var n=dv(null,function(r){return e.forEach(function(o){return Hi(o,r)})});return fv(function(){var r=vu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Hi(a,null)}),s.forEach(function(a){o.has(a)||Hi(a,i)})}vu.set(n,e)},[e]),n}function hv(e){return e}function mv(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 gv(e){e===void 0&&(e={});var t=mv(null);return t.options=wn({async:!0,ssr:!1},e),t}var bu=function(e){var t=e.sideCar,n=yu(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,wn({},n))};bu.isSideCarExport=!0;function xv(e,t){return e.useMedium(t),bu}var wu=gv(),Ui=function(){},rs=v.forwardRef(function(e,t){var n=v.useRef(null),r=v.useState({onScrollCapture:Ui,onWheelCapture:Ui,onTouchMoveCapture:Ui}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,f=e.shards,p=e.sideCar,h=e.noRelative,x=e.noIsolation,y=e.inert,m=e.allowPinchZoom,g=e.as,b=g===void 0?"div":g,S=e.gapMode,k=yu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),T=p,C=pv([n,t]),E=wn(wn({},k),o);return v.createElement(v.Fragment,null,d&&v.createElement(T,{sideCar:wu,removeScrollBar:c,shards:f,noRelative:h,noIsolation:x,inert:y,setCallbacks:s,allowPinchZoom:!!m,lockRef:n,gapMode:S}),i?v.cloneElement(v.Children.only(a),wn(wn({},E),{ref:C})):v.createElement(b,wn({},E,{className:l,ref:C}),a))});rs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},rs.classNames={fullWidth:ns,zeroRight:ts};var yv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function vv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=yv();return t&&e.setAttribute("nonce",t),e}function bv(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 Sv=function(){var e=0,t=null;return{add:function(n){e==0&&(t=vv())&&(bv(t,n),wv(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Cv=function(){var e=Sv();return function(t,n){v.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Su=function(){var e=Cv(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Tv={left:0,top:0,right:0,gap:0},Wi=function(e){return parseInt(e||"",10)||0},kv=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Wi(n),Wi(r),Wi(o)]},Ev=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Tv;var t=kv(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])}},Iv=Su(),Cr="data-scroll-locked",Nv=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 ft=ut.slice(0,ye);ut=ut.slice(ye+2);const gt=Xg(ft);if(!gt)continue;let Tt;try{Tt=JSON.parse(gt)}catch{console.debug("[use-chat] malformed SSE:",gt.slice(0,200));continue}const Oe=Yg(Tt)?Tt.data:Tt;Be=Date.now();const Kt=Oe.seq;if(Kt!==void 0){if(Kt<=Ct){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:Kt,lastProcessedSeq:Ct,type:Oe.type});continue}Ct>0&&Kt>Ct+1&&((D=_==null?void 0:_.onGap)==null||D.call(_,{from:Ct,to:Kt})),Ct=Kt,T.current=Kt,m(Kt)}if(console.debug("[use-chat] received event",{seq:Oe.seq,type:Oe.type,preview:(()=>{var at;try{return Oe.type==="message_delta"?{deltaTypes:(at=Oe.delta)==null?void 0:at.map(kt=>kt.type),textLen:(Oe.delta||[]).filter(kt=>kt.type==="text").map(kt=>String(kt.text||"").length)}:Oe.content||Oe.delta?{hasContent:!0}:{}}catch(kt){return{err:String(kt)}}})()}),Oe.type==="checkpoint")E.current=Oe.checkpointId??null,j.current=Oe.checkpointNs??null,x(Oe.checkpointId??null);else if(Oe.type==="state_history"){A.current=Oe;try{const kt=$r(Oe).latest;kt&&(E.current=kt.checkpointId??null,j.current=kt.checkpointNs??null,x(kt.checkpointId??null))}catch(at){console.warn("[use-chat] Failed to hydrate state_history payload",at)}}try{z==null||z(Oe)}catch(at){console.error("[use-chat] Error in onEvent callback:",at,"for event:",Oe.type)}if(Oe.type==="token"&&e.autoAppendAssistant!==!1)it.push(Oe.content),be();else if(Oe.type==="message_delta"){const at=Oe.delta.filter(kt=>kt.type==="text").map(kt=>kt.text).join("");at&&e.autoAppendAssistant!==!1&&(it.push(at),be())}else if(Oe.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(H=_==null?void 0:_.onHeartbeat)==null||H.call(_,Oe)}catch(at){console.warn("[use-chat] heartbeat callback failed",at)}}else if(vt!==null&&cancelAnimationFrame(vt),re(),Oe.type==="checkpoint")x(Oe.checkpointId);else if(Oe.type==="error"){const at=Oe;if(d(at.message),L="error",M=at.message,at.error_type==="auth_error"||at.code==="TOKEN_EXPIRED"||((te=at.message)==null?void 0:te.includes("token"))||((ae=at.message)==null?void 0:ae.includes("401"))||((ne=at.message)==null?void 0:ne.includes("unauthorized"))||((Le=at.message)==null?void 0:Le.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",at.message);try{(Q=_==null?void 0:_.onAuthError)==null||Q.call(_,at.message)}catch(Kn){console.warn("[use-chat] onAuthError handler failed",Kn)}B.abort()}}}}re(),L===null&&!B.signal.aborted&&(L="complete")}catch(xe){if(xe.name==="AbortError")L=L??"aborted";else{const he=xe.message||String(xe);L="error",M=he,d(he),(ie=_==null?void 0:_.onError)==null||ie.call(_,he)}}finally{try{await rt.cancel()}catch{}finally{(ke=rt.releaseLock)==null||ke.call(rt)}vt!==null&&typeof window<"u"&&window.cancelAnimationFrame(vt),clearInterval(He)}}catch($e){if($e.name==="AbortError")L=L??"aborted";else{const qe=$e.message||String($e);L="error",M=qe,d(qe),(Re=_==null?void 0:_.onError)==null||Re.call(_,qe),J||((Ke=_==null?void 0:_.onConnectionError)==null||Ke.call(_,qe),J=!0)}}finally{const $e=T.current,qe=E.current,Ge=j.current,Qe=A.current,Je=L??(B.signal.aborted?"aborted":M?"error":"complete");try{(ze=_==null?void 0:_.onClosed)==null||ze.call(_,{reason:Je,lastSeq:$e,lastCheckpointId:qe,lastCheckpointNs:Ge,lastStateHistory:Qe,error:M})}catch(rt){console.warn("[use-chat] onClosed callback failed",rt)}l(!1),b(!1),S.current=null,T.current=0,m(0),C.current=null}})(),{close:()=>B.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var R;k.current=!1,(R=S.current)==null||R.abort()},[]),{isStreaming:a,error:c,assistantText:f,lastCheckpointId:h,lastSeq:y,connected:g,stream:$,stop:F,clear:P,setToken:N}}function Yg(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function Xg(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
|
+
`)}const cc=200;function Jg({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onUnhandledEvent:r,onSequenceGap:o,onStreamClosed:s,onConnectionError:i,onAuthError:a,onHeartbeat:l}){const c=w.useRef(null),d=w.useRef(null),f=w.useRef(new Map),p=w.useRef(null),h=w.useCallback(A=>{try{const N=globalThis.structuredClone;if(typeof N=="function")return N(A)}catch{}try{return JSON.parse(JSON.stringify(A))}catch{return A}},[]),x=w.useCallback((A,N)=>{if(!A)return;const P=f.current.get(A)??[],F=h(N),$=P.length>=cc?[...P.slice(P.length-cc+1),F]:[...P,F];f.current.set(A,$)},[h]),y=w.useCallback(A=>{A&&f.current.set(A,[])},[]),m=w.useCallback(A=>{const N=A??d.current;if(!N)return;const P=f.current.get(N);P!=null&&P.length&&P.forEach(F=>{try{n(F)}catch($){console.error("[useChatStreamingService] Failed to replay buffered event",$)}})},[n]),g=w.useCallback(A=>{var F,$,R,z,_;const N=A.seq??null;if(N!==null){const B=c.current;if(B!==null){if(N<=B)return;N>B+1&&(o==null||o({from:B,to:N}))}c.current=N}if(A.type==="thread_info"){d.current=A.threadId,p.current&&(p.current.threadIdGuess=A.threadId),y(A.threadId),console.log("[useChatStreamingService] 🎯 Received thread_info event:",A);try{t(A)}catch(B){console.error("[useChatStreamingService] Error in onThreadInfo handler:",B)}return}if(A.type==="heartbeat"){try{l==null||l(A)}catch(B){console.error("[useChatStreamingService] Error in onHeartbeat handler:",B)}return}if(A.type==="error"){const B=A;if(B.error_type==="auth_error"||B.code==="TOKEN_EXPIRED"||((F=B.message)==null?void 0:F.includes("token"))||(($=B.message)==null?void 0:$.includes("401"))||((R=B.message)==null?void 0:R.includes("unauthorized"))||((z=B.message)==null?void 0:z.includes("Unauthorized"))){console.error("[useChatStreamingService] Auth error event detected:",B.message);try{a==null||a(B.message)}catch(M){console.warn("[useChatStreamingService] onAuthError handler failed",M)}}}const P=A.threadId??(A.type==="state_history"?A.threadId:void 0)??d.current??((_=p.current)==null?void 0:_.threadIdGuess)??null;if(A.type==="state_history"&&(d.current=P??d.current),Hg(A)){A.type==="checkpoint"||A.type==="state_history"?y(P??null):x(P??null,A);try{n(A)}catch(B){console.error("[useChatStreamingService] Error in onMessageEvent handler:",B)}return}try{r==null||r(A)}catch(B){console.error("[useChatStreamingService] Error in onUnhandledEvent handler:",B)}},[x,y,n,o,t,r]),{stream:b,stop:S,isStreaming:k,error:T,setToken:C}=lc({baseUrl:e,token:void 0}),E=w.useCallback((A,N)=>{c.current=null,d.current=A.threadId??null,p.current={request:A,callbacks:N,manualStop:!1,threadIdGuess:A.threadId??null},b(A,g,{onOpen:N==null?void 0:N.onOpen,onError:P=>{var F;(F=N==null?void 0:N.onError)==null||F.call(N,P)},onGap:(N==null?void 0:N.onGap)??o,onConnectionError:P=>{var F;i==null||i(P),(F=N==null?void 0:N.onConnectionError)==null||F.call(N,P)},onAuthError:P=>{var F;a==null||a(P),(F=N==null?void 0:N.onAuthError)==null||F.call(N,P)},onHeartbeat:P=>{var F;try{l==null||l(P)}catch($){console.warn("[useChatStreamingService] onHeartbeat handler failed",$)}try{(F=N==null?void 0:N.onHeartbeat)==null||F.call(N,P)}catch($){console.warn("[useChatStreamingService] downstream onHeartbeat handler failed",$)}},onClosed:P=>{var z,_,B,L;const F=((z=p.current)==null?void 0:z.manualStop)??!1,$=d.current??((_=p.current)==null?void 0:_.threadIdGuess)??((B=P.lastStateHistory)==null?void 0:B.threadId)??null;(P.reason==="complete"||P.reason==="aborted"&&F)&&y($);const R={...P,threadId:$,manualStop:F};try{s==null||s(R)}catch(M){console.warn("[useChatStreamingService] onStreamClosed handler failed",M)}try{(L=N==null?void 0:N.onClosed)==null||L.call(N,R)}catch(M){console.warn("[useChatStreamingService] downstream onClosed handler failed",M)}p.current&&(p.current=null)}})},[y,g,a,i,l,o,s,b]),j=w.useCallback(()=>{p.current&&(p.current.manualStop=!0),S()},[S]);return w.useMemo(()=>({startStream:E,stop:j,isStreaming:k,error:T,setAuthToken:C,replayBufferedEvents:m}),[E,j,k,T,C,m])}const uc=w.createContext(null),dc=w.createContext(null),fc=w.createContext(null);w.createContext(!1);function Zg({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,disableAutoRestore:s=!1,enableFileAgentRouting:i=!1,fileAgentId:a="invoice_reader",onError:l,onAuthError:c,onThreadChange:d}){const{api:f,baseUrl:p}=fi(),h=w.useMemo(()=>En(p),[p]),[x,y]=w.useState([]),[m,g]=w.useState(t),[b,S]=w.useState(!1),[k,T]=w.useState(null),[C,E]=w.useState(!1),[j,A]=w.useState(null),{state:N,seed:P,prepend:F,pushUser:$,onEvent:R}=ec(),[z,_]=w.useState(!1),[B,L]=w.useState(!1),[M,J]=w.useState(null),[X,pe]=w.useState([]),[Ne,je]=w.useState(!1),{setCacheForThread:G,checkpointExists:ee}=Bg(),W=w.useRef(m),D=w.useRef(null);w.useEffect(()=>{W.current=m},[m]);const H=w.useRef(),{startStream:te,stop:ae,isStreaming:ne,error:Le,setAuthToken:Q}=Jg({baseUrl:h,onThreadInfo:re=>{console.log("[ChatSessionProvider] Thread info:",re.threadId),W.current!==re.threadId&&g(re.threadId)},onMessageEvent:R,onUnhandledEvent:re=>{console.warn("[ChatSessionProvider] Unhandled event:",re.type)},onAuthError:c}),ie=w.useCallback(async()=>{S(!0),T(null);try{const re=await f.listThreads();y(re??[])}catch(re){const be=String(re);T(be),l==null||l(be)}finally{S(!1)}},[f,l]),ke=w.useCallback(async re=>{try{const be=await f.createThread(re);return g(be.threadId),await ie(),be.threadId}catch(be){return l==null||l(String(be)),null}},[f,ie,l]),Re=w.useCallback(async re=>{try{await f.deleteThread(re),W.current===re&&(g(null),P([],{})),await ie()}catch(be){l==null||l(String(be))}},[f,ie,P,l]),Ke=w.useCallback(async(re,be)=>{try{await f.updateThread(re,be),await ie()}catch(Be){l==null||l(String(Be))}},[f,ie,l]),ze=w.useCallback(async(re,be)=>{if(re){E(!0),A(null);try{const Be=await f.getStateHistory({threadId:re,checkpointId:be}),{checkpoints:He}=$r(Be),mt=He.filter(he=>he.checkpointId).map(he=>({checkpointId:he.checkpointId,checkpointNs:he.checkpointNs??void 0,createdAt:he.createdAt??""}));G(re,mt);const xe=He.find(he=>he.messages&&he.messages.length>0)??He[0];console.log("[ChatSessionProvider] Loaded thread:",{requestedCheckpointId:be,dataCheckpointId:xe==null?void 0:xe.checkpointId,totalCheckpoints:He.length}),P((xe==null?void 0:xe.messages)??[],{checkpointId:(xe==null?void 0:xe.checkpointId)??null,checkpointNs:(xe==null?void 0:xe.checkpointNs)??null}),pe(He),_(!!(xe!=null&&xe.nextCursor)),J((xe==null?void 0:xe.nextCursor)??null)}catch(Be){const He=String(Be);A(He),l==null||l(He)}finally{E(!1)}}},[f,P,l,G]);w.useEffect(()=>{H.current=ze},[ze]);const $e=w.useCallback(async(re,be)=>{const Be=W.current;if(Be){je(!0);try{const He=await f.getStateHistory({threadId:Be,checkpointId:re,checkpointNs:be??void 0}),{checkpoints:mt}=$r(He),xe=mt.filter(ot=>ot.checkpointId).map(ot=>({checkpointId:ot.checkpointId,checkpointNs:ot.checkpointNs??void 0,createdAt:ot.createdAt??""}));G(Be,xe);const he=mt.find(ot=>ot.checkpointId===re&&(be?ot.checkpointNs===be:!0));if(!he){console.warn("[ChatSessionProvider] Requested checkpoint not found in response:",{checkpointId:re,checkpointNs:be});return}pe(mt),P((he==null?void 0:he.messages)??[],{checkpointId:(he==null?void 0:he.checkpointId)??null,checkpointNs:(he==null?void 0:he.checkpointNs)??null})}catch(He){l==null||l(String(He))}finally{je(!1)}}},[f,P,l,G]),qe=w.useCallback((re,be)=>{P(N.messages,{checkpointId:re??null,checkpointNs:be??null})},[P,N.messages]),Ge=w.useCallback(async()=>{W.current&&await ze(W.current)},[ze]),Qe=w.useCallback(async()=>{if(!(!W.current||!M)){L(!0);try{const re=await f.getStateHistory({threadId:W.current,checkpointId:M}),{checkpoints:be}=$r(re);if(be.length>0){const Be=be[be.length-1];F((Be==null?void 0:Be.messages)??[]),_(!!(Be!=null&&Be.nextCursor)),J((Be==null?void 0:Be.nextCursor)??null)}}catch(re){l==null||l(String(re))}finally{L(!1)}}},[f,M,F,l]),Je=w.useCallback(async()=>{P([],{}),pe([]),_(!1),J(null)},[P]),rt=w.useCallback(async(re,be)=>{console.log("[ChatSessionProvider] Interrupt:",re,be)},[]);w.useEffect(()=>{ie()},[ie]);const At=w.useRef();w.useEffect(()=>{At.current=$e},[$e]),w.useEffect(()=>{var mt,xe;if(!o||!m||C===!0||D.current===m)return;D.current=m;const re=localStorage.getItem("lastCheckpointId");localStorage.getItem("lastCheckpointNs");const be=n,Be=r;let He={id:re};He.id||(He={id:be,ns:Be}),He.id?(console.log("[ChatSessionProvider] Loading thread with checkpoint:",He.id),(mt=H.current)==null||mt.call(H,m,He.id)):(console.log("[ChatSessionProvider] Loading thread with latest checkpoint"),(xe=H.current)==null||xe.call(H,m))},[o,m,C,ee,n,r]),w.useEffect(()=>{d==null||d(m)},[m,d]),w.useEffect(()=>{N.lastCheckpointId&&(localStorage.setItem("lastCheckpointId",N.lastCheckpointId),N.lastCheckpointNs&&localStorage.setItem("lastCheckpointNs",N.lastCheckpointNs))},[N.lastCheckpointId,N.lastCheckpointNs]);const ut=w.useCallback(async(re,be)=>{const Be=W.current,He=(re==null?void 0:re.text)??"";if(!Be&&!He)return;if(!Be){await ke("New Chat");return}const{contentParts:mt}=await Tg(f,(re==null?void 0:re.attachments)??[]),xe=[...mt];He!=null&&He.trim()&&xe.push({type:"text",text:He});const he={id:`msg-${Date.now()}`,role:"user",content:xe,createdAt:new Date().toISOString()};$(he);const ot={threadId:Be,checkpointId:(be==null?void 0:be.checkpointId)??N.lastCheckpointId??void 0,checkpointNs:(be==null?void 0:be.checkpointNs)??N.lastCheckpointNs??void 0};te(ot)},[f,ke,$,N,te]),it=w.useMemo(()=>({threads:x,currentThreadId:m,setCurrentThreadId:g,isLoading:b,error:k,actions:{createThread:ke,deleteThread:Re,renameThread:Ke,refreshThreads:ie}}),[x,m,b,k,ke,Re,Ke,ie]),Ct=w.useMemo(()=>({threadId:m,messages:N.messages,interrupt:null,checkpoint:{id:N.lastCheckpointId??null,namespace:N.lastCheckpointNs??null},checkpoints:X,metadata:null,isLoading:C,isHistoryLoading:B,isLoadingCheckpoint:Ne,error:j,hasMore:z,loadOlder:Qe,clearState:Je,navigateToCheckpoint:$e,setCurrentCheckpointId:qe,returnToLatest:Ge,loadThread:ze,clearThread:Je,respondToInterrupt:rt}),[m,N,X,C,B,Ne,j,z,Qe,Je,$e,qe,Ge,ze,rt]),vt=w.useMemo(()=>({isStreaming:ne,error:Le,connectionState:ne?"connected":"idle",submit:ut,send:ut,stop:ae,setAuthToken:Q}),[ne,Le,ut,ae,Q]);return u.jsx(uc.Provider,{value:it,children:u.jsx(dc.Provider,{value:Ct,children:u.jsx(fc.Provider,{value:vt,children:e})})})}function Oo(){const e=w.useContext(uc);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Mo(){const e=w.useContext(dc);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function pc(){const e=w.useContext(fc);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function Do({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onError:i,onAuthError:a,onThreadChange:l}){return u.jsx(Sg,{apiConfig:t,children:u.jsx(Zg,{initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:i,onAuthError:a,onThreadChange:l,children:e})})}function Z(...e){return Yh.twMerge(Gh.clsx(e))}const Qg=xo.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"}}),tt=v.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Yn.Slot:"button";return u.jsx(i,{className:Z(Qg({variant:t,size:n,className:e})),ref:s,...o})});tt.displayName="Button";const hc=v.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:Z("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}));hc.displayName="Textarea";function mc({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:p="",allowEmptySend:h=!1}){const x=i!==void 0,[y,m]=w.useState(e),g=(x?i:y)??"",[b,S]=w.useTransition(),k=w.useRef(null),T=w.useRef(0),C=w.useRef(null);w.useEffect(()=>{x||(m(e??""),C.current=null,k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`))},[e,t,x]);const E=w.useCallback(()=>{const z=k.current;z&&(z.style.height="auto",z.style.height=`${z.scrollHeight}px`)},[]);w.useEffect(()=>{E()},[E,g]);const j=w.useCallback((z,{fromUser:_})=>{x||m(z),_&&(a==null||a(z))},[x,a]),A=w.useCallback(async z=>{z&&z.preventDefault();const _=(g??"").trim();if(!_&&!h)return;const B=++T.current;C.current={id:B,shouldClear:!0},S(()=>{var L,M,J;try{const X=l(_);X&&typeof X.then=="function"?X.then(()=>{var pe,Ne;((pe=C.current)==null?void 0:pe.id)===B&&C.current.shouldClear&&(x||(m(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((Ne=C.current)==null?void 0:Ne.id)===B&&(C.current=null)}).catch(()=>{var pe;((pe=C.current)==null?void 0:pe.id)===B&&(C.current=null)}):(((L=C.current)==null?void 0:L.id)===B&&C.current.shouldClear&&(x||(m(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((M=C.current)==null?void 0:M.id)===B&&(C.current=null))}catch{((J=C.current)==null?void 0:J.id)===B&&(C.current=null)}})},[g,l,h,x,a]),N=w.useCallback(z=>{const _=z.target.value;j(_,{fromUser:!0}),C.current&&(C.current.shouldClear=!1),k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`)},[j]),P=w.useCallback(z=>{z.key==="Enter"&&!z.shiftKey?(z.preventDefault(),A()):z.key==="Escape"&&t&&(z.preventDefault(),c==null||c())},[A,t,c]),R=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${p}`;return u.jsx("form",{onSubmit:z=>void A(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(hc,{ref:k,value:g,onChange:N,onKeyDown:P,placeholder:t?"Edit your message...":n,className:R,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),u.jsx("div",{children:r?u.jsx(tt,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(se.Square,{size:16})}):u.jsx(tt,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!g.trim()&&!h||b,children:u.jsx(se.Send,{size:16})})})]})})}const ex=w.memo(mc);function fe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function gc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function yi(...e){return t=>{let n=!1;const r=e.map(o=>{const s=gc(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():gc(e[o],null)}}}}function We(...e){return v.useCallback(yi(...e),e)}function tx(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 In(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:p,children:h,...x}=f,y=((g=p==null?void 0:p[e])==null?void 0:g[l])||a,m=v.useMemo(()=>x,Object.values(x));return u.jsx(y.Provider,{value:m,children:h})};c.displayName=s+"Provider";function d(f,p){var y;const h=((y=p==null?void 0:p[e])==null?void 0:y[l])||a,x=v.useContext(h);if(x)return x;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,nx(o,...t)]}function nx(...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 _t=globalThis!=null&&globalThis.document?v.useLayoutEffect:()=>{},rx=v[" useInsertionEffect ".trim().toString()]||_t;function xr({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=ox({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 p=sx(d)?d(e):d;p!==e&&((f=i.current)==null||f.call(i,p))}else s(d)},[a,e,s,i]);return[l,c]}function ox({defaultProp:e,onChange:t}){const[n,r]=v.useState(e),o=v.useRef(n),s=v.useRef(t);return rx(()=>{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 sx(e){return typeof e=="function"}var ix=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],_e=ix.reduce((e,t)=>{const n=Yn.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 xc(e,t){e&&yo.flushSync(()=>e.dispatchEvent(t))}function vi(e){const t=e+"CollectionProvider",[n,r]=In(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=y=>{const{scope:m,children:g}=y,b=w.useRef(null),S=w.useRef(new Map).current;return u.jsx(o,{scope:m,itemMap:S,collectionRef:b,children:g})};i.displayName=t;const a=e+"CollectionSlot",l=Yn.createSlot(a),c=w.forwardRef((y,m)=>{const{scope:g,children:b}=y,S=s(a,g),k=We(m,S.collectionRef);return u.jsx(l,{ref:k,children:b})});c.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",p=Yn.createSlot(d),h=w.forwardRef((y,m)=>{const{scope:g,children:b,...S}=y,k=w.useRef(null),T=We(m,k),C=s(d,g);return w.useEffect(()=>(C.itemMap.set(k,{ref:k,...S}),()=>void C.itemMap.delete(k))),u.jsx(p,{[f]:"",ref:T,children:b})});h.displayName=d;function x(y){const m=s(e+"CollectionConsumer",y);return w.useCallback(()=>{const b=m.collectionRef.current;if(!b)return[];const S=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(m.itemMap.values()).sort((C,E)=>S.indexOf(C.ref.current)-S.indexOf(E.ref.current))},[m.collectionRef,m.itemMap])}return[{Provider:i,Slot:c,ItemSlot:h},x,r]}var ax=v.createContext(void 0);function Lo(e){const t=v.useContext(ax);return e||t||"ltr"}function Rt(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 lx(e,t=globalThis==null?void 0:globalThis.document){const n=Rt(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 cx="DismissableLayer",bi="dismissableLayer.update",ux="dismissableLayer.pointerDownOutside",dx="dismissableLayer.focusOutside",yc,vc=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Fo=v.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=v.useContext(vc),[d,f]=v.useState(null),p=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,h]=v.useState({}),x=We(t,E=>f(E)),y=Array.from(c.layers),[m]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),g=y.indexOf(m),b=d?y.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=b>=g,T=hx(E=>{const j=E.target,A=[...c.branches].some(N=>N.contains(j));!k||A||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},p),C=mx(E=>{const j=E.target;[...c.branches].some(N=>N.contains(j))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},p);return lx(E=>{b===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},p),v.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(yc=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),bc(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=yc)}},[d,p,n,c]),v.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),bc())},[d,c]),v.useEffect(()=>{const E=()=>h({});return document.addEventListener(bi,E),()=>document.removeEventListener(bi,E)},[]),u.jsx(_e.div,{...l,ref:x,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:fe(e.onFocusCapture,C.onFocusCapture),onBlurCapture:fe(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:fe(e.onPointerDownCapture,T.onPointerDownCapture)})});Fo.displayName=cx;var fx="DismissableLayerBranch",px=v.forwardRef((e,t)=>{const n=v.useContext(vc),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(_e.div,{...e,ref:o})});px.displayName=fx;function hx(e,t=globalThis==null?void 0:globalThis.document){const n=Rt(e),r=v.useRef(!1),o=v.useRef(()=>{});return v.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){wc(ux,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 mx(e,t=globalThis==null?void 0:globalThis.document){const n=Rt(e),r=v.useRef(!1);return v.useEffect(()=>{const o=s=>{s.target&&!r.current&&wc(dx,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 bc(){const e=new CustomEvent(bi);document.dispatchEvent(e)}function wc(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?xc(o,s):o.dispatchEvent(s)}var wi=0;function Si(){v.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Sc()),document.body.insertAdjacentElement("beforeend",e[1]??Sc()),wi++,()=>{wi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),wi--}},[])}function Sc(){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 Ci="focusScope.autoFocusOnMount",Ti="focusScope.autoFocusOnUnmount",Cc={bubbles:!1,cancelable:!0},gx="FocusScope",$o=v.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=v.useState(null),c=Rt(o),d=Rt(s),f=v.useRef(null),p=We(t,y=>l(y)),h=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(r){let y=function(S){if(h.paused||!a)return;const k=S.target;a.contains(k)?f.current=k:On(f.current,{select:!0})},m=function(S){if(h.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||On(f.current,{select:!0}))},g=function(S){if(document.activeElement===document.body)for(const T of S)T.removedNodes.length>0&&On(a)};document.addEventListener("focusin",y),document.addEventListener("focusout",m);const b=new MutationObserver(g);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",m),b.disconnect()}}},[r,a,h.paused]),v.useEffect(()=>{if(a){Ec.add(h);const y=document.activeElement;if(!a.contains(y)){const g=new CustomEvent(Ci,Cc);a.addEventListener(Ci,c),a.dispatchEvent(g),g.defaultPrevented||(xx(Sx(Tc(a)),{select:!0}),document.activeElement===y&&On(a))}return()=>{a.removeEventListener(Ci,c),setTimeout(()=>{const g=new CustomEvent(Ti,Cc);a.addEventListener(Ti,d),a.dispatchEvent(g),g.defaultPrevented||On(y??document.body,{select:!0}),a.removeEventListener(Ti,d),Ec.remove(h)},0)}}},[a,c,d,h]);const x=v.useCallback(y=>{if(!n&&!r||h.paused)return;const m=y.key==="Tab"&&!y.altKey&&!y.ctrlKey&&!y.metaKey,g=document.activeElement;if(m&&g){const b=y.currentTarget,[S,k]=yx(b);S&&k?!y.shiftKey&&g===k?(y.preventDefault(),n&&On(S,{select:!0})):y.shiftKey&&g===S&&(y.preventDefault(),n&&On(k,{select:!0})):g===b&&y.preventDefault()}},[n,r,h.paused]);return u.jsx(_e.div,{tabIndex:-1,...i,ref:p,onKeyDown:x})});$o.displayName=gx;function xx(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(On(r,{select:t}),document.activeElement!==n)return}function yx(e){const t=Tc(e),n=kc(t,e),r=kc(t.reverse(),e);return[n,r]}function Tc(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 kc(e,t){for(const n of e)if(!vx(n,{upTo:t}))return n}function vx(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 bx(e){return e instanceof HTMLInputElement&&"select"in e}function On(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&bx(e)&&t&&e.select()}}var Ec=wx();function wx(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Ic(e,t),e.unshift(t)},remove(t){var n;e=Ic(e,t),(n=e[0])==null||n.resume()}}}function Ic(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Sx(e){return e.filter(t=>t.tagName!=="A")}var Cx=v[" useId ".trim().toString()]||(()=>{}),Tx=0;function Nn(e){const[t,n]=v.useState(Cx());return _t(()=>{n(r=>r??String(Tx++))},[e]),t?`radix-${t}`:""}const kx=["top","right","bottom","left"],Mn=Math.min,Gt=Math.max,zo=Math.round,Bo=Math.floor,xn=e=>({x:e,y:e}),Ex={left:"right",right:"left",bottom:"top",top:"bottom"},Ix={start:"end",end:"start"};function ki(e,t,n){return Gt(e,Mn(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function jn(e){return e.split("-")[0]}function yr(e){return e.split("-")[1]}function Ei(e){return e==="x"?"y":"x"}function Ii(e){return e==="y"?"height":"width"}const Nx=new Set(["top","bottom"]);function yn(e){return Nx.has(jn(e))?"y":"x"}function Ni(e){return Ei(yn(e))}function Ax(e,t,n){n===void 0&&(n=!1);const r=yr(e),o=Ni(e),s=Ii(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Ho(i)),[i,Ho(i)]}function jx(e){const t=Ho(e);return[Ai(e),t,Ai(t)]}function Ai(e){return e.replace(/start|end/g,t=>Ix[t])}const Nc=["left","right"],Ac=["right","left"],_x=["top","bottom"],Rx=["bottom","top"];function Px(e,t,n){switch(e){case"top":case"bottom":return n?t?Ac:Nc:t?Nc:Ac;case"left":case"right":return t?_x:Rx;default:return[]}}function Ox(e,t,n,r){const o=yr(e);let s=Px(jn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ai)))),s}function Ho(e){return e.replace(/left|right|bottom|top/g,t=>Ex[t])}function Mx(e){return{top:0,right:0,bottom:0,left:0,...e}}function jc(e){return typeof e!="number"?Mx(e):{top:e,right:e,bottom:e,left:e}}function Uo(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 _c(e,t,n){let{reference:r,floating:o}=e;const s=yn(t),i=Ni(t),a=Ii(i),l=jn(t),c=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,p=r[a]/2-o[a]/2;let h;switch(l){case"top":h={x:d,y:r.y-o.height};break;case"bottom":h={x:d,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-o.width,y:f};break;default:h={x:r.x,y:r.y}}switch(yr(t)){case"start":h[i]-=p*(n&&c?-1:1);break;case"end":h[i]+=p*(n&&c?-1:1);break}return h}const Dx=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}=_c(c,r,l),p=r,h={},x=0;for(let y=0;y<a.length;y++){const{name:m,fn:g}=a[y],{x:b,y:S,data:k,reset:T}=await g({x:d,y:f,initialPlacement:r,placement:p,strategy:o,middlewareData:h,rects:c,platform:i,elements:{reference:e,floating:t}});d=b??d,f=S??f,h={...h,[m]:{...h[m],...k}},T&&x<=50&&(x++,typeof T=="object"&&(T.placement&&(p=T.placement),T.rects&&(c=T.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:d,y:f}=_c(c,p,l)),y=-1)}return{x:d,y:f,placement:p,strategy:o,middlewareData:h}};async function Br(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:p=!1,padding:h=0}=An(t,e),x=jc(h),m=a[p?f==="floating"?"reference":"floating":f],g=Uo(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(m)))==null||n?m:m.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},T=Uo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(g.top-T.top+x.top)/k.y,bottom:(T.bottom-g.bottom+x.bottom)/k.y,left:(g.left-T.left+x.left)/k.x,right:(T.right-g.right+x.right)/k.x}}const Lx=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}=An(e,t)||{};if(c==null)return{};const f=jc(d),p={x:n,y:r},h=Ni(o),x=Ii(h),y=await i.getDimensions(c),m=h==="y",g=m?"top":"left",b=m?"bottom":"right",S=m?"clientHeight":"clientWidth",k=s.reference[x]+s.reference[h]-p[h]-s.floating[x],T=p[h]-s.reference[h],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[x]);const j=k/2-T/2,A=E/2-y[x]/2-1,N=Mn(f[g],A),P=Mn(f[b],A),F=N,$=E-y[x]-P,R=E/2-y[x]/2+j,z=ki(F,R,$),_=!l.arrow&&yr(o)!=null&&R!==z&&s.reference[x]/2-(R<F?N:P)-y[x]/2<0,B=_?R<F?R-F:R-$:0;return{[h]:p[h]+B,data:{[h]:z,centerOffset:R-z-B,..._&&{alignmentOffset:B}},reset:_}}}),Fx=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:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:y=!0,...m}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const g=jn(o),b=yn(a),S=jn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),T=p||(S||!y?[Ho(a)]:jx(a)),C=x!=="none";!p&&C&&T.push(...Ox(a,y,x,k));const E=[a,...T],j=await Br(t,m),A=[];let N=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&A.push(j[g]),f){const R=Ax(o,i,k);A.push(j[R[0]],j[R[1]])}if(N=[...N,{placement:o,overflows:A}],!A.every(R=>R<=0)){var P,F;const R=(((P=s.flip)==null?void 0:P.index)||0)+1,z=E[R];if(z&&(!(f==="alignment"?b!==yn(z):!1)||N.every(L=>yn(L.placement)===b?L.overflows[0]>0:!0)))return{data:{index:R,overflows:N},reset:{placement:z}};let _=(F=N.filter(B=>B.overflows[0]<=0).sort((B,L)=>B.overflows[1]-L.overflows[1])[0])==null?void 0:F.placement;if(!_)switch(h){case"bestFit":{var $;const B=($=N.filter(L=>{if(C){const M=yn(L.placement);return M===b||M==="y"}return!0}).map(L=>[L.placement,L.overflows.filter(M=>M>0).reduce((M,J)=>M+J,0)]).sort((L,M)=>L[1]-M[1])[0])==null?void 0:$[0];B&&(_=B);break}case"initialPlacement":_=a;break}if(o!==_)return{reset:{placement:_}}}return{}}}};function Rc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Pc(e){return kx.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}=An(e,t);switch(r){case"referenceHidden":{const s=await Br(t,{...o,elementContext:"reference"}),i=Rc(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Pc(i)}}}case"escaped":{const s=await Br(t,{...o,altBoundary:!0}),i=Rc(s,n.floating);return{data:{escapedOffsets:i,escaped:Pc(i)}}}default:return{}}}}},Oc=new Set(["left","top"]);async function zx(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=jn(n),a=yr(n),l=yn(n)==="y",c=Oc.has(i)?-1:1,d=s&&l?-1:1,f=An(t,e);let{mainAxis:p,crossAxis:h,alignmentAxis:x}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof x=="number"&&(h=a==="end"?x*-1:x),l?{x:h*d,y:p*c}:{x:p*c,y:h*d}}const Bx=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 zx(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}}}}},Hx=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:m=>{let{x:g,y:b}=m;return{x:g,y:b}}},...l}=An(e,t),c={x:n,y:r},d=await Br(t,l),f=yn(jn(o)),p=Ei(f);let h=c[p],x=c[f];if(s){const m=p==="y"?"top":"left",g=p==="y"?"bottom":"right",b=h+d[m],S=h-d[g];h=ki(b,h,S)}if(i){const m=f==="y"?"top":"left",g=f==="y"?"bottom":"right",b=x+d[m],S=x-d[g];x=ki(b,x,S)}const y=a.fn({...t,[p]:h,[f]:x});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[p]:s,[f]:i}}}}}},Ux=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}=An(e,t),d={x:n,y:r},f=yn(o),p=Ei(f);let h=d[p],x=d[f];const y=An(a,t),m=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(l){const S=p==="y"?"height":"width",k=s.reference[p]-s.floating[S]+m.mainAxis,T=s.reference[p]+s.reference[S]-m.mainAxis;h<k?h=k:h>T&&(h=T)}if(c){var g,b;const S=p==="y"?"width":"height",k=Oc.has(jn(o)),T=s.reference[f]-s.floating[S]+(k&&((g=i.offset)==null?void 0:g[f])||0)+(k?0:m.crossAxis),C=s.reference[f]+s.reference[S]+(k?0:((b=i.offset)==null?void 0:b[f])||0)-(k?m.crossAxis:0);x<T?x=T:x>C&&(x=C)}return{[p]:h,[f]:x}}}},Wx=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}=An(e,t),d=await Br(t,c),f=jn(o),p=yr(o),h=yn(o)==="y",{width:x,height:y}=s.floating;let m,g;f==="top"||f==="bottom"?(m=f,g=p===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(g=f,m=p==="end"?"top":"bottom");const b=y-d.top-d.bottom,S=x-d.left-d.right,k=Mn(y-d[m],b),T=Mn(x-d[g],S),C=!t.middlewareData.shift;let E=k,j=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),C&&!p){const N=Gt(d.left,0),P=Gt(d.right,0),F=Gt(d.top,0),$=Gt(d.bottom,0);h?j=x-2*(N!==0||P!==0?N+P:Gt(d.left,d.right)):E=y-2*(F!==0||$!==0?F+$:Gt(d.top,d.bottom))}await l({...t,availableWidth:j,availableHeight:E});const A=await i.getDimensions(a.floating);return x!==A.width||y!==A.height?{reset:{rects:!0}}:{}}}};function Wo(){return typeof window<"u"}function vr(e){return Mc(e)?(e.nodeName||"").toLowerCase():"#document"}function Yt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function vn(e){var t;return(t=(Mc(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Mc(e){return Wo()?e instanceof Node||e instanceof Yt(e).Node:!1}function un(e){return Wo()?e instanceof Element||e instanceof Yt(e).Element:!1}function bn(e){return Wo()?e instanceof HTMLElement||e instanceof Yt(e).HTMLElement:!1}function Dc(e){return!Wo()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Yt(e).ShadowRoot}const Vx=new Set(["inline","contents"]);function Hr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=dn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Vx.has(o)}const Kx=new Set(["table","td","th"]);function qx(e){return Kx.has(vr(e))}const Gx=[":popover-open",":modal"];function Vo(e){return Gx.some(t=>{try{return e.matches(t)}catch{return!1}})}const Yx=["transform","translate","scale","rotate","perspective"],Xx=["transform","translate","scale","rotate","perspective","filter"],Jx=["paint","layout","strict","content"];function ji(e){const t=_i(),n=un(e)?dn(e):e;return Yx.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)||Xx.some(r=>(n.willChange||"").includes(r))||Jx.some(r=>(n.contain||"").includes(r))}function Zx(e){let t=Dn(e);for(;bn(t)&&!br(t);){if(ji(t))return t;if(Vo(t))return null;t=Dn(t)}return null}function _i(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Qx=new Set(["html","body","#document"]);function br(e){return Qx.has(vr(e))}function dn(e){return Yt(e).getComputedStyle(e)}function Ko(e){return un(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Dn(e){if(vr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Dc(e)&&e.host||vn(e);return Dc(t)?t.host:t}function Lc(e){const t=Dn(e);return br(t)?e.ownerDocument?e.ownerDocument.body:e.body:bn(t)&&Hr(t)?t:Lc(t)}function Ur(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Lc(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Yt(o);if(s){const a=Ri(i);return t.concat(i,i.visualViewport||[],Hr(o)?o:[],a&&n?Ur(a):[])}return t.concat(o,Ur(o,[],n))}function Ri(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Fc(e){const t=dn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=bn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=zo(n)!==s||zo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Pi(e){return un(e)?e:e.contextElement}function wr(e){const t=Pi(e);if(!bn(t))return xn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Fc(t);let i=(s?zo(n.width):n.width)/r,a=(s?zo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const ey=xn(0);function $c(e){const t=Yt(e);return!_i()||!t.visualViewport?ey:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function ty(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Yt(e)?!1:t}function Qn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Pi(e);let i=xn(1);t&&(r?un(r)&&(i=wr(r)):i=wr(e));const a=ty(s,n,r)?$c(s):xn(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 p=Yt(s),h=r&&un(r)?Yt(r):r;let x=p,y=Ri(x);for(;y&&r&&h!==x;){const m=wr(y),g=y.getBoundingClientRect(),b=dn(y),S=g.left+(y.clientLeft+parseFloat(b.paddingLeft))*m.x,k=g.top+(y.clientTop+parseFloat(b.paddingTop))*m.y;l*=m.x,c*=m.y,d*=m.x,f*=m.y,l+=S,c+=k,x=Yt(y),y=Ri(x)}}return Uo({width:d,height:f,x:l,y:c})}function qo(e,t){const n=Ko(e).scrollLeft;return t?t.left+n:Qn(vn(e)).left+n}function zc(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-qo(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function ny(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=vn(r),a=t?Vo(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=xn(1);const d=xn(0),f=bn(r);if((f||!f&&!s)&&((vr(r)!=="body"||Hr(i))&&(l=Ko(r)),bn(r))){const h=Qn(r);c=wr(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}const p=i&&!f&&!s?zc(i,l):xn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+p.x,y:n.y*c.y-l.scrollTop*c.y+d.y+p.y}}function ry(e){return Array.from(e.getClientRects())}function oy(e){const t=vn(e),n=Ko(e),r=e.ownerDocument.body,o=Gt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Gt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+qo(e);const a=-n.scrollTop;return dn(r).direction==="rtl"&&(i+=Gt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Bc=25;function sy(e,t){const n=Yt(e),r=vn(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=_i();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=qo(r);if(c<=0){const d=r.ownerDocument,f=d.body,p=getComputedStyle(f),h=d.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,x=Math.abs(r.clientWidth-f.clientWidth-h);x<=Bc&&(s-=x)}else c<=Bc&&(s+=c);return{width:s,height:i,x:a,y:l}}const iy=new Set(["absolute","fixed"]);function ay(e,t){const n=Qn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=bn(e)?wr(e):xn(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 Hc(e,t,n){let r;if(t==="viewport")r=sy(e,n);else if(t==="document")r=oy(vn(e));else if(un(t))r=ay(t,n);else{const o=$c(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Uo(r)}function Uc(e,t){const n=Dn(e);return n===t||!un(n)||br(n)?!1:dn(n).position==="fixed"||Uc(n,t)}function ly(e,t){const n=t.get(e);if(n)return n;let r=Ur(e,[],!1).filter(a=>un(a)&&vr(a)!=="body"),o=null;const s=dn(e).position==="fixed";let i=s?Dn(e):e;for(;un(i)&&!br(i);){const a=dn(i),l=ji(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&iy.has(o.position)||Hr(i)&&!l&&Uc(e,i))?r=r.filter(d=>d!==i):o=a,i=Dn(i)}return t.set(e,r),r}function cy(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Vo(t)?[]:ly(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const f=Hc(t,d,o);return c.top=Gt(f.top,c.top),c.right=Mn(f.right,c.right),c.bottom=Mn(f.bottom,c.bottom),c.left=Gt(f.left,c.left),c},Hc(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function uy(e){const{width:t,height:n}=Fc(e);return{width:t,height:n}}function dy(e,t,n){const r=bn(t),o=vn(t),s=n==="fixed",i=Qn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=xn(0);function c(){l.x=qo(o)}if(r||!r&&!s)if((vr(t)!=="body"||Hr(o))&&(a=Ko(t)),r){const h=Qn(t,!0,s,t);l.x=h.x+t.clientLeft,l.y=h.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?zc(o,a):xn(0),f=i.left+a.scrollLeft-l.x-d.x,p=i.top+a.scrollTop-l.y-d.y;return{x:f,y:p,width:i.width,height:i.height}}function Oi(e){return dn(e).position==="static"}function Wc(e,t){if(!bn(e)||dn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return vn(e)===n&&(n=n.ownerDocument.body),n}function Vc(e,t){const n=Yt(e);if(Vo(e))return n;if(!bn(e)){let o=Dn(e);for(;o&&!br(o);){if(un(o)&&!Oi(o))return o;o=Dn(o)}return n}let r=Wc(e,t);for(;r&&qx(r)&&Oi(r);)r=Wc(r,t);return r&&br(r)&&Oi(r)&&!ji(r)?n:r||Zx(e)||n}const fy=async function(e){const t=this.getOffsetParent||Vc,n=this.getDimensions,r=await n(e.floating);return{reference:dy(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function py(e){return dn(e).direction==="rtl"}const hy={convertOffsetParentRelativeRectToViewportRelativeRect:ny,getDocumentElement:vn,getClippingRect:cy,getOffsetParent:Vc,getElementRects:fy,getClientRects:ry,getDimensions:uy,getScale:wr,isElement:un,isRTL:py};function Kc(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function my(e,t){let n=null,r;const o=vn(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:p,height:h}=c;if(a||t(),!p||!h)return;const x=Bo(f),y=Bo(o.clientWidth-(d+p)),m=Bo(o.clientHeight-(f+h)),g=Bo(d),S={rootMargin:-x+"px "+-y+"px "+-m+"px "+-g+"px",threshold:Gt(0,Mn(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&&!Kc(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 gy(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=Pi(e),d=o||s?[...c?Ur(c):[],...Ur(t)]:[];d.forEach(g=>{o&&g.addEventListener("scroll",n,{passive:!0}),s&&g.addEventListener("resize",n)});const f=c&&a?my(c,n):null;let p=-1,h=null;i&&(h=new ResizeObserver(g=>{let[b]=g;b&&b.target===c&&h&&(h.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var S;(S=h)==null||S.observe(t)})),n()}),c&&!l&&h.observe(c),h.observe(t));let x,y=l?Qn(e):null;l&&m();function m(){const g=Qn(e);y&&!Kc(y,g)&&n(),y=g,x=requestAnimationFrame(m)}return n(),()=>{var g;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(g=h)==null||g.disconnect(),h=null,l&&cancelAnimationFrame(x)}}const xy=Bx,yy=Hx,vy=Fx,by=Wx,wy=$x,qc=Lx,Sy=Ux,Cy=(e,t,n)=>{const r=new Map,o={platform:hy,...n},s={...o.platform,_c:r};return Dx(e,t,{...o,platform:s})};var Ty=typeof document<"u",ky=function(){},Go=Ty?w.useLayoutEffect:ky;function Yo(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(!Yo(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)&&!Yo(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Gc(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Yc(e,t){const n=Gc(e);return Math.round(t*n)/n}function Mi(e){const t=v.useRef(e);return Go(()=>{t.current=e}),t}function Ey(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}),[p,h]=v.useState(r);Yo(p,r)||h(r);const[x,y]=v.useState(null),[m,g]=v.useState(null),b=v.useCallback(L=>{L!==C.current&&(C.current=L,y(L))},[]),S=v.useCallback(L=>{L!==E.current&&(E.current=L,g(L))},[]),k=s||x,T=i||m,C=v.useRef(null),E=v.useRef(null),j=v.useRef(d),A=l!=null,N=Mi(l),P=Mi(o),F=Mi(c),$=v.useCallback(()=>{if(!C.current||!E.current)return;const L={placement:t,strategy:n,middleware:p};P.current&&(L.platform=P.current),Cy(C.current,E.current,L).then(M=>{const J={...M,isPositioned:F.current!==!1};R.current&&!Yo(j.current,J)&&(j.current=J,yo.flushSync(()=>{f(J)}))})},[p,t,n,P,F]);Go(()=>{c===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,f(L=>({...L,isPositioned:!1})))},[c]);const R=v.useRef(!1);Go(()=>(R.current=!0,()=>{R.current=!1}),[]),Go(()=>{if(k&&(C.current=k),T&&(E.current=T),k&&T){if(N.current)return N.current(k,T,$);$()}},[k,T,$,N,A]);const z=v.useMemo(()=>({reference:C,floating:E,setReference:b,setFloating:S}),[b,S]),_=v.useMemo(()=>({reference:k,floating:T}),[k,T]),B=v.useMemo(()=>{const L={position:n,left:0,top:0};if(!_.floating)return L;const M=Yc(_.floating,d.x),J=Yc(_.floating,d.y);return a?{...L,transform:"translate("+M+"px, "+J+"px)",...Gc(_.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:M,top:J}},[n,a,_.floating,d.x,d.y]);return v.useMemo(()=>({...d,update:$,refs:z,elements:_,floatingStyles:B}),[d,$,z,_,B])}const Iy=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?qc({element:r.current,padding:o}).fn(n):{}:r?qc({element:r,padding:o}).fn(n):{}}}},Ny=(e,t)=>({...xy(e),options:[e,t]}),Ay=(e,t)=>({...yy(e),options:[e,t]}),jy=(e,t)=>({...Sy(e),options:[e,t]}),_y=(e,t)=>({...vy(e),options:[e,t]}),Ry=(e,t)=>({...by(e),options:[e,t]}),Py=(e,t)=>({...wy(e),options:[e,t]}),Oy=(e,t)=>({...Iy(e),options:[e,t]});var My="Arrow",Xc=v.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(_e.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"})})});Xc.displayName=My;var Dy=Xc;function Jc(e){const[t,n]=v.useState(void 0);return _t(()=>{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 Di="Popper",[Zc,Xo]=In(Di),[Ly,Qc]=Zc(Di),eu=e=>{const{__scopePopper:t,children:n}=e,[r,o]=v.useState(null);return u.jsx(Ly,{scope:t,anchor:r,onAnchorChange:o,children:n})};eu.displayName=Di;var tu="PopperAnchor",nu=v.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Qc(tu,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(_e.div,{...o,ref:a})});nu.displayName=tu;var Li="PopperContent",[Fy,$y]=Zc(Li),ru=v.forwardRef((e,t)=>{var W,D,H,te,ae,ne;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:p=!1,updatePositionStrategy:h="optimized",onPlaced:x,...y}=e,m=Qc(Li,n),[g,b]=v.useState(null),S=We(t,Le=>b(Le)),[k,T]=v.useState(null),C=Jc(k),E=(C==null?void 0:C.width)??0,j=(C==null?void 0:C.height)??0,A=r+(s!=="center"?"-"+s:""),N=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},P=Array.isArray(c)?c:[c],F=P.length>0,$={padding:N,boundary:P.filter(By),altBoundary:F},{refs:R,floatingStyles:z,placement:_,isPositioned:B,middlewareData:L}=Ey({strategy:"fixed",placement:A,whileElementsMounted:(...Le)=>gy(...Le,{animationFrame:h==="always"}),elements:{reference:m.anchor},middleware:[Ny({mainAxis:o+j,alignmentAxis:i}),l&&Ay({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?jy():void 0,...$}),l&&_y({...$}),Ry({...$,apply:({elements:Le,rects:Q,availableWidth:ie,availableHeight:ke})=>{const{width:Re,height:Ke}=Q.reference,ze=Le.floating.style;ze.setProperty("--radix-popper-available-width",`${ie}px`),ze.setProperty("--radix-popper-available-height",`${ke}px`),ze.setProperty("--radix-popper-anchor-width",`${Re}px`),ze.setProperty("--radix-popper-anchor-height",`${Ke}px`)}}),k&&Oy({element:k,padding:a}),Hy({arrowWidth:E,arrowHeight:j}),p&&Py({strategy:"referenceHidden",...$})]}),[M,J]=iu(_),X=Rt(x);_t(()=>{B&&(X==null||X())},[B,X]);const pe=(W=L.arrow)==null?void 0:W.x,Ne=(D=L.arrow)==null?void 0:D.y,je=((H=L.arrow)==null?void 0:H.centerOffset)!==0,[G,ee]=v.useState();return _t(()=>{g&&ee(window.getComputedStyle(g).zIndex)},[g]),u.jsx("div",{ref:R.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:B?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:G,"--radix-popper-transform-origin":[(te=L.transformOrigin)==null?void 0:te.x,(ae=L.transformOrigin)==null?void 0:ae.y].join(" "),...((ne=L.hide)==null?void 0:ne.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(Fy,{scope:n,placedSide:M,onArrowChange:T,arrowX:pe,arrowY:Ne,shouldHideArrow:je,children:u.jsx(_e.div,{"data-side":M,"data-align":J,...y,ref:S,style:{...y.style,animation:B?void 0:"none"}})})})});ru.displayName=Li;var ou="PopperArrow",zy={top:"bottom",right:"left",bottom:"top",left:"right"},su=v.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=$y(ou,r),i=zy[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(Dy,{...o,ref:n,style:{...o.style,display:"block"}})})});su.displayName=ou;function By(e){return e!==null}var Hy=e=>({name:"transformOrigin",options:e,fn(t){var m,g,b;const{placement:n,rects:r,middlewareData:o}=t,i=((m=o.arrow)==null?void 0:m.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,d]=iu(n),f={start:"0%",center:"50%",end:"100%"}[d],p=(((g=o.arrow)==null?void 0:g.x)??0)+a/2,h=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let x="",y="";return c==="bottom"?(x=i?f:`${p}px`,y=`${-l}px`):c==="top"?(x=i?f:`${p}px`,y=`${r.floating.height+l}px`):c==="right"?(x=`${-l}px`,y=i?f:`${h}px`):c==="left"&&(x=`${r.floating.width+l}px`,y=i?f:`${h}px`),{data:{x,y}}}});function iu(e){const[t,n="center"]=e.split("-");return[t,n]}var au=eu,lu=nu,cu=ru,uu=su,Uy="Portal",Jo=v.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=v.useState(!1);_t(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Js.createPortal(u.jsx(_e.div,{...r,ref:t}),i):null});Jo.displayName=Uy;function Wy(e,t){return v.useReducer((n,r)=>t[n][r]??n,e)}var tn=e=>{const{present:t,children:n}=e,r=Vy(t),o=typeof n=="function"?n({present:r.isPresent}):v.Children.only(n),s=We(r.ref,Ky(o));return typeof n=="function"||r.isPresent?v.cloneElement(o,{ref:s}):null};tn.displayName="Presence";function Vy(e){const[t,n]=v.useState(),r=v.useRef(null),o=v.useRef(e),s=v.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Wy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const c=Zo(r.current);s.current=a==="mounted"?c:"none"},[a]),_t(()=>{const c=r.current,d=o.current;if(d!==e){const p=s.current,h=Zo(c);e?l("MOUNT"):h==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&p!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),_t(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,f=h=>{const y=Zo(r.current).includes(CSS.escape(h.animationName));if(h.target===t&&y&&(l("ANIMATION_END"),!o.current)){const m=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=m)})}},p=h=>{h.target===t&&(s.current=Zo(r.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",p),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 Zo(e){return(e==null?void 0:e.animationName)||"none"}function Ky(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 Fi="rovingFocusGroup.onEntryFocus",qy={bubbles:!1,cancelable:!0},Wr="RovingFocusGroup",[$i,du,Gy]=vi(Wr),[Yy,fu]=In(Wr,[Gy]),[Xy,Jy]=Yy(Wr),pu=v.forwardRef((e,t)=>u.jsx($i.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx($i.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Zy,{...e,ref:t})})}));pu.displayName=Wr;var Zy=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,p=v.useRef(null),h=We(t,p),x=Lo(s),[y,m]=xr({prop:i,defaultProp:a??null,onChange:l,caller:Wr}),[g,b]=v.useState(!1),S=Rt(c),k=du(n),T=v.useRef(!1),[C,E]=v.useState(0);return v.useEffect(()=>{const j=p.current;if(j)return j.addEventListener(Fi,S),()=>j.removeEventListener(Fi,S)},[S]),u.jsx(Xy,{scope:n,orientation:r,dir:x,loop:o,currentTabStopId:y,onItemFocus:v.useCallback(j=>m(j),[m]),onItemShiftTab:v.useCallback(()=>b(!0),[]),onFocusableItemAdd:v.useCallback(()=>E(j=>j+1),[]),onFocusableItemRemove:v.useCallback(()=>E(j=>j-1),[]),children:u.jsx(_e.div,{tabIndex:g||C===0?-1:0,"data-orientation":r,...f,ref:h,style:{outline:"none",...e.style},onMouseDown:fe(e.onMouseDown,()=>{T.current=!0}),onFocus:fe(e.onFocus,j=>{const A=!T.current;if(j.target===j.currentTarget&&A&&!g){const N=new CustomEvent(Fi,qy);if(j.currentTarget.dispatchEvent(N),!N.defaultPrevented){const P=k().filter(_=>_.focusable),F=P.find(_=>_.active),$=P.find(_=>_.id===y),z=[F,$,...P].filter(Boolean).map(_=>_.ref.current);gu(z,d)}}T.current=!1}),onBlur:fe(e.onBlur,()=>b(!1))})})}),hu="RovingFocusGroupItem",mu=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Nn(),c=s||l,d=Jy(hu,n),f=d.currentTabStopId===c,p=du(n),{onFocusableItemAdd:h,onFocusableItemRemove:x,currentTabStopId:y}=d;return v.useEffect(()=>{if(r)return h(),()=>x()},[r,h,x]),u.jsx($i.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(_e.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:fe(e.onMouseDown,m=>{r?d.onItemFocus(c):m.preventDefault()}),onFocus:fe(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:fe(e.onKeyDown,m=>{if(m.key==="Tab"&&m.shiftKey){d.onItemShiftTab();return}if(m.target!==m.currentTarget)return;const g=tv(m,d.orientation,d.dir);if(g!==void 0){if(m.metaKey||m.ctrlKey||m.altKey||m.shiftKey)return;m.preventDefault();let S=p().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(m.currentTarget);S=d.loop?nv(S,k+1):S.slice(k+1)}setTimeout(()=>gu(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:y!=null}):i})})});mu.displayName=hu;var Qy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ev(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function tv(e,t,n){const r=ev(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Qy[r]}function gu(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function nv(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var rv=pu,ov=mu,sv=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Sr=new WeakMap,Qo=new WeakMap,es={},zi=0,xu=function(e){return e&&(e.host||xu(e.parentNode))},iv=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=xu(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})},av=function(e,t,n,r){var o=iv(t,Array.isArray(e)?e:[e]);es[n]||(es[n]=new WeakMap);var s=es[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(p){if(a.has(p))d(p);else try{var h=p.getAttribute(r),x=h!==null&&h!=="false",y=(Sr.get(p)||0)+1,m=(s.get(p)||0)+1;Sr.set(p,y),s.set(p,m),i.push(p),y===1&&x&&Qo.set(p,!0),m===1&&p.setAttribute(n,"true"),x||p.setAttribute(r,"true")}catch(g){console.error("aria-hidden: cannot operate on ",p,g)}})};return d(t),a.clear(),zi++,function(){i.forEach(function(f){var p=Sr.get(f)-1,h=s.get(f)-1;Sr.set(f,p),s.set(f,h),p||(Qo.has(f)||f.removeAttribute(r),Qo.delete(f)),h||f.removeAttribute(n)}),zi--,zi||(Sr=new WeakMap,Sr=new WeakMap,Qo=new WeakMap,es={})}},Bi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=sv(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),av(r,o,n,"aria-hidden")):function(){return null}},wn=function(){return wn=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},wn.apply(this,arguments)};function yu(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 lv(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 ts="right-scroll-bar-position",ns="width-before-scroll-bar",cv="with-scroll-bars-hidden",uv="--removed-body-scroll-bar-size";function Hi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function dv(e,t){var n=w.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var fv=typeof window<"u"?v.useLayoutEffect:v.useEffect,vu=new WeakMap;function pv(e,t){var n=dv(null,function(r){return e.forEach(function(o){return Hi(o,r)})});return fv(function(){var r=vu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Hi(a,null)}),s.forEach(function(a){o.has(a)||Hi(a,i)})}vu.set(n,e)},[e]),n}function hv(e){return e}function mv(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 gv(e){e===void 0&&(e={});var t=mv(null);return t.options=wn({async:!0,ssr:!1},e),t}var bu=function(e){var t=e.sideCar,n=yu(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,wn({},n))};bu.isSideCarExport=!0;function xv(e,t){return e.useMedium(t),bu}var wu=gv(),Ui=function(){},rs=v.forwardRef(function(e,t){var n=v.useRef(null),r=v.useState({onScrollCapture:Ui,onWheelCapture:Ui,onTouchMoveCapture:Ui}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,f=e.shards,p=e.sideCar,h=e.noRelative,x=e.noIsolation,y=e.inert,m=e.allowPinchZoom,g=e.as,b=g===void 0?"div":g,S=e.gapMode,k=yu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),T=p,C=pv([n,t]),E=wn(wn({},k),o);return v.createElement(v.Fragment,null,d&&v.createElement(T,{sideCar:wu,removeScrollBar:c,shards:f,noRelative:h,noIsolation:x,inert:y,setCallbacks:s,allowPinchZoom:!!m,lockRef:n,gapMode:S}),i?v.cloneElement(v.Children.only(a),wn(wn({},E),{ref:C})):v.createElement(b,wn({},E,{className:l,ref:C}),a))});rs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},rs.classNames={fullWidth:ns,zeroRight:ts};var yv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function vv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=yv();return t&&e.setAttribute("nonce",t),e}function bv(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 Sv=function(){var e=0,t=null;return{add:function(n){e==0&&(t=vv())&&(bv(t,n),wv(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Cv=function(){var e=Sv();return function(t,n){v.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Su=function(){var e=Cv(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Tv={left:0,top:0,right:0,gap:0},Wi=function(e){return parseInt(e||"",10)||0},kv=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Wi(n),Wi(r),Wi(o)]},Ev=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Tv;var t=kv(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])}},Iv=Su(),Cr="data-scroll-locked",Nv=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(cv,` {
|
|
40
40
|
overflow: hidden `).concat(r,`;
|
|
41
41
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
@@ -75,7 +75,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
75
75
|
`)},Cu=function(){var e=parseInt(document.body.getAttribute(Cr)||"0",10);return isFinite(e)?e:0},Av=function(){v.useEffect(function(){return document.body.setAttribute(Cr,(Cu()+1).toString()),function(){var e=Cu()-1;e<=0?document.body.removeAttribute(Cr):document.body.setAttribute(Cr,e.toString())}},[])},jv=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Av();var s=v.useMemo(function(){return Ev(o)},[o]);return v.createElement(Iv,{styles:Nv(s,!t,o,n?"":"!important")})},Vi=!1;if(typeof window<"u")try{var os=Object.defineProperty({},"passive",{get:function(){return Vi=!0,!0}});window.addEventListener("test",os,os),window.removeEventListener("test",os,os)}catch{Vi=!1}var Tr=Vi?{passive:!1}:!1,_v=function(e){return e.tagName==="TEXTAREA"},Tu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!_v(e)&&n[t]==="visible")},Rv=function(e){return Tu(e,"overflowY")},Pv=function(e){return Tu(e,"overflowX")},ku=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Eu(e,r);if(o){var s=Iu(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Ov=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Mv=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Eu=function(e,t){return e==="v"?Rv(t):Pv(t)},Iu=function(e,t){return e==="v"?Ov(t):Mv(t)},Dv=function(e,t){return e==="h"&&t==="rtl"?-1:1},Lv=function(e,t,n,r,o){var s=Dv(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,f=0,p=0;do{if(!a)break;var h=Iu(e,a),x=h[0],y=h[1],m=h[2],g=y-m-s*x;(x||g)&&Eu(e,a)&&(f+=g,p+=x);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(p)<1)&&(c=!0),c},ss=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Nu=function(e){return[e.deltaX,e.deltaY]},Au=function(e){return e&&"current"in e?e.current:e},Fv=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
|
-
`)},zv=0,kr=[];function Bv(e){var t=v.useRef([]),n=v.useRef([0,0]),r=v.useRef(),o=v.useState(zv++)[0],s=v.useState(Su)[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 y=lv([e.lockRef.current],(e.shards||[]).map(Au),!0).filter(Boolean);return y.forEach(function(m){return m.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),y.forEach(function(m){return m.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=v.useCallback(function(y,m){if("touches"in y&&y.touches.length===2||y.type==="wheel"&&y.ctrlKey)return!i.current.allowPinchZoom;var g=ss(y),b=n.current,S="deltaX"in y?y.deltaX:b[0]-g[0],k="deltaY"in y?y.deltaY:b[1]-g[1],T,C=y.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in y&&E==="h"&&C.type==="range")return!1;var j=ku(E,C);if(!j)return!0;if(j?T=E:(T=E==="v"?"h":"v",j=ku(E,C)),!j)return!1;if(!r.current&&"changedTouches"in y&&(S||k)&&(r.current=T),!T)return!0;var A=r.current||T;return Lv(A,m,y,A==="h"?S:k)},[]),l=v.useCallback(function(y){var m=y;if(!(!kr.length||kr[kr.length-1]!==s)){var g="deltaY"in m?Nu(m):ss(m),b=t.current.filter(function(T){return T.name===m.type&&(T.target===m.target||m.target===T.shadowParent)&&Fv(T.delta,g)})[0];if(b&&b.should){m.cancelable&&m.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Au).filter(Boolean).filter(function(T){return T.contains(m.target)}),k=S.length>0?a(m,S[0]):!i.current.noIsolation;k&&m.cancelable&&m.preventDefault()}}},[]),c=v.useCallback(function(y,m,g,b){var S={name:y,delta:m,target:g,should:b,shadowParent:Hv(g)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=v.useCallback(function(y){n.current=ss(y),r.current=void 0},[]),f=v.useCallback(function(y){c(y.type,Nu(y),y.target,a(y,e.lockRef.current))},[]),p=v.useCallback(function(y){c(y.type,ss(y),y.target,a(y,e.lockRef.current))},[]);v.useEffect(function(){return kr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",l,Tr),document.addEventListener("touchmove",l,Tr),document.addEventListener("touchstart",d,Tr),function(){kr=kr.filter(function(y){return y!==s}),document.removeEventListener("wheel",l,Tr),document.removeEventListener("touchmove",l,Tr),document.removeEventListener("touchstart",d,Tr)}},[]);var h=e.removeScrollBar,x=e.inert;return v.createElement(v.Fragment,null,x?v.createElement(s,{styles:$v(o)}):null,h?v.createElement(jv,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Hv(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Uv=xv(wu,Bv);var is=v.forwardRef(function(e,t){return v.createElement(rs,wn({},e,{ref:t,sideCar:Uv}))});is.classNames=rs.classNames;var Ki=["Enter"," "],Wv=["ArrowDown","PageUp","Home"],ju=["ArrowUp","PageDown","End"],Vv=[...Wv,...ju],Kv={ltr:[...Ki,"ArrowRight"],rtl:[...Ki,"ArrowLeft"]},qv={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Vr="Menu",[Kr,Gv,Yv]=vi(Vr),[er,_u]=In(Vr,[Yv,Xo,fu]),as=Xo(),Ru=fu(),[Xv,tr]=er(Vr),[Jv,qr]=er(Vr),Pu=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=as(t),[l,c]=v.useState(null),d=v.useRef(!1),f=Rt(s),p=Lo(o);return v.useEffect(()=>{const h=()=>{d.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},x=()=>d.current=!1;return document.addEventListener("keydown",h,{capture:!0}),()=>{document.removeEventListener("keydown",h,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),u.jsx(au,{...a,children:u.jsx(Xv,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c,children:u.jsx(Jv,{scope:t,onClose:v.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:i,children:r})})})};Pu.displayName=Vr;var Zv="MenuAnchor",qi=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=as(n);return u.jsx(lu,{...o,...r,ref:t})});qi.displayName=Zv;var Gi="MenuPortal",[Qv,Ou]=er(Gi,{forceMount:void 0}),Mu=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=tr(Gi,t);return u.jsx(Qv,{scope:t,forceMount:n,children:u.jsx(tn,{present:n||s.open,children:u.jsx(Jo,{asChild:!0,container:o,children:r})})})};Mu.displayName=Gi;var nn="MenuContent",[eb,Yi]=er(nn),Du=v.forwardRef((e,t)=>{const n=Ou(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(nn,e.__scopeMenu),i=qr(nn,e.__scopeMenu);return u.jsx(Kr.Provider,{scope:e.__scopeMenu,children:u.jsx(tn,{present:r||s.open,children:u.jsx(Kr.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(tb,{...o,ref:t}):u.jsx(nb,{...o,ref:t})})})})}),tb=v.forwardRef((e,t)=>{const n=tr(nn,e.__scopeMenu),r=v.useRef(null),o=Ue(t,r);return v.useEffect(()=>{const s=r.current;if(s)return Bi(s)},[]),u.jsx(Xi,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:fe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),nb=v.forwardRef((e,t)=>{const n=tr(nn,e.__scopeMenu);return u.jsx(Xi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),rb=Yn.createSlot("MenuContent.ScrollLock"),Xi=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:p,onDismiss:h,disableOutsideScroll:x,...y}=e,m=tr(nn,n),g=qr(nn,n),b=as(n),S=Ru(n),k=Gv(n),[T,C]=v.useState(null),E=v.useRef(null),j=Ue(t,E,m.onContentChange),A=v.useRef(0),N=v.useRef(""),P=v.useRef(0),F=v.useRef(null),$=v.useRef("right"),R=v.useRef(0),z=x?is:v.Fragment,_=x?{as:rb,allowPinchZoom:!0}:void 0,B=M=>{var W,D;const J=N.current+M,X=k().filter(H=>!H.disabled),pe=document.activeElement,Ie=(W=X.find(H=>H.ref.current===pe))==null?void 0:W.textValue,je=X.map(H=>H.textValue),G=mb(je,J,Ie),ee=(D=X.find(H=>H.textValue===G))==null?void 0:D.ref.current;(function H(te){N.current=te,window.clearTimeout(A.current),te!==""&&(A.current=window.setTimeout(()=>H(""),1e3))})(J),ee&&setTimeout(()=>ee.focus())};v.useEffect(()=>()=>window.clearTimeout(A.current),[]),Si();const L=v.useCallback(M=>{var X,pe;return $.current===((X=F.current)==null?void 0:X.side)&&xb(M,(pe=F.current)==null?void 0:pe.area)},[]);return u.jsx(eb,{scope:n,searchRef:N,onItemEnter:v.useCallback(M=>{L(M)&&M.preventDefault()},[L]),onItemLeave:v.useCallback(M=>{var J;L(M)||((J=E.current)==null||J.focus(),C(null))},[L]),onTriggerLeave:v.useCallback(M=>{L(M)&&M.preventDefault()},[L]),pointerGraceTimerRef:P,onPointerGraceIntentChange:v.useCallback(M=>{F.current=M},[]),children:u.jsx(z,{..._,children:u.jsx($o,{asChild:!0,trapped:o,onMountAutoFocus:fe(s,M=>{var J;M.preventDefault(),(J=E.current)==null||J.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Fo,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:h,children:u.jsx(rv,{asChild:!0,...S,dir:g.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:C,onEntryFocus:fe(l,M=>{g.isUsingKeyboardRef.current||M.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(cu,{role:"menu","aria-orientation":"vertical","data-state":Qu(m.open),"data-radix-menu-content":"",dir:g.dir,...b,...y,ref:j,style:{outline:"none",...y.style},onKeyDown:fe(y.onKeyDown,M=>{const X=M.target.closest("[data-radix-menu-content]")===M.currentTarget,pe=M.ctrlKey||M.altKey||M.metaKey,Ie=M.key.length===1;X&&(M.key==="Tab"&&M.preventDefault(),!pe&&Ie&&B(M.key));const je=E.current;if(M.target!==je||!Vv.includes(M.key))return;M.preventDefault();const ee=k().filter(W=>!W.disabled).map(W=>W.ref.current);ju.includes(M.key)&&ee.reverse(),pb(ee)}),onBlur:fe(e.onBlur,M=>{M.currentTarget.contains(M.target)||(window.clearTimeout(A.current),N.current="")}),onPointerMove:fe(e.onPointerMove,Yr(M=>{const J=M.target,X=R.current!==M.clientX;if(M.currentTarget.contains(J)&&X){const pe=M.clientX>R.current?"right":"left";$.current=pe,R.current=M.clientX}}))})})})})})})});Du.displayName=nn;var ob="MenuGroup",Ji=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(_e.div,{role:"group",...r,ref:t})});Ji.displayName=ob;var sb="MenuLabel",Lu=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(_e.div,{...r,ref:t})});Lu.displayName=sb;var ls="MenuItem",Fu="menu.itemSelect",cs=v.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=v.useRef(null),i=qr(ls,e.__scopeMenu),a=Yi(ls,e.__scopeMenu),l=Ue(t,s),c=v.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const p=new CustomEvent(Fu,{bubbles:!0,cancelable:!0});f.addEventListener(Fu,h=>r==null?void 0:r(h),{once:!0}),xc(f,p),p.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx($u,{...o,ref:l,disabled:n,onClick:fe(e.onClick,d),onPointerDown:f=>{var p;(p=e.onPointerDown)==null||p.call(e,f),c.current=!0},onPointerUp:fe(e.onPointerUp,f=>{var p;c.current||(p=f.currentTarget)==null||p.click()}),onKeyDown:fe(e.onKeyDown,f=>{const p=a.searchRef.current!=="";n||p&&f.key===" "||Ki.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});cs.displayName=ls;var $u=v.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Yi(ls,n),a=Ru(n),l=v.useRef(null),c=Ue(t,l),[d,f]=v.useState(!1),[p,h]=v.useState("");return v.useEffect(()=>{const x=l.current;x&&h((x.textContent??"").trim())},[s.children]),u.jsx(Kr.ItemSlot,{scope:n,disabled:r,textValue:o??p,children:u.jsx(ov,{asChild:!0,...a,focusable:!r,children:u.jsx(_e.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:fe(e.onPointerMove,Yr(x=>{r?i.onItemLeave(x):(i.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:fe(e.onPointerLeave,Yr(x=>i.onItemLeave(x))),onFocus:fe(e.onFocus,()=>f(!0)),onBlur:fe(e.onBlur,()=>f(!1))})})})}),ib="MenuCheckboxItem",zu=v.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(Vu,{scope:e.__scopeMenu,checked:n,children:u.jsx(cs,{role:"menuitemcheckbox","aria-checked":us(n)?"mixed":n,...o,ref:t,"data-state":Qi(n),onSelect:fe(o.onSelect,()=>r==null?void 0:r(us(n)?!0:!n),{checkForDefaultPrevented:!1})})})});zu.displayName=ib;var Bu="MenuRadioGroup",[ab,lb]=er(Bu,{value:void 0,onValueChange:()=>{}}),Hu=v.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Rt(r);return u.jsx(ab,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Ji,{...o,ref:t})})});Hu.displayName=Bu;var Uu="MenuRadioItem",Wu=v.forwardRef((e,t)=>{const{value:n,...r}=e,o=lb(Uu,e.__scopeMenu),s=n===o.value;return u.jsx(Vu,{scope:e.__scopeMenu,checked:s,children:u.jsx(cs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Qi(s),onSelect:fe(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Wu.displayName=Uu;var Zi="MenuItemIndicator",[Vu,cb]=er(Zi,{checked:!1}),Ku=v.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=cb(Zi,n);return u.jsx(tn,{present:r||us(s.checked)||s.checked===!0,children:u.jsx(_e.span,{...o,ref:t,"data-state":Qi(s.checked)})})});Ku.displayName=Zi;var ub="MenuSeparator",qu=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(_e.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});qu.displayName=ub;var db="MenuArrow",Gu=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=as(n);return u.jsx(uu,{...o,...r,ref:t})});Gu.displayName=db;var fb="MenuSub",[gT,Yu]=er(fb),Gr="MenuSubTrigger",Xu=v.forwardRef((e,t)=>{const n=tr(Gr,e.__scopeMenu),r=qr(Gr,e.__scopeMenu),o=Yu(Gr,e.__scopeMenu),s=Yi(Gr,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(qi,{asChild:!0,...c,children:u.jsx($u,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Qu(n.open),...e,ref:yi(t,o.onTriggerChange),onClick:f=>{var p;(p=e.onClick)==null||p.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:fe(e.onPointerMove,Yr(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:fe(e.onPointerLeave,Yr(f=>{var h,x;d();const p=(h=n.content)==null?void 0:h.getBoundingClientRect();if(p){const y=(x=n.content)==null?void 0:x.dataset.side,m=y==="right",g=m?-5:5,b=p[m?"left":"right"],S=p[m?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+g,y:f.clientY},{x:b,y:p.top},{x:S,y:p.top},{x:S,y:p.bottom},{x:b,y:p.bottom}],side:y}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:fe(e.onKeyDown,f=>{var h;const p=s.searchRef.current!=="";e.disabled||p&&f.key===" "||Kv[r.dir].includes(f.key)&&(n.onOpenChange(!0),(h=n.content)==null||h.focus(),f.preventDefault())})})})});Xu.displayName=Gr;var Ju="MenuSubContent",Zu=v.forwardRef((e,t)=>{const n=Ou(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(nn,e.__scopeMenu),i=qr(nn,e.__scopeMenu),a=Yu(Ju,e.__scopeMenu),l=v.useRef(null),c=Ue(t,l);return u.jsx(Kr.Provider,{scope:e.__scopeMenu,children:u.jsx(tn,{present:r||s.open,children:u.jsx(Kr.Slot,{scope:e.__scopeMenu,children:u.jsx(Xi,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:fe(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:fe(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:fe(e.onKeyDown,d=>{var h;const f=d.currentTarget.contains(d.target),p=qv[i.dir].includes(d.key);f&&p&&(s.onOpenChange(!1),(h=a.trigger)==null||h.focus(),d.preventDefault())})})})})})});Zu.displayName=Ju;function Qu(e){return e?"open":"closed"}function us(e){return e==="indeterminate"}function Qi(e){return us(e)?"indeterminate":e?"checked":"unchecked"}function pb(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function hb(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function mb(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=hb(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 gb(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,p=l.y;d>r!=p>r&&n<(f-c)*(r-d)/(p-d)+c&&(o=!o)}return o}function xb(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return gb(n,t)}function Yr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var yb=Pu,vb=qi,bb=Mu,wb=Du,Sb=Ji,Cb=Lu,Tb=cs,kb=zu,Eb=Hu,Ib=Wu,Nb=Ku,Ab=qu,jb=Gu,_b=Xu,Rb=Zu,ds="DropdownMenu",[Pb,xT]=In(ds,[_u]),zt=_u(),[Ob,ed]=Pb(ds),td=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=zt(t),c=v.useRef(null),[d,f]=xr({prop:o,defaultProp:s??!1,onChange:i,caller:ds});return u.jsx(Ob,{scope:t,triggerId:Nn(),triggerRef:c,contentId:Nn(),open:d,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(p=>!p),[f]),modal:a,children:u.jsx(yb,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};td.displayName=ds;var nd="DropdownMenuTrigger",rd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=ed(nd,n),i=zt(n);return u.jsx(vb,{asChild:!0,...i,children:u.jsx(_e.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:yi(t,s.triggerRef),onPointerDown:fe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:fe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});rd.displayName=nd;var Mb="DropdownMenuPortal",od=e=>{const{__scopeDropdownMenu:t,...n}=e,r=zt(t);return u.jsx(bb,{...r,...n})};od.displayName=Mb;var sd="DropdownMenuContent",id=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ed(sd,n),s=zt(n),i=v.useRef(!1);return u.jsx(wb,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:fe(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:fe(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});id.displayName=sd;var Db="DropdownMenuGroup",Lb=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Sb,{...o,...r,ref:t})});Lb.displayName=Db;var Fb="DropdownMenuLabel",ad=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Cb,{...o,...r,ref:t})});ad.displayName=Fb;var $b="DropdownMenuItem",ld=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Tb,{...o,...r,ref:t})});ld.displayName=$b;var zb="DropdownMenuCheckboxItem",cd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(kb,{...o,...r,ref:t})});cd.displayName=zb;var Bb="DropdownMenuRadioGroup",Hb=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Eb,{...o,...r,ref:t})});Hb.displayName=Bb;var Ub="DropdownMenuRadioItem",ud=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Ib,{...o,...r,ref:t})});ud.displayName=Ub;var Wb="DropdownMenuItemIndicator",dd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Nb,{...o,...r,ref:t})});dd.displayName=Wb;var Vb="DropdownMenuSeparator",fd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Ab,{...o,...r,ref:t})});fd.displayName=Vb;var Kb="DropdownMenuArrow",qb=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(jb,{...o,...r,ref:t})});qb.displayName=Kb;var Gb="DropdownMenuSubTrigger",pd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(_b,{...o,...r,ref:t})});pd.displayName=Gb;var Yb="DropdownMenuSubContent",hd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Rb,{...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)"}})});hd.displayName=Yb;var Xb=td,Jb=rd,Zb=od,md=id,gd=ad,xd=ld,yd=cd,vd=ud,bd=dd,wd=fd,Sd=pd,Cd=hd;const Qb=Xb,ew=Jb,tw=v.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Sd,{ref:o,className:Z("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(se.ChevronRight,{className:"ml-auto h-4 w-4"})]}));tw.displayName=Sd.displayName;const nw=v.forwardRef(({className:e,...t},n)=>u.jsx(Cd,{ref:n,className:Z("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}));nw.displayName=Cd.displayName;const Td=v.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Zb,{children:u.jsx(md,{ref:r,sideOffset:t,className:Z("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})}));Td.displayName=md.displayName;const ea=v.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(xd,{ref:r,className:Z("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}));ea.displayName=xd.displayName;const rw=v.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(yd,{ref:o,className:Z("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(bd,{children:u.jsx(se.Check,{className:"h-4 w-4"})})}),t]}));rw.displayName=yd.displayName;const ow=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(vd,{ref:r,className:Z("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(bd,{children:u.jsx(se.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));ow.displayName=vd.displayName;const sw=v.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(gd,{ref:r,className:Z("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));sw.displayName=gd.displayName;const iw=v.forwardRef(({className:e,...t},n)=>u.jsx(wd,{ref:n,className:Z("-mx-1 my-1 h-px bg-muted",e),...t}));iw.displayName=wd.displayName;const fs=1e4;function aw(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
|
+
`)},zv=0,kr=[];function Bv(e){var t=v.useRef([]),n=v.useRef([0,0]),r=v.useRef(),o=v.useState(zv++)[0],s=v.useState(Su)[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 y=lv([e.lockRef.current],(e.shards||[]).map(Au),!0).filter(Boolean);return y.forEach(function(m){return m.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),y.forEach(function(m){return m.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=v.useCallback(function(y,m){if("touches"in y&&y.touches.length===2||y.type==="wheel"&&y.ctrlKey)return!i.current.allowPinchZoom;var g=ss(y),b=n.current,S="deltaX"in y?y.deltaX:b[0]-g[0],k="deltaY"in y?y.deltaY:b[1]-g[1],T,C=y.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in y&&E==="h"&&C.type==="range")return!1;var j=ku(E,C);if(!j)return!0;if(j?T=E:(T=E==="v"?"h":"v",j=ku(E,C)),!j)return!1;if(!r.current&&"changedTouches"in y&&(S||k)&&(r.current=T),!T)return!0;var A=r.current||T;return Lv(A,m,y,A==="h"?S:k)},[]),l=v.useCallback(function(y){var m=y;if(!(!kr.length||kr[kr.length-1]!==s)){var g="deltaY"in m?Nu(m):ss(m),b=t.current.filter(function(T){return T.name===m.type&&(T.target===m.target||m.target===T.shadowParent)&&Fv(T.delta,g)})[0];if(b&&b.should){m.cancelable&&m.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Au).filter(Boolean).filter(function(T){return T.contains(m.target)}),k=S.length>0?a(m,S[0]):!i.current.noIsolation;k&&m.cancelable&&m.preventDefault()}}},[]),c=v.useCallback(function(y,m,g,b){var S={name:y,delta:m,target:g,should:b,shadowParent:Hv(g)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=v.useCallback(function(y){n.current=ss(y),r.current=void 0},[]),f=v.useCallback(function(y){c(y.type,Nu(y),y.target,a(y,e.lockRef.current))},[]),p=v.useCallback(function(y){c(y.type,ss(y),y.target,a(y,e.lockRef.current))},[]);v.useEffect(function(){return kr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",l,Tr),document.addEventListener("touchmove",l,Tr),document.addEventListener("touchstart",d,Tr),function(){kr=kr.filter(function(y){return y!==s}),document.removeEventListener("wheel",l,Tr),document.removeEventListener("touchmove",l,Tr),document.removeEventListener("touchstart",d,Tr)}},[]);var h=e.removeScrollBar,x=e.inert;return v.createElement(v.Fragment,null,x?v.createElement(s,{styles:$v(o)}):null,h?v.createElement(jv,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Hv(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Uv=xv(wu,Bv);var is=v.forwardRef(function(e,t){return v.createElement(rs,wn({},e,{ref:t,sideCar:Uv}))});is.classNames=rs.classNames;var Ki=["Enter"," "],Wv=["ArrowDown","PageUp","Home"],ju=["ArrowUp","PageDown","End"],Vv=[...Wv,...ju],Kv={ltr:[...Ki,"ArrowRight"],rtl:[...Ki,"ArrowLeft"]},qv={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Vr="Menu",[Kr,Gv,Yv]=vi(Vr),[er,_u]=In(Vr,[Yv,Xo,fu]),as=Xo(),Ru=fu(),[Xv,tr]=er(Vr),[Jv,qr]=er(Vr),Pu=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=as(t),[l,c]=v.useState(null),d=v.useRef(!1),f=Rt(s),p=Lo(o);return v.useEffect(()=>{const h=()=>{d.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},x=()=>d.current=!1;return document.addEventListener("keydown",h,{capture:!0}),()=>{document.removeEventListener("keydown",h,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),u.jsx(au,{...a,children:u.jsx(Xv,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c,children:u.jsx(Jv,{scope:t,onClose:v.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:i,children:r})})})};Pu.displayName=Vr;var Zv="MenuAnchor",qi=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=as(n);return u.jsx(lu,{...o,...r,ref:t})});qi.displayName=Zv;var Gi="MenuPortal",[Qv,Ou]=er(Gi,{forceMount:void 0}),Mu=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=tr(Gi,t);return u.jsx(Qv,{scope:t,forceMount:n,children:u.jsx(tn,{present:n||s.open,children:u.jsx(Jo,{asChild:!0,container:o,children:r})})})};Mu.displayName=Gi;var nn="MenuContent",[eb,Yi]=er(nn),Du=v.forwardRef((e,t)=>{const n=Ou(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(nn,e.__scopeMenu),i=qr(nn,e.__scopeMenu);return u.jsx(Kr.Provider,{scope:e.__scopeMenu,children:u.jsx(tn,{present:r||s.open,children:u.jsx(Kr.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(tb,{...o,ref:t}):u.jsx(nb,{...o,ref:t})})})})}),tb=v.forwardRef((e,t)=>{const n=tr(nn,e.__scopeMenu),r=v.useRef(null),o=We(t,r);return v.useEffect(()=>{const s=r.current;if(s)return Bi(s)},[]),u.jsx(Xi,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:fe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),nb=v.forwardRef((e,t)=>{const n=tr(nn,e.__scopeMenu);return u.jsx(Xi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),rb=Yn.createSlot("MenuContent.ScrollLock"),Xi=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:p,onDismiss:h,disableOutsideScroll:x,...y}=e,m=tr(nn,n),g=qr(nn,n),b=as(n),S=Ru(n),k=Gv(n),[T,C]=v.useState(null),E=v.useRef(null),j=We(t,E,m.onContentChange),A=v.useRef(0),N=v.useRef(""),P=v.useRef(0),F=v.useRef(null),$=v.useRef("right"),R=v.useRef(0),z=x?is:v.Fragment,_=x?{as:rb,allowPinchZoom:!0}:void 0,B=M=>{var W,D;const J=N.current+M,X=k().filter(H=>!H.disabled),pe=document.activeElement,Ne=(W=X.find(H=>H.ref.current===pe))==null?void 0:W.textValue,je=X.map(H=>H.textValue),G=mb(je,J,Ne),ee=(D=X.find(H=>H.textValue===G))==null?void 0:D.ref.current;(function H(te){N.current=te,window.clearTimeout(A.current),te!==""&&(A.current=window.setTimeout(()=>H(""),1e3))})(J),ee&&setTimeout(()=>ee.focus())};v.useEffect(()=>()=>window.clearTimeout(A.current),[]),Si();const L=v.useCallback(M=>{var X,pe;return $.current===((X=F.current)==null?void 0:X.side)&&xb(M,(pe=F.current)==null?void 0:pe.area)},[]);return u.jsx(eb,{scope:n,searchRef:N,onItemEnter:v.useCallback(M=>{L(M)&&M.preventDefault()},[L]),onItemLeave:v.useCallback(M=>{var J;L(M)||((J=E.current)==null||J.focus(),C(null))},[L]),onTriggerLeave:v.useCallback(M=>{L(M)&&M.preventDefault()},[L]),pointerGraceTimerRef:P,onPointerGraceIntentChange:v.useCallback(M=>{F.current=M},[]),children:u.jsx(z,{..._,children:u.jsx($o,{asChild:!0,trapped:o,onMountAutoFocus:fe(s,M=>{var J;M.preventDefault(),(J=E.current)==null||J.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Fo,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:h,children:u.jsx(rv,{asChild:!0,...S,dir:g.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:C,onEntryFocus:fe(l,M=>{g.isUsingKeyboardRef.current||M.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(cu,{role:"menu","aria-orientation":"vertical","data-state":Qu(m.open),"data-radix-menu-content":"",dir:g.dir,...b,...y,ref:j,style:{outline:"none",...y.style},onKeyDown:fe(y.onKeyDown,M=>{const X=M.target.closest("[data-radix-menu-content]")===M.currentTarget,pe=M.ctrlKey||M.altKey||M.metaKey,Ne=M.key.length===1;X&&(M.key==="Tab"&&M.preventDefault(),!pe&&Ne&&B(M.key));const je=E.current;if(M.target!==je||!Vv.includes(M.key))return;M.preventDefault();const ee=k().filter(W=>!W.disabled).map(W=>W.ref.current);ju.includes(M.key)&&ee.reverse(),pb(ee)}),onBlur:fe(e.onBlur,M=>{M.currentTarget.contains(M.target)||(window.clearTimeout(A.current),N.current="")}),onPointerMove:fe(e.onPointerMove,Yr(M=>{const J=M.target,X=R.current!==M.clientX;if(M.currentTarget.contains(J)&&X){const pe=M.clientX>R.current?"right":"left";$.current=pe,R.current=M.clientX}}))})})})})})})});Du.displayName=nn;var ob="MenuGroup",Ji=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(_e.div,{role:"group",...r,ref:t})});Ji.displayName=ob;var sb="MenuLabel",Lu=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(_e.div,{...r,ref:t})});Lu.displayName=sb;var ls="MenuItem",Fu="menu.itemSelect",cs=v.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=v.useRef(null),i=qr(ls,e.__scopeMenu),a=Yi(ls,e.__scopeMenu),l=We(t,s),c=v.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const p=new CustomEvent(Fu,{bubbles:!0,cancelable:!0});f.addEventListener(Fu,h=>r==null?void 0:r(h),{once:!0}),xc(f,p),p.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx($u,{...o,ref:l,disabled:n,onClick:fe(e.onClick,d),onPointerDown:f=>{var p;(p=e.onPointerDown)==null||p.call(e,f),c.current=!0},onPointerUp:fe(e.onPointerUp,f=>{var p;c.current||(p=f.currentTarget)==null||p.click()}),onKeyDown:fe(e.onKeyDown,f=>{const p=a.searchRef.current!=="";n||p&&f.key===" "||Ki.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});cs.displayName=ls;var $u=v.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Yi(ls,n),a=Ru(n),l=v.useRef(null),c=We(t,l),[d,f]=v.useState(!1),[p,h]=v.useState("");return v.useEffect(()=>{const x=l.current;x&&h((x.textContent??"").trim())},[s.children]),u.jsx(Kr.ItemSlot,{scope:n,disabled:r,textValue:o??p,children:u.jsx(ov,{asChild:!0,...a,focusable:!r,children:u.jsx(_e.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:fe(e.onPointerMove,Yr(x=>{r?i.onItemLeave(x):(i.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:fe(e.onPointerLeave,Yr(x=>i.onItemLeave(x))),onFocus:fe(e.onFocus,()=>f(!0)),onBlur:fe(e.onBlur,()=>f(!1))})})})}),ib="MenuCheckboxItem",zu=v.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(Vu,{scope:e.__scopeMenu,checked:n,children:u.jsx(cs,{role:"menuitemcheckbox","aria-checked":us(n)?"mixed":n,...o,ref:t,"data-state":Qi(n),onSelect:fe(o.onSelect,()=>r==null?void 0:r(us(n)?!0:!n),{checkForDefaultPrevented:!1})})})});zu.displayName=ib;var Bu="MenuRadioGroup",[ab,lb]=er(Bu,{value:void 0,onValueChange:()=>{}}),Hu=v.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Rt(r);return u.jsx(ab,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Ji,{...o,ref:t})})});Hu.displayName=Bu;var Uu="MenuRadioItem",Wu=v.forwardRef((e,t)=>{const{value:n,...r}=e,o=lb(Uu,e.__scopeMenu),s=n===o.value;return u.jsx(Vu,{scope:e.__scopeMenu,checked:s,children:u.jsx(cs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Qi(s),onSelect:fe(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Wu.displayName=Uu;var Zi="MenuItemIndicator",[Vu,cb]=er(Zi,{checked:!1}),Ku=v.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=cb(Zi,n);return u.jsx(tn,{present:r||us(s.checked)||s.checked===!0,children:u.jsx(_e.span,{...o,ref:t,"data-state":Qi(s.checked)})})});Ku.displayName=Zi;var ub="MenuSeparator",qu=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(_e.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});qu.displayName=ub;var db="MenuArrow",Gu=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=as(n);return u.jsx(uu,{...o,...r,ref:t})});Gu.displayName=db;var fb="MenuSub",[gT,Yu]=er(fb),Gr="MenuSubTrigger",Xu=v.forwardRef((e,t)=>{const n=tr(Gr,e.__scopeMenu),r=qr(Gr,e.__scopeMenu),o=Yu(Gr,e.__scopeMenu),s=Yi(Gr,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(qi,{asChild:!0,...c,children:u.jsx($u,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Qu(n.open),...e,ref:yi(t,o.onTriggerChange),onClick:f=>{var p;(p=e.onClick)==null||p.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:fe(e.onPointerMove,Yr(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:fe(e.onPointerLeave,Yr(f=>{var h,x;d();const p=(h=n.content)==null?void 0:h.getBoundingClientRect();if(p){const y=(x=n.content)==null?void 0:x.dataset.side,m=y==="right",g=m?-5:5,b=p[m?"left":"right"],S=p[m?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+g,y:f.clientY},{x:b,y:p.top},{x:S,y:p.top},{x:S,y:p.bottom},{x:b,y:p.bottom}],side:y}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:fe(e.onKeyDown,f=>{var h;const p=s.searchRef.current!=="";e.disabled||p&&f.key===" "||Kv[r.dir].includes(f.key)&&(n.onOpenChange(!0),(h=n.content)==null||h.focus(),f.preventDefault())})})})});Xu.displayName=Gr;var Ju="MenuSubContent",Zu=v.forwardRef((e,t)=>{const n=Ou(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(nn,e.__scopeMenu),i=qr(nn,e.__scopeMenu),a=Yu(Ju,e.__scopeMenu),l=v.useRef(null),c=We(t,l);return u.jsx(Kr.Provider,{scope:e.__scopeMenu,children:u.jsx(tn,{present:r||s.open,children:u.jsx(Kr.Slot,{scope:e.__scopeMenu,children:u.jsx(Xi,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:fe(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:fe(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:fe(e.onKeyDown,d=>{var h;const f=d.currentTarget.contains(d.target),p=qv[i.dir].includes(d.key);f&&p&&(s.onOpenChange(!1),(h=a.trigger)==null||h.focus(),d.preventDefault())})})})})})});Zu.displayName=Ju;function Qu(e){return e?"open":"closed"}function us(e){return e==="indeterminate"}function Qi(e){return us(e)?"indeterminate":e?"checked":"unchecked"}function pb(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function hb(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function mb(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=hb(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 gb(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,p=l.y;d>r!=p>r&&n<(f-c)*(r-d)/(p-d)+c&&(o=!o)}return o}function xb(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return gb(n,t)}function Yr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var yb=Pu,vb=qi,bb=Mu,wb=Du,Sb=Ji,Cb=Lu,Tb=cs,kb=zu,Eb=Hu,Ib=Wu,Nb=Ku,Ab=qu,jb=Gu,_b=Xu,Rb=Zu,ds="DropdownMenu",[Pb,xT]=In(ds,[_u]),zt=_u(),[Ob,ed]=Pb(ds),td=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=zt(t),c=v.useRef(null),[d,f]=xr({prop:o,defaultProp:s??!1,onChange:i,caller:ds});return u.jsx(Ob,{scope:t,triggerId:Nn(),triggerRef:c,contentId:Nn(),open:d,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(p=>!p),[f]),modal:a,children:u.jsx(yb,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};td.displayName=ds;var nd="DropdownMenuTrigger",rd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=ed(nd,n),i=zt(n);return u.jsx(vb,{asChild:!0,...i,children:u.jsx(_e.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:yi(t,s.triggerRef),onPointerDown:fe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:fe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});rd.displayName=nd;var Mb="DropdownMenuPortal",od=e=>{const{__scopeDropdownMenu:t,...n}=e,r=zt(t);return u.jsx(bb,{...r,...n})};od.displayName=Mb;var sd="DropdownMenuContent",id=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ed(sd,n),s=zt(n),i=v.useRef(!1);return u.jsx(wb,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:fe(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:fe(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});id.displayName=sd;var Db="DropdownMenuGroup",Lb=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Sb,{...o,...r,ref:t})});Lb.displayName=Db;var Fb="DropdownMenuLabel",ad=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Cb,{...o,...r,ref:t})});ad.displayName=Fb;var $b="DropdownMenuItem",ld=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Tb,{...o,...r,ref:t})});ld.displayName=$b;var zb="DropdownMenuCheckboxItem",cd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(kb,{...o,...r,ref:t})});cd.displayName=zb;var Bb="DropdownMenuRadioGroup",Hb=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Eb,{...o,...r,ref:t})});Hb.displayName=Bb;var Ub="DropdownMenuRadioItem",ud=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Ib,{...o,...r,ref:t})});ud.displayName=Ub;var Wb="DropdownMenuItemIndicator",dd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Nb,{...o,...r,ref:t})});dd.displayName=Wb;var Vb="DropdownMenuSeparator",fd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Ab,{...o,...r,ref:t})});fd.displayName=Vb;var Kb="DropdownMenuArrow",qb=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(jb,{...o,...r,ref:t})});qb.displayName=Kb;var Gb="DropdownMenuSubTrigger",pd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(_b,{...o,...r,ref:t})});pd.displayName=Gb;var Yb="DropdownMenuSubContent",hd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Rb,{...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)"}})});hd.displayName=Yb;var Xb=td,Jb=rd,Zb=od,md=id,gd=ad,xd=ld,yd=cd,vd=ud,bd=dd,wd=fd,Sd=pd,Cd=hd;const Qb=Xb,ew=Jb,tw=v.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Sd,{ref:o,className:Z("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(se.ChevronRight,{className:"ml-auto h-4 w-4"})]}));tw.displayName=Sd.displayName;const nw=v.forwardRef(({className:e,...t},n)=>u.jsx(Cd,{ref:n,className:Z("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}));nw.displayName=Cd.displayName;const Td=v.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Zb,{children:u.jsx(md,{ref:r,sideOffset:t,className:Z("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})}));Td.displayName=md.displayName;const ea=v.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(xd,{ref:r,className:Z("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}));ea.displayName=xd.displayName;const rw=v.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(yd,{ref:o,className:Z("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(bd,{children:u.jsx(se.Check,{className:"h-4 w-4"})})}),t]}));rw.displayName=yd.displayName;const ow=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(vd,{ref:r,className:Z("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(bd,{children:u.jsx(se.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));ow.displayName=vd.displayName;const sw=v.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(gd,{ref:r,className:Z("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));sw.displayName=gd.displayName;const iw=v.forwardRef(({className:e,...t},n)=>u.jsx(wd,{ref:n,className:Z("-mx-1 my-1 h-px bg-muted",e),...t}));iw.displayName=wd.displayName;const fs=1e4;function aw(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,7 +83,7 @@ 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 lw(e,t=fs){if(!e||typeof e!="string")throw new Error("Invalid content: must be a non-empty string");if(e.length>t)throw new Error(`Message exceeds maximum length of ${t} characters`);return e}function cw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),lw(t),aw(t)}const ps=0,Ln=1,Er=2,kd=4;function Ed(e){return()=>e}function uw(e){e()}function Id(e,t){return n=>e(t(n))}function Nd(e,t){return()=>e(t)}function dw(e,t){return n=>e(t,n)}function ta(e){return e!==void 0}function fw(...e){return()=>{e.map(uw)}}function Ir(){}function hs(e,t){return t(e),e}function pw(e,t){return t(e)}function pt(...e){return e}function nt(e,t){return e(Ln,t)}function De(e,t){e(ps,t)}function na(e){e(Er)}function Ct(e){return e(kd)}function he(e,t){return nt(e,dw(t,ps))}function fn(e,t){const n=e(Ln,r=>{n(),t(r)});return n}function Ad(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function jd(e,t){return e===t}function ht(e=jd){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function ke(e){return t=>n=>{e(n)&&t(n)}}function ue(e){return t=>Id(t,e)}function Sn(e){return t=>()=>{t(e)}}function U(e,...t){const n=hw(...t);return(r,o)=>{switch(r){case Er:na(e);return;case Ln:return nt(e,n(o))}}}function Cn(e,t){return n=>r=>{n(t=e(t,r))}}function nr(e){return t=>n=>{e>0?e--:t(n)}}function _n(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Le(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);nt(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 hw(...e){return t=>e.reduceRight(pw,t)}function mw(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Ln:return s?n===s?void 0:(r(),n=s,t=nt(e,s),t):(r(),Ir);case Er:r(),n=null;return}}}function Y(e){let t=e;const n=We();return(r,o)=>{switch(r){case ps:t=o;break;case Ln:{o(t);break}case kd:return t}return n(r,o)}}function Dt(e,t){return hs(Y(t),n=>he(e,n))}function We(){const e=[];return(t,n)=>{switch(t){case ps:e.slice().forEach(r=>{r(n)});return;case Er:e.splice(0,e.length);return;case Ln:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Xt(e){return hs(We(),t=>he(e,t))}function Ze(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:gw(),singleton:n}}const gw=()=>Symbol();function xw(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 Nt(...e){const t=We(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);nt(s,l=>{n[i]=l,r=r|a,r===o&&De(t,n)})}),function(s,i){switch(s){case Er:{na(t);return}case Ln:return r===o&&i(n),nt(t,i)}}}function Se(e,t=jd){return U(e,ht(t))}function ra(...e){return function(t,n){switch(t){case Er:return;case Ln:return fw(...e.map(r=>nt(r,n)))}}}var Vt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Vt||{});const yw={0:"debug",3:"error",1:"log",2:"warn"},vw=()=>typeof globalThis>"u"?window:globalThis,Fn=Ze(()=>{const e=Y(3);return{log:Y((t,n,r=1)=>{var o;const s=(o=vw().VIRTUOSO_LOG_LEVEL)!=null?o:Ct(e);r>=s&&console[yw[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function rr(e,t,n){return oa(e,t,n).callbackRef}function oa(e,t,n){const r=w.useRef(null);let o=i=>{};const s=w.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function bw(e,t,n,r,o,s,i,a,l){const c=w.useCallback(d=>{const f=ww(d.children,t,a?"offsetWidth":"offsetHeight",o);let p=d.parentElement;for(;!p.dataset.virtuosoScroller;)p=p.parentElement;const h=p.lastElementChild.dataset.viewportType==="window";let x;h&&(x=p.ownerDocument.defaultView);const y=i?a?i.scrollLeft:i.scrollTop:h?a?x.scrollX||x.document.documentElement.scrollLeft:x.scrollY||x.document.documentElement.scrollTop:a?p.scrollLeft:p.scrollTop,m=i?a?i.scrollWidth:i.scrollHeight:h?a?x.document.documentElement.scrollWidth:x.document.documentElement.scrollHeight:a?p.scrollWidth:p.scrollHeight,g=i?a?i.offsetWidth:i.offsetHeight:h?a?x.innerWidth:x.innerHeight:a?p.offsetWidth:p.offsetHeight;r({scrollHeight:m,scrollTop:Math.max(y,0),viewportHeight:g}),s==null||s(a?_d("column-gap",getComputedStyle(d).columnGap,o):_d("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return oa(c,n,l)}function ww(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},Vt.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 _d(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Vt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Rd(e,t,n){const r=w.useRef(null),o=w.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let f,p;if(t){const h=t.getBoundingClientRect(),x=c.top-h.top;p=h.height-Math.max(0,x),f=x+t.scrollTop}else{const h=i.current.ownerDocument.defaultView;p=h.innerHeight-Math.max(0,c.top),f=c.top+h.scrollY}r.current={offsetTop:f,visibleHeight:p,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=oa(o,!0,n),a=w.useCallback(()=>{o(i.current)},[o,i]);return w.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 Bt=Ze(()=>{const e=We(),t=We(),n=Y(0),r=We(),o=Y(0),s=We(),i=We(),a=Y(0),l=Y(0),c=Y(0),d=Y(0),f=We(),p=We(),h=Y(!1),x=Y(!1),y=Y(!1);return he(U(e,ue(({scrollTop:m})=>m)),t),he(U(e,ue(({scrollHeight:m})=>m)),i),he(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:x,scrollBy:p,scrollContainerState:e,scrollHeight:i,scrollingInProgress:h,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:y,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Xr={lvl:0};function Pd(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 lt(e){return e===Xr}function Jr(e,t){if(!lt(e))return t===e.k?e.v:t<e.k?Jr(e.l,t):Jr(e.r,t)}function pn(e,t,n="k"){if(lt(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=pn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return pn(e.l,t,n)}function Jt(e,t,n){return lt(e)?Dd(t,n,1):t===e.k?At(e,{k:t,v:n}):t<e.k?Ld(At(e,{l:Jt(e.l,t,n)})):Ld(At(e,{r:Jt(e.r,t,n)}))}function Nr(){return Xr}function ms(e,t,n){if(lt(e))return[];const r=pn(e,t)[0];return Sw(ia(e,r,n))}function sa(e,t){if(lt(e))return Xr;const{k:n,l:r,r:o}=e;if(t===n){if(lt(r))return o;if(lt(o))return r;{const[s,i]=Md(r);return gs(At(e,{k:s,l:Od(r),v:i}))}}else return t<n?gs(At(e,{l:sa(r,t)})):gs(At(e,{r:sa(o,t)}))}function or(e){return lt(e)?[]:[...or(e.l),{k:e.k,v:e.v},...or(e.r)]}function ia(e,t,n){if(lt(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(ia(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(ia(s,t,n))),a}function gs(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(aa(t))return Fd(At(e,{lvl:n-1}));if(!lt(t)&&!lt(t.r))return At(t.r,{l:At(t,{r:t.r.l}),lvl:n,r:At(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(aa(e))return la(At(e,{lvl:n-1}));if(!lt(r)&&!lt(r.l)){const o=r.l,s=aa(o)?r.lvl-1:r.lvl;return At(o,{l:At(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:la(At(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function At(e,t){return Dd(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 Od(e){return lt(e.r)?e.l:gs(At(e,{r:Od(e.r)}))}function aa(e){return lt(e)||e.lvl>e.r.lvl}function Md(e){return lt(e.r)?[e.k,e.v]:Md(e.r)}function Dd(e,t,n,r=Xr,o=Xr){return{k:e,l:r,lvl:n,r:o,v:t}}function Ld(e){return la(Fd(e))}function Fd(e){const{l:t}=e;return!lt(t)&&t.lvl===e.lvl?At(t,{r:At(e,{l:t.r})}):e}function la(e){const{lvl:t,r:n}=e;return!lt(n)&&!lt(n.r)&&n.lvl===t&&n.r.lvl===t?At(n,{l:At(e,{r:n.l}),lvl:t+1}):e}function Sw(e){return Pd(e,({k:t,v:n})=>({index:t,value:n}))}function $d(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Zr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const ca=Ze(()=>({recalcInProgress:Y(!1)}),[],{singleton:!0});function zd(e,t,n){return e[xs(e,t,n)]}function xs(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 Cw(e,t,n,r){const o=xs(e,t,r),s=xs(e,n,r,o);return e.slice(o,s+1)}function $n(e,t){return Math.round(e.getBoundingClientRect()[t])}function ys(e){return!lt(e.groupOffsetTree)}function ua({index:e},t){return t===e?0:t<e?-1:1}function Tw(){return{groupIndices:[],groupOffsetTree:Nr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Nr()}}function kw(e,t){let n=lt(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),lt(e)){e=Jt(e,0,s);continue}const a=ms(e,i-1,o+1);if(a.some(Rw(r)))continue;let l=!1,c=!1;for(const{end:d,start:f,value:p}of a)l?(o>=f||s===p)&&(e=sa(e,f)):(c=p!==s,l=!0),d>o&&o>=f&&p!==s&&(e=Jt(e,o+1,p));c&&(e=Jt(e,i,s))}return[e,n]}function Ew(e){return typeof e.groupIndex<"u"}function Iw({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}=zd(t,e,ua),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Bd(e,t){if(!ys(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Hd(e,t,n){if(Ew(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Bd(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function Nw(e,t,n,r=0){return r>0&&(t=Math.max(t,zd(e,r,ua).offset)),Pd(Cw(e,t,n,Iw),_w)}function Aw(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Vt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&<(s)&&t.length===2){const p=t[0].size,h=t[1].size;i=n.reduce((x,y)=>Jt(Jt(x,y,p),y+1,h),i)}else[i,a]=kw(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f}=da(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((p,h)=>Jt(p,h,Qr(h,f,o)),Nr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f,sizeTree:i}}function jw(e){return or(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 Ud(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 da(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=xs(o,t-1,ua),a=o[l].offset;const c=pn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===pn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of ms(n,t,1/0)){const f=c-s,p=f*i+a+f*r;o.push({index:c,offset:p,size:d}),s=c,a=p,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function _w(e){return{index:e.index,value:e}}function Rw(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 Pw={offsetHeight:"height",offsetWidth:"width"},Tn=Ze(([{log:e},{recalcInProgress:t}])=>{const n=We(),r=We(),o=Dt(r,0),s=We(),i=We(),a=Y(0),l=Y([]),c=Y(void 0),d=Y(void 0),f=Y((T,C)=>$n(T,Pw[C])),p=Y(void 0),h=Y(0),x=Tw(),y=Dt(U(n,Le(l,e,h),Cn(Aw,x),ht()),x),m=Dt(U(l,ht(),Cn((T,C)=>({current:C,prev:T.current}),{current:[],prev:[]}),ue(({prev:T})=>T)),[]);he(U(l,ke(T=>T.length>0),Le(y,h),ue(([T,C,E])=>{const j=T.reduce((A,N,P)=>Jt(A,N,Qr(N,C.offsetTree,E)||P),Nr());return{...C,groupIndices:T,groupOffsetTree:j}})),y),he(U(r,Le(y),ke(([T,{lastIndex:C}])=>T<C),ue(([T,{lastIndex:C,lastSize:E}])=>[{endIndex:C,size:E,startIndex:T}])),n),he(c,d);const g=Dt(U(c,ue(T=>T===void 0)),!0);he(U(d,ke(T=>T!==void 0&<(Ct(y).sizeTree)),ue(T=>[{endIndex:0,size:T,startIndex:0}])),n);const b=Xt(U(n,Le(y),Cn(({sizes:T},[C,E])=>({changed:E!==T,sizes:E}),{changed:!1,sizes:x}),ue(T=>T.changed)));nt(U(a,Cn((T,C)=>({diff:T.prev-C,prev:C}),{diff:0,prev:0}),ue(T=>T.diff)),T=>{const{groupIndices:C}=Ct(y);if(T>0)De(t,!0),De(s,T+Ud(T,C));else if(T<0){const E=Ct(m);E.length>0&&(T-=Ud(-T,E)),De(i,T)}}),nt(U(a,Le(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},Vt.ERROR)});const S=Xt(s);he(U(s,Le(y),ue(([T,C])=>{const E=C.groupIndices.length>0,j=[],A=C.lastSize;if(E){const N=Jr(C.sizeTree,0);let P=0,F=0;for(;P<T;){const R=C.groupIndices[F],z=C.groupIndices.length===F+1?1/0:C.groupIndices[F+1]-R-1;j.push({endIndex:R,size:N,startIndex:R}),j.push({endIndex:R+1+z-1,size:A,startIndex:R+1}),F++,P+=z+1}const $=or(C.sizeTree);return P!==T&&$.shift(),$.reduce((R,{k:z,v:_})=>{let B=R.ranges;return R.prevSize!==0&&(B=[...R.ranges,{endIndex:z+T-1,size:R.prevSize,startIndex:R.prevIndex}]),{prevIndex:z+T,prevSize:_,ranges:B}},{prevIndex:T,prevSize:0,ranges:j}).ranges}return or(C.sizeTree).reduce((N,{k:P,v:F})=>({prevIndex:P+T,prevSize:F,ranges:[...N.ranges,{endIndex:P+T-1,size:N.prevSize,startIndex:N.prevIndex}]}),{prevIndex:0,prevSize:A,ranges:[]}).ranges})),n);const k=Xt(U(i,Le(y,h),ue(([T,{offsetTree:C},E])=>{const j=-T;return Qr(j,C,E)})));return he(U(i,Le(y,h),ue(([T,C,E])=>{if(C.groupIndices.length>0){if(lt(C.sizeTree))return C;let j=Nr();const A=Ct(m);let N=0,P=0,F=0;for(;N<-T;){F=A[P];const $=A[P+1]-F-1;P++,N+=$+1}if(j=or(C.sizeTree).reduce(($,{k:R,v:z})=>Jt($,Math.max(0,R+T),z),j),N!==-T){const $=Jr(C.sizeTree,F);j=Jt(j,0,$);const R=pn(C.sizeTree,-T+1)[1];j=Jt(j,1,R)}return{...C,sizeTree:j,...da(C.offsetTree,0,j,E)}}else{const j=or(C.sizeTree).reduce((A,{k:N,v:P})=>Jt(A,Math.max(0,N+T),P),Nr());return{...C,sizeTree:j,...da(C.offsetTree,0,j,E)}}})),y),{beforeUnshiftWith:S,data:p,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:h,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:y,statefulTotalCount:o,totalCount:r,trackItemSizes:g,unshiftWith:s}},pt(Fn,ca),{singleton:!0});function Ow(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Wd=Ze(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=We(),i=We(),a=Xt(U(s,ue(Ow)));return he(U(a,ue(l=>l.totalCount)),n),he(U(a,ue(l=>l.groupIndices)),e),he(U(Nt(o,t,r),ke(([l,c])=>ys(c)),ue(([l,c,d])=>pn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),ht(),ue(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},pt(Tn,Bt)),zn=Ze(([{log:e}])=>{const t=Y(!1),n=Xt(U(t,ke(r=>r),ht()));return nt(t,r=>{r&&Ct(e)("props updated",{},Vt.DEBUG)}),{didMount:n,propsReady:t}},pt(Fn),{singleton:!0}),Mw=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Vd(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Mw)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const eo=Ze(([{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:p}])=>{const h=We(),x=We(),y=Y(0);let m=null,g=null,b=null;function S(){m&&(m(),m=null),b&&(b(),b=null),g&&(clearTimeout(g),g=null),De(l,!1)}return he(U(h,Le(n,f,r,y,a,i,p),Le(e,s,o),ue(([[k,T,C,E,j,A,N,P],F,$,R])=>{const z=Vd(k),{align:_,behavior:B,offset:L}=z,M=E-1,J=Hd(z,T,M);let X=Qr(J,T.offsetTree,F)+A;_==="end"?(X+=$+pn(T.sizeTree,J)[1]-C+R,J===M&&(X+=N)):_==="center"?X+=($+pn(T.sizeTree,J)[1]-C+R)/2:X-=j,L&&(X+=L);const pe=Ie=>{S(),Ie?(P("retrying to scroll to",{location:k},Vt.DEBUG),De(h,k)):(De(x,!0),P("list did not change, scroll successful",{},Vt.DEBUG))};if(S(),B==="smooth"){let Ie=!1;b=nt(t,je=>{Ie=Ie||je}),m=fn(d,()=>{pe(Ie)})}else m=fn(U(t,Dw(150)),pe);return g=setTimeout(()=>{S()},1200),De(l,!0),P("scrolling from index to",{behavior:B,index:J,top:X},Vt.DEBUG),{behavior:B,top:X}})),c),{scrollTargetReached:x,scrollToIndex:h,topListHeight:y}},pt(Tn,Bt,Fn),{singleton:!0});function Dw(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function fa(e,t){e==0?t():requestAnimationFrame(()=>{fa(e-1,t)})}function pa(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const to=Ze(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=Y(!0),l=Y(0),c=Y(!0);return he(U(i,Le(l),ke(([d,f])=>!!f),Sn(!1)),a),he(U(i,Le(l),ke(([d,f])=>!!f),Sn(!1)),c),nt(U(Nt(t,i),Le(a,n,e,c),ke(([[,d],f,{sizeTree:p},h,x])=>d&&(!lt(p)||ta(h))&&!f&&!x),Le(l)),([,d])=>{fn(o,()=>{De(c,!0)}),fa(4,()=>{fn(r,()=>{De(a,!0)}),De(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},pt(Tn,Bt,eo,zn),{singleton:!0});function Kd(e,t){return Math.abs(e-t)<1.01}const no="up",ro="down",Lw="none",Fw={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},$w=0,oo=Ze(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=Y(!1),a=Y(!0),l=We(),c=We(),d=Y(4),f=Y($w),p=Dt(U(ra(U(Se(o),nr(1),Sn(!0)),U(Se(o),nr(1),Sn(!1),Ad(100))),ht()),!1),h=Dt(U(ra(U(n,Sn(!0)),U(n,Sn(!1),Ad(200))),ht()),!1);he(U(Nt(Se(o),Se(f)),ue(([b,S])=>b<=S),ht()),a),he(U(a,_n(50)),c);const x=Xt(U(Nt(r,Se(s),Se(t),Se(e),Se(d)),Cn((b,[{scrollHeight:S,scrollTop:k},T,C,E,j])=>{const A=k+T-S>-j,N={scrollHeight:S,scrollTop:k,viewportHeight:T};if(A){let F,$;return k>b.state.scrollTop?(F="SCROLLED_DOWN",$=b.state.scrollTop-k):(F="SIZE_DECREASED",$=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:F,scrollTopDelta:$,state:N}}let P;return N.scrollHeight>b.state.scrollHeight?P="SIZE_INCREASED":T<b.state.viewportHeight?P="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?P="SCROLLING_UPWARDS":P="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:P,state:N}},Fw),ht((b,S)=>b&&b.atBottom===S.atBottom))),y=Dt(U(r,Cn((b,{scrollHeight:S,scrollTop:k,viewportHeight:T})=>{if(Kd(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const C=S-(k+T)<1;return b.scrollTop!==k&&C?{changed:!0,jump:b.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ke(b=>b.changed),ue(b=>b.jump)),0);he(U(x,ue(b=>b.atBottom)),i),he(U(i,_n(50)),l);const m=Y(ro);he(U(r,ue(({scrollTop:b})=>b),ht(),Cn((b,S)=>Ct(h)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?no:ro,prevScrollTop:S},{direction:ro,prevScrollTop:0}),ue(b=>b.direction)),m),he(U(r,_n(50),Sn(Lw)),m);const g=Y(0);return he(U(p,ke(b=>!b),Sn(0)),g),he(U(o,_n(100),Le(p),ke(([b,S])=>!!S),Cn(([b,S],[k])=>[S,k],[0,0]),ue(([b,S])=>S-b)),g),{atBottomState:x,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:p,lastJumpDueToItemResize:y,scrollDirection:m,scrollVelocity:g}},pt(Bt)),vs="top",bs="bottom",qd="none";function Gd(e,t,n){return typeof e=="number"?n===no&&t===vs||n===ro&&t===bs?e:0:n===no?t===vs?e.main:e.reverse:t===bs?e.main:e.reverse}function Yd(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const ha=Ze(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=We(),i=Y(0),a=Y(0),l=Y(0),c=Dt(U(Nt(Se(r),Se(o),Se(n),Se(s,Zr),Se(l),Se(i),Se(t),Se(e),Se(a)),ue(([d,f,p,[h,x],y,m,g,b,S])=>{const k=d-b,T=m+g,C=Math.max(p-k,0);let E=qd;const j=Yd(S,vs),A=Yd(S,bs);return h-=b,h+=p+g,x+=p+g,x-=b,h>d+T-j&&(E=no),x<d-C+f+A&&(E=ro),E!==qd?[Math.max(k-p-Gd(y,vs,E)-j,0),k-C-g+f+Gd(y,bs,E)+A]:null}),ke(d=>d!=null),ht(Zr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},pt(Bt),{singleton:!0});function zw(e,t,n){if(ys(t)){const r=Bd(e,t);return[{index:pn(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 ma={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function ws(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 y=e[e.length-1];d=y.offset+y.size}const f=n-i,p=a+f*l+(f-1)*r,h=c,x=p-d;return{bottom:d,firstItemIndex:s,items:Jd(e,o,s),offsetBottom:x,offsetTop:c,top:h,topItems:Jd(t,o,s),topListHeight:t.reduce((y,m)=>m.size+y,0),totalCount:n}}function Xd(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=pa(t,a),c=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return ws(c,[],a,o,n,r)}function Jd(e,t,n){if(e.length===0)return[];if(!ys(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=ms(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 sr=Ze(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:f},p,{didMount:h},{recalcInProgress:x}])=>{const y=Y([]),m=Y(0),g=We();he(s.topItemsIndexes,y);const b=Dt(U(Nt(h,x,Se(l,Zr),Se(o),Se(r),Se(c),d,Se(y),Se(t),Se(n),e),ke(([C,E,,j,,,,,,,A])=>{const N=A&&A.length!==j;return C&&!E&&!N}),ue(([,,[C,E],j,A,N,P,F,$,R,z])=>{const _=A,{offsetTree:B,sizeTree:L}=_,M=Ct(m);if(j===0)return{...ma,totalCount:j};if(C===0&&E===0)return M===0?{...ma,totalCount:j}:Xd(M,N,A,$,R,z||[]);if(lt(L))return M>0?null:ws(zw(pa(N,j),_,z),[],j,R,_,$);const J=[];if(F.length>0){const G=F[0],ee=F[F.length-1];let W=0;for(const D of ms(L,G,ee)){const H=D.value,te=Math.max(D.start,G),ae=Math.min(D.end,ee);for(let ne=te;ne<=ae;ne++)J.push({data:z==null?void 0:z[ne],index:ne,offset:W,size:H}),W+=H}}if(!P)return ws([],J,j,R,_,$);const X=F.length>0?F[F.length-1]+1:0,pe=Nw(B,C,E,X);if(pe.length===0)return null;const Ie=j-1,je=hs([],G=>{for(const ee of pe){const W=ee.value;let D=W.offset,H=ee.start;const te=W.size;if(W.offset<C){H+=Math.floor((C-W.offset+R)/(te+R));const ne=H-ee.start;D+=ne*te+ne*R}H<X&&(D+=(X-H)*te,H=X);const ae=Math.min(ee.end,Ie);for(let ne=H;ne<=ae&&!(D>=E);ne++)G.push({data:z==null?void 0:z[ne],index:ne,offset:D,size:te}),D+=te+R}});return ws(je,J,j,R,_,$)}),ke(C=>C!==null),ht()),ma);he(U(e,ke(ta),ue(C=>C==null?void 0:C.length)),o),he(U(b,ue(C=>C.topListHeight)),f),he(f,a),he(U(b,ue(C=>[C.top,C.bottom])),i),he(U(b,ue(C=>C.items)),g);const S=Xt(U(b,ke(({items:C})=>C.length>0),Le(o,e),ke(([{items:C},E])=>C[C.length-1].originalIndex===E-1),ue(([,C,E])=>[C-1,E]),ht(Zr),ue(([C])=>C))),k=Xt(U(b,_n(200),ke(({items:C,topItems:E})=>C.length>0&&C[0].originalIndex===E.length),ue(({items:C})=>C[0].index),ht())),T=Xt(U(b,ke(({items:C})=>C.length>0),ue(({items:C})=>{let E=0,j=C.length-1;for(;C[E].type==="group"&&E<j;)E++;for(;C[j].type==="group"&&j>E;)j--;return{endIndex:C[j].index,startIndex:C[E].index}}),ht($d)));return{endReached:S,initialItemCount:m,itemsRendered:g,listState:b,rangeChanged:T,startReached:k,topItemsIndexes:y,...p}},pt(Tn,Wd,ha,to,eo,oo,zn,ca),{singleton:!0}),Zd=Ze(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=We(),i=Dt(U(Nt(n,e,r,t,o),ue(([a,l,c,d,f])=>a+l+c+d+f.offsetBottom+f.bottom)),0);return he(Se(i),s),{totalListHeight:i,totalListHeightChanged:s}},pt(Bt,sr),{singleton:!0}),Bw=Ze(([{viewportHeight:e},{totalListHeight:t}])=>{const n=Y(!1),r=Dt(U(Nt(n,e,t),ke(([o])=>o),ue(([,o,s])=>Math.max(0,o-s)),_n(0),ht()),0);return{alignToBottom:n,paddingTopAddition:r}},pt(Bt,Zd),{singleton:!0}),Qd=Ze(()=>({context:Y(null)})),Hw=({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,ef=Ze(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=We();return he(U(d,Le(t,l,n,s,o,r,a),Le(e),ue(([[f,p,h,x,y,m,g,b],S])=>{const{align:k,behavior:T,calculateViewLocation:C=Hw,done:E,...j}=f,A=Hd(f,p,x-1),N=Qr(A,p.offsetTree,S)+y+m,P=N+pn(p.sizeTree,A)[1],F=b+m,$=b+h-g,R=C({itemBottom:P,itemTop:N,locationParams:{align:k,behavior:T,...j},viewportBottom:$,viewportTop:F});return R?E&&fn(U(i,ke(z=>!z),nr(Ct(i)?1:2)),E):E&&E(),R}),ke(f=>f!==null)),c),{scrollIntoView:d}},pt(Tn,Bt,eo,sr,Fn),{singleton:!0});function tf(e){return e?e==="smooth"?"smooth":"auto":!1}const Uw=(e,t)=>typeof e=="function"?tf(e(t)):t&&tf(e),Ww=Ze(([{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:p},{scrollIntoView:h}])=>{const x=Y(!1),y=We();let m=null;function g(T){De(i,{align:"end",behavior:T,index:"LAST"})}nt(U(Nt(U(Se(t),nr(1)),l),Le(Se(x),s,a,f),ue(([[T,C],E,j,A,N])=>{let P=C&&A,F="auto";return P&&(F=Uw(E,j||N),P=P&&!!F),{followOutputBehavior:F,shouldFollow:P,totalCount:T}}),ke(({shouldFollow:T})=>T)),({followOutputBehavior:T,totalCount:C})=>{m&&(m(),m=null),Ct(n)?requestAnimationFrame(()=>{Ct(d)("following output to ",{totalCount:C},Vt.DEBUG),g(T)}):m=fn(e,()=>{Ct(d)("following output to ",{totalCount:C},Vt.DEBUG),g(T),m=null})});function b(T){const C=fn(o,E=>{T&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!m&&(Ct(d)("scrolling to bottom due to increased size",{},Vt.DEBUG),g("auto"))});setTimeout(C,100)}nt(U(Nt(Se(x),t,c),ke(([T,,C])=>T&&C),Cn(({value:T},[,C])=>({refreshed:T===C,value:C}),{refreshed:!1,value:0}),ke(({refreshed:T})=>T),Le(x,t)),([,T])=>{Ct(a)&&b(T!==!1)}),nt(y,()=>{b(Ct(x)!==!1)}),nt(Nt(Se(x),o),([T,C])=>{T&&!C.atBottom&&C.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&g("auto")});const S=Y(null),k=We();return he(ra(U(Se(r),ue(T=>{var C;return(C=T==null?void 0:T.length)!=null?C:0})),U(Se(t))),k),nt(U(Nt(U(k,nr(1)),l),Le(Se(S),a,f,p),ue(([[T,C],E,j,A,N])=>C&&j&&(E==null?void 0:E({context:N,totalCount:T,scrollingInProgress:A}))),ke(T=>!!T),_n(0)),T=>{m&&(m(),m=null),Ct(n)?requestAnimationFrame(()=>{Ct(d)("scrolling into view",{}),De(h,T)}):m=fn(e,()=>{Ct(d)("scrolling into view",{}),De(h,T),m=null})}),{autoscrollToBottom:y,followOutput:x,scrollIntoViewOnChange:S}},pt(Tn,oo,eo,to,zn,Fn,Bt,Qd,ef)),Vw=Ze(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(he(U(a,Le(s),ke(([,l])=>l!==0),Le(o,r,t,n,e),ue(([[,l],c,d,f,p,h=[]])=>Xd(l,c,d,f,p,h))),i),{}),pt(Tn,to,sr,zn),{singleton:!0}),Kw=Ze(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=Y(0);return nt(U(e,Le(r),ke(([,o])=>o!==0),ue(([,o])=>({top:o}))),o=>{fn(U(n,nr(1),ke(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{De(t,o)})})}),{initialScrollTop:r}},pt(zn,Bt,sr),{singleton:!0}),nf=Ze(([{scrollVelocity:e}])=>{const t=Y(!1),n=We(),r=Y(!1);return he(U(e,Le(r,t,n),ke(([o,s])=>!!s),ue(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),ht()),t),nt(U(Nt(t,e,n),Le(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},pt(oo),{singleton:!0}),ga=Ze(([{scrollContainerState:e,scrollTo:t}])=>{const n=We(),r=We(),o=We(),s=Y(!1),i=Y(void 0);return he(U(Nt(n,r),ue(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),he(U(t,Le(r),ue(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},pt(Bt)),qw=Ze(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=We(),d=Y(void 0),f=Y(null),p=Y(null);return he(a,f),he(l,p),nt(U(c,Le(t,r,i,f,p,n)),([h,x,y,m,g,b,S])=>{const k=jw(x.sizeTree);m&&g!==null&&b!==null&&(y=g.scrollTop-b.offsetTop),y-=S,h({ranges:k,scrollTop:y})}),he(U(d,ke(ta),ue(Gw)),o),he(U(s,Le(d),ke(([,h])=>h!==void 0),ht(),ue(([,h])=>h.ranges)),e),{getState:c,restoreStateFrom:d}},pt(Tn,Bt,to,zn,ga));function Gw(e){return{align:"start",index:0,offset:e.scrollTop}}const Yw=Ze(([{topItemsIndexes:e}])=>{const t=Y(0);return he(U(t,ke(n=>n>=0),ue(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},pt(sr));function rf(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const Xw=rf(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Jw=Ze(([{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:p},{log:h},{recalcInProgress:x}])=>{const y=Xt(U(l,Le(i),Cn(([,g,b,S],[{bottom:k,items:T,offsetBottom:C,totalCount:E},j])=>{const A=k+C;let N=0;return b===E&&g.length>0&&T.length>0&&(T[0].originalIndex===0&&g[0].originalIndex===0||(N=A-S,N!==0&&(N+=j))),[N,T,E,A]},[0,[],0,0]),ke(([g])=>g!==0),Le(r,a,n,o,h,x),ke(([,g,b,S,,,k])=>!k&&!S&&g!==0&&b===no),ue(([[g],,,,,b])=>(b("Upward scrolling compensation",{amount:g},Vt.DEBUG),g))));function m(g){g>0?(De(t,{behavior:"auto",top:-g}),De(e,0)):(De(e,0),De(t,{behavior:"auto",top:-g}))}return nt(U(y,Le(e,s)),([g,b,S])=>{S&&Xw()?De(e,b-g):m(-g)}),nt(U(Nt(Dt(s,!1),e,x),ke(([g,b,S])=>!g&&!S&&b!==0),ue(([g,b])=>b),_n(1)),m),he(U(f,ue(g=>({top:-g}))),t),nt(U(c,Le(p,d),ue(([g,{groupIndices:b,lastSize:S,sizeTree:k},T])=>{function C(E){return E*(S+T)}if(b.length===0)return C(g);{let E=0;const j=Jr(k,0);let A=0,N=0;for(;A<g;){A++,E+=j;let P=b.length===N+1?1/0:b[N+1]-b[N]-1;A+P>g&&(E-=j,P=g-A+1),A+=P,E+=C(P),N++}return E}})),g=>{De(e,g),requestAnimationFrame(()=>{De(t,{top:g}),requestAnimationFrame(()=>{De(e,0),De(x,!1)})})}),{deviation:e}},pt(Bt,oo,sr,Tn,Fn,ca)),Zw=Ze(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),pt(ha,Vw,zn,nf,Zd,Kw,Bw,ga,ef,Fn,Qd)),of=Ze(([{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:p,initialTopMostItemIndex:h,scrolledToInitialItem:x},y,m,g,{listState:b,topItemsIndexes:S,...k},{scrollToIndex:T},C,{topItemCount:E},{groupCounts:j},A])=>(he(k.rangeChanged,A.scrollSeekRangeChanged),he(U(A.windowViewportRect,ue(N=>N.visibleHeight)),y.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:j,initialItemFinalLocationReached:p,initialTopMostItemIndex:h,scrolledToInitialItem:x,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...g,groupIndices:s,itemSize:i,listState:b,scrollToIndex:T,statefulTotalCount:c,trackItemSizes:f,...k,...A,...y,sizes:l,...m}),pt(Tn,to,Bt,qw,Ww,sr,eo,Jw,Yw,Wd,Zw));function Qw(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 Ss=typeof document<"u"?w.useLayoutEffect:w.useEffect;function sf(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=w.createContext({});function l(m,g){m.propsReady&&De(m.propsReady,!1);for(const b of r){const S=m[t.required[b]];De(S,g[b])}for(const b of o)if(b in g){const S=m[t.optional[b]];De(S,g[b])}m.propsReady&&De(m.propsReady,!0)}function c(m){return s.reduce((g,b)=>(g[b]=S=>{const k=m[t.methods[b]];De(k,S)},g),{})}function d(m){return i.reduce((g,b)=>(g[b]=mw(m[t.events[b]]),g),{})}const f=w.forwardRef((m,g)=>{const{children:b,...S}=m,[k]=w.useState(()=>hs(xw(e),E=>{l(E,S)})),[T]=w.useState(Nd(d,k));Ss(()=>{for(const E of i)E in S&&nt(T[E],S[E]);return()=>{Object.values(T).map(na)}},[S,T,k]),Ss(()=>{l(k,S)}),w.useImperativeHandle(g,Ed(c(k)));const C=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(C,{...Qw([...r,...o,...i],S),children:b}):b})}),p=m=>{const g=w.useContext(a);return w.useCallback(b=>{De(g[m],b)},[g,m])},h=m=>{const g=w.useContext(a)[m],b=w.useCallback(S=>nt(g,S),[g]);return w.useSyncExternalStore(b,()=>Ct(g),()=>Ct(g))},x=m=>{const g=w.useContext(a)[m],[b,S]=w.useState(Nd(Ct,g));return Ss(()=>nt(g,k=>{k!==b&&S(Ed(k))}),[g,b]),b},y=w.version.startsWith("18")?h:x;return{Component:f,useEmitter:(m,g)=>{const b=w.useContext(a)[m];Ss(()=>nt(b,g),[g,b])},useEmitterValue:y,usePublisher:p}}const af=w.createContext(void 0),lf=w.createContext(void 0),cf=typeof document<"u"?w.useLayoutEffect:w.useEffect;function xa(e){return"self"in e}function e0(e){return"body"in e}function uf(e,t,n,r=Ir,o,s){const i=w.useRef(null),a=w.useRef(null),l=w.useRef(null),c=w.useCallback(p=>{let h,x,y;const m=p.target;if(e0(m)||xa(m)){const b=xa(m)?m:m.defaultView;y=s?b.scrollX:b.scrollY,h=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,x=s?b.innerWidth:b.innerHeight}else y=s?m.scrollLeft:m.scrollTop,h=s?m.scrollWidth:m.scrollHeight,x=s?m.offsetWidth:m.offsetHeight;const g=()=>{e({scrollHeight:h,scrollTop:Math.max(y,0),viewportHeight:x})};p.suppressFlushSync?g():Js.flushSync(g),a.current!==null&&(y===a.current||y<=0||y===h-x)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);w.useEffect(()=>{const p=o||i.current;return r(o||i.current),c({suppressFlushSync:!0,target:p}),p.addEventListener("scroll",c,{passive:!0}),()=>{r(null),p.removeEventListener("scroll",c)}},[i,c,n,r,o]);function d(p){const h=i.current;if(!h||(s?"offsetWidth"in h&&h.offsetWidth===0:"offsetHeight"in h&&h.offsetHeight===0))return;const x=p.behavior==="smooth";let y,m,g;xa(h)?(m=Math.max($n(h.document.documentElement,s?"width":"height"),s?h.document.documentElement.scrollWidth:h.document.documentElement.scrollHeight),y=s?h.innerWidth:h.innerHeight,g=s?window.scrollX:window.scrollY):(m=h[s?"scrollWidth":"scrollHeight"],y=$n(h,s?"width":"height"),g=h[s?"scrollLeft":"scrollTop"]);const b=m-y;if(p.top=Math.ceil(Math.max(Math.min(b,p.top),0)),Kd(y,m)||p.top===g){e({scrollHeight:m,scrollTop:g,viewportHeight:y}),x&&t(!0);return}x?(a.current=p.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(p={behavior:p.behavior,left:p.top}),h.scrollTo(p)}function f(p){s&&(p={behavior:p.behavior,left:p.top}),i.current.scrollBy(p)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const ya="-webkit-sticky",df="sticky",va=rf(()=>{if(typeof document>"u")return df;const e=document.createElement("div");return e.style.position=ya,e.style.position===ya?ya:df});function ba(e){return e}const t0=Ze(()=>{const e=Y(a=>`Item ${a}`),t=Y(a=>`Group ${a}`),n=Y({}),r=Y(ba),o=Y("div"),s=Y(Ir),i=(a,l=null)=>Dt(U(n,ue(c=>c[a]),ht()),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")}}),n0=Ze(([e,t])=>({...e,...t}),pt(of,t0)),r0=({height:e})=>u.jsx("div",{style:{height:e}}),o0={overflowAnchor:"none",position:va(),zIndex:1},ff={overflowAnchor:"none"},s0={...ff,display:"inline-block",height:"100%"},pf=w.memo(function({showTopList:e=!1}){const t=Ae("listState"),n=rn("sizeRanges"),r=Ae("useWindowScroll"),o=Ae("customScrollParent"),s=rn("windowScrollContainerState"),i=rn("scrollContainerState"),a=o||r?s:i,l=Ae("itemContent"),c=Ae("context"),d=Ae("groupContent"),f=Ae("trackItemSizes"),p=Ae("itemSize"),h=Ae("log"),x=rn("gap"),y=Ae("horizontalDirection"),{callbackRef:m}=bw(n,p,f,e?Ir:a,h,x,o,y,Ae("skipAnimationFrameInResizeObserver")),[g,b]=w.useState(0);wa("deviation",R=>{g!==R&&b(R)});const S=Ae("EmptyPlaceholder"),k=Ae("ScrollSeekPlaceholder")||r0,T=Ae("ListComponent"),C=Ae("ItemComponent"),E=Ae("GroupComponent"),j=Ae("computeItemKey"),A=Ae("isSeeking"),N=Ae("groupIndices").length>0,P=Ae("alignToBottom"),F=Ae("initialItemFinalLocationReached"),$=e?{}:{boxSizing:"border-box",...y?{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},...F?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{...Lt(S,c)}):u.jsx(T,{...Lt(T,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:m,style:$,children:(e?t.topItems:t.items).map(R=>{const z=R.originalIndex,_=j(z+t.firstItemIndex,R.data,c);return A?w.createElement(k,{...Lt(k,c),height:R.size,index:R.index,key:_,type:R.type||"item",...R.type==="group"?{}:{groupIndex:R.groupIndex}}):R.type==="group"?w.createElement(E,{...Lt(E,c),"data-index":z,"data-item-index":R.index,"data-known-size":R.size,key:_,style:o0},d(R.index,c)):w.createElement(C,{...Lt(C,c),...c0(C,R.data),"data-index":z,"data-item-group-index":R.groupIndex,"data-item-index":R.index,"data-known-size":R.size,key:_,style:y?s0:ff},N?l(R.index,R.groupIndex,R.data,c):l(R.index,R.data,c))})})}),i0={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},a0={outline:"none",overflowX:"auto",position:"relative"},Cs=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),l0={position:va(),top:0,width:"100%",zIndex:1};function Lt(e,t){if(typeof e!="string")return{context:t}}function c0(e,t){return{item:typeof e=="string"?void 0:t}}const u0=w.memo(function(){const e=Ae("HeaderComponent"),t=rn("headerHeight"),n=Ae("HeaderFooterTag"),r=rr(w.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Lt(e,o)})}):null}),d0=w.memo(function(){const e=Ae("FooterComponent"),t=rn("footerHeight"),n=Ae("HeaderFooterTag"),r=rr(w.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Lt(e,o)})}):null});function hf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.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:p,scrollerRef:h,scrollToCallback:x}=uf(a,c,l,d,void 0,f);return e("scrollTo",x),e("scrollBy",p),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:h,style:{...f?a0:i0,...o},tabIndex:0,...i,...Lt(l,s),children:r})})}function mf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.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"),p=t("customScrollParent"),h=w.useRef(null),x=t("scrollerRef"),{scrollByCallback:y,scrollerRef:m,scrollToCallback:g}=uf(a,c,l,x,p);return cf(()=>{var b;return m.current=p||((b=h.current)==null?void 0:b.ownerDocument.defaultView),()=>{m.current=null}},[m,p]),e("windowScrollTo",g),e("scrollBy",y),u.jsx(l,{ref:h,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Lt(l,s),children:r})})}const f0=({children:e})=>{const t=w.useContext(af),n=rn("viewportHeight"),r=rn("fixedItemHeight"),o=Ae("alignToBottom"),s=Ae("horizontalDirection"),i=w.useMemo(()=>Id(n,l=>$n(l,s?"width":"height")),[n,s]),a=rr(i,!0,Ae("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Cs(o),children:e})},p0=({children:e})=>{const t=w.useContext(af),n=rn("windowViewportRect"),r=rn("fixedItemHeight"),o=Ae("customScrollParent"),s=Rd(n,o,Ae("skipAnimationFrameInResizeObserver")),i=Ae("alignToBottom");return w.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:s,style:Cs(i),children:e})},h0=({children:e})=>{const t=Ae("TopItemListComponent")||"div",n=Ae("headerHeight"),r={...l0,marginTop:`${n}px`},o=Ae("context");return u.jsx(t,{style:r,...Lt(t,o),children:e})},m0=w.memo(function(e){const t=Ae("useWindowScroll"),n=Ae("topItemsIndexes").length>0,r=Ae("customScrollParent"),o=Ae("context");return u.jsxs(r||t?y0:x0,{...e,context:o,children:[n&&u.jsx(h0,{children:u.jsx(pf,{showTopList:!0})}),u.jsxs(r||t?p0:f0,{children:[u.jsx(u0,{}),u.jsx(pf,{}),u.jsx(d0,{})]})]})}),{Component:g0,useEmitter:wa,useEmitterValue:Ae,usePublisher:rn}=sf(n0,{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"}},m0),x0=hf({useEmitter:wa,useEmitterValue:Ae,usePublisher:rn}),y0=mf({useEmitter:wa,useEmitterValue:Ae,usePublisher:rn}),v0=g0;pt(of,Ze(()=>{const e=Y(c=>u.jsxs("td",{children:["Item $",c]})),t=Y(null),n=Y(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=Y(null),o=Y(null),s=Y({}),i=Y(ba),a=Y(Ir),l=(c,d=null)=>Dt(U(s,ue(f=>f[c]),ht()),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")}})),va();const gf={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},b0={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:xf,floor:Ts,max:so,min:Sa,round:yf}=Math;function vf(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{...b0,items:e}}function ks(e,t){return e&&e.width===t.width&&e.height===t.height}function S0(e,t){return e&&e.column===t.column&&e.row===t.row}const C0=Ze(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:f},p,h,{didMount:x,propsReady:y},{customScrollParent:m,useWindowScroll:g,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k},T])=>{const C=Y(0),E=Y(0),j=Y(gf),A=Y({height:0,width:0}),N=Y({height:0,width:0}),P=We(),F=We(),$=Y(0),R=Y(null),z=Y({column:0,row:0}),_=We(),B=We(),L=Y(!1),M=Y(0),J=Y(!0),X=Y(!1),pe=Y(!1);nt(U(x,Le(M),ke(([D,H])=>!!H)),()=>{De(J,!1)}),nt(U(Nt(x,J,N,A,M,X),ke(([D,H,te,ae,,ne])=>D&&!H&&te.height!==0&&ae.height!==0&&!ne)),([,,,,D])=>{De(X,!0),fa(1,()=>{De(P,D)}),fn(U(c),()=>{De(t,[0,0]),De(J,!0)})}),he(U(B,ke(D=>D!=null&&D.scrollTop>0),Sn(0)),E),nt(U(x,Le(B),ke(([,D])=>D!=null)),([,D])=>{D&&(De(A,D.viewport),De(N,D.item),De(z,D.gap),D.scrollTop>0&&(De(L,!0),fn(U(c,nr(1)),H=>{De(L,!1)}),De(l,{top:D.scrollTop})))}),he(U(A,ue(({height:D})=>D)),f),he(U(Nt(Se(A,ks),Se(N,ks),Se(z,(D,H)=>D&&D.column===H.column&&D.row===H.row),Se(c)),ue(([D,H,te,ae])=>({gap:te,item:H,scrollTop:ae,viewport:D}))),_),he(U(Nt(Se(C),r,Se(z,S0),Se(N,ks),Se(A,ks),Se(R),Se(E),Se(L),Se(J),Se(M)),ke(([,,,,,,,D])=>!D),ue(([D,[H,te],ae,ne,Fe,Q,ie,,Ce,Re])=>{const{column:Ke,row:Be}=ae,{height:ze,width:qe}=ne,{width:Ge}=Fe;if(ie===0&&(D===0||Ge===0))return gf;if(qe===0){const re=pa(Re,D),Te=re+Math.max(ie-1,0);return w0(vf(re,Te,Q))}const Qe=bf(Ge,qe,Ke);let Je,rt;Ce?H===0&&te===0&&ie>0?(Je=0,rt=ie-1):(Je=Qe*Ts((H+Be)/(ze+Be)),rt=Qe*xf((te+Be)/(ze+Be))-1,rt=Sa(D-1,so(rt,Qe-1)),Je=Sa(rt,so(0,Je))):(Je=0,rt=-1);const wt=vf(Je,rt,Q),{bottom:ut,top:it}=wf(Fe,ae,ne,wt),Tt=xf(D/Qe),yt=Tt*ze+(Tt-1)*Be-ut;return{bottom:ut,itemHeight:ze,items:wt,itemWidth:qe,offsetBottom:yt,offsetTop:it,top:it}})),j),he(U(R,ke(D=>D!==null),ue(D=>D.length)),C),he(U(Nt(A,N,j,z),ke(([D,H,{items:te}])=>te.length>0&&H.height!==0&&D.height!==0),ue(([D,H,{items:te},ae])=>{const{bottom:ne,top:Fe}=wf(D,ae,H,te);return[Fe,ne]}),ht(Zr)),t);const Ie=Y(!1);he(U(c,Le(Ie),ue(([D,H])=>H||D!==0)),Ie);const je=Xt(U(Nt(j,C),ke(([{items:D}])=>D.length>0),Le(Ie),ke(([[D,H],te])=>{const ae=D.items[D.items.length-1].index===H-1;return(te||D.bottom>0&&D.itemHeight>0&&D.offsetBottom===0&&D.items.length===H)&&ae}),ue(([[,D]])=>D-1),ht())),G=Xt(U(Se(j),ke(({items:D})=>D.length>0&&D[0].index===0),Sn(0),ht())),ee=Xt(U(Se(j),Le(L),ke(([{items:D},H])=>D.length>0&&!H),ue(([{items:D}])=>({endIndex:D[D.length-1].index,startIndex:D[0].index})),ht($d),_n(0)));he(ee,h.scrollSeekRangeChanged),he(U(P,Le(A,N,C,z),ue(([D,H,te,ae,ne])=>{const Fe=Vd(D),{align:Q,behavior:ie,offset:Ce}=Fe;let Re=Fe.index;Re==="LAST"&&(Re=ae-1),Re=so(0,Re,Sa(ae-1,Re));let Ke=Ca(H,ne,te,Re);return Q==="end"?Ke=yf(Ke-H.height+te.height):Q==="center"&&(Ke=yf(Ke-H.height/2+te.height/2)),Ce&&(Ke+=Ce),{behavior:ie,top:Ke}})),l);const W=Dt(U(j,ue(D=>D.offsetBottom+D.bottom)),0);return he(U(k,ue(D=>({height:D.visibleHeight,width:D.visibleWidth}))),A),{customScrollParent:m,data:R,deviation:$,footerHeight:o,gap:z,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:N,overscan:n,restoreStateFrom:B,scrollBy:i,scrollContainerState:a,scrollHeight:F,scrollTo:l,scrollToIndex:P,scrollTop:c,smoothScrollTargetReached:d,totalCount:C,useWindowScroll:g,viewportDimensions:A,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k,...h,gridState:j,horizontalDirection:pe,initialTopMostItemIndex:M,totalListHeight:W,...p,endReached:je,propsReady:y,rangeChanged:ee,startReached:G,stateChanged:_,stateRestoreInProgress:L,...T}},pt(ha,Bt,oo,nf,zn,ga,Fn));function bf(e,t,n){return so(1,Ts((e+n)/(Ts(t)+n)))}function wf(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Ca(e,t,n,r[0].index);return{bottom:Ca(e,t,n,r[r.length-1].index)+o,top:s}}function Ca(e,t,n,r){const o=bf(e.width,n.width,t.column),s=Ts(r/o),i=s*n.height+so(0,s-1)*t.row;return i>0?i+t.row:i}const T0=Ze(()=>{const e=Y(f=>`Item ${f}`),t=Y({}),n=Y(null),r=Y("virtuoso-grid-item"),o=Y("virtuoso-grid-list"),s=Y(ba),i=Y("div"),a=Y(Ir),l=(f,p=null)=>Dt(U(t,ue(h=>h[f]),ht()),p),c=Y(!1),d=Y(!1);return he(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")}}),k0=Ze(([e,t])=>({...e,...t}),pt(C0,T0)),E0=w.memo(function(){const e=gt("gridState"),t=gt("listClassName"),n=gt("itemClassName"),r=gt("itemContent"),o=gt("computeItemKey"),s=gt("isSeeking"),i=on("scrollHeight"),a=gt("ItemComponent"),l=gt("ListComponent"),c=gt("ScrollSeekPlaceholder"),d=gt("context"),f=on("itemDimensions"),p=on("gap"),h=gt("log"),x=gt("stateRestoreInProgress"),y=on("reportReadyState"),m=rr(w.useMemo(()=>g=>{const b=g.parentElement.parentElement.scrollHeight;i(b);const S=g.firstChild;if(S){const{height:k,width:T}=S.getBoundingClientRect();f({height:k,width:T})}p({column:Cf("column-gap",getComputedStyle(g).columnGap,h),row:Cf("row-gap",getComputedStyle(g).rowGap,h)})},[i,f,p,h]),!0,!1);return cf(()=>{e.itemHeight>0&&e.itemWidth>0&&y(!0)},[e]),x?null:u.jsx(l,{className:t,ref:m,...Lt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(g=>{const b=o(g.index,g.data,d);return s?u.jsx(c,{...Lt(c,d),height:e.itemHeight,index:g.index,width:e.itemWidth},b):w.createElement(a,{...Lt(a,d),className:n,"data-index":g.index,key:b},r(g.index,g.data,d))})})}),I0=w.memo(function(){const e=gt("HeaderComponent"),t=on("headerHeight"),n=gt("headerFooterTag"),r=rr(w.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,!1),o=gt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Lt(e,o)})}):null}),N0=w.memo(function(){const e=gt("FooterComponent"),t=on("footerHeight"),n=gt("headerFooterTag"),r=rr(w.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,!1),o=gt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Lt(e,o)})}):null}),A0=({children:e})=>{const t=w.useContext(lf),n=on("itemDimensions"),r=on("viewportDimensions"),o=rr(w.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return w.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),u.jsx("div",{ref:o,style:Cs(!1),children:e})},j0=({children:e})=>{const t=w.useContext(lf),n=on("windowViewportRect"),r=on("itemDimensions"),o=gt("customScrollParent"),s=Rd(n,o,!1);return w.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),u.jsx("div",{ref:s,style:Cs(!1),children:e})},_0=w.memo(function({...e}){const t=gt("useWindowScroll"),n=gt("customScrollParent"),r=n||t?P0:R0,o=n||t?j0:A0,s=gt("context");return u.jsx(r,{...e,...Lt(r,s),children:u.jsxs(o,{children:[u.jsx(I0,{}),u.jsx(E0,{}),u.jsx(N0,{})]})})}),{useEmitter:Sf,useEmitterValue:gt,usePublisher:on}=sf(k0,{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"}},_0),R0=hf({useEmitter:Sf,useEmitterValue:gt,usePublisher:on}),P0=mf({useEmitter:Sf,useEmitterValue:gt,usePublisher:on});function Cf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Vt.WARN),t==="normal"?0:parseInt(t??"0",10)}const O0=xo.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 Tf({className:e,variant:t,...n}){return u.jsx("div",{className:Z(O0({variant:t}),e),...n})}const io=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:Z("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));io.displayName="Card";const ao=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:Z("flex flex-col space-y-1.5 p-6",e),...t}));ao.displayName="CardHeader";const lo=v.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:Z("text-2xl font-semibold leading-none tracking-tight",e),...t}));lo.displayName="CardTitle";const kf=v.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:Z("text-sm text-muted-foreground",e),...t}));kf.displayName="CardDescription";const co=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:Z("p-6 pt-0",e),...t}));co.displayName="CardContent";const Ef=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:Z("flex items-center p-6 pt-0",e),...t}));Ef.displayName="CardFooter";const M0=1,D0=1e6;let Ta=0;function L0(){return Ta=(Ta+1)%Number.MAX_SAFE_INTEGER,Ta.toString()}const ka=new Map,If=e=>{if(ka.has(e))return;const t=setTimeout(()=>{ka.delete(e),uo({type:"REMOVE_TOAST",toastId:e})},D0);ka.set(e,t)},F0=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,M0)};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?If(n):e.toasts.forEach(r=>{If(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)}}},Es=[];let Is={toasts:[]};function uo(e){Is=F0(Is,e),Es.forEach(t=>{t(Is)})}function $0({...e}){const t=L0(),n=o=>uo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>uo({type:"DISMISS_TOAST",toastId:t});return uo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Ea(){const[e,t]=v.useState(Is);return v.useEffect(()=>(Es.push(t),()=>{const n=Es.indexOf(t);n>-1&&Es.splice(n,1)}),[e]),{...e,toast:$0,dismiss:n=>uo({type:"DISMISS_TOAST",toastId:n})}}async function Nf(e,t){return await Qt(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function Af(e,t){return await(await Nf(`/files/${e}/view`,t)).text()}async function z0(e,t){const n=await Nf(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Qt(`/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 B0(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Qt("/files",{params:r})}function Ia(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 jf(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function fo(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(fo).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(jf(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=fo(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 po(e){if(typeof e=="string")return e;if(jf(e))return"";try{const t=fo(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function H0(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function U0(e){const t=po(e);return typeof e=="string"&&H0(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function Ns(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Ia(t);if(n!==null)return Ns(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?Ns(e.content):e}var As="Dialog",[_f,vT]=In(As),[W0,hn]=_f(As),Rf=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]=xr({prop:r,defaultProp:o??!1,onChange:s,caller:As});return u.jsx(W0,{scope:t,triggerRef:a,contentRef:l,contentId:Nn(),titleId:Nn(),descriptionId:Nn(),open:c,onOpenChange:d,onOpenToggle:v.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Rf.displayName=As;var Pf="DialogTrigger",Of=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Pf,n),s=Ue(t,o.triggerRef);return u.jsx(_e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":ja(o.open),...r,ref:s,onClick:fe(e.onClick,o.onOpenToggle)})});Of.displayName=Pf;var Na="DialogPortal",[V0,Mf]=_f(Na,{forceMount:void 0}),Df=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=hn(Na,t);return u.jsx(V0,{scope:t,forceMount:n,children:v.Children.map(r,i=>u.jsx(tn,{present:n||s.open,children:u.jsx(Jo,{asChild:!0,container:o,children:i})}))})};Df.displayName=Na;var js="DialogOverlay",Lf=v.forwardRef((e,t)=>{const n=Mf(js,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(js,e.__scopeDialog);return s.modal?u.jsx(tn,{present:r||s.open,children:u.jsx(q0,{...o,ref:t})}):null});Lf.displayName=js;var K0=Yn.createSlot("DialogOverlay.RemoveScroll"),q0=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(js,n);return u.jsx(is,{as:K0,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(_e.div,{"data-state":ja(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ir="DialogContent",Ff=v.forwardRef((e,t)=>{const n=Mf(ir,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(ir,e.__scopeDialog);return u.jsx(tn,{present:r||s.open,children:s.modal?u.jsx(G0,{...o,ref:t}):u.jsx(Y0,{...o,ref:t})})});Ff.displayName=ir;var G0=v.forwardRef((e,t)=>{const n=hn(ir,e.__scopeDialog),r=v.useRef(null),o=Ue(t,n.contentRef,r);return v.useEffect(()=>{const s=r.current;if(s)return Bi(s)},[]),u.jsx($f,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:fe(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:fe(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:fe(e.onFocusOutside,s=>s.preventDefault())})}),Y0=v.forwardRef((e,t)=>{const n=hn(ir,e.__scopeDialog),r=v.useRef(!1),o=v.useRef(!1);return u.jsx($f,{...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()}})}),$f=v.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=hn(ir,n),l=v.useRef(null),c=Ue(t,l);return Si(),u.jsxs(u.Fragment,{children:[u.jsx($o,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(Fo,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":ja(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(X0,{titleId:a.titleId}),u.jsx(Z0,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Aa="DialogTitle",zf=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Aa,n);return u.jsx(_e.h2,{id:o.titleId,...r,ref:t})});zf.displayName=Aa;var Bf="DialogDescription",Hf=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Bf,n);return u.jsx(_e.p,{id:o.descriptionId,...r,ref:t})});Hf.displayName=Bf;var Uf="DialogClose",Wf=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Uf,n);return u.jsx(_e.button,{type:"button",...r,ref:t,onClick:fe(e.onClick,()=>o.onOpenChange(!1))})});Wf.displayName=Uf;function ja(e){return e?"open":"closed"}var Vf="DialogTitleWarning",[bT,Kf]=tx(Vf,{contentName:ir,titleName:Aa,docsSlug:"dialog"}),X0=({titleId:e})=>{const t=Kf(Vf),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 lw(e,t=fs){if(!e||typeof e!="string")throw new Error("Invalid content: must be a non-empty string");if(e.length>t)throw new Error(`Message exceeds maximum length of ${t} characters`);return e}function cw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),lw(t),aw(t)}const ps=0,Ln=1,Er=2,kd=4;function Ed(e){return()=>e}function uw(e){e()}function Id(e,t){return n=>e(t(n))}function Nd(e,t){return()=>e(t)}function dw(e,t){return n=>e(t,n)}function ta(e){return e!==void 0}function fw(...e){return()=>{e.map(uw)}}function Ir(){}function hs(e,t){return t(e),e}function pw(e,t){return t(e)}function pt(...e){return e}function nt(e,t){return e(Ln,t)}function Me(e,t){e(ps,t)}function na(e){e(Er)}function St(e){return e(kd)}function me(e,t){return nt(e,dw(t,ps))}function fn(e,t){const n=e(Ln,r=>{n(),t(r)});return n}function Ad(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function jd(e,t){return e===t}function ht(e=jd){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ee(e){return t=>n=>{e(n)&&t(n)}}function ue(e){return t=>Id(t,e)}function Sn(e){return t=>()=>{t(e)}}function U(e,...t){const n=hw(...t);return(r,o)=>{switch(r){case Er:na(e);return;case Ln:return nt(e,n(o))}}}function Cn(e,t){return n=>r=>{n(t=e(t,r))}}function nr(e){return t=>n=>{e>0?e--:t(n)}}function _n(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function De(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);nt(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 hw(...e){return t=>e.reduceRight(pw,t)}function mw(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Ln:return s?n===s?void 0:(r(),n=s,t=nt(e,s),t):(r(),Ir);case Er:r(),n=null;return}}}function Y(e){let t=e;const n=Ve();return(r,o)=>{switch(r){case ps:t=o;break;case Ln:{o(t);break}case kd:return t}return n(r,o)}}function Dt(e,t){return hs(Y(t),n=>me(e,n))}function Ve(){const e=[];return(t,n)=>{switch(t){case ps:e.slice().forEach(r=>{r(n)});return;case Er:e.splice(0,e.length);return;case Ln:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Xt(e){return hs(Ve(),t=>me(e,t))}function Ze(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:gw(),singleton:n}}const gw=()=>Symbol();function xw(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 It(...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);nt(s,l=>{n[i]=l,r=r|a,r===o&&Me(t,n)})}),function(s,i){switch(s){case Er:{na(t);return}case Ln:return r===o&&i(n),nt(t,i)}}}function Te(e,t=jd){return U(e,ht(t))}function ra(...e){return function(t,n){switch(t){case Er:return;case Ln:return fw(...e.map(r=>nt(r,n)))}}}var Vt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Vt||{});const yw={0:"debug",3:"error",1:"log",2:"warn"},vw=()=>typeof globalThis>"u"?window:globalThis,Fn=Ze(()=>{const e=Y(3);return{log:Y((t,n,r=1)=>{var o;const s=(o=vw().VIRTUOSO_LOG_LEVEL)!=null?o:St(e);r>=s&&console[yw[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function rr(e,t,n){return oa(e,t,n).callbackRef}function oa(e,t,n){const r=w.useRef(null);let o=i=>{};const s=w.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function bw(e,t,n,r,o,s,i,a,l){const c=w.useCallback(d=>{const f=ww(d.children,t,a?"offsetWidth":"offsetHeight",o);let p=d.parentElement;for(;!p.dataset.virtuosoScroller;)p=p.parentElement;const h=p.lastElementChild.dataset.viewportType==="window";let x;h&&(x=p.ownerDocument.defaultView);const y=i?a?i.scrollLeft:i.scrollTop:h?a?x.scrollX||x.document.documentElement.scrollLeft:x.scrollY||x.document.documentElement.scrollTop:a?p.scrollLeft:p.scrollTop,m=i?a?i.scrollWidth:i.scrollHeight:h?a?x.document.documentElement.scrollWidth:x.document.documentElement.scrollHeight:a?p.scrollWidth:p.scrollHeight,g=i?a?i.offsetWidth:i.offsetHeight:h?a?x.innerWidth:x.innerHeight:a?p.offsetWidth:p.offsetHeight;r({scrollHeight:m,scrollTop:Math.max(y,0),viewportHeight:g}),s==null||s(a?_d("column-gap",getComputedStyle(d).columnGap,o):_d("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return oa(c,n,l)}function ww(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},Vt.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 _d(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Vt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Rd(e,t,n){const r=w.useRef(null),o=w.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let f,p;if(t){const h=t.getBoundingClientRect(),x=c.top-h.top;p=h.height-Math.max(0,x),f=x+t.scrollTop}else{const h=i.current.ownerDocument.defaultView;p=h.innerHeight-Math.max(0,c.top),f=c.top+h.scrollY}r.current={offsetTop:f,visibleHeight:p,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=oa(o,!0,n),a=w.useCallback(()=>{o(i.current)},[o,i]);return w.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 Bt=Ze(()=>{const e=Ve(),t=Ve(),n=Y(0),r=Ve(),o=Y(0),s=Ve(),i=Ve(),a=Y(0),l=Y(0),c=Y(0),d=Y(0),f=Ve(),p=Ve(),h=Y(!1),x=Y(!1),y=Y(!1);return me(U(e,ue(({scrollTop:m})=>m)),t),me(U(e,ue(({scrollHeight:m})=>m)),i),me(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:x,scrollBy:p,scrollContainerState:e,scrollHeight:i,scrollingInProgress:h,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:y,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Xr={lvl:0};function Pd(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 lt(e){return e===Xr}function Jr(e,t){if(!lt(e))return t===e.k?e.v:t<e.k?Jr(e.l,t):Jr(e.r,t)}function pn(e,t,n="k"){if(lt(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=pn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return pn(e.l,t,n)}function Jt(e,t,n){return lt(e)?Dd(t,n,1):t===e.k?Nt(e,{k:t,v:n}):t<e.k?Ld(Nt(e,{l:Jt(e.l,t,n)})):Ld(Nt(e,{r:Jt(e.r,t,n)}))}function Nr(){return Xr}function ms(e,t,n){if(lt(e))return[];const r=pn(e,t)[0];return Sw(ia(e,r,n))}function sa(e,t){if(lt(e))return Xr;const{k:n,l:r,r:o}=e;if(t===n){if(lt(r))return o;if(lt(o))return r;{const[s,i]=Md(r);return gs(Nt(e,{k:s,l:Od(r),v:i}))}}else return t<n?gs(Nt(e,{l:sa(r,t)})):gs(Nt(e,{r:sa(o,t)}))}function or(e){return lt(e)?[]:[...or(e.l),{k:e.k,v:e.v},...or(e.r)]}function ia(e,t,n){if(lt(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(ia(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(ia(s,t,n))),a}function gs(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(aa(t))return Fd(Nt(e,{lvl:n-1}));if(!lt(t)&&!lt(t.r))return Nt(t.r,{l:Nt(t,{r:t.r.l}),lvl:n,r:Nt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(aa(e))return la(Nt(e,{lvl:n-1}));if(!lt(r)&&!lt(r.l)){const o=r.l,s=aa(o)?r.lvl-1:r.lvl;return Nt(o,{l:Nt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:la(Nt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Nt(e,t){return Dd(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 Od(e){return lt(e.r)?e.l:gs(Nt(e,{r:Od(e.r)}))}function aa(e){return lt(e)||e.lvl>e.r.lvl}function Md(e){return lt(e.r)?[e.k,e.v]:Md(e.r)}function Dd(e,t,n,r=Xr,o=Xr){return{k:e,l:r,lvl:n,r:o,v:t}}function Ld(e){return la(Fd(e))}function Fd(e){const{l:t}=e;return!lt(t)&&t.lvl===e.lvl?Nt(t,{r:Nt(e,{l:t.r})}):e}function la(e){const{lvl:t,r:n}=e;return!lt(n)&&!lt(n.r)&&n.lvl===t&&n.r.lvl===t?Nt(n,{l:Nt(e,{r:n.l}),lvl:t+1}):e}function Sw(e){return Pd(e,({k:t,v:n})=>({index:t,value:n}))}function $d(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Zr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const ca=Ze(()=>({recalcInProgress:Y(!1)}),[],{singleton:!0});function zd(e,t,n){return e[xs(e,t,n)]}function xs(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 Cw(e,t,n,r){const o=xs(e,t,r),s=xs(e,n,r,o);return e.slice(o,s+1)}function $n(e,t){return Math.round(e.getBoundingClientRect()[t])}function ys(e){return!lt(e.groupOffsetTree)}function ua({index:e},t){return t===e?0:t<e?-1:1}function Tw(){return{groupIndices:[],groupOffsetTree:Nr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Nr()}}function kw(e,t){let n=lt(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),lt(e)){e=Jt(e,0,s);continue}const a=ms(e,i-1,o+1);if(a.some(Rw(r)))continue;let l=!1,c=!1;for(const{end:d,start:f,value:p}of a)l?(o>=f||s===p)&&(e=sa(e,f)):(c=p!==s,l=!0),d>o&&o>=f&&p!==s&&(e=Jt(e,o+1,p));c&&(e=Jt(e,i,s))}return[e,n]}function Ew(e){return typeof e.groupIndex<"u"}function Iw({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}=zd(t,e,ua),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Bd(e,t){if(!ys(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Hd(e,t,n){if(Ew(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Bd(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function Nw(e,t,n,r=0){return r>0&&(t=Math.max(t,zd(e,r,ua).offset)),Pd(Cw(e,t,n,Iw),_w)}function Aw(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Vt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&<(s)&&t.length===2){const p=t[0].size,h=t[1].size;i=n.reduce((x,y)=>Jt(Jt(x,y,p),y+1,h),i)}else[i,a]=kw(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f}=da(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((p,h)=>Jt(p,h,Qr(h,f,o)),Nr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f,sizeTree:i}}function jw(e){return or(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 Ud(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 da(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=xs(o,t-1,ua),a=o[l].offset;const c=pn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===pn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of ms(n,t,1/0)){const f=c-s,p=f*i+a+f*r;o.push({index:c,offset:p,size:d}),s=c,a=p,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function _w(e){return{index:e.index,value:e}}function Rw(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 Pw={offsetHeight:"height",offsetWidth:"width"},Tn=Ze(([{log:e},{recalcInProgress:t}])=>{const n=Ve(),r=Ve(),o=Dt(r,0),s=Ve(),i=Ve(),a=Y(0),l=Y([]),c=Y(void 0),d=Y(void 0),f=Y((T,C)=>$n(T,Pw[C])),p=Y(void 0),h=Y(0),x=Tw(),y=Dt(U(n,De(l,e,h),Cn(Aw,x),ht()),x),m=Dt(U(l,ht(),Cn((T,C)=>({current:C,prev:T.current}),{current:[],prev:[]}),ue(({prev:T})=>T)),[]);me(U(l,Ee(T=>T.length>0),De(y,h),ue(([T,C,E])=>{const j=T.reduce((A,N,P)=>Jt(A,N,Qr(N,C.offsetTree,E)||P),Nr());return{...C,groupIndices:T,groupOffsetTree:j}})),y),me(U(r,De(y),Ee(([T,{lastIndex:C}])=>T<C),ue(([T,{lastIndex:C,lastSize:E}])=>[{endIndex:C,size:E,startIndex:T}])),n),me(c,d);const g=Dt(U(c,ue(T=>T===void 0)),!0);me(U(d,Ee(T=>T!==void 0&<(St(y).sizeTree)),ue(T=>[{endIndex:0,size:T,startIndex:0}])),n);const b=Xt(U(n,De(y),Cn(({sizes:T},[C,E])=>({changed:E!==T,sizes:E}),{changed:!1,sizes:x}),ue(T=>T.changed)));nt(U(a,Cn((T,C)=>({diff:T.prev-C,prev:C}),{diff:0,prev:0}),ue(T=>T.diff)),T=>{const{groupIndices:C}=St(y);if(T>0)Me(t,!0),Me(s,T+Ud(T,C));else if(T<0){const E=St(m);E.length>0&&(T-=Ud(-T,E)),Me(i,T)}}),nt(U(a,De(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},Vt.ERROR)});const S=Xt(s);me(U(s,De(y),ue(([T,C])=>{const E=C.groupIndices.length>0,j=[],A=C.lastSize;if(E){const N=Jr(C.sizeTree,0);let P=0,F=0;for(;P<T;){const R=C.groupIndices[F],z=C.groupIndices.length===F+1?1/0:C.groupIndices[F+1]-R-1;j.push({endIndex:R,size:N,startIndex:R}),j.push({endIndex:R+1+z-1,size:A,startIndex:R+1}),F++,P+=z+1}const $=or(C.sizeTree);return P!==T&&$.shift(),$.reduce((R,{k:z,v:_})=>{let B=R.ranges;return R.prevSize!==0&&(B=[...R.ranges,{endIndex:z+T-1,size:R.prevSize,startIndex:R.prevIndex}]),{prevIndex:z+T,prevSize:_,ranges:B}},{prevIndex:T,prevSize:0,ranges:j}).ranges}return or(C.sizeTree).reduce((N,{k:P,v:F})=>({prevIndex:P+T,prevSize:F,ranges:[...N.ranges,{endIndex:P+T-1,size:N.prevSize,startIndex:N.prevIndex}]}),{prevIndex:0,prevSize:A,ranges:[]}).ranges})),n);const k=Xt(U(i,De(y,h),ue(([T,{offsetTree:C},E])=>{const j=-T;return Qr(j,C,E)})));return me(U(i,De(y,h),ue(([T,C,E])=>{if(C.groupIndices.length>0){if(lt(C.sizeTree))return C;let j=Nr();const A=St(m);let N=0,P=0,F=0;for(;N<-T;){F=A[P];const $=A[P+1]-F-1;P++,N+=$+1}if(j=or(C.sizeTree).reduce(($,{k:R,v:z})=>Jt($,Math.max(0,R+T),z),j),N!==-T){const $=Jr(C.sizeTree,F);j=Jt(j,0,$);const R=pn(C.sizeTree,-T+1)[1];j=Jt(j,1,R)}return{...C,sizeTree:j,...da(C.offsetTree,0,j,E)}}else{const j=or(C.sizeTree).reduce((A,{k:N,v:P})=>Jt(A,Math.max(0,N+T),P),Nr());return{...C,sizeTree:j,...da(C.offsetTree,0,j,E)}}})),y),{beforeUnshiftWith:S,data:p,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:h,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:y,statefulTotalCount:o,totalCount:r,trackItemSizes:g,unshiftWith:s}},pt(Fn,ca),{singleton:!0});function Ow(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Wd=Ze(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Ve(),i=Ve(),a=Xt(U(s,ue(Ow)));return me(U(a,ue(l=>l.totalCount)),n),me(U(a,ue(l=>l.groupIndices)),e),me(U(It(o,t,r),Ee(([l,c])=>ys(c)),ue(([l,c,d])=>pn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),ht(),ue(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},pt(Tn,Bt)),zn=Ze(([{log:e}])=>{const t=Y(!1),n=Xt(U(t,Ee(r=>r),ht()));return nt(t,r=>{r&&St(e)("props updated",{},Vt.DEBUG)}),{didMount:n,propsReady:t}},pt(Fn),{singleton:!0}),Mw=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Vd(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Mw)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const eo=Ze(([{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:p}])=>{const h=Ve(),x=Ve(),y=Y(0);let m=null,g=null,b=null;function S(){m&&(m(),m=null),b&&(b(),b=null),g&&(clearTimeout(g),g=null),Me(l,!1)}return me(U(h,De(n,f,r,y,a,i,p),De(e,s,o),ue(([[k,T,C,E,j,A,N,P],F,$,R])=>{const z=Vd(k),{align:_,behavior:B,offset:L}=z,M=E-1,J=Hd(z,T,M);let X=Qr(J,T.offsetTree,F)+A;_==="end"?(X+=$+pn(T.sizeTree,J)[1]-C+R,J===M&&(X+=N)):_==="center"?X+=($+pn(T.sizeTree,J)[1]-C+R)/2:X-=j,L&&(X+=L);const pe=Ne=>{S(),Ne?(P("retrying to scroll to",{location:k},Vt.DEBUG),Me(h,k)):(Me(x,!0),P("list did not change, scroll successful",{},Vt.DEBUG))};if(S(),B==="smooth"){let Ne=!1;b=nt(t,je=>{Ne=Ne||je}),m=fn(d,()=>{pe(Ne)})}else m=fn(U(t,Dw(150)),pe);return g=setTimeout(()=>{S()},1200),Me(l,!0),P("scrolling from index to",{behavior:B,index:J,top:X},Vt.DEBUG),{behavior:B,top:X}})),c),{scrollTargetReached:x,scrollToIndex:h,topListHeight:y}},pt(Tn,Bt,Fn),{singleton:!0});function Dw(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function fa(e,t){e==0?t():requestAnimationFrame(()=>{fa(e-1,t)})}function pa(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const to=Ze(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=Y(!0),l=Y(0),c=Y(!0);return me(U(i,De(l),Ee(([d,f])=>!!f),Sn(!1)),a),me(U(i,De(l),Ee(([d,f])=>!!f),Sn(!1)),c),nt(U(It(t,i),De(a,n,e,c),Ee(([[,d],f,{sizeTree:p},h,x])=>d&&(!lt(p)||ta(h))&&!f&&!x),De(l)),([,d])=>{fn(o,()=>{Me(c,!0)}),fa(4,()=>{fn(r,()=>{Me(a,!0)}),Me(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},pt(Tn,Bt,eo,zn),{singleton:!0});function Kd(e,t){return Math.abs(e-t)<1.01}const no="up",ro="down",Lw="none",Fw={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},$w=0,oo=Ze(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=Y(!1),a=Y(!0),l=Ve(),c=Ve(),d=Y(4),f=Y($w),p=Dt(U(ra(U(Te(o),nr(1),Sn(!0)),U(Te(o),nr(1),Sn(!1),Ad(100))),ht()),!1),h=Dt(U(ra(U(n,Sn(!0)),U(n,Sn(!1),Ad(200))),ht()),!1);me(U(It(Te(o),Te(f)),ue(([b,S])=>b<=S),ht()),a),me(U(a,_n(50)),c);const x=Xt(U(It(r,Te(s),Te(t),Te(e),Te(d)),Cn((b,[{scrollHeight:S,scrollTop:k},T,C,E,j])=>{const A=k+T-S>-j,N={scrollHeight:S,scrollTop:k,viewportHeight:T};if(A){let F,$;return k>b.state.scrollTop?(F="SCROLLED_DOWN",$=b.state.scrollTop-k):(F="SIZE_DECREASED",$=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:F,scrollTopDelta:$,state:N}}let P;return N.scrollHeight>b.state.scrollHeight?P="SIZE_INCREASED":T<b.state.viewportHeight?P="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?P="SCROLLING_UPWARDS":P="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:P,state:N}},Fw),ht((b,S)=>b&&b.atBottom===S.atBottom))),y=Dt(U(r,Cn((b,{scrollHeight:S,scrollTop:k,viewportHeight:T})=>{if(Kd(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const C=S-(k+T)<1;return b.scrollTop!==k&&C?{changed:!0,jump:b.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ee(b=>b.changed),ue(b=>b.jump)),0);me(U(x,ue(b=>b.atBottom)),i),me(U(i,_n(50)),l);const m=Y(ro);me(U(r,ue(({scrollTop:b})=>b),ht(),Cn((b,S)=>St(h)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?no:ro,prevScrollTop:S},{direction:ro,prevScrollTop:0}),ue(b=>b.direction)),m),me(U(r,_n(50),Sn(Lw)),m);const g=Y(0);return me(U(p,Ee(b=>!b),Sn(0)),g),me(U(o,_n(100),De(p),Ee(([b,S])=>!!S),Cn(([b,S],[k])=>[S,k],[0,0]),ue(([b,S])=>S-b)),g),{atBottomState:x,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:p,lastJumpDueToItemResize:y,scrollDirection:m,scrollVelocity:g}},pt(Bt)),vs="top",bs="bottom",qd="none";function Gd(e,t,n){return typeof e=="number"?n===no&&t===vs||n===ro&&t===bs?e:0:n===no?t===vs?e.main:e.reverse:t===bs?e.main:e.reverse}function Yd(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const ha=Ze(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Ve(),i=Y(0),a=Y(0),l=Y(0),c=Dt(U(It(Te(r),Te(o),Te(n),Te(s,Zr),Te(l),Te(i),Te(t),Te(e),Te(a)),ue(([d,f,p,[h,x],y,m,g,b,S])=>{const k=d-b,T=m+g,C=Math.max(p-k,0);let E=qd;const j=Yd(S,vs),A=Yd(S,bs);return h-=b,h+=p+g,x+=p+g,x-=b,h>d+T-j&&(E=no),x<d-C+f+A&&(E=ro),E!==qd?[Math.max(k-p-Gd(y,vs,E)-j,0),k-C-g+f+Gd(y,bs,E)+A]:null}),Ee(d=>d!=null),ht(Zr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},pt(Bt),{singleton:!0});function zw(e,t,n){if(ys(t)){const r=Bd(e,t);return[{index:pn(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 ma={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function ws(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 y=e[e.length-1];d=y.offset+y.size}const f=n-i,p=a+f*l+(f-1)*r,h=c,x=p-d;return{bottom:d,firstItemIndex:s,items:Jd(e,o,s),offsetBottom:x,offsetTop:c,top:h,topItems:Jd(t,o,s),topListHeight:t.reduce((y,m)=>m.size+y,0),totalCount:n}}function Xd(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=pa(t,a),c=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return ws(c,[],a,o,n,r)}function Jd(e,t,n){if(e.length===0)return[];if(!ys(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=ms(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 sr=Ze(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:f},p,{didMount:h},{recalcInProgress:x}])=>{const y=Y([]),m=Y(0),g=Ve();me(s.topItemsIndexes,y);const b=Dt(U(It(h,x,Te(l,Zr),Te(o),Te(r),Te(c),d,Te(y),Te(t),Te(n),e),Ee(([C,E,,j,,,,,,,A])=>{const N=A&&A.length!==j;return C&&!E&&!N}),ue(([,,[C,E],j,A,N,P,F,$,R,z])=>{const _=A,{offsetTree:B,sizeTree:L}=_,M=St(m);if(j===0)return{...ma,totalCount:j};if(C===0&&E===0)return M===0?{...ma,totalCount:j}:Xd(M,N,A,$,R,z||[]);if(lt(L))return M>0?null:ws(zw(pa(N,j),_,z),[],j,R,_,$);const J=[];if(F.length>0){const G=F[0],ee=F[F.length-1];let W=0;for(const D of ms(L,G,ee)){const H=D.value,te=Math.max(D.start,G),ae=Math.min(D.end,ee);for(let ne=te;ne<=ae;ne++)J.push({data:z==null?void 0:z[ne],index:ne,offset:W,size:H}),W+=H}}if(!P)return ws([],J,j,R,_,$);const X=F.length>0?F[F.length-1]+1:0,pe=Nw(B,C,E,X);if(pe.length===0)return null;const Ne=j-1,je=hs([],G=>{for(const ee of pe){const W=ee.value;let D=W.offset,H=ee.start;const te=W.size;if(W.offset<C){H+=Math.floor((C-W.offset+R)/(te+R));const ne=H-ee.start;D+=ne*te+ne*R}H<X&&(D+=(X-H)*te,H=X);const ae=Math.min(ee.end,Ne);for(let ne=H;ne<=ae&&!(D>=E);ne++)G.push({data:z==null?void 0:z[ne],index:ne,offset:D,size:te}),D+=te+R}});return ws(je,J,j,R,_,$)}),Ee(C=>C!==null),ht()),ma);me(U(e,Ee(ta),ue(C=>C==null?void 0:C.length)),o),me(U(b,ue(C=>C.topListHeight)),f),me(f,a),me(U(b,ue(C=>[C.top,C.bottom])),i),me(U(b,ue(C=>C.items)),g);const S=Xt(U(b,Ee(({items:C})=>C.length>0),De(o,e),Ee(([{items:C},E])=>C[C.length-1].originalIndex===E-1),ue(([,C,E])=>[C-1,E]),ht(Zr),ue(([C])=>C))),k=Xt(U(b,_n(200),Ee(({items:C,topItems:E})=>C.length>0&&C[0].originalIndex===E.length),ue(({items:C})=>C[0].index),ht())),T=Xt(U(b,Ee(({items:C})=>C.length>0),ue(({items:C})=>{let E=0,j=C.length-1;for(;C[E].type==="group"&&E<j;)E++;for(;C[j].type==="group"&&j>E;)j--;return{endIndex:C[j].index,startIndex:C[E].index}}),ht($d)));return{endReached:S,initialItemCount:m,itemsRendered:g,listState:b,rangeChanged:T,startReached:k,topItemsIndexes:y,...p}},pt(Tn,Wd,ha,to,eo,oo,zn,ca),{singleton:!0}),Zd=Ze(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Ve(),i=Dt(U(It(n,e,r,t,o),ue(([a,l,c,d,f])=>a+l+c+d+f.offsetBottom+f.bottom)),0);return me(Te(i),s),{totalListHeight:i,totalListHeightChanged:s}},pt(Bt,sr),{singleton:!0}),Bw=Ze(([{viewportHeight:e},{totalListHeight:t}])=>{const n=Y(!1),r=Dt(U(It(n,e,t),Ee(([o])=>o),ue(([,o,s])=>Math.max(0,o-s)),_n(0),ht()),0);return{alignToBottom:n,paddingTopAddition:r}},pt(Bt,Zd),{singleton:!0}),Qd=Ze(()=>({context:Y(null)})),Hw=({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,ef=Ze(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=Ve();return me(U(d,De(t,l,n,s,o,r,a),De(e),ue(([[f,p,h,x,y,m,g,b],S])=>{const{align:k,behavior:T,calculateViewLocation:C=Hw,done:E,...j}=f,A=Hd(f,p,x-1),N=Qr(A,p.offsetTree,S)+y+m,P=N+pn(p.sizeTree,A)[1],F=b+m,$=b+h-g,R=C({itemBottom:P,itemTop:N,locationParams:{align:k,behavior:T,...j},viewportBottom:$,viewportTop:F});return R?E&&fn(U(i,Ee(z=>!z),nr(St(i)?1:2)),E):E&&E(),R}),Ee(f=>f!==null)),c),{scrollIntoView:d}},pt(Tn,Bt,eo,sr,Fn),{singleton:!0});function tf(e){return e?e==="smooth"?"smooth":"auto":!1}const Uw=(e,t)=>typeof e=="function"?tf(e(t)):t&&tf(e),Ww=Ze(([{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:p},{scrollIntoView:h}])=>{const x=Y(!1),y=Ve();let m=null;function g(T){Me(i,{align:"end",behavior:T,index:"LAST"})}nt(U(It(U(Te(t),nr(1)),l),De(Te(x),s,a,f),ue(([[T,C],E,j,A,N])=>{let P=C&&A,F="auto";return P&&(F=Uw(E,j||N),P=P&&!!F),{followOutputBehavior:F,shouldFollow:P,totalCount:T}}),Ee(({shouldFollow:T})=>T)),({followOutputBehavior:T,totalCount:C})=>{m&&(m(),m=null),St(n)?requestAnimationFrame(()=>{St(d)("following output to ",{totalCount:C},Vt.DEBUG),g(T)}):m=fn(e,()=>{St(d)("following output to ",{totalCount:C},Vt.DEBUG),g(T),m=null})});function b(T){const C=fn(o,E=>{T&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!m&&(St(d)("scrolling to bottom due to increased size",{},Vt.DEBUG),g("auto"))});setTimeout(C,100)}nt(U(It(Te(x),t,c),Ee(([T,,C])=>T&&C),Cn(({value:T},[,C])=>({refreshed:T===C,value:C}),{refreshed:!1,value:0}),Ee(({refreshed:T})=>T),De(x,t)),([,T])=>{St(a)&&b(T!==!1)}),nt(y,()=>{b(St(x)!==!1)}),nt(It(Te(x),o),([T,C])=>{T&&!C.atBottom&&C.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&g("auto")});const S=Y(null),k=Ve();return me(ra(U(Te(r),ue(T=>{var C;return(C=T==null?void 0:T.length)!=null?C:0})),U(Te(t))),k),nt(U(It(U(k,nr(1)),l),De(Te(S),a,f,p),ue(([[T,C],E,j,A,N])=>C&&j&&(E==null?void 0:E({context:N,totalCount:T,scrollingInProgress:A}))),Ee(T=>!!T),_n(0)),T=>{m&&(m(),m=null),St(n)?requestAnimationFrame(()=>{St(d)("scrolling into view",{}),Me(h,T)}):m=fn(e,()=>{St(d)("scrolling into view",{}),Me(h,T),m=null})}),{autoscrollToBottom:y,followOutput:x,scrollIntoViewOnChange:S}},pt(Tn,oo,eo,to,zn,Fn,Bt,Qd,ef)),Vw=Ze(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(me(U(a,De(s),Ee(([,l])=>l!==0),De(o,r,t,n,e),ue(([[,l],c,d,f,p,h=[]])=>Xd(l,c,d,f,p,h))),i),{}),pt(Tn,to,sr,zn),{singleton:!0}),Kw=Ze(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=Y(0);return nt(U(e,De(r),Ee(([,o])=>o!==0),ue(([,o])=>({top:o}))),o=>{fn(U(n,nr(1),Ee(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Me(t,o)})})}),{initialScrollTop:r}},pt(zn,Bt,sr),{singleton:!0}),nf=Ze(([{scrollVelocity:e}])=>{const t=Y(!1),n=Ve(),r=Y(!1);return me(U(e,De(r,t,n),Ee(([o,s])=>!!s),ue(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),ht()),t),nt(U(It(t,e,n),De(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},pt(oo),{singleton:!0}),ga=Ze(([{scrollContainerState:e,scrollTo:t}])=>{const n=Ve(),r=Ve(),o=Ve(),s=Y(!1),i=Y(void 0);return me(U(It(n,r),ue(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),me(U(t,De(r),ue(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},pt(Bt)),qw=Ze(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=Ve(),d=Y(void 0),f=Y(null),p=Y(null);return me(a,f),me(l,p),nt(U(c,De(t,r,i,f,p,n)),([h,x,y,m,g,b,S])=>{const k=jw(x.sizeTree);m&&g!==null&&b!==null&&(y=g.scrollTop-b.offsetTop),y-=S,h({ranges:k,scrollTop:y})}),me(U(d,Ee(ta),ue(Gw)),o),me(U(s,De(d),Ee(([,h])=>h!==void 0),ht(),ue(([,h])=>h.ranges)),e),{getState:c,restoreStateFrom:d}},pt(Tn,Bt,to,zn,ga));function Gw(e){return{align:"start",index:0,offset:e.scrollTop}}const Yw=Ze(([{topItemsIndexes:e}])=>{const t=Y(0);return me(U(t,Ee(n=>n>=0),ue(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},pt(sr));function rf(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const Xw=rf(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Jw=Ze(([{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:p},{log:h},{recalcInProgress:x}])=>{const y=Xt(U(l,De(i),Cn(([,g,b,S],[{bottom:k,items:T,offsetBottom:C,totalCount:E},j])=>{const A=k+C;let N=0;return b===E&&g.length>0&&T.length>0&&(T[0].originalIndex===0&&g[0].originalIndex===0||(N=A-S,N!==0&&(N+=j))),[N,T,E,A]},[0,[],0,0]),Ee(([g])=>g!==0),De(r,a,n,o,h,x),Ee(([,g,b,S,,,k])=>!k&&!S&&g!==0&&b===no),ue(([[g],,,,,b])=>(b("Upward scrolling compensation",{amount:g},Vt.DEBUG),g))));function m(g){g>0?(Me(t,{behavior:"auto",top:-g}),Me(e,0)):(Me(e,0),Me(t,{behavior:"auto",top:-g}))}return nt(U(y,De(e,s)),([g,b,S])=>{S&&Xw()?Me(e,b-g):m(-g)}),nt(U(It(Dt(s,!1),e,x),Ee(([g,b,S])=>!g&&!S&&b!==0),ue(([g,b])=>b),_n(1)),m),me(U(f,ue(g=>({top:-g}))),t),nt(U(c,De(p,d),ue(([g,{groupIndices:b,lastSize:S,sizeTree:k},T])=>{function C(E){return E*(S+T)}if(b.length===0)return C(g);{let E=0;const j=Jr(k,0);let A=0,N=0;for(;A<g;){A++,E+=j;let P=b.length===N+1?1/0:b[N+1]-b[N]-1;A+P>g&&(E-=j,P=g-A+1),A+=P,E+=C(P),N++}return E}})),g=>{Me(e,g),requestAnimationFrame(()=>{Me(t,{top:g}),requestAnimationFrame(()=>{Me(e,0),Me(x,!1)})})}),{deviation:e}},pt(Bt,oo,sr,Tn,Fn,ca)),Zw=Ze(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),pt(ha,Vw,zn,nf,Zd,Kw,Bw,ga,ef,Fn,Qd)),of=Ze(([{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:p,initialTopMostItemIndex:h,scrolledToInitialItem:x},y,m,g,{listState:b,topItemsIndexes:S,...k},{scrollToIndex:T},C,{topItemCount:E},{groupCounts:j},A])=>(me(k.rangeChanged,A.scrollSeekRangeChanged),me(U(A.windowViewportRect,ue(N=>N.visibleHeight)),y.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:j,initialItemFinalLocationReached:p,initialTopMostItemIndex:h,scrolledToInitialItem:x,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...g,groupIndices:s,itemSize:i,listState:b,scrollToIndex:T,statefulTotalCount:c,trackItemSizes:f,...k,...A,...y,sizes:l,...m}),pt(Tn,to,Bt,qw,Ww,sr,eo,Jw,Yw,Wd,Zw));function Qw(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 Ss=typeof document<"u"?w.useLayoutEffect:w.useEffect;function sf(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=w.createContext({});function l(m,g){m.propsReady&&Me(m.propsReady,!1);for(const b of r){const S=m[t.required[b]];Me(S,g[b])}for(const b of o)if(b in g){const S=m[t.optional[b]];Me(S,g[b])}m.propsReady&&Me(m.propsReady,!0)}function c(m){return s.reduce((g,b)=>(g[b]=S=>{const k=m[t.methods[b]];Me(k,S)},g),{})}function d(m){return i.reduce((g,b)=>(g[b]=mw(m[t.events[b]]),g),{})}const f=w.forwardRef((m,g)=>{const{children:b,...S}=m,[k]=w.useState(()=>hs(xw(e),E=>{l(E,S)})),[T]=w.useState(Nd(d,k));Ss(()=>{for(const E of i)E in S&&nt(T[E],S[E]);return()=>{Object.values(T).map(na)}},[S,T,k]),Ss(()=>{l(k,S)}),w.useImperativeHandle(g,Ed(c(k)));const C=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(C,{...Qw([...r,...o,...i],S),children:b}):b})}),p=m=>{const g=w.useContext(a);return w.useCallback(b=>{Me(g[m],b)},[g,m])},h=m=>{const g=w.useContext(a)[m],b=w.useCallback(S=>nt(g,S),[g]);return w.useSyncExternalStore(b,()=>St(g),()=>St(g))},x=m=>{const g=w.useContext(a)[m],[b,S]=w.useState(Nd(St,g));return Ss(()=>nt(g,k=>{k!==b&&S(Ed(k))}),[g,b]),b},y=w.version.startsWith("18")?h:x;return{Component:f,useEmitter:(m,g)=>{const b=w.useContext(a)[m];Ss(()=>nt(b,g),[g,b])},useEmitterValue:y,usePublisher:p}}const af=w.createContext(void 0),lf=w.createContext(void 0),cf=typeof document<"u"?w.useLayoutEffect:w.useEffect;function xa(e){return"self"in e}function e0(e){return"body"in e}function uf(e,t,n,r=Ir,o,s){const i=w.useRef(null),a=w.useRef(null),l=w.useRef(null),c=w.useCallback(p=>{let h,x,y;const m=p.target;if(e0(m)||xa(m)){const b=xa(m)?m:m.defaultView;y=s?b.scrollX:b.scrollY,h=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,x=s?b.innerWidth:b.innerHeight}else y=s?m.scrollLeft:m.scrollTop,h=s?m.scrollWidth:m.scrollHeight,x=s?m.offsetWidth:m.offsetHeight;const g=()=>{e({scrollHeight:h,scrollTop:Math.max(y,0),viewportHeight:x})};p.suppressFlushSync?g():Js.flushSync(g),a.current!==null&&(y===a.current||y<=0||y===h-x)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);w.useEffect(()=>{const p=o||i.current;return r(o||i.current),c({suppressFlushSync:!0,target:p}),p.addEventListener("scroll",c,{passive:!0}),()=>{r(null),p.removeEventListener("scroll",c)}},[i,c,n,r,o]);function d(p){const h=i.current;if(!h||(s?"offsetWidth"in h&&h.offsetWidth===0:"offsetHeight"in h&&h.offsetHeight===0))return;const x=p.behavior==="smooth";let y,m,g;xa(h)?(m=Math.max($n(h.document.documentElement,s?"width":"height"),s?h.document.documentElement.scrollWidth:h.document.documentElement.scrollHeight),y=s?h.innerWidth:h.innerHeight,g=s?window.scrollX:window.scrollY):(m=h[s?"scrollWidth":"scrollHeight"],y=$n(h,s?"width":"height"),g=h[s?"scrollLeft":"scrollTop"]);const b=m-y;if(p.top=Math.ceil(Math.max(Math.min(b,p.top),0)),Kd(y,m)||p.top===g){e({scrollHeight:m,scrollTop:g,viewportHeight:y}),x&&t(!0);return}x?(a.current=p.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(p={behavior:p.behavior,left:p.top}),h.scrollTo(p)}function f(p){s&&(p={behavior:p.behavior,left:p.top}),i.current.scrollBy(p)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const ya="-webkit-sticky",df="sticky",va=rf(()=>{if(typeof document>"u")return df;const e=document.createElement("div");return e.style.position=ya,e.style.position===ya?ya:df});function ba(e){return e}const t0=Ze(()=>{const e=Y(a=>`Item ${a}`),t=Y(a=>`Group ${a}`),n=Y({}),r=Y(ba),o=Y("div"),s=Y(Ir),i=(a,l=null)=>Dt(U(n,ue(c=>c[a]),ht()),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")}}),n0=Ze(([e,t])=>({...e,...t}),pt(of,t0)),r0=({height:e})=>u.jsx("div",{style:{height:e}}),o0={overflowAnchor:"none",position:va(),zIndex:1},ff={overflowAnchor:"none"},s0={...ff,display:"inline-block",height:"100%"},pf=w.memo(function({showTopList:e=!1}){const t=Ae("listState"),n=rn("sizeRanges"),r=Ae("useWindowScroll"),o=Ae("customScrollParent"),s=rn("windowScrollContainerState"),i=rn("scrollContainerState"),a=o||r?s:i,l=Ae("itemContent"),c=Ae("context"),d=Ae("groupContent"),f=Ae("trackItemSizes"),p=Ae("itemSize"),h=Ae("log"),x=rn("gap"),y=Ae("horizontalDirection"),{callbackRef:m}=bw(n,p,f,e?Ir:a,h,x,o,y,Ae("skipAnimationFrameInResizeObserver")),[g,b]=w.useState(0);wa("deviation",R=>{g!==R&&b(R)});const S=Ae("EmptyPlaceholder"),k=Ae("ScrollSeekPlaceholder")||r0,T=Ae("ListComponent"),C=Ae("ItemComponent"),E=Ae("GroupComponent"),j=Ae("computeItemKey"),A=Ae("isSeeking"),N=Ae("groupIndices").length>0,P=Ae("alignToBottom"),F=Ae("initialItemFinalLocationReached"),$=e?{}:{boxSizing:"border-box",...y?{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},...F?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{...Lt(S,c)}):u.jsx(T,{...Lt(T,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:m,style:$,children:(e?t.topItems:t.items).map(R=>{const z=R.originalIndex,_=j(z+t.firstItemIndex,R.data,c);return A?w.createElement(k,{...Lt(k,c),height:R.size,index:R.index,key:_,type:R.type||"item",...R.type==="group"?{}:{groupIndex:R.groupIndex}}):R.type==="group"?w.createElement(E,{...Lt(E,c),"data-index":z,"data-item-index":R.index,"data-known-size":R.size,key:_,style:o0},d(R.index,c)):w.createElement(C,{...Lt(C,c),...c0(C,R.data),"data-index":z,"data-item-group-index":R.groupIndex,"data-item-index":R.index,"data-known-size":R.size,key:_,style:y?s0:ff},N?l(R.index,R.groupIndex,R.data,c):l(R.index,R.data,c))})})}),i0={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},a0={outline:"none",overflowX:"auto",position:"relative"},Cs=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),l0={position:va(),top:0,width:"100%",zIndex:1};function Lt(e,t){if(typeof e!="string")return{context:t}}function c0(e,t){return{item:typeof e=="string"?void 0:t}}const u0=w.memo(function(){const e=Ae("HeaderComponent"),t=rn("headerHeight"),n=Ae("HeaderFooterTag"),r=rr(w.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Lt(e,o)})}):null}),d0=w.memo(function(){const e=Ae("FooterComponent"),t=rn("footerHeight"),n=Ae("HeaderFooterTag"),r=rr(w.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Lt(e,o)})}):null});function hf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.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:p,scrollerRef:h,scrollToCallback:x}=uf(a,c,l,d,void 0,f);return e("scrollTo",x),e("scrollBy",p),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:h,style:{...f?a0:i0,...o},tabIndex:0,...i,...Lt(l,s),children:r})})}function mf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.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"),p=t("customScrollParent"),h=w.useRef(null),x=t("scrollerRef"),{scrollByCallback:y,scrollerRef:m,scrollToCallback:g}=uf(a,c,l,x,p);return cf(()=>{var b;return m.current=p||((b=h.current)==null?void 0:b.ownerDocument.defaultView),()=>{m.current=null}},[m,p]),e("windowScrollTo",g),e("scrollBy",y),u.jsx(l,{ref:h,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Lt(l,s),children:r})})}const f0=({children:e})=>{const t=w.useContext(af),n=rn("viewportHeight"),r=rn("fixedItemHeight"),o=Ae("alignToBottom"),s=Ae("horizontalDirection"),i=w.useMemo(()=>Id(n,l=>$n(l,s?"width":"height")),[n,s]),a=rr(i,!0,Ae("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Cs(o),children:e})},p0=({children:e})=>{const t=w.useContext(af),n=rn("windowViewportRect"),r=rn("fixedItemHeight"),o=Ae("customScrollParent"),s=Rd(n,o,Ae("skipAnimationFrameInResizeObserver")),i=Ae("alignToBottom");return w.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:s,style:Cs(i),children:e})},h0=({children:e})=>{const t=Ae("TopItemListComponent")||"div",n=Ae("headerHeight"),r={...l0,marginTop:`${n}px`},o=Ae("context");return u.jsx(t,{style:r,...Lt(t,o),children:e})},m0=w.memo(function(e){const t=Ae("useWindowScroll"),n=Ae("topItemsIndexes").length>0,r=Ae("customScrollParent"),o=Ae("context");return u.jsxs(r||t?y0:x0,{...e,context:o,children:[n&&u.jsx(h0,{children:u.jsx(pf,{showTopList:!0})}),u.jsxs(r||t?p0:f0,{children:[u.jsx(u0,{}),u.jsx(pf,{}),u.jsx(d0,{})]})]})}),{Component:g0,useEmitter:wa,useEmitterValue:Ae,usePublisher:rn}=sf(n0,{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"}},m0),x0=hf({useEmitter:wa,useEmitterValue:Ae,usePublisher:rn}),y0=mf({useEmitter:wa,useEmitterValue:Ae,usePublisher:rn}),v0=g0;pt(of,Ze(()=>{const e=Y(c=>u.jsxs("td",{children:["Item $",c]})),t=Y(null),n=Y(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=Y(null),o=Y(null),s=Y({}),i=Y(ba),a=Y(Ir),l=(c,d=null)=>Dt(U(s,ue(f=>f[c]),ht()),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")}})),va();const gf={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},b0={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:xf,floor:Ts,max:so,min:Sa,round:yf}=Math;function vf(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{...b0,items:e}}function ks(e,t){return e&&e.width===t.width&&e.height===t.height}function S0(e,t){return e&&e.column===t.column&&e.row===t.row}const C0=Ze(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:f},p,h,{didMount:x,propsReady:y},{customScrollParent:m,useWindowScroll:g,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k},T])=>{const C=Y(0),E=Y(0),j=Y(gf),A=Y({height:0,width:0}),N=Y({height:0,width:0}),P=Ve(),F=Ve(),$=Y(0),R=Y(null),z=Y({column:0,row:0}),_=Ve(),B=Ve(),L=Y(!1),M=Y(0),J=Y(!0),X=Y(!1),pe=Y(!1);nt(U(x,De(M),Ee(([D,H])=>!!H)),()=>{Me(J,!1)}),nt(U(It(x,J,N,A,M,X),Ee(([D,H,te,ae,,ne])=>D&&!H&&te.height!==0&&ae.height!==0&&!ne)),([,,,,D])=>{Me(X,!0),fa(1,()=>{Me(P,D)}),fn(U(c),()=>{Me(t,[0,0]),Me(J,!0)})}),me(U(B,Ee(D=>D!=null&&D.scrollTop>0),Sn(0)),E),nt(U(x,De(B),Ee(([,D])=>D!=null)),([,D])=>{D&&(Me(A,D.viewport),Me(N,D.item),Me(z,D.gap),D.scrollTop>0&&(Me(L,!0),fn(U(c,nr(1)),H=>{Me(L,!1)}),Me(l,{top:D.scrollTop})))}),me(U(A,ue(({height:D})=>D)),f),me(U(It(Te(A,ks),Te(N,ks),Te(z,(D,H)=>D&&D.column===H.column&&D.row===H.row),Te(c)),ue(([D,H,te,ae])=>({gap:te,item:H,scrollTop:ae,viewport:D}))),_),me(U(It(Te(C),r,Te(z,S0),Te(N,ks),Te(A,ks),Te(R),Te(E),Te(L),Te(J),Te(M)),Ee(([,,,,,,,D])=>!D),ue(([D,[H,te],ae,ne,Le,Q,ie,,ke,Re])=>{const{column:Ke,row:ze}=ae,{height:$e,width:qe}=ne,{width:Ge}=Le;if(ie===0&&(D===0||Ge===0))return gf;if(qe===0){const re=pa(Re,D),be=re+Math.max(ie-1,0);return w0(vf(re,be,Q))}const Qe=bf(Ge,qe,Ke);let Je,rt;ke?H===0&&te===0&&ie>0?(Je=0,rt=ie-1):(Je=Qe*Ts((H+ze)/($e+ze)),rt=Qe*xf((te+ze)/($e+ze))-1,rt=Sa(D-1,so(rt,Qe-1)),Je=Sa(rt,so(0,Je))):(Je=0,rt=-1);const At=vf(Je,rt,Q),{bottom:ut,top:it}=wf(Le,ae,ne,At),Ct=xf(D/Qe),vt=Ct*$e+(Ct-1)*ze-ut;return{bottom:ut,itemHeight:$e,items:At,itemWidth:qe,offsetBottom:vt,offsetTop:it,top:it}})),j),me(U(R,Ee(D=>D!==null),ue(D=>D.length)),C),me(U(It(A,N,j,z),Ee(([D,H,{items:te}])=>te.length>0&&H.height!==0&&D.height!==0),ue(([D,H,{items:te},ae])=>{const{bottom:ne,top:Le}=wf(D,ae,H,te);return[Le,ne]}),ht(Zr)),t);const Ne=Y(!1);me(U(c,De(Ne),ue(([D,H])=>H||D!==0)),Ne);const je=Xt(U(It(j,C),Ee(([{items:D}])=>D.length>0),De(Ne),Ee(([[D,H],te])=>{const ae=D.items[D.items.length-1].index===H-1;return(te||D.bottom>0&&D.itemHeight>0&&D.offsetBottom===0&&D.items.length===H)&&ae}),ue(([[,D]])=>D-1),ht())),G=Xt(U(Te(j),Ee(({items:D})=>D.length>0&&D[0].index===0),Sn(0),ht())),ee=Xt(U(Te(j),De(L),Ee(([{items:D},H])=>D.length>0&&!H),ue(([{items:D}])=>({endIndex:D[D.length-1].index,startIndex:D[0].index})),ht($d),_n(0)));me(ee,h.scrollSeekRangeChanged),me(U(P,De(A,N,C,z),ue(([D,H,te,ae,ne])=>{const Le=Vd(D),{align:Q,behavior:ie,offset:ke}=Le;let Re=Le.index;Re==="LAST"&&(Re=ae-1),Re=so(0,Re,Sa(ae-1,Re));let Ke=Ca(H,ne,te,Re);return Q==="end"?Ke=yf(Ke-H.height+te.height):Q==="center"&&(Ke=yf(Ke-H.height/2+te.height/2)),ke&&(Ke+=ke),{behavior:ie,top:Ke}})),l);const W=Dt(U(j,ue(D=>D.offsetBottom+D.bottom)),0);return me(U(k,ue(D=>({height:D.visibleHeight,width:D.visibleWidth}))),A),{customScrollParent:m,data:R,deviation:$,footerHeight:o,gap:z,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:N,overscan:n,restoreStateFrom:B,scrollBy:i,scrollContainerState:a,scrollHeight:F,scrollTo:l,scrollToIndex:P,scrollTop:c,smoothScrollTargetReached:d,totalCount:C,useWindowScroll:g,viewportDimensions:A,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k,...h,gridState:j,horizontalDirection:pe,initialTopMostItemIndex:M,totalListHeight:W,...p,endReached:je,propsReady:y,rangeChanged:ee,startReached:G,stateChanged:_,stateRestoreInProgress:L,...T}},pt(ha,Bt,oo,nf,zn,ga,Fn));function bf(e,t,n){return so(1,Ts((e+n)/(Ts(t)+n)))}function wf(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Ca(e,t,n,r[0].index);return{bottom:Ca(e,t,n,r[r.length-1].index)+o,top:s}}function Ca(e,t,n,r){const o=bf(e.width,n.width,t.column),s=Ts(r/o),i=s*n.height+so(0,s-1)*t.row;return i>0?i+t.row:i}const T0=Ze(()=>{const e=Y(f=>`Item ${f}`),t=Y({}),n=Y(null),r=Y("virtuoso-grid-item"),o=Y("virtuoso-grid-list"),s=Y(ba),i=Y("div"),a=Y(Ir),l=(f,p=null)=>Dt(U(t,ue(h=>h[f]),ht()),p),c=Y(!1),d=Y(!1);return me(Te(d),c),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),k0=Ze(([e,t])=>({...e,...t}),pt(C0,T0)),E0=w.memo(function(){const e=xt("gridState"),t=xt("listClassName"),n=xt("itemClassName"),r=xt("itemContent"),o=xt("computeItemKey"),s=xt("isSeeking"),i=on("scrollHeight"),a=xt("ItemComponent"),l=xt("ListComponent"),c=xt("ScrollSeekPlaceholder"),d=xt("context"),f=on("itemDimensions"),p=on("gap"),h=xt("log"),x=xt("stateRestoreInProgress"),y=on("reportReadyState"),m=rr(w.useMemo(()=>g=>{const b=g.parentElement.parentElement.scrollHeight;i(b);const S=g.firstChild;if(S){const{height:k,width:T}=S.getBoundingClientRect();f({height:k,width:T})}p({column:Cf("column-gap",getComputedStyle(g).columnGap,h),row:Cf("row-gap",getComputedStyle(g).rowGap,h)})},[i,f,p,h]),!0,!1);return cf(()=>{e.itemHeight>0&&e.itemWidth>0&&y(!0)},[e]),x?null:u.jsx(l,{className:t,ref:m,...Lt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(g=>{const b=o(g.index,g.data,d);return s?u.jsx(c,{...Lt(c,d),height:e.itemHeight,index:g.index,width:e.itemWidth},b):w.createElement(a,{...Lt(a,d),className:n,"data-index":g.index,key:b},r(g.index,g.data,d))})})}),I0=w.memo(function(){const e=xt("HeaderComponent"),t=on("headerHeight"),n=xt("headerFooterTag"),r=rr(w.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,!1),o=xt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Lt(e,o)})}):null}),N0=w.memo(function(){const e=xt("FooterComponent"),t=on("footerHeight"),n=xt("headerFooterTag"),r=rr(w.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,!1),o=xt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Lt(e,o)})}):null}),A0=({children:e})=>{const t=w.useContext(lf),n=on("itemDimensions"),r=on("viewportDimensions"),o=rr(w.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return w.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),u.jsx("div",{ref:o,style:Cs(!1),children:e})},j0=({children:e})=>{const t=w.useContext(lf),n=on("windowViewportRect"),r=on("itemDimensions"),o=xt("customScrollParent"),s=Rd(n,o,!1);return w.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),u.jsx("div",{ref:s,style:Cs(!1),children:e})},_0=w.memo(function({...e}){const t=xt("useWindowScroll"),n=xt("customScrollParent"),r=n||t?P0:R0,o=n||t?j0:A0,s=xt("context");return u.jsx(r,{...e,...Lt(r,s),children:u.jsxs(o,{children:[u.jsx(I0,{}),u.jsx(E0,{}),u.jsx(N0,{})]})})}),{useEmitter:Sf,useEmitterValue:xt,usePublisher:on}=sf(k0,{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"}},_0),R0=hf({useEmitter:Sf,useEmitterValue:xt,usePublisher:on}),P0=mf({useEmitter:Sf,useEmitterValue:xt,usePublisher:on});function Cf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Vt.WARN),t==="normal"?0:parseInt(t??"0",10)}const O0=xo.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 Tf({className:e,variant:t,...n}){return u.jsx("div",{className:Z(O0({variant:t}),e),...n})}const io=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:Z("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));io.displayName="Card";const ao=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:Z("flex flex-col space-y-1.5 p-6",e),...t}));ao.displayName="CardHeader";const lo=v.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:Z("text-2xl font-semibold leading-none tracking-tight",e),...t}));lo.displayName="CardTitle";const kf=v.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:Z("text-sm text-muted-foreground",e),...t}));kf.displayName="CardDescription";const co=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:Z("p-6 pt-0",e),...t}));co.displayName="CardContent";const Ef=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:Z("flex items-center p-6 pt-0",e),...t}));Ef.displayName="CardFooter";const M0=1,D0=1e6;let Ta=0;function L0(){return Ta=(Ta+1)%Number.MAX_SAFE_INTEGER,Ta.toString()}const ka=new Map,If=e=>{if(ka.has(e))return;const t=setTimeout(()=>{ka.delete(e),uo({type:"REMOVE_TOAST",toastId:e})},D0);ka.set(e,t)},F0=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,M0)};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?If(n):e.toasts.forEach(r=>{If(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)}}},Es=[];let Is={toasts:[]};function uo(e){Is=F0(Is,e),Es.forEach(t=>{t(Is)})}function $0({...e}){const t=L0(),n=o=>uo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>uo({type:"DISMISS_TOAST",toastId:t});return uo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Ea(){const[e,t]=v.useState(Is);return v.useEffect(()=>(Es.push(t),()=>{const n=Es.indexOf(t);n>-1&&Es.splice(n,1)}),[e]),{...e,toast:$0,dismiss:n=>uo({type:"DISMISS_TOAST",toastId:n})}}async function Nf(e,t){return await Qt(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function Af(e,t){return await(await Nf(`/files/${e}/view`,t)).text()}async function z0(e,t){const n=await Nf(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Qt(`/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 B0(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Qt("/files",{params:r})}function Ia(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 jf(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function fo(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(fo).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(jf(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=fo(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 po(e){if(typeof e=="string")return e;if(jf(e))return"";try{const t=fo(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function H0(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function U0(e){const t=po(e);return typeof e=="string"&&H0(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function Ns(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Ia(t);if(n!==null)return Ns(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?Ns(e.content):e}var As="Dialog",[_f,vT]=In(As),[W0,hn]=_f(As),Rf=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]=xr({prop:r,defaultProp:o??!1,onChange:s,caller:As});return u.jsx(W0,{scope:t,triggerRef:a,contentRef:l,contentId:Nn(),titleId:Nn(),descriptionId:Nn(),open:c,onOpenChange:d,onOpenToggle:v.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Rf.displayName=As;var Pf="DialogTrigger",Of=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Pf,n),s=We(t,o.triggerRef);return u.jsx(_e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":ja(o.open),...r,ref:s,onClick:fe(e.onClick,o.onOpenToggle)})});Of.displayName=Pf;var Na="DialogPortal",[V0,Mf]=_f(Na,{forceMount:void 0}),Df=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=hn(Na,t);return u.jsx(V0,{scope:t,forceMount:n,children:v.Children.map(r,i=>u.jsx(tn,{present:n||s.open,children:u.jsx(Jo,{asChild:!0,container:o,children:i})}))})};Df.displayName=Na;var js="DialogOverlay",Lf=v.forwardRef((e,t)=>{const n=Mf(js,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(js,e.__scopeDialog);return s.modal?u.jsx(tn,{present:r||s.open,children:u.jsx(q0,{...o,ref:t})}):null});Lf.displayName=js;var K0=Yn.createSlot("DialogOverlay.RemoveScroll"),q0=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(js,n);return u.jsx(is,{as:K0,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(_e.div,{"data-state":ja(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ir="DialogContent",Ff=v.forwardRef((e,t)=>{const n=Mf(ir,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(ir,e.__scopeDialog);return u.jsx(tn,{present:r||s.open,children:s.modal?u.jsx(G0,{...o,ref:t}):u.jsx(Y0,{...o,ref:t})})});Ff.displayName=ir;var G0=v.forwardRef((e,t)=>{const n=hn(ir,e.__scopeDialog),r=v.useRef(null),o=We(t,n.contentRef,r);return v.useEffect(()=>{const s=r.current;if(s)return Bi(s)},[]),u.jsx($f,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:fe(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:fe(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:fe(e.onFocusOutside,s=>s.preventDefault())})}),Y0=v.forwardRef((e,t)=>{const n=hn(ir,e.__scopeDialog),r=v.useRef(!1),o=v.useRef(!1);return u.jsx($f,{...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()}})}),$f=v.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=hn(ir,n),l=v.useRef(null),c=We(t,l);return Si(),u.jsxs(u.Fragment,{children:[u.jsx($o,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(Fo,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":ja(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(X0,{titleId:a.titleId}),u.jsx(Z0,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Aa="DialogTitle",zf=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Aa,n);return u.jsx(_e.h2,{id:o.titleId,...r,ref:t})});zf.displayName=Aa;var Bf="DialogDescription",Hf=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Bf,n);return u.jsx(_e.p,{id:o.descriptionId,...r,ref:t})});Hf.displayName=Bf;var Uf="DialogClose",Wf=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Uf,n);return u.jsx(_e.button,{type:"button",...r,ref:t,onClick:fe(e.onClick,()=>o.onOpenChange(!1))})});Wf.displayName=Uf;function ja(e){return e?"open":"closed"}var Vf="DialogTitleWarning",[bT,Kf]=tx(Vf,{contentName:ir,titleName:Aa,docsSlug:"dialog"}),X0=({titleId:e})=>{const t=Kf(Vf),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
|
|
|
@@ -99,8 +99,8 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
99
99
|
`+f}!l&&!f.trim()&&(l=!0),r+=p+`
|
|
100
100
|
`,t=t.substring(p.length+1),d=f.slice(i)}}g.loose||(c?g.loose=!0:/\n *\n *$/.test(r)&&(c=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(h),o&&(s=o[0]!=="[ ] ",h=h.replace(/^\[[ xX]\] +/,""))),g.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:h}),g.raw+=r}g.items[g.items.length-1].raw=r.trimRight(),g.items[g.items.length-1].text=h.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]):Ft(n[0]);r.type="paragraph",r.text=o,r.tokens=this.lexer.inline(o)}return r}}def(t){const n=this.rules.block.def.exec(t);if(n){const r=n[1].toLowerCase().replace(/\s+/g," "),o=n[2]?n[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline._escapes,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:o,title:s}}}table(t){const n=this.rules.block.table.exec(t);if(n){const r={type:"table",header:ip(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]=ip(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:Ft(n[1])}}tag(t){const n=this.rules.inline.tag.exec(t);if(n)return!this.lexer.state.inLink&&/^<a /i.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):Ft(n[0]):n[0]}}link(t){const n=this.rules.inline.link.exec(t);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const i=Ds(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=gS(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)),lp(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 lp(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 p=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const x=p.slice(1,-1);return{type:"em",raw:p,text:x,tokens:this.lexer.inlineTokens(x)}}const h=p.slice(2,-2);return{type:"strong",raw:p,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=Ft(r,!0),{type:"codespan",raw:n[0],text:r}}}br(t){const n=this.rules.inline.br.exec(t);if(n)return{type:"br",raw:n[0]}}del(t){const n=this.rules.inline.del.exec(t);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(t,n){const r=this.rules.inline.autolink.exec(t);if(r){let o,s;return r[2]==="@"?(o=Ft(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Ft(r[1]),s=o),{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}url(t,n){let r;if(r=this.rules.inline.url.exec(t)){let o,s;if(r[2]==="@")o=Ft(this.options.mangle?n(r[0]):r[0]),s="mailto:"+o;else{let i;do i=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0];while(i!==r[0]);o=Ft(r[0]),r[1]==="www."?s="http://"+r[0]:s=r[0]}return{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}inlineText(t,n){const r=this.rules.inline.text.exec(t);if(r){let o;return this.lexer.state.inRawBlock?o=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):Ft(r[0]):r[0]:o=Ft(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const
|
|
103
|
-
]`).replace("lheading",
|
|
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:Ft(n[1])}}tag(t){const n=this.rules.inline.tag.exec(t);if(n)return!this.lexer.state.inLink&&/^<a /i.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):Ft(n[0]):n[0]}}link(t){const n=this.rules.inline.link.exec(t);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const i=Ds(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=gS(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)),lp(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 lp(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 p=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const x=p.slice(1,-1);return{type:"em",raw:p,text:x,tokens:this.lexer.inlineTokens(x)}}const h=p.slice(2,-2);return{type:"strong",raw:p,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=Ft(r,!0),{type:"codespan",raw:n[0],text:r}}}br(t){const n=this.rules.inline.br.exec(t);if(n)return{type:"br",raw:n[0]}}del(t){const n=this.rules.inline.del.exec(t);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(t,n){const r=this.rules.inline.autolink.exec(t);if(r){let o,s;return r[2]==="@"?(o=Ft(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Ft(r[1]),s=o),{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}url(t,n){let r;if(r=this.rules.inline.url.exec(t)){let o,s;if(r[2]==="@")o=Ft(this.options.mangle?n(r[0]):r[0]),s="mailto:"+o;else{let i;do i=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0];while(i!==r[0]);o=Ft(r[0]),r[1]==="www."?s="http://"+r[0]:s=r[0]}return{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}inlineText(t,n){const r=this.rules.inline.text.exec(t);if(r){let o;return this.lexer.state.inRawBlock?o=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):Ft(r[0]):r[0]:o=Ft(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const ve={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:Ms,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};ve._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,ve._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,ve.def=ct(ve.def).replace("label",ve._label).replace("title",ve._title).getRegex(),ve.bullet=/(?:[*+-]|\d{1,9}[.)])/,ve.listItemStart=ct(/^( *)(bull) */).replace("bull",ve.bullet).getRegex(),ve.list=ct(ve.list).replace(/bull/g,ve.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ve.def.source+")").getRegex(),ve._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ve._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,ve.html=ct(ve.html,"i").replace("comment",ve._comment).replace("tag",ve._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ve.paragraph=ct(ve._paragraph).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ve._tag).getRegex(),ve.blockquote=ct(ve.blockquote).replace("paragraph",ve.paragraph).getRegex(),ve.normal={...ve},ve.gfm={...ve.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},ve.gfm.table=ct(ve.gfm.table).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ve._tag).getRegex(),ve.gfm.paragraph=ct(ve._paragraph).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",ve.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ve._tag).getRegex(),ve.pedantic={...ve.normal,html:ct(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ve._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ms,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ct(ve.normal._paragraph).replace("hr",ve.hr).replace("heading",` *#{1,6} *[^
|
|
103
|
+
]`).replace("lheading",ve.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const de={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ms,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:Ms,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};de._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",de.punctuation=ct(de.punctuation).replace(/punctuation/g,de._punctuation).getRegex(),de.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,de.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,de._comment=ct(ve._comment).replace("(?:-->|$)","-->").getRegex(),de.emStrong.lDelim=ct(de.emStrong.lDelim).replace(/punct/g,de._punctuation).getRegex(),de.emStrong.rDelimAst=ct(de.emStrong.rDelimAst,"g").replace(/punct/g,de._punctuation).getRegex(),de.emStrong.rDelimUnd=ct(de.emStrong.rDelimUnd,"g").replace(/punct/g,de._punctuation).getRegex(),de._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,de._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,de._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,de.autolink=ct(de.autolink).replace("scheme",de._scheme).replace("email",de._email).getRegex(),de._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,de.tag=ct(de.tag).replace("comment",de._comment).replace("attribute",de._attribute).getRegex(),de._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,de._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,de._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,de.link=ct(de.link).replace("label",de._label).replace("href",de._href).replace("title",de._title).getRegex(),de.reflink=ct(de.reflink).replace("label",de._label).replace("ref",ve._label).getRegex(),de.nolink=ct(de.nolink).replace("ref",ve._label).getRegex(),de.reflinkSearch=ct(de.reflinkSearch,"g").replace("reflink",de.reflink).replace("nolink",de.nolink).getRegex(),de.normal={...de},de.pedantic={...de.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:ct(/^!?\[(label)\]\((.*?)\)/).replace("label",de._label).getRegex(),reflink:ct(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",de._label).getRegex()},de.gfm={...de.normal,escape:ct(de.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},de.gfm.url=ct(de.gfm.url,"i").replace("email",de.gfm._extended_email).getRegex(),de.breaks={...de.gfm,br:ct(de.br).replace("{2,}","*").getRegex(),text:ct(de.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function vS(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 cp(e){let t="",n,r;const o=e.length;for(n=0;n<o;n++)r=e.charCodeAt(n),Math.random()>.5&&(r="x"+r.toString(16)),t+="&#"+r+";";return t}class Bn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||lr,this.options.tokenizer=this.options.tokenizer||new _a,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:ve.normal,inline:de.normal};this.options.pedantic?(n.block=ve.pedantic,n.inline=de.pedantic):this.options.gfm&&(n.block=ve.gfm,this.options.breaks?n.inline=de.breaks:n.inline=de.gfm),this.tokenizer.rules=n}static get rules(){return{block:ve,inline:de}}static lex(t,n){return new Bn(n).lex(t)}static lexInline(t,n){return new Bn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
|
|
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+=`
|
|
@@ -132,6 +132,6 @@ ${t}</tr>
|
|
|
132
132
|
`}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
|
|
133
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=sp(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=sp(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 up{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 dp{constructor(){this.seen={}}serialize(t){return t.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(t,n){let r=t,o=0;if(this.seen.hasOwnProperty(r)){o=this.seen[t];do o++,r=t+"-"+o;while(this.seen.hasOwnProperty(r))}return n||(this.seen[t]=o,this.seen[r]=0),r}slug(t,n={}){const r=this.serialize(t);return this.getNextSafeSlug(r,n.dryrun)}}class Hn{constructor(t){this.options=t||lr,this.options.renderer=this.options.renderer||new Ra,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new up,this.slugger=new dp}static parse(t,n){return new Hn(n).parse(t)}static parseInline(t,n){return new Hn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,f,p,h,x,y,m,g,b,S,k,T,C;const E=t.length;for(o=0;o<E;o++){if(h=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[h.type]&&(C=this.options.extensions.renderers[h.type].call({parser:this},h),C!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(h.type))){r+=C||"";continue}switch(h.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(h.tokens),h.depth,op(this.parseInline(h.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(h.text,h.lang,h.escaped);continue}case"table":{for(f="",d="",a=h.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(h.header[s].tokens),{header:!0,align:h.align[s]});for(f+=this.renderer.tablerow(d),p="",a=h.rows.length,s=0;s<a;s++){for(c=h.rows[s],d="",l=c.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(c[i].tokens),{header:!1,align:h.align[i]});p+=this.renderer.tablerow(d)}r+=this.renderer.table(f,p);continue}case"blockquote":{p=this.parse(h.tokens),r+=this.renderer.blockquote(p);continue}case"list":{for(x=h.ordered,y=h.start,m=h.loose,a=h.items.length,p="",s=0;s<a;s++)b=h.items[s],S=b.checked,k=b.task,g="",b.task&&(T=this.renderer.checkbox(S),m?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=T+" "+b.tokens[0].text,b.tokens[0].tokens&&b.tokens[0].tokens.length>0&&b.tokens[0].tokens[0].type==="text"&&(b.tokens[0].tokens[0].text=T+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:T}):g+=T),g+=this.parse(b.tokens,m),p+=this.renderer.listitem(g,k,S);r+=this.renderer.list(p,x,y);continue}case"html":{r+=this.renderer.html(h.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(h.tokens));continue}case"text":{for(p=h.tokens?this.parseInline(h.tokens):h.text;o+1<E&&t[o+1].type==="text";)h=t[++o],p+=`
|
|
134
134
|
`+(h.tokens?this.parseInline(h.tokens):h.text);r+=n?this.renderer.paragraph(p):p;continue}default:{const j='Token with "'+h.type+'" type was not found.';if(this.options.silent){console.error(j);return}else throw new Error(j)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Ls{constructor(t){this.options=t||lr}preprocess(t){return t}postprocess(t){return t}}Kh(Ls,"passThroughHooks",new Set(["preprocess","postprocess"]));function bS(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>"+Ft(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function fp(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...
|
|
136
|
-
`)):r=t(e),r||""}function TS(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function hp(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 kS({className:e}){const[t,n]=w.useState(0);return w.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:Z("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const Pa=w.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:f=!0,customStyles:p={},onEdit:h,onRegenerate:x,onCancelEdit:y,onCopy:m,activeInterrupt:g,disableInterruptActions:b=!1,onInterruptActionStart:S,onInterruptActionEnd:k,checkpointCandidates:T=[],activeCheckpointId:C=null,onSelectCheckpoint:E,defaultCheckpointId:j=null,messageParentCheckpointId:A=null}){const[N,P]=w.useState(!1),[F,$]=w.useState("preview"),[R,z]=w.useState(!1),{currentThreadId:_}=Oo(),{respondToInterrupt:B}=Mo(),L=l==="phone"||l==="half-screen",M=t.role,J=M==="tool",X=w.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),pe=!!X,
|
|
137
|
-
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[je[ve]?u.jsx(se.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[ft,je[ve]?" (processing)":""]})]},ve)}if(V.type==="interrupt"){const ge=V,ft=Fs((ge==null?void 0:ge.id)??(ge==null?void 0:ge.interrupt_id)),mt=!!(Ce&&ft&&ft===Ce),kt=mt?Re??(ge==null?void 0:ge.value):ge==null?void 0:ge.value,Me=ft?{...ge,id:ft,interrupt_id:ft}:ge;return u.jsx(ES,{interruptPart:Me,onApprove:rt,onReject:wt,disabled:b,isActive:mt,payload:kt},ve)}return null},[G,je,rt,wt,M,c,d,R,L,Ce,Re,g,b,Q]),it=w.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(se.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),Tt=w.useCallback(()=>{const V=te.trim().length>0||ne.length>0||Fe.length>0||Q.length>0;if(!J&&Fe.length>0&&!r)return it();if(!J&&!V&&!r)return null;if(J)return u.jsx(AS,{message:t,viewMode:F},t.id);if(!J&&!X){const ve=t,ge=u.jsx("div",{className:"space-y-2",children:ve.content.map((ft,mt)=>u.jsx(ut,{part:ft,i:mt},mt))});return r?u.jsxs("div",{"aria-busy":"true",role:"status",children:[ge,u.jsx(kS,{className:H})]}):ge}},[te,ne.length,Fe.length,Q.length,r,J,F,it,H]),yt=w.useMemo(()=>X?"Assistant":TS(t),[X,t]),re=w.useMemo(()=>X?[]:Array.isArray(T)?T:[],[T,X]),Te=w.useMemo(()=>{var V;return re.length?j&&re.some(ve=>ve.id===j)?j:((V=re[0])==null?void 0:V.id)??null:null},[j,re]),Oe=w.useMemo(()=>!re.length||!C?null:re.some(V=>V.id===C)?C:null,[C,re])??Te,ot=M==="user"&&re.length>0&&typeof E=="function",Ne=w.useCallback(V=>{if(!E)return;const ve=(V==null?void 0:V.id)??null,ge=(V==null?void 0:V.parentId)??A??null;E(ve,ge)},[A,E]),ye=w.useMemo(()=>Oe?re.findIndex(V=>V.id===Oe):-1,[Oe,re]),vt=w.useMemo(()=>ye<0?null:re[ye]??null,[ye,re]),jt=w.useCallback(V=>{const ve=[];if(V.step!==null&&ve.push(`Step ${V.step}`),V.source&&ve.push(V.source),!V.createdAt)return ve.length?ve.join(" • "):V.id.slice(0,8);let ge="";try{const ft=new Date(V.createdAt);Number.isNaN(ft.getTime())||(ge=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(ft))}catch{ge=""}return`${ge}`},[]);return J&&!f?null:u.jsxs(u.Fragment,{children:[u.jsx("div",{className:Z(Qe(),p.container),children:u.jsxs("div",{className:Z(Je(),p.content),children:[(i||a||J)&&u.jsxs("div",{className:Z("flex items-center justify-between mb-2 pb-2 border-b border-current/10",L&&"mb-1 pb-1",H,p.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[Ge(),a&&yt&&u.jsx("span",{className:Z("font-medium",L?"text-xs":"text-sm"),children:yt}),J&&u.jsxs(Tf,{variant:"outline",className:Z("text-xs flex items-center gap-1 cursor-pointer select-none",H,"border border-current/40",L&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":F==="expanded",onClick:()=>$(V=>V==="expanded"?"preview":"expanded"),onKeyDown:V=>{(V.key==="Enter"||V.key===" ")&&(V.preventDefault(),$(ve=>ve==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:ae.name??"Tool Output"}),ae.toolCallId&&u.jsx("span",{className:"opacity-70",children:ae.toolCallId.slice(0,8)}),F==="expanded"?u.jsx(se.ChevronUp,{className:"h-3 w-3"}):u.jsx(se.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[ot&&vt&&ye>=0&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:Z("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",ye>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(ye<=0)return;const V=re[ye-1];V&&Ne(V)},"aria-label":"Previous checkpoint",disabled:ye<=0,children:u.jsx(se.ChevronLeft,{className:"h-3 w-3"})}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("span",{className:"whitespace-nowrap",children:[ye+1," / ",re.length]}),u.jsx("span",{className:"text-muted-foreground",children:jt(vt)})]}),u.jsx("button",{type:"button",className:Z("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",ye<re.length-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(ye>=re.length-1)return;const V=re[ye+1];V&&Ne(V)},"aria-label":"Next checkpoint",disabled:ye>=re.length-1,children:u.jsx(se.ChevronRight,{className:"h-3 w-3"})})]}),i&&t.createdAt&&u.jsx("time",{className:Z("text-xs opacity-60",H,L&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&u.jsxs("div",{className:Z("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>Be(),className:Z("h-6 w-6 p-0 hover:bg-foreground/10",H,L&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(se.Copy,{className:Z(N?"text-success":H,L?"h-3 w-3":"h-4 w-4")})})}),M==="user"&&h&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:ze,className:Z("h-6 w-6 p-0 hover:bg-foreground/10",H,L&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(se.Edit,{className:Z(H,L?"h-3 w-3":"h-4 w-4")})}),M==="assistant"&&x&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:qe,className:Z("h-6 w-6 p-0 hover:bg-foreground/10",H,L&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(se.RotateCcw,{className:Z(H,L?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsx("div",{className:"relative",children:Tt()}),J&&F==="expanded"&&(ae.toolCallId||ae.name)&&u.jsxs("div",{className:Z("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",L&&"text-xs"),children:[ae.name&&u.jsxs("div",{children:["Function: ",ae.name]}),ae.toolCallId&&u.jsxs("div",{children:["Call ID: ",ae.toolCallId]})]}),!(i||a||J)&&s&&!o&&u.jsxs("div",{className:Z("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>Be(),className:Z("h-6 w-6 p-0 hover:bg-background/50 text-current",L&&"h-5 w-5"),children:u.jsx(se.Copy,{className:Z(N?"text-success":"text-current",L?"h-3 w-3":"h-4 w-4")})}),M==="user"&&h&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:ze,className:Z("h-6 w-6 p-0 hover:bg-background/50 text-current",L&&"h-5 w-5"),children:u.jsx(se.Edit,{className:Z("text-current",L?"h-3 w-3":"h-4 w-4")})}),M==="assistant"&&x&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:qe,className:Z("h-6 w-6 p-0 hover:bg-background/50 text-current",L&&"h-5 w-5"),children:u.jsx(se.RotateCcw,{className:Z("text-current",L?"h-3 w-3":"h-4 w-4")})})]})]})}),W&&u.jsx(rS,{isOpen:ee,onClose:D,fileId:W.id,fileName:W.name,mimeType:W.mimeType})]})},(e,t)=>{var i,a,l,c,d,f,p,h;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&hp(e.message)===hp(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(x=>e[x]===t[x]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((l=e.customStyles)==null?void 0:l.content)===((c=t.customStyles)==null?void 0:c.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((p=e.customStyles)==null?void 0:p.header)===((h=t.customStyles)==null?void 0:h.header);return o&&s});function mp({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:po(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:po(e)})}function ES({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=po(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(io,{className:Z("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(ao,{className:"pb-3",children:[u.jsx(lo,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(kf,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(co,{className:"pt-0 pb-3",children:a}),u.jsx(Ef,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(tt,{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(tt,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}function IS(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=Ea(),[o,s]=w.useState({}),[i,a]=w.useState(null),[l,c]=w.useState(!1),d=w.useCallback(()=>{c(!1),a(null)},[]),f=w.useCallback(h=>{a(h),c(!0)},[]),p=w.useCallback(async(h,x,y)=>{var m,g;if(!t){h.preventDefault();return}if(o[y]){h.preventDefault();return}try{const b=String(x.url??""),S=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){h.preventDefault();const k=S[1],T=x.name||`file_${k}`,C=x.mimeType||"application/octet-stream";f({id:k,name:T,mimeType:C});return}if(b.startsWith("data:")){h.preventDefault(),s(T=>({...T,[y]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const T=await B0(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??"")===(x.name??""))?!1:typeof x.size=="number"&&typeof E.size=="number"?E.size===x.size:!0);if(!(C!=null&&C.id))throw new Error(`File "${x.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:x.name||C.filename||`file_${C.id}`,mimeType:x.mimeType||C.mime_type||"application/octet-stream"}),(m=k.update)==null||m.call(k,{id:k.id,title:"Success",description:`Opened ${x.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,[y]:!1}))}}}catch(b){console.error("File click error:",b),s(S=>({...S,[y]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:p,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function NS({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:Z("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(ho,{content:e,allowHtml:!1}):u.jsxs("pre",{className:Z("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(tt,{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(se.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(se.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function AS({message:e,viewMode:t}){const r=pp(e).name||"tool",o=c=>{if(c==null)return null;const d=typeof c=="string"?Ia(c)??c:c;if(d&&typeof d=="object")return u.jsx(mp,{data:d});const f=typeof d=="string"?d:(()=>{try{return po(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}=U0(c);return f?u.jsx(ho,{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(se.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=Ns(d);return s(f)}const a=fo(i),l=Ns(a);return s(l)}const gp=(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},Oa=w.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:p,emptyMessage:h,followNewMessages:x=!0,isNavigatingCheckpoint:y=!1,onScrollAway:m,onAtBottom:g,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:T,showToolMessages:C=!0,checkpointMetaById:E,checkpointIndexByKey:j,activeCheckpointId:A,onSelectCheckpoint:N,timelineCheckpoints:P},F)=>{const $=w.useRef(null),R=w.useRef(null),z=w.useRef(!1),[_,B]=w.useState(!0),L=w.useMemo(()=>b?e.some(Q=>"type"in Q&&Q.type==="default_message"?!1:Array.isArray(Q==null?void 0:Q.content)&&Q.content.some(ie=>ie&&ie.type==="interrupt"&&(ie.id??ie.interrupt_id)===b.id)):!1,[b,e]),M=w.useMemo(()=>{if(!b||L)return null;const Q=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let ie;const Ce=b.value;if(Ce&&typeof Ce=="object"&&!Array.isArray(Ce)){const Re=Ce.title;typeof Re=="string"&&Re.trim()&&(ie=Re.trim())}return{id:`interrupt-${Q}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:Q,value:Ce,title:ie}]}},[b,L]),J=w.useMemo(()=>M?[...e,M]:e,[e,M]),X=w.useMemo(()=>C?J:J.filter(Q=>(Q==null?void 0:Q.role)!=="tool"),[J,C]),pe=w.useMemo(()=>{const Q=new Set,ie=[];for(let Ce=X.length-1;Ce>=0;Ce--){const Re=X[Ce];if(!Re)continue;if("type"in Re&&Re.type==="default_message"){ie.push(Re);continue}const Ke=Re,Be=jS(Ke);Q.has(Be)||(Q.add(Be),ie.push(Ke))}return ie.reverse()},[X]),Ie=w.useCallback(Q=>{B(Q),m&&m(!Q),g&&g(Q)},[m,g]),je=w.useMemo(()=>{if(a)return async()=>{if(!z.current){z.current=!0;try{await a()}finally{z.current=!1}}}},[a]),G=w.useMemo(()=>!x||y?!1:_?"auto":!1,[_,x,y]),ee=w.useMemo(()=>P??[],[P]),W=A??(ee.length?ee[ee.length-1].id:null),D=ee.length>0,H=w.useMemo(()=>{if(typeof h!="string")return null;const Q=h.trim();return Q?{id:"default-message",role:"assistant",type:"default_message",content:Q,createdAt:new Date().toISOString()}:null},[h]),te=D?u.jsxs("div",{className:"hidden w-48 flex-shrink-0 flex-col border-r border-border/40 pr-4 md:flex",children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-5 pb-5 pr-1",children:[u.jsxs("div",{className:"absolute left-0 right-0 top-1 flex items-center justify-between px-2 pb-3 text-xs 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(se.Info,{className:"h-3.5 w-3.5 text-muted-foreground cursor-help"}),u.jsx("div",{className:"pointer-events-auto fixed hidden w-56 rounded-md border bg-background p-3 text-[11px] font-normal text-muted-foreground shadow-lg group-hover:block whitespace-normal leading-relaxed",style:{zIndex:9999},children:'Shows user inputs and the latest loop checkpoint. Click a dot to jump the chat to that point. Click on the "Latest" button to return to the most recent messages.'})]})]}),u.jsx("div",{className:"pointer-events-none absolute left-5 top-0 bottom-0 w-px bg-border/50"}),u.jsx("div",{className:"flex flex-col gap-4",children:ee.map(Q=>{const ie=W===Q.id;return u.jsxs("button",{type:"button",disabled:!N,onClick:()=>N==null?void 0:N(Q.id),className:`relative flex items-start gap-3 text-left text-xs transition ${ie?"text-primary":"text-muted-foreground"} ${N?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-4 w-4 items-center justify-center rounded-full border ${ie?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${ie?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium",children:Q.label||"User input"}),u.jsxs("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground/70",children:[Q.step!==null?`STEP ${Q.step}`:"STEP —",Q.next?` - ${Q.next}`:""]})]})]},Q.id)})})]}),N&&u.jsx("button",{type:"button",onClick:()=>N==null?void 0:N(null),className:"mt-auto rounded-md border border-border/70 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]}):null,ae=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),ne=()=>H?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Pa,{message:H,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:h??"No messages yet. Start a conversation!"}),Fe=pe.length>0;return w.useImperativeHandle(F,()=>({scrollToLatest:()=>{var Q,ie;if($.current&&pe.length>0){const Ce=pe.length-1;(ie=(Q=$.current).scrollToIndex)==null||ie.call(Q,{index:Ce,align:"end",behavior:"auto"})}else R.current&&(R.current.scrollTop=R.current.scrollHeight)},scrollToTop:()=>{var Q,ie;$.current&&pe.length>0?(ie=(Q=$.current).scrollToIndex)==null||ie.call(Q,{index:0,align:"start",behavior:"auto"}):R.current&&(R.current.scrollTop=0)}}),[pe]),u.jsxs("div",{className:ae,style:p,children:[te,u.jsx("div",{className:"relative flex-1 min-h-0",children:Fe?u.jsx(v0,{ref:Q=>{$.current=Q},scrollerRef:Q=>{R.current=Q instanceof HTMLDivElement?Q:null},data:pe,followOutput:G,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{je&&je()},atBottomStateChange:Ie,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(Q,ie)=>gp(ie,Q),itemContent:(Q,ie)=>{var rt;const Ce=gp(ie,Q),Re="type"in ie&&ie.type==="default_message";let Ke=[],Be=null,ze={},qe={},Ge=null,Qe=null;if(!Re){const wt=ie,ut=wt.checkpointId??null;ze=wt.additionalKwargs??{},qe=wt.responseMetadata??{};const it=ut&&E?E.get(ut)??null:null;Ge=typeof ze.step=="number"?ze.step:typeof qe.step=="number"?qe.step:(it==null?void 0:it.step)??null;const Tt=typeof ze.source=="string"?ze.source:typeof qe.source=="string"?qe.source:(it==null?void 0:it.source)??null;Qe=Tt?String(Tt):null;const yt=Ge!==null&&Qe?`${Ge}:${Qe}`:null;yt&&(j!=null&&j.has(yt))?Ke=j.get(yt)??[]:ut&&it&&(Ke=[it]),Be=ut??((rt=Ke[0])==null?void 0:rt.id)??null}const Je=(()=>{if(typeof ze.parentCheckpointId=="string")return ze.parentCheckpointId;if(typeof qe.parentCheckpointId=="string")return qe.parentCheckpointId})();return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":Ce,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Pa,{message:ie,messageIndex:Q,isStreamingMessage:t&&n===ie.id,streamingDebounceMs:r,isEditing:i===ie.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:l,onRegenerate:()=>c(Q),onCancelEdit:d,activeInterrupt:b,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:T,showToolMessages:C,checkpointCandidates:Ke,activeCheckpointId:A??null,onSelectCheckpoint:N,defaultCheckpointId:Be,messageParentCheckpointId:Je})})}}):ne()})]})});Oa.displayName="MessageList";const xp={value:""};function $s({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:p,onExcelUploadSuccess:h,onError:x}){const{api:y}=fi(),{currentThreadId:m}=Oo(),{threadId:g,messages:b,hasMore:S,isHistoryLoading:k,isLoading:T,loadOlder:C,navigateToCheckpoint:E,returnToLatest:j,checkpoint:A,checkpoints:N,interrupt:P,metadata:F}=Mo(),{isStreaming:$,error:R,connectionState:z,submit:_,stop:B}=pc(),L=g??m??null,M=(A==null?void 0:A.id)??null,J=(A==null?void 0:A.namespace)??null,X=(F==null?void 0:F.assemblingMessageId)??null,pe=P,[Ie,je]=w.useState(!1);w.useEffect(()=>{pe||je(!1)},[pe]);const G=w.useCallback(()=>{je(!0)},[]),ee=w.useCallback(()=>{je(!1)},[]),W=!!pe||Ie,[D,H]=w.useState(null),[te,ae]=w.useState(""),[ne,Fe]=w.useState(null),[Q,ie]=w.useState(null),[Ce,Re]=w.useState([]),[Ke,Be]=w.useState(0),[ze,qe]=w.useState(0),[Ge,Qe]=w.useState(!1),[Je,rt]=w.useState(null),[wt,ut]=w.useState(null),[it,Tt]=w.useState(!1),[yt,re]=w.useState(null),[Te,Ve]=w.useState(!1),Oe=w.useRef(!1),[ot,Ne]=w.useState(()=>xp.value),ye=w.useRef(ot),vt=w.useRef(null),jt=w.useCallback(q=>{xp.value=q,Ne(q)},[]),[V,ve]=w.useState(!1),ge=w.useRef(null),ft=w.useCallback(q=>{if(!Array.isArray(q))return{text:null,messageId:null};for(let oe=q.length-1;oe>=0;oe--){const ce=q[oe];if(!ce||ce.role!=="user")continue;const we=(ce.content??[]).filter(Xe=>(Xe==null?void 0:Xe.type)==="text").map(Xe=>Xe.text).filter(Xe=>typeof Xe=="string"&&Xe.trim().length>0);return{text:we.length?we.join(" ").trim():null,messageId:ce.id??null}}return{text:null,messageId:null}},[]),mt=w.useCallback((q,oe)=>{if(!q||typeof q!="object")return null;const ce=q[oe];return typeof ce=="number"?ce:null},[]),kt=w.useCallback((q,oe)=>{if(!q||typeof q!="object")return null;const ce=q[oe];return typeof ce=="string"&&ce.trim()?ce:null},[]),Me=w.useMemo(()=>{const q=we=>{if(!Array.isArray(we)||we.length===0)return null;const dt=we.map(Xe=>{if(typeof Xe=="string")return Xe.trim();if(Xe&&typeof Xe=="object"&&"type"in Xe){const et=Xe;if(typeof et.type=="string")return et.type}return null}).filter(Xe=>!!(Xe&&Xe.length));return dt.length?dt.join(", "):null},oe=Array.isArray(N)?N.map(we=>{const dt=q(we.next);return dt?{...we,metadata:{...we.metadata??{},next:dt}}:we}):[];return oe.some(we=>mt(we.metadata,"step")!==null)&&oe.sort((we,dt)=>{const Xe=mt(we.metadata,"step"),et=mt(dt.metadata,"step");if(Xe!==null||et!==null)return(et??Number.NEGATIVE_INFINITY)-(Xe??Number.NEGATIVE_INFINITY);const Ot=Date.parse(we.createdAt??""),ln=Date.parse(dt.createdAt??"");return Number.isNaN(Ot)||Number.isNaN(ln)?0:ln-Ot}),oe},[N,mt]),{checkpointMetaById:Kt,checkpointIndexByKey:at}=w.useMemo(()=>{const q=new Map,oe=new Map;for(const ce of Me){const we=ce.checkpointId??null;if(!we)continue;const dt=mt(ce.metadata,"step"),Xe=kt(ce.metadata,"source"),et={id:we,step:dt,source:Xe,createdAt:ce.createdAt??null,namespace:ce.checkpointNs??null,parentId:ce.parentId??null};if(q.set(we,et),dt!==null&&Xe){const Ot=`${dt}:${Xe}`,ln=oe.get(Ot)??[];ln.push(et),oe.set(Ot,ln)}}for(const ce of oe.values())ce.sort((we,dt)=>{const Xe=we.createdAt??"";return(dt.createdAt??"").localeCompare(Xe)});return{checkpointMetaById:q,checkpointIndexByKey:oe}},[Me,mt,kt]),Et=w.useMemo(()=>{var Xe;if(!Me.length)return[];const q=[...Me].reverse(),oe=(et,Ot)=>{const ln=et.checkpointId??null;if(!ln)return null;const pr=kt(et.metadata,"source");kt(et.metadata,"next");const{text:Vh,messageId:WC}=ft(et.messages),Za=Vh&&Vh.replace(/\s+/g," ").trim()||kt(et.metadata,"title")||kt(et.metadata,"label")||Ot||pr||"Checkpoint",VC=Za.length>60?`${Za.slice(0,57)}…`:Za;return{id:ln,label:VC,messageId:WC??null,createdAt:et.createdAt??null,step:mt(et.metadata,"step"),source:pr??null,next:kt(et.metadata,"next")}},ce=[],we=new Set;for(const et of q){const Ot=((Xe=kt(et.metadata,"source"))==null?void 0:Xe.toLowerCase())??null;if(!(Ot==="input"||Ot==="user_input"||Ot==="user"))continue;const pr=oe(et,"User input");pr&&!we.has(pr.id)&&(ce.push(pr),we.add(pr.id))}if(!ce.length)for(const et of q){const Ot=oe(et);Ot&&!we.has(Ot.id)&&(ce.push(Ot),we.add(Ot.id))}const dt=Me.find(et=>{var ln;return(((ln=kt(et.metadata,"source"))==null?void 0:ln.toLowerCase())??null)==="loop"});if(dt){const et=oe(dt,"Latest loop");et&&!we.has(et.id)&&(ce.push(et),we.add(et.id))}return ce},[Me,ft,mt,kt]),Kn=w.useRef(null),fr=w.useRef(null),qn=w.useCallback(()=>{Kn.current&&(Kn.current.value=""),fr.current&&(fr.current.value=""),Be(q=>q+1),qe(q=>q+1)},[]),Ya=w.useCallback(q=>{jt(q)},[jt]),Xs=w.useRef(!1);w.useEffect(()=>{Xs.current&&!$&&(Re([]),qn()),Xs.current=$},[$,qn]);const[Xa,Ja]=w.useState("desktop");w.useEffect(()=>{const q=()=>{const oe=window.innerWidth;Ja(oe<640?"phone":oe<1024?"tablet":"desktop")};return q(),window.addEventListener("resize",q),()=>window.removeEventListener("resize",q)},[]),w.useEffect(()=>{Ve(!1),Oe.current=!1},[L]),w.useEffect(()=>{ye.current=ot},[ot]),w.useEffect(()=>{if(!D){vt.current=null;return}vt.current===null&&(vt.current=ye.current),jt(te??"")},[te,D,jt]);const I=w.useCallback(async()=>{if(!(!S||k||!Te))try{await C()}catch(q){console.warn("loadOlder failed",q)}},[S,Te,k,C]);w.useEffect(()=>{(async()=>{if(!y.baseUrl){re(null);return}try{const ce=(await y.getAgent("default")).uiDefaultMessage||"";re(ce||null)}catch(oe){console.warn("Failed to fetch default message:",oe),re(null)}})()},[y.baseUrl]),w.useEffect(()=>{R&&!it&&(x==null||x(R))},[R,it,x]);const K=q=>{if(q.length>fs)return`Message too long (${q.length}/${fs} characters)`;try{return cw(q),null}catch(oe){return(oe==null?void 0:oe.message)||"Invalid message"}},le=async q=>{const oe=q.trim();if(!(!oe&&Ce.length===0)){if(oe){const ce=K(oe);if(ce){ie(ce);return}}try{const ce=M??void 0,we=J??void 0,dt=D?{edit:!0,originalMessageId:D,...ne!=null&&ne.checkpointId?{originalCheckpointId:ne.checkpointId}:{},...ne!=null&&ne.checkpointNs?{originalCheckpointNs:ne.checkpointNs}:{}}:void 0;await _({text:oe||"",attachments:Ce,messageAdditionalKwargs:dt},{checkpointId:ce,checkpointNs:we}),p==null||p(oe),jt(""),ie(null),Re([]),qn(),H(null),ae(""),Fe(null)}catch(ce){const we=(ce==null?void 0:ce.message)||"Failed to send message";ie(we),x==null||x(we)}}},be=w.useCallback((q,oe,ce)=>{c&&(vt.current=ot,H(q),ae(oe),jt(oe),ie(null),Fe({checkpointId:(ce==null?void 0:ce.checkpointId)??null,checkpointNs:(ce==null?void 0:ce.checkpointNs)??null}))},[ot,c,jt]),Ye=w.useCallback(()=>{H(null),ae(""),Fe(null),ie(null),jt(vt.current??ot),vt.current=null},[ot,jt]),st=w.useCallback((q,oe,ce)=>{be(q,oe,ce)},[be]),He=w.useCallback(q=>{for(let oe=q-1;oe>=0;oe--)if(b[oe].role==="user"){const ce=b[oe].content||[],dt=ce.filter(Xe=>Xe.type==="text").map(Xe=>Xe.text).join("")||(()=>{try{return JSON.stringify(ce,null,2)}catch{return String(ce)}})();dt&&_({text:dt},{checkpointId:M??void 0,checkpointNs:J??void 0});break}},[b,_,M,J]),$e=q=>{const oe=Array.from(q.target.files||[]);Re(ce=>[...ce,...oe]),q.target.value=""},Pt=q=>{Re(oe=>{const ce=oe.filter((we,dt)=>q!==dt);return ce.length===0&&qn(),ce})},bt=async q=>{const oe=(q.target.files||[])[0];if(oe){rt(null),ut(null),Qe(!0);try{await _({attachments:[oe]},{checkpointId:M??void 0,checkpointNs:J??void 0});const ce=`Uploaded ${oe.name} - processing through chat stream`;ut(ce)}catch(ce){const we=ce instanceof Error?ce.message:"Failed to upload Excel file";console.error("Excel upload failed",ce),rt(we),x==null||x(we)}finally{Qe(!1),q.target.value="",qn()}}},xt=async q=>{if(m){ve(!0);try{if(!q){await j(),Ve(!1),requestAnimationFrame(()=>{var we;(we=ge.current)==null||we.scrollToLatest()});return}const oe=Me.find(we=>we.checkpointId===q),ce=(oe==null?void 0:oe.checkpointNs)??null;await E(q,ce),Ve(!0),requestAnimationFrame(()=>{var we;(we=ge.current)==null||we.scrollToTop()})}finally{ve(!1)}}},qt=w.useCallback(async q=>{await xt(q)},[xt]),Gn=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${f.container||""}`,Rn=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${f.messagesArea||""}`,$t=`flex-shrink-0 w-full border-t p-4 bg-transparent ${f.inputArea||""}`,go=w.useCallback(q=>{if(!q)return"Latest";const oe=[];q.step!==null&&oe.push(`Step ${q.step}`),q.source&&oe.push(q.source);const ce=q.createdAt?new Date(q.createdAt):null,we=ce&&!Number.isNaN(ce.getTime())?ce.toLocaleString():q.createdAt??q.id,dt=oe.length?` — ${oe.join(" • ")}`:"";return`${we}${dt}`},[]);return u.jsxs("div",{className:Gn,children:[!!R&&!it&&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:R}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>Tt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(se.X,{size:16})})]}),m&&Me.length>0&&u.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[u.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),u.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:M??"",onChange:q=>{const oe=q.target.value||null;xt(oe)},children:[u.jsx("option",{value:"",children:"Latest"}),Me.map(q=>{const oe=Kt.get(q.checkpointId??"")??null;return u.jsx("option",{value:q.checkpointId??void 0,children:go(oe)},q.checkpointId)})]})]}),u.jsxs("div",{className:`relative ${Rn}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(Oa,{ref:ge,className:"h-full",style:{height:"100%"},messages:b,isStreaming:$,streamingAssistantId:X,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Xa,enableMessageEditing:c,editingMessageId:D,onStartReached:()=>{Te&&I()},onScrollAway:q=>{if(!Oe.current){Oe.current=!0;return}q&&Ve(!0)},onEdit:st,onRegenerate:He,onCancelEdit:Ye,emptyMessage:yt??void 0,isNavigatingCheckpoint:V,activeInterrupt:pe,disableInterruptActions:Ie,onInterruptActionStart:G,onInterruptActionEnd:ee,showToolMessages:d,checkpointMetaById:Kt,checkpointIndexByKey:at,activeCheckpointId:M,onSelectCheckpoint:qt,timelineCheckpoints:Et}),(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(se.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"}),T&&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(se.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),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(se.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:$t,children:[D&&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(se.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:Ye,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(se.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:Kn,type:"file",multiple:!0,onChange:q=>$e(q),className:"hidden"},Ke),Ce.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:Ce.map((q,oe)=>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(se.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:q.name}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>Pt(oe),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(se.X,{size:12})})]},oe))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:fr,type:"file",accept:".xls,.xlsx,.xlsm",onChange:bt,className:"hidden"},ze),Ge&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(se.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),wt&&!Ge&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:wt}),Je&&!Ge&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Je})]})]}),Q&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Q}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(Qb,{children:[u.jsx(ew,{asChild:!0,children:u.jsx(tt,{type:"button",size:"icon",variant:"outline",disabled:$||W,title:"More input actions",className:f.moreButton||"",children:u.jsx(se.Plus,{size:16})})}),u.jsxs(Td,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(ea,{onClick:()=>{var q;return(q=Kn.current)==null?void 0:q.click()},className:"cursor-pointer",children:[u.jsx(se.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(ea,{onClick:()=>{var q;Ge||(q=fr.current)==null||q.click()},className:`cursor-pointer ${Ge?"opacity-60 pointer-events-none":""}`,children:[u.jsx(se.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(ex,{initialValue:te,editingMessageId:D,value:ot,onValueChange:Ya,placeholder:D?"Edit your message...":t,isStreaming:$,disabled:W,maxLength:fs,onSend:le,onCancelEdit:Ye,onStop:B,allowEmptySend:Ce.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${D?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${Q?"border-red-400":""} ${f.textarea||""}`})})]})]})]})}const zs=v.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:Z("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));zs.displayName="Input";function Ma(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 Da="ScrollArea",[yp,wT]=In(Da),[RS,sn]=yp(Da),vp=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,p]=v.useState(null),[h,x]=v.useState(null),[y,m]=v.useState(null),[g,b]=v.useState(0),[S,k]=v.useState(0),[T,C]=v.useState(!1),[E,j]=v.useState(!1),A=Ue(t,P=>l(P)),N=Lo(o);return u.jsx(RS,{scope:n,type:r,dir:N,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:f,onContentChange:p,scrollbarX:h,onScrollbarXChange:x,scrollbarXEnabled:T,onScrollbarXEnabledChange:C,scrollbarY:y,onScrollbarYChange:m,scrollbarYEnabled:E,onScrollbarYEnabledChange:j,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(_e.div,{dir:N,...i,ref:A,style:{position:"relative","--radix-scroll-area-corner-width":g+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});vp.displayName=Da;var bp="ScrollAreaViewport",wp=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=sn(bp,n),a=v.useRef(null),l=Ue(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(_e.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})})]})});wp.displayName=bp;var kn="ScrollAreaScrollbar",La=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(kn,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(Sp,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Fa,{...r,ref:t}):null});La.displayName=kn;var PS=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(kn,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(tn,{present:n||s,children:u.jsx(Sp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),OS=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(kn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Ws(()=>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 p=()=>{const h=c[d];f!==h&&(l("SCROLL"),i()),f=h};return c.addEventListener("scroll",p),()=>c.removeEventListener("scroll",p)}},[o.viewport,s,l,i]),u.jsx(tn,{present:n||a!=="hidden",children:u.jsx(Fa,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:fe(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:fe(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Sp=v.forwardRef((e,t)=>{const n=sn(kn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=v.useState(!1),a=e.orientation==="horizontal",l=Ws(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Ar(n.viewport,l),Ar(n.content,l),u.jsx(tn,{present:r||s,children:u.jsx(Fa,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Fa=v.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=sn(kn,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=Ip(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:p=>s.current=p,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:p=>i.current=p};function f(p,h){return zS(p,i.current,a,h)}return n==="horizontal"?u.jsx(MS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollLeft,h=Np(p,a,o.dir);s.current.style.transform=`translate3d(${h}px, 0, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollLeft=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollLeft=f(p,o.dir))}}):n==="vertical"?u.jsx(DS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollTop,h=Np(p,a);s.current.style.transform=`translate3d(0, ${h}px, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollTop=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollTop=f(p))}}):null}),MS=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(kn,e.__scopeScrollArea),[i,a]=v.useState(),l=v.useRef(null),c=Ue(t,l,s.onScrollbarXChange);return v.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Tp,{"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":Us(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const p=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(p),jp(p,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Hs(i.paddingLeft),paddingEnd:Hs(i.paddingRight)}})}})}),DS=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(kn,e.__scopeScrollArea),[i,a]=v.useState(),l=v.useRef(null),c=Ue(t,l,s.onScrollbarYChange);return v.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Tp,{"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":Us(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const p=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(p),jp(p,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Hs(i.paddingTop),paddingEnd:Hs(i.paddingBottom)}})}})}),[LS,Cp]=yp(kn),Tp=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,...p}=e,h=sn(kn,n),[x,y]=v.useState(null),m=Ue(t,A=>y(A)),g=v.useRef(null),b=v.useRef(""),S=h.viewport,k=r.content-r.viewport,T=Rt(d),C=Rt(l),E=Ws(f,10);function j(A){if(g.current){const N=A.clientX-g.current.left,P=A.clientY-g.current.top;c({x:N,y:P})}}return v.useEffect(()=>{const A=N=>{const P=N.target;(x==null?void 0:x.contains(P))&&T(N,k)};return document.addEventListener("wheel",A,{passive:!1}),()=>document.removeEventListener("wheel",A,{passive:!1})},[S,x,k,T]),v.useEffect(C,[r,C]),Ar(x,E),Ar(h.content,E),u.jsx(LS,{scope:n,scrollbar:x,hasThumb:o,onThumbChange:Rt(s),onThumbPointerUp:Rt(i),onThumbPositionChange:C,onThumbPointerDown:Rt(a),children:u.jsx(_e.div,{...p,ref:m,style:{position:"absolute",...p.style},onPointerDown:fe(e.onPointerDown,A=>{A.button===0&&(A.target.setPointerCapture(A.pointerId),g.current=x.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),j(A))}),onPointerMove:fe(e.onPointerMove,j),onPointerUp:fe(e.onPointerUp,A=>{const N=A.target;N.hasPointerCapture(A.pointerId)&&N.releasePointerCapture(A.pointerId),document.body.style.webkitUserSelect=b.current,h.viewport&&(h.viewport.style.scrollBehavior=""),g.current=null})})})}),Bs="ScrollAreaThumb",kp=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Cp(Bs,e.__scopeScrollArea);return u.jsx(tn,{present:n||o.hasThumb,children:u.jsx(FS,{ref:t,...r})})}),FS=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=sn(Bs,n),i=Cp(Bs,n),{onThumbPositionChange:a}=i,l=Ue(t,f=>i.onThumbChange(f)),c=v.useRef(void 0),d=Ws(()=>{c.current&&(c.current(),c.current=void 0)},100);return v.useEffect(()=>{const f=s.viewport;if(f){const p=()=>{if(d(),!c.current){const h=BS(f,a);c.current=h,a()}};return a(),f.addEventListener("scroll",p),()=>f.removeEventListener("scroll",p)}},[s.viewport,d,a]),u.jsx(_e.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:fe(e.onPointerDownCapture,f=>{const h=f.target.getBoundingClientRect(),x=f.clientX-h.left,y=f.clientY-h.top;i.onThumbPointerDown({x,y})}),onPointerUp:fe(e.onPointerUp,i.onThumbPointerUp)})});kp.displayName=Bs;var $a="ScrollAreaCorner",Ep=v.forwardRef((e,t)=>{const n=sn($a,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx($S,{...e,ref:t}):null});Ep.displayName=$a;var $S=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=sn($a,n),[s,i]=v.useState(0),[a,l]=v.useState(0),c=!!(s&&a);return Ar(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Ar(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(_e.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 Hs(e){return e?parseInt(e,10):0}function Ip(e,t){const n=e/t;return isNaN(n)?0:n}function Us(e){const t=Ip(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function zS(e,t,n,r="ltr"){const o=Us(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 Ap([l,c],f)(e)}function Np(e,t,n="ltr"){const r=Us(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=Ma(e,l);return Ap([0,i],[0,a])(c)}function Ap(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function jp(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 Ws(e,t){const n=Rt(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 Ar(e,t){const n=Rt(t);_t(()=>{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 _p=vp,HS=wp,US=Ep;const Rp=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(_p,{ref:r,className:Z("relative overflow-hidden",e),...n,children:[u.jsx(HS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(Pp,{}),u.jsx(US,{})]}));Rp.displayName=_p.displayName;const Pp=v.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(La,{ref:r,orientation:t,className:Z("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(kp,{className:"relative flex-1 rounded-full bg-border"})}));Pp.displayName=La.displayName;const Op=25;function za({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:p,setCurrentThreadId:h,isLoading:x,actions:y}=Oo(),{loadThread:m}=Mo(),{createThread:g,deleteThread:b,renameThread:S}=y,[k,T]=w.useState(Array.isArray(f)?f:[]),C=w.useRef(k.length>0),E=w.useRef(null),j=w.useRef(0),[A,N]=w.useState(null),[P,F]=w.useState(""),[$,R]=w.useState(!1);w.useEffect(()=>{const G=Array.isArray(f)?f:[];if(G.length>0){C.current=!0,T(G);return}x||(C.current=!1,T(G))},[f,x]),w.useEffect(()=>{if(!E.current)return;const G=E.current.querySelector("[data-radix-scroll-area-viewport]");if(!G)return;let ee=null,W=null;return ee=requestAnimationFrame(()=>{W=requestAnimationFrame(()=>{G.scrollTop=j.current})}),()=>{ee!==null&&cancelAnimationFrame(ee),W!==null&&cancelAnimationFrame(W)}},[k]);const z=async G=>{try{h(G),await m(G),a==null||a(G),l==null||l(G)}catch(ee){console.error("Failed to select thread:",ee)}},_=async()=>{try{R(!0);const G=await g();G&&(c==null||c(G),a==null||a(G))}catch(G){console.error("Failed to create thread:",G)}finally{R(!1)}},B=async(G,ee)=>{if(ee.stopPropagation(),!!confirm("Delete this thread?")){if(E.current){const W=E.current.querySelector("[data-radix-scroll-area-viewport]");W&&(j.current=W.scrollTop)}try{await b(G),d==null||d(G)}catch(W){console.error("Failed to delete thread:",W)}}},L=(G,ee)=>{ee.stopPropagation(),N(G.threadId),F(G.title||`Thread ${G.threadId.slice(0,8)}`)},M=async G=>{if(P.trim())try{await S(G,P.trim()),N(null),F("")}catch(ee){console.error("Failed to update title:",ee)}},J=()=>{N(null),F("")},X=(G,ee)=>{G.key==="Enter"?M(ee):G.key==="Escape"&&J()},pe=G=>{if(!G)return"";try{const ee=new Date(G),D=new Date().getTime()-ee.getTime(),H=Math.floor(D/(1e3*60*60*24));return H===0?ee.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):H===1?"Yesterday":H<7?`${H} days ago`:ee.toLocaleDateString()}catch{return""}},Ie=G=>G.title||`Thread ${G.threadId.slice(0,8)}`,je=G=>{const ee=Ie(G);return ee.length<=Op?ee:`${ee.slice(0,Op)}...`};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(tt,{onClick:_,disabled:$||x,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:$?"Creating...":"New Chat",children:u.jsx(se.MessageSquarePlus,{size:20})})}),u.jsx(Rp,{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:x?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(se.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(se.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,ee)=>new Date(ee.updatedAt||ee.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??p)===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:A===G.threadId?u.jsxs("div",{className:"flex items-center gap-2",onClick:ee=>ee.stopPropagation(),children:[u.jsx(zs,{value:P,onChange:ee=>F(ee.target.value),onKeyDown:ee=>X(ee,G.threadId),className:"h-6 text-sm",autoFocus:!0}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>M(G.threadId),className:"h-6 w-6 p-0",children:u.jsx(se.Check,{size:12})}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:J,className:"h-6 w-6 p-0",children:u.jsx(se.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(se.Calendar,{size:10}),u.jsx("span",{children:pe(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&&A!==G.threadId&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:ee=>L(G,ee),className:"h-6 w-6 p-0",title:"Edit title",children:u.jsx(se.Edit3,{size:12})}),n&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:ee=>B(G.threadId,ee),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(se.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 jr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function WS(e){if(typeof e!="string")return;const t=e.trim();if(t)return En(t)}function Mp(){const e=[jr("__API_BASE_URL__"),jr("__CHAT_API_BASE_URL__"),jr("__CHAT_API_URL__")];for(const t of e){const n=WS(t);if(n)return n}}function Dp(){const e=[jr("__API_AUTH_TOKEN__"),jr("__CHAT_API_KEY__"),jr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Lp(...e){for(const t of e)if(typeof t=="string"&&t.trim())return En(t);return En()}function Fp(){const e={},t=Mp(),n=Dp();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function $p(){const e=Fp(),t=Pn.getAuthToken(),n=Mp();return{apiBaseUrl:Lp(e.baseUrl,Pn.baseUrl,n),apiKey:t||e.apiKey||Dp()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const zp="chat-settings";function VS(){try{const e=localStorage.getItem(zp);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function KS(e){try{const t={...e,apiBaseUrl:En(e.apiBaseUrl)};localStorage.setItem(zp,JSON.stringify(t)),t.apiKey&&Pn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function qS(){const e=$p(),t=VS(),n=Pn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Lp(Pn.baseUrl,r,e.apiBaseUrl)}}function GS(e){Pn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),KS(e)}var YS="Label",Bp=v.forwardRef((e,t)=>u.jsx(_e.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())}}));Bp.displayName=YS;var Hp=Bp;const XS=xo.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),an=v.forwardRef(({className:e,...t},n)=>u.jsx(Hp,{ref:n,className:Z(XS(),e),...t}));an.displayName=Hp.displayName;function Up(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 Vs="Switch",[JS,ST]=In(Vs),[ZS,QS]=JS(Vs),Wp=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,[p,h]=v.useState(null),x=Ue(t,S=>h(S)),y=v.useRef(!1),m=p?d||!!p.closest("form"):!0,[g,b]=xr({prop:o,defaultProp:s??!1,onChange:c,caller:Vs});return u.jsxs(ZS,{scope:n,checked:g,disabled:a,children:[u.jsx(_e.button,{type:"button",role:"switch","aria-checked":g,"aria-required":i,"data-state":Gp(g),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:x,onClick:fe(e.onClick,S=>{b(k=>!k),m&&(y.current=S.isPropagationStopped(),y.current||S.stopPropagation())})}),m&&u.jsx(qp,{control:p,bubbles:!y.current,name:r,value:l,checked:g,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Wp.displayName=Vs;var Vp="SwitchThumb",Kp=v.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=QS(Vp,n);return u.jsx(_e.span,{"data-state":Gp(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Kp.displayName=Vp;var eC="SwitchBubbleInput",qp=v.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=v.useRef(null),a=Ue(i,s),l=Up(n),c=Jc(t);return v.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&h){const x=new Event("click",{bubbles:r});h.call(d,n),d.dispatchEvent(x)}},[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}})});qp.displayName=eC;function Gp(e){return e?"checked":"unchecked"}var Yp=Wp,tC=Kp;const Un=v.forwardRef(({className:e,...t},n)=>u.jsx(Yp,{className:Z("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:Z("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")})}));Un.displayName=Yp.displayName;var Xp=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(_e.span,{...e,ref:t,style:{...Xp,...e.style}}));rC.displayName=nC;var oC=[" ","Enter","ArrowUp","ArrowDown"],sC=[" ","Enter"],cr="Select",[Ks,qs,iC]=vi(cr),[_r,CT]=In(cr,[iC,Xo]),Gs=Xo(),[aC,Wn]=_r(cr),[lC,cC]=_r(cr),Jp=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:p,required:h,form:x}=e,y=Gs(t),[m,g]=v.useState(null),[b,S]=v.useState(null),[k,T]=v.useState(!1),C=Lo(c),[E,j]=xr({prop:r,defaultProp:o??!1,onChange:s,caller:cr}),[A,N]=xr({prop:i,defaultProp:a,onChange:l,caller:cr}),P=v.useRef(null),F=m?x||!!m.closest("form"):!0,[$,R]=v.useState(new Set),z=Array.from($).map(_=>_.props.value).join(";");return u.jsx(au,{...y,children:u.jsxs(aC,{required:h,scope:t,trigger:m,onTriggerChange:g,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:T,contentId:Nn(),value:A,onValueChange:N,open:E,onOpenChange:j,dir:C,triggerPointerDownPosRef:P,disabled:p,children:[u.jsx(Ks.Provider,{scope:t,children:u.jsx(lC,{scope:e.__scopeSelect,onNativeOptionAdd:v.useCallback(_=>{R(B=>new Set(B).add(_))},[]),onNativeOptionRemove:v.useCallback(_=>{R(B=>{const L=new Set(B);return L.delete(_),L})},[]),children:n})}),F?u.jsxs(wh,{"aria-hidden":!0,required:h,tabIndex:-1,name:d,autoComplete:f,value:A,onChange:_=>N(_.target.value),disabled:p,form:x,children:[A===void 0?u.jsx("option",{value:""}):null,Array.from($)]},z):null]})})};Jp.displayName=cr;var Zp="SelectTrigger",Qp=v.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Gs(n),i=Wn(Zp,n),a=i.disabled||r,l=Ue(t,i.onTriggerChange),c=qs(n),d=v.useRef("touch"),[f,p,h]=Ch(y=>{const m=c().filter(S=>!S.disabled),g=m.find(S=>S.value===i.value),b=Th(m,y,g);b!==void 0&&i.onValueChange(b.value)}),x=y=>{a||(i.onOpenChange(!0),h()),y&&(i.triggerPointerDownPosRef.current={x:Math.round(y.pageX),y:Math.round(y.pageY)})};return u.jsx(lu,{asChild:!0,...s,children:u.jsx(_e.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":Sh(i.value)?"":void 0,...o,ref:l,onClick:fe(o.onClick,y=>{y.currentTarget.focus(),d.current!=="mouse"&&x(y)}),onPointerDown:fe(o.onPointerDown,y=>{d.current=y.pointerType;const m=y.target;m.hasPointerCapture(y.pointerId)&&m.releasePointerCapture(y.pointerId),y.button===0&&y.ctrlKey===!1&&y.pointerType==="mouse"&&(x(y),y.preventDefault())}),onKeyDown:fe(o.onKeyDown,y=>{const m=f.current!=="";!(y.ctrlKey||y.altKey||y.metaKey)&&y.key.length===1&&p(y.key),!(m&&y.key===" ")&&oC.includes(y.key)&&(x(),y.preventDefault())})})})});Qp.displayName=Zp;var eh="SelectValue",th=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Wn(eh,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,f=Ue(t,l.onValueNodeChange);return _t(()=>{c(d)},[c,d]),u.jsx(_e.span,{...a,ref:f,style:{pointerEvents:"none"},children:Sh(l.value)?u.jsx(u.Fragment,{children:i}):s})});th.displayName=eh;var uC="SelectIcon",nh=v.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(_e.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});nh.displayName=uC;var dC="SelectPortal",rh=e=>u.jsx(Jo,{asChild:!0,...e});rh.displayName=dC;var ur="SelectContent",oh=v.forwardRef((e,t)=>{const n=Wn(ur,e.__scopeSelect),[r,o]=v.useState();if(_t(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?yo.createPortal(u.jsx(sh,{scope:e.__scopeSelect,children:u.jsx(Ks.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(ih,{...e,ref:t})});oh.displayName=ur;var mn=10,[sh,Vn]=_r(ur),fC="SelectContentImpl",pC=Yn.createSlot("SelectContent.RemoveScroll"),ih=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:p,collisionPadding:h,sticky:x,hideWhenDetached:y,avoidCollisions:m,...g}=e,b=Wn(ur,n),[S,k]=v.useState(null),[T,C]=v.useState(null),E=Ue(t,W=>k(W)),[j,A]=v.useState(null),[N,P]=v.useState(null),F=qs(n),[$,R]=v.useState(!1),z=v.useRef(!1);v.useEffect(()=>{if(S)return Bi(S)},[S]),Si();const _=v.useCallback(W=>{const[D,...H]=F().map(ne=>ne.ref.current),[te]=H.slice(-1),ae=document.activeElement;for(const ne of W)if(ne===ae||(ne==null||ne.scrollIntoView({block:"nearest"}),ne===D&&T&&(T.scrollTop=0),ne===te&&T&&(T.scrollTop=T.scrollHeight),ne==null||ne.focus(),document.activeElement!==ae))return},[F,T]),B=v.useCallback(()=>_([j,S]),[_,j,S]);v.useEffect(()=>{$&&B()},[$,B]);const{onOpenChange:L,triggerPointerDownPosRef:M}=b;v.useEffect(()=>{if(S){let W={x:0,y:0};const D=te=>{var ae,ne;W={x:Math.abs(Math.round(te.pageX)-(((ae=M.current)==null?void 0:ae.x)??0)),y:Math.abs(Math.round(te.pageY)-(((ne=M.current)==null?void 0:ne.y)??0))}},H=te=>{W.x<=10&&W.y<=10?te.preventDefault():S.contains(te.target)||L(!1),document.removeEventListener("pointermove",D),M.current=null};return M.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",H,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",H,{capture:!0})}}},[S,L,M]),v.useEffect(()=>{const W=()=>L(!1);return window.addEventListener("blur",W),window.addEventListener("resize",W),()=>{window.removeEventListener("blur",W),window.removeEventListener("resize",W)}},[L]);const[J,X]=Ch(W=>{const D=F().filter(ae=>!ae.disabled),H=D.find(ae=>ae.ref.current===document.activeElement),te=Th(D,W,H);te&&setTimeout(()=>te.ref.current.focus())}),pe=v.useCallback((W,D,H)=>{const te=!z.current&&!H;(b.value!==void 0&&b.value===D||te)&&(A(W),te&&(z.current=!0))},[b.value]),Ie=v.useCallback(()=>S==null?void 0:S.focus(),[S]),je=v.useCallback((W,D,H)=>{const te=!z.current&&!H;(b.value!==void 0&&b.value===D||te)&&P(W)},[b.value]),G=r==="popper"?Ba:ah,ee=G===Ba?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:h,sticky:x,hideWhenDetached:y,avoidCollisions:m}:{};return u.jsx(sh,{scope:n,content:S,viewport:T,onViewportChange:C,itemRefCallback:pe,selectedItem:j,onItemLeave:Ie,itemTextRefCallback:je,focusSelectedItem:B,selectedItemText:N,position:r,isPositioned:$,searchRef:J,children:u.jsx(is,{as:pC,allowPinchZoom:!0,children:u.jsx($o,{asChild:!0,trapped:b.open,onMountAutoFocus:W=>{W.preventDefault()},onUnmountAutoFocus:fe(o,W=>{var D;(D=b.trigger)==null||D.focus({preventScroll:!0}),W.preventDefault()}),children:u.jsx(Fo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:W=>W.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx(G,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:W=>W.preventDefault(),...g,...ee,onPlaced:()=>R(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...g.style},onKeyDown:fe(g.onKeyDown,W=>{const D=W.ctrlKey||W.altKey||W.metaKey;if(W.key==="Tab"&&W.preventDefault(),!D&&W.key.length===1&&X(W.key),["ArrowUp","ArrowDown","Home","End"].includes(W.key)){let te=F().filter(ae=>!ae.disabled).map(ae=>ae.ref.current);if(["ArrowUp","End"].includes(W.key)&&(te=te.slice().reverse()),["ArrowUp","ArrowDown"].includes(W.key)){const ae=W.target,ne=te.indexOf(ae);te=te.slice(ne+1)}setTimeout(()=>_(te)),W.preventDefault()}})})})})})})});ih.displayName=fC;var hC="SelectItemAlignedPosition",ah=v.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Wn(ur,n),i=Vn(ur,n),[a,l]=v.useState(null),[c,d]=v.useState(null),f=Ue(t,E=>d(E)),p=qs(n),h=v.useRef(!1),x=v.useRef(!0),{viewport:y,selectedItem:m,selectedItemText:g,focusSelectedItem:b}=i,S=v.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&y&&m&&g){const E=s.trigger.getBoundingClientRect(),j=c.getBoundingClientRect(),A=s.valueNode.getBoundingClientRect(),N=g.getBoundingClientRect();if(s.dir!=="rtl"){const ae=N.left-j.left,ne=A.left-ae,Fe=E.left-ne,Q=E.width+Fe,ie=Math.max(Q,j.width),Ce=window.innerWidth-mn,Re=Ma(ne,[mn,Math.max(mn,Ce-ie)]);a.style.minWidth=Q+"px",a.style.left=Re+"px"}else{const ae=j.right-N.right,ne=window.innerWidth-A.right-ae,Fe=window.innerWidth-E.right-ne,Q=E.width+Fe,ie=Math.max(Q,j.width),Ce=window.innerWidth-mn,Re=Ma(ne,[mn,Math.max(mn,Ce-ie)]);a.style.minWidth=Q+"px",a.style.right=Re+"px"}const P=p(),F=window.innerHeight-mn*2,$=y.scrollHeight,R=window.getComputedStyle(c),z=parseInt(R.borderTopWidth,10),_=parseInt(R.paddingTop,10),B=parseInt(R.borderBottomWidth,10),L=parseInt(R.paddingBottom,10),M=z+_+$+L+B,J=Math.min(m.offsetHeight*5,M),X=window.getComputedStyle(y),pe=parseInt(X.paddingTop,10),Ie=parseInt(X.paddingBottom,10),je=E.top+E.height/2-mn,G=F-je,ee=m.offsetHeight/2,W=m.offsetTop+ee,D=z+_+W,H=M-D;if(D<=je){const ae=P.length>0&&m===P[P.length-1].ref.current;a.style.bottom="0px";const ne=c.clientHeight-y.offsetTop-y.offsetHeight,Fe=Math.max(G,ee+(ae?Ie:0)+ne+B),Q=D+Fe;a.style.height=Q+"px"}else{const ae=P.length>0&&m===P[0].ref.current;a.style.top="0px";const Fe=Math.max(je,z+y.offsetTop+(ae?pe:0)+ee)+H;a.style.height=Fe+"px",y.scrollTop=D-je+y.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=J+"px",a.style.maxHeight=F+"px",r==null||r(),requestAnimationFrame(()=>h.current=!0)}},[p,s.trigger,s.valueNode,a,c,y,m,g,s.dir,r]);_t(()=>S(),[S]);const[k,T]=v.useState();_t(()=>{c&&T(window.getComputedStyle(c).zIndex)},[c]);const C=v.useCallback(E=>{E&&x.current===!0&&(S(),b==null||b(),x.current=!1)},[S,b]);return u.jsx(gC,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:h,onScrollButtonChange:C,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(_e.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});ah.displayName=hC;var mC="SelectPopperPosition",Ba=v.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...s}=e,i=Gs(n);return u.jsx(cu,{...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)"}})});Ba.displayName=mC;var[gC,Ha]=_r(ur,{}),Ua="SelectViewport",lh=v.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Vn(Ua,n),i=Ha(Ua,n),a=Ue(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(Ks.Slot,{scope:n,children:u.jsx(_e.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:fe(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:p}=i;if(p!=null&&p.current&&f){const h=Math.abs(l.current-d.scrollTop);if(h>0){const x=window.innerHeight-mn*2,y=parseFloat(f.style.minHeight),m=parseFloat(f.style.height),g=Math.max(y,m);if(g<x){const b=g+h,S=Math.min(x,b),k=b-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});lh.displayName=Ua;var ch="SelectGroup",[xC,yC]=_r(ch),vC=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Nn();return u.jsx(xC,{scope:n,id:o,children:u.jsx(_e.div,{role:"group","aria-labelledby":o,...r,ref:t})})});vC.displayName=ch;var uh="SelectLabel",dh=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=yC(uh,n);return u.jsx(_e.div,{id:o.id,...r,ref:t})});dh.displayName=uh;var Ys="SelectItem",[bC,fh]=_r(Ys),ph=v.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Wn(Ys,n),l=Vn(Ys,n),c=a.value===r,[d,f]=v.useState(s??""),[p,h]=v.useState(!1),x=Ue(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),y=Nn(),m=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(bC,{scope:n,value:r,disabled:o,textId:y,isSelected:c,onItemTextChange:v.useCallback(b=>{f(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(Ks.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(_e.div,{role:"option","aria-labelledby":y,"data-highlighted":p?"":void 0,"aria-selected":c&&p,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:x,onFocus:fe(i.onFocus,()=>h(!0)),onBlur:fe(i.onBlur,()=>h(!1)),onClick:fe(i.onClick,()=>{m.current!=="mouse"&&g()}),onPointerUp:fe(i.onPointerUp,()=>{m.current==="mouse"&&g()}),onPointerDown:fe(i.onPointerDown,b=>{m.current=b.pointerType}),onPointerMove:fe(i.onPointerMove,b=>{var S;m.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):m.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:fe(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:fe(i.onKeyDown,b=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(sC.includes(b.key)&&g(),b.key===" "&&b.preventDefault())})})})})});ph.displayName=Ys;var mo="SelectItemText",hh=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Wn(mo,n),a=Vn(mo,n),l=fh(mo,n),c=cC(mo,n),[d,f]=v.useState(null),p=Ue(t,g=>f(g),l.onItemTextChange,g=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,g,l.value,l.disabled)}),h=d==null?void 0:d.textContent,x=v.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:h},l.value),[l.disabled,l.value,h]),{onNativeOptionAdd:y,onNativeOptionRemove:m}=c;return _t(()=>(y(x),()=>m(x)),[y,m,x]),u.jsxs(u.Fragment,{children:[u.jsx(_e.span,{id:l.textId,...s,ref:p}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?yo.createPortal(s.children,i.valueNode):null]})});hh.displayName=mo;var mh="SelectItemIndicator",gh=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return fh(mh,n).isSelected?u.jsx(_e.span,{"aria-hidden":!0,...r,ref:t}):null});gh.displayName=mh;var Wa="SelectScrollUpButton",xh=v.forwardRef((e,t)=>{const n=Vn(Wa,e.__scopeSelect),r=Ha(Wa,e.__scopeSelect),[o,s]=v.useState(!1),i=Ue(t,r.onScrollButtonChange);return _t(()=>{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(vh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});xh.displayName=Wa;var Va="SelectScrollDownButton",yh=v.forwardRef((e,t)=>{const n=Vn(Va,e.__scopeSelect),r=Ha(Va,e.__scopeSelect),[o,s]=v.useState(!1),i=Ue(t,r.onScrollButtonChange);return _t(()=>{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(vh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});yh.displayName=Va;var vh=v.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Vn("SelectScrollButton",n),i=v.useRef(null),a=qs(n),l=v.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return v.useEffect(()=>()=>l(),[l]),_t(()=>{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(_e.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:fe(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:fe(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:fe(o.onPointerLeave,()=>{l()})})}),wC="SelectSeparator",bh=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(_e.div,{"aria-hidden":!0,...r,ref:t})});bh.displayName=wC;var Ka="SelectArrow",SC=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Gs(n),s=Wn(Ka,n),i=Vn(Ka,n);return s.open&&i.position==="popper"?u.jsx(uu,{...o,...r,ref:t}):null});SC.displayName=Ka;var CC="SelectBubbleInput",wh=v.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=v.useRef(null),s=Ue(r,o),i=Up(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(_e.select,{...n,style:{...Xp,...n.style},ref:s,defaultValue:t})});wh.displayName=CC;function Sh(e){return e===""||e===void 0}function Ch(e){const t=Rt(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 Th(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=Jp,kh=Qp,EC=th,IC=nh,NC=rh,Eh=oh,AC=lh,Ih=dh,Nh=ph,jC=hh,_C=gh,Ah=xh,jh=yh,_h=bh;const Rh=kC,Ph=EC,qa=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(kh,{ref:r,className:Z("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(se.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));qa.displayName=kh.displayName;const Oh=v.forwardRef(({className:e,...t},n)=>u.jsx(Ah,{ref:n,className:Z("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(se.ChevronUp,{className:"h-4 w-4"})}));Oh.displayName=Ah.displayName;const Mh=v.forwardRef(({className:e,...t},n)=>u.jsx(jh,{ref:n,className:Z("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(se.ChevronDown,{className:"h-4 w-4"})}));Mh.displayName=jh.displayName;const Ga=v.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(NC,{children:u.jsxs(Eh,{ref:o,className:Z("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(Oh,{}),u.jsx(AC,{className:Z("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(Mh,{})]})}));Ga.displayName=Eh.displayName;const RC=v.forwardRef(({className:e,...t},n)=>u.jsx(Ih,{ref:n,className:Z("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));RC.displayName=Ih.displayName;const dr=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Nh,{ref:r,className:Z("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(se.Check,{className:"h-4 w-4"})})}),u.jsx(jC,{children:t})]}));dr.displayName=Nh.displayName;const PC=v.forwardRef(({className:e,...t},n)=>u.jsx(_h,{ref:n,className:Z("-mx-1 my-1 h-px bg-muted",e),...t}));PC.displayName=_h.displayName;var OC="Separator",Dh="horizontal",MC=["horizontal","vertical"],Lh=v.forwardRef((e,t)=>{const{decorative:n,orientation:r=Dh,...o}=e,s=DC(r)?r:Dh,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(_e.div,{"data-orientation":s,...a,...o,ref:t})});Lh.displayName=OC;function DC(e){return MC.includes(e)}var Fh=Lh;const $h=v.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(Fh,{ref:o,decorative:n,orientation:t,className:Z("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));$h.displayName=Fh.displayName;const LC=qf,FC=Q0,$C=Gf,zh=v.forwardRef(({className:e,...t},n)=>u.jsx(_s,{className:Z("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}));zh.displayName=_s.displayName;const zC=xo.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"}}),Bh=v.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs($C,{children:[u.jsx(zh,{}),u.jsxs(Rs,{ref:o,className:Z(zC({side:e}),t),...r,children:[n,u.jsxs(Yf,{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(se.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Bh.displayName=Rs.displayName;const Hh=({className:e,...t})=>u.jsx("div",{className:Z("flex flex-col space-y-2 text-center sm:text-left",e),...t});Hh.displayName="SheetHeader";const Uh=v.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:Z("text-lg font-semibold text-foreground",e),...t}));Uh.displayName=ar.displayName;const Wh=v.forwardRef(({className:e,...t},n)=>u.jsx(Ps,{ref:n,className:Z("text-sm text-muted-foreground",e),...t}));Wh.displayName=Ps.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]=w.useState(!1),[s,i]=w.useState(!1),[a,l]=w.useState(e),[c,d]=w.useState(!1),{toast:f}=Ea();w.useEffect(()=>{const m=JSON.stringify(a)!==JSON.stringify(e);d(m)},[a,e]),w.useEffect(()=>{l(e)},[e]);const p=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},h=()=>{l(BC),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},x=()=>{l(e),d(!1),o(!1)},y=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(FC,{asChild:!0,children:u.jsxs(tt,{variant:"outline",size:"sm",className:n,children:[u.jsx(se.Settings,{className:"h-4 w-4 mr-2"}),"Settings",c&&u.jsx(Tf,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),u.jsxs(Bh,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[u.jsxs(Hh,{children:[u.jsx(Uh,{children:"Chat Settings"}),u.jsx(Wh,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),u.jsxs("div",{className:"space-y-6 py-6",children:[u.jsxs(io,{children:[u.jsx(ao,{className:"pb-3",children:u.jsxs(lo,{className:"text-lg flex items-center gap-2",children:[u.jsx(se.Server,{className:"h-5 w-5"}),"API Configuration"]})}),u.jsxs(co,{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(an,{htmlFor:"api-url",children:"API Base URL"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(zs,{id:"api-url",value:a.api.baseUrl,onChange:m=>l(g=>({...g,api:{...g.api,baseUrl:m.target.value}})),placeholder:"http://localhost:8000/api"}),u.jsx(tt,{variant:"outline",onClick:y,children:"Test"})]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(an,{htmlFor:"enable-auth",children:"Enable Authentication"}),u.jsx(Un,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:m=>l(g=>({...g,api:{...g.api,enableAuth:m}}))})]}),a.api.enableAuth&&u.jsxs("div",{className:"space-y-2",children:[u.jsx(an,{htmlFor:"auth-token",children:"Authentication Token"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(zs,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:m=>l(g=>({...g,api:{...g.api,authToken:m.target.value}})),placeholder:"Enter your Bearer token"}),u.jsx(tt,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?u.jsx(se.EyeOff,{className:"h-4 w-4"}):u.jsx(se.Eye,{className:"h-4 w-4"})})]})]})]})]}),u.jsxs(io,{children:[u.jsx(ao,{className:"pb-3",children:u.jsxs(lo,{className:"text-lg flex items-center gap-2",children:[u.jsx(se.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),u.jsxs(co,{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(an,{htmlFor:"layout",children:"Layout Style"}),u.jsxs(Rh,{value:a.ui.layout,onValueChange:m=>l(g=>({...g,ui:{...g.ui,layout:m}})),children:[u.jsx(qa,{children:u.jsx(Ph,{})}),u.jsxs(Ga,{children:[u.jsx(dr,{value:"sidebar",children:"Sidebar Layout"}),u.jsx(dr,{value:"fullscreen",children:"Fullscreen"}),u.jsx(dr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(an,{htmlFor:"theme",children:"Theme"}),u.jsxs(Rh,{value:a.ui.theme,onValueChange:m=>l(g=>({...g,ui:{...g.ui,theme:m}})),children:[u.jsx(qa,{children:u.jsx(Ph,{})}),u.jsxs(Ga,{children:[u.jsx(dr,{value:"light",children:"Light"}),u.jsx(dr,{value:"dark",children:"Dark"}),u.jsx(dr,{value:"system",children:"System"})]})]})]}),u.jsx($h,{}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(an,{htmlFor:"show-timestamps",children:"Show Timestamps"}),u.jsx(Un,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:m=>l(g=>({...g,ui:{...g.ui,showTimestamps:m}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(an,{htmlFor:"show-agent-names",children:"Show Agent Names"}),u.jsx(Un,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:m=>l(g=>({...g,ui:{...g.ui,showAgentNames:m}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(an,{htmlFor:"compact-messages",children:"Compact Messages"}),u.jsx(Un,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:m=>l(g=>({...g,ui:{...g.ui,compactMessages:m}}))})]})]})]})]}),u.jsxs(io,{children:[u.jsx(ao,{className:"pb-3",children:u.jsxs(lo,{className:"text-lg flex items-center gap-2",children:[u.jsx(se.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),u.jsxs(co,{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(an,{htmlFor:"auto-save",children:"Auto-save Conversations"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),u.jsx(Un,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:m=>l(g=>({...g,behavior:{...g.behavior,autoSave:m}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(an,{htmlFor:"enable-streaming",children:"Enable Streaming"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),u.jsx(Un,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:m=>l(g=>({...g,behavior:{...g.behavior,enableStreaming:m}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(an,{htmlFor:"typing-indicator",children:"Typing Indicator"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),u.jsx(Un,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:m=>l(g=>({...g,behavior:{...g.behavior,showTypingIndicator:m}}))})]})]})]})]}),u.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[u.jsxs(tt,{variant:"outline",onClick:h,children:[u.jsx(se.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(tt,{variant:"outline",onClick:x,children:"Cancel"}),u.jsxs(tt,{onClick:p,disabled:!c,children:[u.jsx(se.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=w.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(Do,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx($s,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(Do,{...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(za,{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($s,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(Do,{...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(za,{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($s,{onError:s.onError,enableFileUpload:!0})})]})})}Ee.ChatApi=ql,Ee.ChatInput=mc,Ee.ChatInterface=$s,Ee.ChatProviders=Do,Ee.ChatSettings=HC,Ee.MarkdownContent=ho,Ee.MessageComponent=Pa,Ee.MessageList=Oa,Ee.ThreadManager=za,Ee.applySettings=GS,Ee.chatApiClient=Pn,Ee.default=UC,Ee.del=Kl,Ee.get=Qt,Ee.getChatToken=Ul,Ee.getCurrentSettings=qS,Ee.getDefaultApiConfig=Fp,Ee.getDefaultChatSettings=$p,Ee.onChatTokenChanged=Wl,Ee.post=di,Ee.put=Vl,Ee.setChatToken=jo,Ee.useApi=fi,Ee.useChatStream=lc,Ee.useMessagesReducer=ec,Ee.useStream=pc,Ee.useThreadState=Mo,Ee.useThreads=Oo,Object.defineProperties(Ee,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
135
|
+
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Ft(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function fp(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ge.defaults,...s};const i=bS(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(xS(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 p;if(!f)try{r.walkTokens&&ge.walkTokens(l,r.walkTokens),p=t(l,r),r.hooks&&(p=r.hooks.postprocess(p))}catch(h){f=h}return r.highlight=a,f?i(f):o(null,p)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;ge.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(p,h){if(p)return c(p);h!=null&&h!==f.text&&(f.text=h,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(ge.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&&ge.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ge(e,t,n){return fp(Bn.lex,Hn.parse)(e,t,n)}ge.options=ge.setOptions=function(e){return ge.defaults={...ge.defaults,...e},oS(ge.defaults),ge},ge.getDefaults=ep,ge.defaults=lr,ge.use=function(...e){const t=ge.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ge.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=ge.defaults.renderer||new Ra;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=ge.defaults.tokenizer||new _a;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=ge.defaults.hooks||new Ls;for(const s in n.hooks){const i=o[s];Ls.passThroughHooks.has(s)?o[s]=a=>{if(ge.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=ge.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}}ge.setOptions(r)})},ge.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ge,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ge.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ge.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ge.walkTokens(r.items,t));break}default:ge.defaults.extensions&&ge.defaults.extensions.childTokens&&ge.defaults.extensions.childTokens[r.type]?ge.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ge.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ge.walkTokens(r.tokens,t)))}return n},ge.parseInline=fp(Bn.lexInline,Hn.parseInline),ge.Parser=Hn,ge.parser=Hn.parse,ge.Renderer=Ra,ge.TextRenderer=up,ge.Lexer=Bn,ge.lexer=Bn.lex,ge.Tokenizer=_a,ge.Slugger=dp,ge.Hooks=Ls,ge.parse=ge,ge.options,ge.setOptions,ge.use,ge.walkTokens,ge.parseInline,Hn.parse,Bn.lex;function ho({content:e,className:t="",allowHtml:n=!1,style:r}){const o=w.useMemo(()=>{try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof ge.parse=="function"?ge.parse(i):ge(i)}return typeof ge.parse=="function"?ge.parse(e):ge(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=w.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:Z("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 SS(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function pp(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 Fs(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function CS(e){const t=o=>{try{const s=fo(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 TS(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function hp(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 kS({className:e}){const[t,n]=w.useState(0);return w.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:Z("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const Pa=w.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:f=!0,customStyles:p={},onEdit:h,onRegenerate:x,onCancelEdit:y,onCopy:m,activeInterrupt:g,disableInterruptActions:b=!1,onInterruptActionStart:S,onInterruptActionEnd:k,checkpointCandidates:T=[],activeCheckpointId:C=null,onSelectCheckpoint:E,defaultCheckpointId:j=null,messageParentCheckpointId:A=null}){const[N,P]=w.useState(!1),[F,$]=w.useState("preview"),[R,z]=w.useState(!1),{currentThreadId:_}=Oo(),{respondToInterrupt:B}=Mo(),L=l==="phone"||l==="half-screen",M=t.role,J=M==="tool",X=w.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),pe=!!X,Ne=!(r&&M!=="user"),{uploadingFiles:je,handleFileClick:G,fileViewerOpen:ee,currentFileInfo:W,closeFileViewer:D}=IS({allowFileOpen:Ne,currentThreadId:_}),H=w.useMemo(()=>{switch(M){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))]"}},[M]),te=w.useMemo(()=>X?"":SS(t.content),[X,t]),ae=w.useMemo(()=>X?{}:pp(t),[X,t]),ne=w.useMemo(()=>X?[]:t.content.filter(V=>V.type==="image_url"),[X,t]),Le=w.useMemo(()=>X?[]:t.content.filter(V=>V.type==="file"),[X,t]),Q=w.useMemo(()=>X?[]:t.content.filter(V=>V.type==="interrupt"),[X,t]),ie=(g==null?void 0:g.id)??(g==null?void 0:g.interrupt_id),ke=Fs(ie),Re=g==null?void 0:g.value,Ke=w.useMemo(()=>X?"":CS(t.content),[X,t]),ze=w.useCallback(async()=>{const V=J?Ke:te;async function we(ye){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(ye);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const ft=new Blob([ye],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":ft})]);return}throw new Error("Clipboard API not supported in this context.")}try{await we(V),P(!0),setTimeout(()=>P(!1),2e3),m==null||m(V)}catch(ye){console.error("Failed to copy:",ye)}},[J,Ke,te,m]),$e=w.useCallback(()=>{if(!h)return;const V=J?Ke:te,we="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};h(t.id,V,we)},[h,t.id,J,Ke,te,t]),qe=w.useCallback(()=>{x==null||x(n)},[x,n]),Ge=w.useCallback(()=>{const we=Z(L?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",H);switch(M){case"user":return u.jsx(se.User,{className:we});case"assistant":return u.jsx(se.Bot,{className:we});case"tool":return u.jsx(se.Wrench,{className:we});default:return u.jsx(se.Bot,{className:we})}},[L,H,M]),Qe=w.useCallback(()=>{const V="group relative mb-4 flex w-full";switch(M){case"user":return Z(V,"justify-end");case"assistant":case"tool":case"system":return Z(V,"justify-start");default:return V}},[M]),Je=w.useCallback(()=>{const V=Z("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",L&&"px-3 py-2 text-sm");if(pe)return Z(V,"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(M){case"user":return Z(V,"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 Z(V,"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 Z(V,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return Z(V,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return Z(V,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[L,pe,M]);if(pe&&X)return u.jsx("div",{className:Z(Qe(),p.container),children:u.jsxs("div",{className:Z(Je(),p.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(se.Bot,{className:Z("h-4 w-4",H)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(ho,{content:X.content,className:"text-current"})]})});const rt=w.useCallback(async V=>{if(b)return;const we=Fs((V==null?void 0:V.id)??(V==null?void 0:V.interrupt_id));if(!we){console.warn("Interrupt part missing id",V);return}try{S==null||S(),await B(we,!0)}catch(ye){console.error("Failed to approve interrupt:",ye)}finally{k==null||k()}},[b,k,S,B]),At=w.useCallback(async V=>{if(b)return;const we=Fs((V==null?void 0:V.id)??(V==null?void 0:V.interrupt_id));if(!we){console.warn("Interrupt part missing id",V);return}try{S==null||S(),await B(we,!1)}catch(ye){console.error("Failed to reject interrupt:",ye)}finally{k==null||k()}},[b,k,S,B]),ut=w.useCallback(({part:V,i:we})=>{if(V.type==="text"){const ye=V.text??"",ft=ye.trim(),gt=Ia(ft);return gt&&M!=="tool"?u.jsx(mp,{data:gt},we):M==="user"&&c&&ft.length>d?u.jsx(NS,{text:ft,expanded:R,onExpandedChange:z,previewLength:d,isCompact:L},we):u.jsx(ho,{content:ye,allowHtml:!1},we)}if(V.type==="image_url"){const ye=V;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:ye.url,alt:ye.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},we)}if(V.type==="file"){const ye=V,ft=ye.name||"file";return u.jsxs("a",{href:ye.url,onClick:gt=>G(gt,ye,we),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:[je[we]?u.jsx(se.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[ft,je[we]?" (processing)":""]})]},we)}if(V.type==="interrupt"){const ye=V,ft=Fs((ye==null?void 0:ye.id)??(ye==null?void 0:ye.interrupt_id)),gt=!!(ke&&ft&&ft===ke),Tt=gt?Re??(ye==null?void 0:ye.value):ye==null?void 0:ye.value,Oe=ft?{...ye,id:ft,interrupt_id:ft}:ye;return u.jsx(ES,{interruptPart:Oe,onApprove:rt,onReject:At,disabled:b,isActive:gt,payload:Tt},we)}return null},[G,je,rt,At,M,c,d,R,L,ke,Re,g,b,Q]),it=w.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(se.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),Ct=w.useCallback(()=>{const V=te.trim().length>0||ne.length>0||Le.length>0||Q.length>0;if(!J&&Le.length>0&&!r)return it();if(!J&&!V&&!r)return null;if(J)return u.jsx(AS,{message:t,viewMode:F},t.id);if(!J&&!X){const we=t,ye=u.jsx("div",{className:"space-y-2",children:we.content.map((ft,gt)=>u.jsx(ut,{part:ft,i:gt},gt))});return r?u.jsxs("div",{"aria-busy":"true",role:"status",children:[ye,u.jsx(kS,{className:H})]}):ye}},[te,ne.length,Le.length,Q.length,r,J,F,it,H]),vt=w.useMemo(()=>X?"Assistant":TS(t),[X,t]),re=w.useMemo(()=>X?[]:Array.isArray(T)?T:[],[T,X]),be=w.useMemo(()=>{var V;return re.length?j&&re.some(we=>we.id===j)?j:((V=re[0])==null?void 0:V.id)??null:null},[j,re]),He=w.useMemo(()=>!re.length||!C?null:re.some(V=>V.id===C)?C:null,[C,re])??be,mt=M==="user"&&re.length>0&&typeof E=="function",xe=w.useCallback(V=>{if(!E)return;const we=(V==null?void 0:V.id)??null,ye=(V==null?void 0:V.parentId)??A??null;E(we,ye)},[A,E]),he=w.useMemo(()=>He?re.findIndex(V=>V.id===He):-1,[He,re]),ot=w.useMemo(()=>he<0?null:re[he]??null,[he,re]),jt=w.useCallback(V=>{const we=[];if(V.step!==null&&we.push(`Step ${V.step}`),V.source&&we.push(V.source),!V.createdAt)return we.length?we.join(" • "):V.id.slice(0,8);let ye="";try{const ft=new Date(V.createdAt);Number.isNaN(ft.getTime())||(ye=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(ft))}catch{ye=""}return`${ye}`},[]);return J&&!f?null:u.jsxs(u.Fragment,{children:[u.jsx("div",{className:Z(Qe(),p.container),children:u.jsxs("div",{className:Z(Je(),p.content),children:[(i||a||J)&&u.jsxs("div",{className:Z("flex items-center justify-between mb-2 pb-2 border-b border-current/10",L&&"mb-1 pb-1",H,p.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[Ge(),a&&vt&&u.jsx("span",{className:Z("font-medium",L?"text-xs":"text-sm"),children:vt}),J&&u.jsxs(Tf,{variant:"outline",className:Z("text-xs flex items-center gap-1 cursor-pointer select-none",H,"border border-current/40",L&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":F==="expanded",onClick:()=>$(V=>V==="expanded"?"preview":"expanded"),onKeyDown:V=>{(V.key==="Enter"||V.key===" ")&&(V.preventDefault(),$(we=>we==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:ae.name??"Tool Output"}),ae.toolCallId&&u.jsx("span",{className:"opacity-70",children:ae.toolCallId.slice(0,8)}),F==="expanded"?u.jsx(se.ChevronUp,{className:"h-3 w-3"}):u.jsx(se.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[mt&&ot&&he>=0&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:Z("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",he>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(he<=0)return;const V=re[he-1];V&&xe(V)},"aria-label":"Previous checkpoint",disabled:he<=0,children:u.jsx(se.ChevronLeft,{className:"h-3 w-3"})}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("span",{className:"whitespace-nowrap",children:[he+1," / ",re.length]}),u.jsx("span",{className:"text-muted-foreground",children:jt(ot)})]}),u.jsx("button",{type:"button",className:Z("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",he<re.length-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(he>=re.length-1)return;const V=re[he+1];V&&xe(V)},"aria-label":"Next checkpoint",disabled:he>=re.length-1,children:u.jsx(se.ChevronRight,{className:"h-3 w-3"})})]}),i&&t.createdAt&&u.jsx("time",{className:Z("text-xs opacity-60",H,L&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&u.jsxs("div",{className:Z("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>ze(),className:Z("h-6 w-6 p-0 hover:bg-foreground/10",H,L&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(se.Copy,{className:Z(N?"text-success":H,L?"h-3 w-3":"h-4 w-4")})})}),M==="user"&&h&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:$e,className:Z("h-6 w-6 p-0 hover:bg-foreground/10",H,L&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(se.Edit,{className:Z(H,L?"h-3 w-3":"h-4 w-4")})}),M==="assistant"&&x&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:qe,className:Z("h-6 w-6 p-0 hover:bg-foreground/10",H,L&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(se.RotateCcw,{className:Z(H,L?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsx("div",{className:"relative",children:Ct()}),J&&F==="expanded"&&(ae.toolCallId||ae.name)&&u.jsxs("div",{className:Z("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",L&&"text-xs"),children:[ae.name&&u.jsxs("div",{children:["Function: ",ae.name]}),ae.toolCallId&&u.jsxs("div",{children:["Call ID: ",ae.toolCallId]})]}),!(i||a||J)&&s&&!o&&u.jsxs("div",{className:Z("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>ze(),className:Z("h-6 w-6 p-0 hover:bg-background/50 text-current",L&&"h-5 w-5"),children:u.jsx(se.Copy,{className:Z(N?"text-success":"text-current",L?"h-3 w-3":"h-4 w-4")})}),M==="user"&&h&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:$e,className:Z("h-6 w-6 p-0 hover:bg-background/50 text-current",L&&"h-5 w-5"),children:u.jsx(se.Edit,{className:Z("text-current",L?"h-3 w-3":"h-4 w-4")})}),M==="assistant"&&x&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:qe,className:Z("h-6 w-6 p-0 hover:bg-background/50 text-current",L&&"h-5 w-5"),children:u.jsx(se.RotateCcw,{className:Z("text-current",L?"h-3 w-3":"h-4 w-4")})})]})]})}),W&&u.jsx(rS,{isOpen:ee,onClose:D,fileId:W.id,fileName:W.name,mimeType:W.mimeType})]})},(e,t)=>{var i,a,l,c,d,f,p,h;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&hp(e.message)===hp(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(x=>e[x]===t[x]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((l=e.customStyles)==null?void 0:l.content)===((c=t.customStyles)==null?void 0:c.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((p=e.customStyles)==null?void 0:p.header)===((h=t.customStyles)==null?void 0:h.header);return o&&s});function mp({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:po(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:po(e)})}function ES({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=po(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(io,{className:Z("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(ao,{className:"pb-3",children:[u.jsx(lo,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(kf,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(co,{className:"pt-0 pb-3",children:a}),u.jsx(Ef,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(tt,{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(tt,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}function IS(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=Ea(),[o,s]=w.useState({}),[i,a]=w.useState(null),[l,c]=w.useState(!1),d=w.useCallback(()=>{c(!1),a(null)},[]),f=w.useCallback(h=>{a(h),c(!0)},[]),p=w.useCallback(async(h,x,y)=>{var m,g;if(!t){h.preventDefault();return}if(o[y]){h.preventDefault();return}try{const b=String(x.url??""),S=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){h.preventDefault();const k=S[1],T=x.name||`file_${k}`,C=x.mimeType||"application/octet-stream";f({id:k,name:T,mimeType:C});return}if(b.startsWith("data:")){h.preventDefault(),s(T=>({...T,[y]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const T=await B0(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??"")===(x.name??""))?!1:typeof x.size=="number"&&typeof E.size=="number"?E.size===x.size:!0);if(!(C!=null&&C.id))throw new Error(`File "${x.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:x.name||C.filename||`file_${C.id}`,mimeType:x.mimeType||C.mime_type||"application/octet-stream"}),(m=k.update)==null||m.call(k,{id:k.id,title:"Success",description:`Opened ${x.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,[y]:!1}))}}}catch(b){console.error("File click error:",b),s(S=>({...S,[y]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:p,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function NS({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:Z("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(ho,{content:e,allowHtml:!1}):u.jsxs("pre",{className:Z("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(tt,{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(se.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(se.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function AS({message:e,viewMode:t}){const r=pp(e).name||"tool",o=c=>{if(c==null)return null;const d=typeof c=="string"?Ia(c)??c:c;if(d&&typeof d=="object")return u.jsx(mp,{data:d});const f=typeof d=="string"?d:(()=>{try{return po(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}=U0(c);return f?u.jsx(ho,{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(se.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=Ns(d);return s(f)}const a=fo(i),l=Ns(a);return s(l)}const gp=(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},Oa=w.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:p,emptyMessage:h,followNewMessages:x=!0,isNavigatingCheckpoint:y=!1,onScrollAway:m,onAtBottom:g,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:T,showToolMessages:C=!0,checkpointMetaById:E,checkpointIndexByKey:j,activeCheckpointId:A,onSelectCheckpoint:N,timelineCheckpoints:P},F)=>{const $=w.useRef(null),R=w.useRef(null),z=w.useRef(!1),[_,B]=w.useState(!0),L=w.useMemo(()=>b?e.some(Q=>"type"in Q&&Q.type==="default_message"?!1:Array.isArray(Q==null?void 0:Q.content)&&Q.content.some(ie=>ie&&ie.type==="interrupt"&&(ie.id??ie.interrupt_id)===b.id)):!1,[b,e]),M=w.useMemo(()=>{if(!b||L)return null;const Q=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let ie;const ke=b.value;if(ke&&typeof ke=="object"&&!Array.isArray(ke)){const Re=ke.title;typeof Re=="string"&&Re.trim()&&(ie=Re.trim())}return{id:`interrupt-${Q}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:Q,value:ke,title:ie}]}},[b,L]),J=w.useMemo(()=>M?[...e,M]:e,[e,M]),X=w.useMemo(()=>C?J:J.filter(Q=>(Q==null?void 0:Q.role)!=="tool"),[J,C]),pe=w.useMemo(()=>{const Q=new Set,ie=[];for(let ke=X.length-1;ke>=0;ke--){const Re=X[ke];if(!Re)continue;if("type"in Re&&Re.type==="default_message"){ie.push(Re);continue}const Ke=Re,ze=jS(Ke);Q.has(ze)||(Q.add(ze),ie.push(Ke))}return ie.reverse()},[X]),Ne=w.useCallback(Q=>{B(Q),m&&m(!Q),g&&g(Q)},[m,g]),je=w.useMemo(()=>{if(a)return async()=>{if(!z.current){z.current=!0;try{await a()}finally{z.current=!1}}}},[a]),G=w.useMemo(()=>!x||y?!1:_?"auto":!1,[_,x,y]),ee=w.useMemo(()=>P??[],[P]),W=A??(ee.length?ee[ee.length-1].id:null),D=ee.length>0,H=w.useMemo(()=>{if(typeof h!="string")return null;const Q=h.trim();return Q?{id:"default-message",role:"assistant",type:"default_message",content:Q,createdAt:new Date().toISOString()}:null},[h]),te=D?u.jsxs("div",{className:"hidden w-48 flex-shrink-0 flex-col border-r border-border/40 pr-4 md:flex",children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-5 pb-5 pr-1",children:[u.jsxs("div",{className:"absolute left-0 right-0 top-1 flex items-center justify-between px-2 pb-3 text-xs 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(se.Info,{className:"h-3.5 w-3.5 text-muted-foreground cursor-help"}),u.jsx("div",{className:"pointer-events-auto fixed hidden w-56 rounded-md border bg-background p-3 text-[11px] font-normal text-muted-foreground shadow-lg group-hover:block whitespace-normal leading-relaxed",style:{zIndex:9999},children:'Shows user inputs and the latest loop checkpoint. Click a dot to jump the chat to that point. Click on the "Latest" button to return to the most recent messages.'})]})]}),u.jsx("div",{className:"pointer-events-none absolute left-5 top-0 bottom-0 w-px bg-border/50"}),u.jsx("div",{className:"flex flex-col gap-4",children:ee.map(Q=>{const ie=W===Q.id;return u.jsxs("button",{type:"button",disabled:!N,onClick:()=>N==null?void 0:N(Q.id),className:`relative flex items-start gap-3 text-left text-xs transition ${ie?"text-primary":"text-muted-foreground"} ${N?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-4 w-4 items-center justify-center rounded-full border ${ie?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${ie?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium",children:Q.label||"User input"}),u.jsxs("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground/70",children:[Q.step!==null?`STEP ${Q.step}`:"STEP —",Q.next?` - ${Q.next}`:""]})]})]},Q.id)})})]}),N&&u.jsx("button",{type:"button",onClick:()=>N==null?void 0:N(null),className:"mt-auto rounded-md border border-border/70 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]}):null,ae=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),ne=()=>H?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Pa,{message:H,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:h??"No messages yet. Start a conversation!"}),Le=pe.length>0;return w.useImperativeHandle(F,()=>({scrollToLatest:()=>{var Q,ie;if($.current&&pe.length>0){const ke=pe.length-1;(ie=(Q=$.current).scrollToIndex)==null||ie.call(Q,{index:ke,align:"end",behavior:"auto"})}else R.current&&(R.current.scrollTop=R.current.scrollHeight)},scrollToTop:()=>{var Q,ie;$.current&&pe.length>0?(ie=(Q=$.current).scrollToIndex)==null||ie.call(Q,{index:0,align:"start",behavior:"auto"}):R.current&&(R.current.scrollTop=0)}}),[pe]),u.jsxs("div",{className:ae,style:p,children:[te,u.jsx("div",{className:"relative flex-1 min-h-0",children:Le?u.jsx(v0,{ref:Q=>{$.current=Q},scrollerRef:Q=>{R.current=Q instanceof HTMLDivElement?Q:null},data:pe,followOutput:G,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{je&&je()},atBottomStateChange:Ne,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(Q,ie)=>gp(ie,Q),itemContent:(Q,ie)=>{var rt;const ke=gp(ie,Q),Re="type"in ie&&ie.type==="default_message";let Ke=[],ze=null,$e={},qe={},Ge=null,Qe=null;if(!Re){const At=ie,ut=At.checkpointId??null;$e=At.additionalKwargs??{},qe=At.responseMetadata??{};const it=ut&&E?E.get(ut)??null:null;Ge=typeof $e.step=="number"?$e.step:typeof qe.step=="number"?qe.step:(it==null?void 0:it.step)??null;const Ct=typeof $e.source=="string"?$e.source:typeof qe.source=="string"?qe.source:(it==null?void 0:it.source)??null;Qe=Ct?String(Ct):null;const vt=Ge!==null&&Qe?`${Ge}:${Qe}`:null;vt&&(j!=null&&j.has(vt))?Ke=j.get(vt)??[]:ut&&it&&(Ke=[it]),ze=ut??((rt=Ke[0])==null?void 0:rt.id)??null}const Je=(()=>{if(typeof $e.parentCheckpointId=="string")return $e.parentCheckpointId;if(typeof qe.parentCheckpointId=="string")return qe.parentCheckpointId})();return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":ke,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Pa,{message:ie,messageIndex:Q,isStreamingMessage:t&&n===ie.id,streamingDebounceMs:r,isEditing:i===ie.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:l,onRegenerate:()=>c(Q),onCancelEdit:d,activeInterrupt:b,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:T,showToolMessages:C,checkpointCandidates:Ke,activeCheckpointId:A??null,onSelectCheckpoint:N,defaultCheckpointId:ze,messageParentCheckpointId:Je})})}}):ne()})]})});Oa.displayName="MessageList";const xp={value:""};function $s({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:p,onExcelUploadSuccess:h,onError:x}){const{api:y}=fi(),{currentThreadId:m}=Oo(),{threadId:g,messages:b,hasMore:S,isHistoryLoading:k,isLoading:T,loadOlder:C,navigateToCheckpoint:E,returnToLatest:j,checkpoint:A,checkpoints:N,interrupt:P,metadata:F}=Mo(),{isStreaming:$,error:R,connectionState:z,submit:_,stop:B}=pc(),L=g??m??null,M=(A==null?void 0:A.id)??null,J=(A==null?void 0:A.namespace)??null,X=(F==null?void 0:F.assemblingMessageId)??null,pe=P,[Ne,je]=w.useState(!1);w.useEffect(()=>{pe||je(!1)},[pe]);const G=w.useCallback(()=>{je(!0)},[]),ee=w.useCallback(()=>{je(!1)},[]),W=!!pe||Ne,[D,H]=w.useState(null),[te,ae]=w.useState(""),[ne,Le]=w.useState(null),[Q,ie]=w.useState(null),[ke,Re]=w.useState([]),[Ke,ze]=w.useState(0),[$e,qe]=w.useState(0),[Ge,Qe]=w.useState(!1),[Je,rt]=w.useState(null),[At,ut]=w.useState(null),[it,Ct]=w.useState(!1),[vt,re]=w.useState(null),[be,Be]=w.useState(!1),He=w.useRef(!1),[mt,xe]=w.useState(()=>xp.value),he=w.useRef(mt),ot=w.useRef(null),jt=w.useCallback(q=>{xp.value=q,xe(q)},[]),[V,we]=w.useState(!1),ye=w.useRef(null),ft=w.useCallback(q=>{if(!Array.isArray(q))return{text:null,messageId:null};for(let oe=q.length-1;oe>=0;oe--){const ce=q[oe];if(!ce||ce.role!=="user")continue;const Ce=(ce.content??[]).filter(Xe=>(Xe==null?void 0:Xe.type)==="text").map(Xe=>Xe.text).filter(Xe=>typeof Xe=="string"&&Xe.trim().length>0);return{text:Ce.length?Ce.join(" ").trim():null,messageId:ce.id??null}}return{text:null,messageId:null}},[]),gt=w.useCallback((q,oe)=>{if(!q||typeof q!="object")return null;const ce=q[oe];return typeof ce=="number"?ce:null},[]),Tt=w.useCallback((q,oe)=>{if(!q||typeof q!="object")return null;const ce=q[oe];return typeof ce=="string"&&ce.trim()?ce:null},[]),Oe=w.useMemo(()=>{const q=Ce=>{if(!Array.isArray(Ce)||Ce.length===0)return null;const dt=Ce.map(Xe=>{if(typeof Xe=="string")return Xe.trim();if(Xe&&typeof Xe=="object"&&"type"in Xe){const et=Xe;if(typeof et.type=="string")return et.type}return null}).filter(Xe=>!!(Xe&&Xe.length));return dt.length?dt.join(", "):null},oe=Array.isArray(N)?N.map(Ce=>{const dt=q(Ce.next);return dt?{...Ce,metadata:{...Ce.metadata??{},next:dt}}:Ce}):[];return oe.some(Ce=>gt(Ce.metadata,"step")!==null)&&oe.sort((Ce,dt)=>{const Xe=gt(Ce.metadata,"step"),et=gt(dt.metadata,"step");if(Xe!==null||et!==null)return(et??Number.NEGATIVE_INFINITY)-(Xe??Number.NEGATIVE_INFINITY);const Ot=Date.parse(Ce.createdAt??""),ln=Date.parse(dt.createdAt??"");return Number.isNaN(Ot)||Number.isNaN(ln)?0:ln-Ot}),oe},[N,gt]),{checkpointMetaById:Kt,checkpointIndexByKey:at}=w.useMemo(()=>{const q=new Map,oe=new Map;for(const ce of Oe){const Ce=ce.checkpointId??null;if(!Ce)continue;const dt=gt(ce.metadata,"step"),Xe=Tt(ce.metadata,"source"),et={id:Ce,step:dt,source:Xe,createdAt:ce.createdAt??null,namespace:ce.checkpointNs??null,parentId:ce.parentId??null};if(q.set(Ce,et),dt!==null&&Xe){const Ot=`${dt}:${Xe}`,ln=oe.get(Ot)??[];ln.push(et),oe.set(Ot,ln)}}for(const ce of oe.values())ce.sort((Ce,dt)=>{const Xe=Ce.createdAt??"";return(dt.createdAt??"").localeCompare(Xe)});return{checkpointMetaById:q,checkpointIndexByKey:oe}},[Oe,gt,Tt]),kt=w.useMemo(()=>{var Xe;if(!Oe.length)return[];const q=[...Oe].reverse(),oe=(et,Ot)=>{const ln=et.checkpointId??null;if(!ln)return null;const pr=Tt(et.metadata,"source");Tt(et.metadata,"next");const{text:Vh,messageId:WC}=ft(et.messages),Za=Vh&&Vh.replace(/\s+/g," ").trim()||Tt(et.metadata,"title")||Tt(et.metadata,"label")||Ot||pr||"Checkpoint",VC=Za.length>60?`${Za.slice(0,57)}…`:Za;return{id:ln,label:VC,messageId:WC??null,createdAt:et.createdAt??null,step:gt(et.metadata,"step"),source:pr??null,next:Tt(et.metadata,"next")}},ce=[],Ce=new Set;for(const et of q){const Ot=((Xe=Tt(et.metadata,"source"))==null?void 0:Xe.toLowerCase())??null;if(!(Ot==="input"||Ot==="user_input"||Ot==="user"))continue;const pr=oe(et,"User input");pr&&!Ce.has(pr.id)&&(ce.push(pr),Ce.add(pr.id))}if(!ce.length)for(const et of q){const Ot=oe(et);Ot&&!Ce.has(Ot.id)&&(ce.push(Ot),Ce.add(Ot.id))}const dt=Oe.find(et=>{var ln;return(((ln=Tt(et.metadata,"source"))==null?void 0:ln.toLowerCase())??null)==="loop"});if(dt){const et=oe(dt,"Latest loop");et&&!Ce.has(et.id)&&(ce.push(et),Ce.add(et.id))}return ce},[Oe,ft,gt,Tt]),Kn=w.useRef(null),fr=w.useRef(null),qn=w.useCallback(()=>{Kn.current&&(Kn.current.value=""),fr.current&&(fr.current.value=""),ze(q=>q+1),qe(q=>q+1)},[]),Ya=w.useCallback(q=>{jt(q)},[jt]),Xs=w.useRef(!1);w.useEffect(()=>{Xs.current&&!$&&(Re([]),qn()),Xs.current=$},[$,qn]);const[Xa,Ja]=w.useState("desktop");w.useEffect(()=>{const q=()=>{const oe=window.innerWidth;Ja(oe<640?"phone":oe<1024?"tablet":"desktop")};return q(),window.addEventListener("resize",q),()=>window.removeEventListener("resize",q)},[]),w.useEffect(()=>{Be(!1),He.current=!1},[L]),w.useEffect(()=>{he.current=mt},[mt]),w.useEffect(()=>{if(!D){ot.current=null;return}ot.current===null&&(ot.current=he.current),jt(te??"")},[te,D,jt]);const I=w.useCallback(async()=>{if(!(!S||k||!be))try{await C()}catch(q){console.warn("loadOlder failed",q)}},[S,be,k,C]);w.useEffect(()=>{(async()=>{if(!y.baseUrl){re(null);return}try{const ce=(await y.getAgent("default")).uiDefaultMessage||"";re(ce||null)}catch(oe){console.warn("Failed to fetch default message:",oe),re(null)}})()},[y.baseUrl]),w.useEffect(()=>{R&&!it&&(x==null||x(R))},[R,it,x]);const K=q=>{if(q.length>fs)return`Message too long (${q.length}/${fs} characters)`;try{return cw(q),null}catch(oe){return(oe==null?void 0:oe.message)||"Invalid message"}},le=async q=>{const oe=q.trim();if(!(!oe&&ke.length===0)){if(oe){const ce=K(oe);if(ce){ie(ce);return}}try{const ce=M??void 0,Ce=J??void 0,dt=D?{edit:!0,originalMessageId:D,...ne!=null&&ne.checkpointId?{originalCheckpointId:ne.checkpointId}:{},...ne!=null&&ne.checkpointNs?{originalCheckpointNs:ne.checkpointNs}:{}}:void 0;await _({text:oe||"",attachments:ke,messageAdditionalKwargs:dt},{checkpointId:ce,checkpointNs:Ce}),p==null||p(oe),jt(""),ie(null),Re([]),qn(),H(null),ae(""),Le(null)}catch(ce){const Ce=(ce==null?void 0:ce.message)||"Failed to send message";ie(Ce),x==null||x(Ce)}}},Se=w.useCallback((q,oe,ce)=>{c&&(ot.current=mt,H(q),ae(oe),jt(oe),ie(null),Le({checkpointId:(ce==null?void 0:ce.checkpointId)??null,checkpointNs:(ce==null?void 0:ce.checkpointNs)??null}))},[mt,c,jt]),Ye=w.useCallback(()=>{H(null),ae(""),Le(null),ie(null),jt(ot.current??mt),ot.current=null},[mt,jt]),st=w.useCallback((q,oe,ce)=>{Se(q,oe,ce)},[Se]),Ue=w.useCallback(q=>{for(let oe=q-1;oe>=0;oe--)if(b[oe].role==="user"){const ce=b[oe].content||[],dt=ce.filter(Xe=>Xe.type==="text").map(Xe=>Xe.text).join("")||(()=>{try{return JSON.stringify(ce,null,2)}catch{return String(ce)}})();dt&&_({text:dt},{checkpointId:M??void 0,checkpointNs:J??void 0});break}},[b,_,M,J]),Fe=q=>{const oe=Array.from(q.target.files||[]);Re(ce=>[...ce,...oe]),q.target.value=""},Pt=q=>{Re(oe=>{const ce=oe.filter((Ce,dt)=>q!==dt);return ce.length===0&&qn(),ce})},bt=async q=>{const oe=(q.target.files||[])[0];if(oe){rt(null),ut(null),Qe(!0);try{await _({attachments:[oe]},{checkpointId:M??void 0,checkpointNs:J??void 0});const ce=`Uploaded ${oe.name} - processing through chat stream`;ut(ce)}catch(ce){const Ce=ce instanceof Error?ce.message:"Failed to upload Excel file";console.error("Excel upload failed",ce),rt(Ce),x==null||x(Ce)}finally{Qe(!1),q.target.value="",qn()}}},yt=async q=>{if(m){we(!0);try{if(!q){await j(),Be(!1),requestAnimationFrame(()=>{var Ce;(Ce=ye.current)==null||Ce.scrollToLatest()});return}const oe=Oe.find(Ce=>Ce.checkpointId===q),ce=(oe==null?void 0:oe.checkpointNs)??null;await E(q,ce),Be(!0),requestAnimationFrame(()=>{var Ce;(Ce=ye.current)==null||Ce.scrollToTop()})}finally{we(!1)}}},qt=w.useCallback(async q=>{await yt(q)},[yt]),Gn=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${f.container||""}`,Rn=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${f.messagesArea||""}`,$t=`flex-shrink-0 w-full border-t p-4 bg-transparent ${f.inputArea||""}`,go=w.useCallback(q=>{if(!q)return"Latest";const oe=[];q.step!==null&&oe.push(`Step ${q.step}`),q.source&&oe.push(q.source);const ce=q.createdAt?new Date(q.createdAt):null,Ce=ce&&!Number.isNaN(ce.getTime())?ce.toLocaleString():q.createdAt??q.id,dt=oe.length?` — ${oe.join(" • ")}`:"";return`${Ce}${dt}`},[]);return u.jsxs("div",{className:Gn,children:[!!R&&!it&&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:R}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>Ct(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(se.X,{size:16})})]}),m&&Oe.length>0&&u.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[u.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),u.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:M??"",onChange:q=>{const oe=q.target.value||null;yt(oe)},children:[u.jsx("option",{value:"",children:"Latest"}),Oe.map(q=>{const oe=Kt.get(q.checkpointId??"")??null;return u.jsx("option",{value:q.checkpointId??void 0,children:go(oe)},q.checkpointId)})]})]}),u.jsxs("div",{className:`relative ${Rn}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(Oa,{ref:ye,className:"h-full",style:{height:"100%"},messages:b,isStreaming:$,streamingAssistantId:X,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Xa,enableMessageEditing:c,editingMessageId:D,onStartReached:()=>{be&&I()},onScrollAway:q=>{if(!He.current){He.current=!0;return}q&&Be(!0)},onEdit:st,onRegenerate:Ue,onCancelEdit:Ye,emptyMessage:vt??void 0,isNavigatingCheckpoint:V,activeInterrupt:pe,disableInterruptActions:Ne,onInterruptActionStart:G,onInterruptActionEnd:ee,showToolMessages:d,checkpointMetaById:Kt,checkpointIndexByKey:at,activeCheckpointId:M,onSelectCheckpoint:qt,timelineCheckpoints:kt}),(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(se.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"}),T&&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(se.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),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(se.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:$t,children:[D&&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(se.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:Ye,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(se.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:Kn,type:"file",multiple:!0,onChange:q=>Fe(q),className:"hidden"},Ke),ke.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:ke.map((q,oe)=>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(se.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:q.name}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>Pt(oe),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(se.X,{size:12})})]},oe))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:fr,type:"file",accept:".xls,.xlsx,.xlsm",onChange:bt,className:"hidden"},$e),Ge&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(se.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),At&&!Ge&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:At}),Je&&!Ge&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Je})]})]}),Q&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Q}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(Qb,{children:[u.jsx(ew,{asChild:!0,children:u.jsx(tt,{type:"button",size:"icon",variant:"outline",disabled:$||W,title:"More input actions",className:f.moreButton||"",children:u.jsx(se.Plus,{size:16})})}),u.jsxs(Td,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(ea,{onClick:()=>{var q;return(q=Kn.current)==null?void 0:q.click()},className:"cursor-pointer",children:[u.jsx(se.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(ea,{onClick:()=>{var q;Ge||(q=fr.current)==null||q.click()},className:`cursor-pointer ${Ge?"opacity-60 pointer-events-none":""}`,children:[u.jsx(se.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(ex,{initialValue:te,editingMessageId:D,value:mt,onValueChange:Ya,placeholder:D?"Edit your message...":t,isStreaming:$,disabled:W,maxLength:fs,onSend:le,onCancelEdit:Ye,onStop:B,allowEmptySend:ke.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${D?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${Q?"border-red-400":""} ${f.textarea||""}`})})]})]})]})}const zs=v.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:Z("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));zs.displayName="Input";function Ma(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 Da="ScrollArea",[yp,wT]=In(Da),[RS,sn]=yp(Da),vp=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,p]=v.useState(null),[h,x]=v.useState(null),[y,m]=v.useState(null),[g,b]=v.useState(0),[S,k]=v.useState(0),[T,C]=v.useState(!1),[E,j]=v.useState(!1),A=We(t,P=>l(P)),N=Lo(o);return u.jsx(RS,{scope:n,type:r,dir:N,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:f,onContentChange:p,scrollbarX:h,onScrollbarXChange:x,scrollbarXEnabled:T,onScrollbarXEnabledChange:C,scrollbarY:y,onScrollbarYChange:m,scrollbarYEnabled:E,onScrollbarYEnabledChange:j,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(_e.div,{dir:N,...i,ref:A,style:{position:"relative","--radix-scroll-area-corner-width":g+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});vp.displayName=Da;var bp="ScrollAreaViewport",wp=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=sn(bp,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(_e.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})})]})});wp.displayName=bp;var kn="ScrollAreaScrollbar",La=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(kn,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(Sp,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Fa,{...r,ref:t}):null});La.displayName=kn;var PS=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(kn,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(tn,{present:n||s,children:u.jsx(Sp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),OS=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(kn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Ws(()=>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 p=()=>{const h=c[d];f!==h&&(l("SCROLL"),i()),f=h};return c.addEventListener("scroll",p),()=>c.removeEventListener("scroll",p)}},[o.viewport,s,l,i]),u.jsx(tn,{present:n||a!=="hidden",children:u.jsx(Fa,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:fe(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:fe(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Sp=v.forwardRef((e,t)=>{const n=sn(kn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=v.useState(!1),a=e.orientation==="horizontal",l=Ws(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Ar(n.viewport,l),Ar(n.content,l),u.jsx(tn,{present:r||s,children:u.jsx(Fa,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Fa=v.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=sn(kn,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=Ip(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:p=>s.current=p,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:p=>i.current=p};function f(p,h){return zS(p,i.current,a,h)}return n==="horizontal"?u.jsx(MS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollLeft,h=Np(p,a,o.dir);s.current.style.transform=`translate3d(${h}px, 0, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollLeft=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollLeft=f(p,o.dir))}}):n==="vertical"?u.jsx(DS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollTop,h=Np(p,a);s.current.style.transform=`translate3d(0, ${h}px, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollTop=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollTop=f(p))}}):null}),MS=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(kn,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(Tp,{"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":Us(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const p=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(p),jp(p,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Hs(i.paddingLeft),paddingEnd:Hs(i.paddingRight)}})}})}),DS=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(kn,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(Tp,{"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":Us(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const p=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(p),jp(p,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Hs(i.paddingTop),paddingEnd:Hs(i.paddingBottom)}})}})}),[LS,Cp]=yp(kn),Tp=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,...p}=e,h=sn(kn,n),[x,y]=v.useState(null),m=We(t,A=>y(A)),g=v.useRef(null),b=v.useRef(""),S=h.viewport,k=r.content-r.viewport,T=Rt(d),C=Rt(l),E=Ws(f,10);function j(A){if(g.current){const N=A.clientX-g.current.left,P=A.clientY-g.current.top;c({x:N,y:P})}}return v.useEffect(()=>{const A=N=>{const P=N.target;(x==null?void 0:x.contains(P))&&T(N,k)};return document.addEventListener("wheel",A,{passive:!1}),()=>document.removeEventListener("wheel",A,{passive:!1})},[S,x,k,T]),v.useEffect(C,[r,C]),Ar(x,E),Ar(h.content,E),u.jsx(LS,{scope:n,scrollbar:x,hasThumb:o,onThumbChange:Rt(s),onThumbPointerUp:Rt(i),onThumbPositionChange:C,onThumbPointerDown:Rt(a),children:u.jsx(_e.div,{...p,ref:m,style:{position:"absolute",...p.style},onPointerDown:fe(e.onPointerDown,A=>{A.button===0&&(A.target.setPointerCapture(A.pointerId),g.current=x.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),j(A))}),onPointerMove:fe(e.onPointerMove,j),onPointerUp:fe(e.onPointerUp,A=>{const N=A.target;N.hasPointerCapture(A.pointerId)&&N.releasePointerCapture(A.pointerId),document.body.style.webkitUserSelect=b.current,h.viewport&&(h.viewport.style.scrollBehavior=""),g.current=null})})})}),Bs="ScrollAreaThumb",kp=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Cp(Bs,e.__scopeScrollArea);return u.jsx(tn,{present:n||o.hasThumb,children:u.jsx(FS,{ref:t,...r})})}),FS=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=sn(Bs,n),i=Cp(Bs,n),{onThumbPositionChange:a}=i,l=We(t,f=>i.onThumbChange(f)),c=v.useRef(void 0),d=Ws(()=>{c.current&&(c.current(),c.current=void 0)},100);return v.useEffect(()=>{const f=s.viewport;if(f){const p=()=>{if(d(),!c.current){const h=BS(f,a);c.current=h,a()}};return a(),f.addEventListener("scroll",p),()=>f.removeEventListener("scroll",p)}},[s.viewport,d,a]),u.jsx(_e.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:fe(e.onPointerDownCapture,f=>{const h=f.target.getBoundingClientRect(),x=f.clientX-h.left,y=f.clientY-h.top;i.onThumbPointerDown({x,y})}),onPointerUp:fe(e.onPointerUp,i.onThumbPointerUp)})});kp.displayName=Bs;var $a="ScrollAreaCorner",Ep=v.forwardRef((e,t)=>{const n=sn($a,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx($S,{...e,ref:t}):null});Ep.displayName=$a;var $S=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=sn($a,n),[s,i]=v.useState(0),[a,l]=v.useState(0),c=!!(s&&a);return Ar(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Ar(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(_e.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 Hs(e){return e?parseInt(e,10):0}function Ip(e,t){const n=e/t;return isNaN(n)?0:n}function Us(e){const t=Ip(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function zS(e,t,n,r="ltr"){const o=Us(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 Ap([l,c],f)(e)}function Np(e,t,n="ltr"){const r=Us(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=Ma(e,l);return Ap([0,i],[0,a])(c)}function Ap(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function jp(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 Ws(e,t){const n=Rt(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 Ar(e,t){const n=Rt(t);_t(()=>{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 _p=vp,HS=wp,US=Ep;const Rp=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(_p,{ref:r,className:Z("relative overflow-hidden",e),...n,children:[u.jsx(HS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(Pp,{}),u.jsx(US,{})]}));Rp.displayName=_p.displayName;const Pp=v.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(La,{ref:r,orientation:t,className:Z("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(kp,{className:"relative flex-1 rounded-full bg-border"})}));Pp.displayName=La.displayName;const Op=25;function za({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:p,setCurrentThreadId:h,isLoading:x,actions:y}=Oo(),{loadThread:m}=Mo(),{createThread:g,deleteThread:b,renameThread:S}=y,[k,T]=w.useState(Array.isArray(f)?f:[]),C=w.useRef(k.length>0),E=w.useRef(null),j=w.useRef(0),[A,N]=w.useState(null),[P,F]=w.useState(""),[$,R]=w.useState(!1);w.useEffect(()=>{const G=Array.isArray(f)?f:[];if(G.length>0){C.current=!0,T(G);return}x||(C.current=!1,T(G))},[f,x]),w.useEffect(()=>{if(!E.current)return;const G=E.current.querySelector("[data-radix-scroll-area-viewport]");if(!G)return;let ee=null,W=null;return ee=requestAnimationFrame(()=>{W=requestAnimationFrame(()=>{G.scrollTop=j.current})}),()=>{ee!==null&&cancelAnimationFrame(ee),W!==null&&cancelAnimationFrame(W)}},[k]);const z=async G=>{try{h(G),await m(G),a==null||a(G),l==null||l(G)}catch(ee){console.error("Failed to select thread:",ee)}},_=async()=>{try{R(!0);const G=await g();G&&(c==null||c(G),a==null||a(G))}catch(G){console.error("Failed to create thread:",G)}finally{R(!1)}},B=async(G,ee)=>{if(ee.stopPropagation(),!!confirm("Delete this thread?")){if(E.current){const W=E.current.querySelector("[data-radix-scroll-area-viewport]");W&&(j.current=W.scrollTop)}try{await b(G),d==null||d(G)}catch(W){console.error("Failed to delete thread:",W)}}},L=(G,ee)=>{ee.stopPropagation(),N(G.threadId),F(G.title||`Thread ${G.threadId.slice(0,8)}`)},M=async G=>{if(P.trim())try{await S(G,P.trim()),N(null),F("")}catch(ee){console.error("Failed to update title:",ee)}},J=()=>{N(null),F("")},X=(G,ee)=>{G.key==="Enter"?M(ee):G.key==="Escape"&&J()},pe=G=>{if(!G)return"";try{const ee=new Date(G),D=new Date().getTime()-ee.getTime(),H=Math.floor(D/(1e3*60*60*24));return H===0?ee.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):H===1?"Yesterday":H<7?`${H} days ago`:ee.toLocaleDateString()}catch{return""}},Ne=G=>G.title||`Thread ${G.threadId.slice(0,8)}`,je=G=>{const ee=Ne(G);return ee.length<=Op?ee:`${ee.slice(0,Op)}...`};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(tt,{onClick:_,disabled:$||x,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:$?"Creating...":"New Chat",children:u.jsx(se.MessageSquarePlus,{size:20})})}),u.jsx(Rp,{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:x?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(se.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(se.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,ee)=>new Date(ee.updatedAt||ee.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??p)===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:A===G.threadId?u.jsxs("div",{className:"flex items-center gap-2",onClick:ee=>ee.stopPropagation(),children:[u.jsx(zs,{value:P,onChange:ee=>F(ee.target.value),onKeyDown:ee=>X(ee,G.threadId),className:"h-6 text-sm",autoFocus:!0}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>M(G.threadId),className:"h-6 w-6 p-0",children:u.jsx(se.Check,{size:12})}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:J,className:"h-6 w-6 p-0",children:u.jsx(se.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(se.Calendar,{size:10}),u.jsx("span",{children:pe(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&&A!==G.threadId&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:ee=>L(G,ee),className:"h-6 w-6 p-0",title:"Edit title",children:u.jsx(se.Edit3,{size:12})}),n&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:ee=>B(G.threadId,ee),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(se.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 jr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function WS(e){if(typeof e!="string")return;const t=e.trim();if(t)return En(t)}function Mp(){const e=[jr("__API_BASE_URL__"),jr("__CHAT_API_BASE_URL__"),jr("__CHAT_API_URL__")];for(const t of e){const n=WS(t);if(n)return n}}function Dp(){const e=[jr("__API_AUTH_TOKEN__"),jr("__CHAT_API_KEY__"),jr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Lp(...e){for(const t of e)if(typeof t=="string"&&t.trim())return En(t);return En()}function Fp(){const e={},t=Mp(),n=Dp();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function $p(){const e=Fp(),t=Pn.getAuthToken(),n=Mp();return{apiBaseUrl:Lp(e.baseUrl,Pn.baseUrl,n),apiKey:t||e.apiKey||Dp()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const zp="chat-settings";function VS(){try{const e=localStorage.getItem(zp);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function KS(e){try{const t={...e,apiBaseUrl:En(e.apiBaseUrl)};localStorage.setItem(zp,JSON.stringify(t)),t.apiKey&&Pn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function qS(){const e=$p(),t=VS(),n=Pn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Lp(Pn.baseUrl,r,e.apiBaseUrl)}}function GS(e){Pn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),KS(e)}var YS="Label",Bp=v.forwardRef((e,t)=>u.jsx(_e.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())}}));Bp.displayName=YS;var Hp=Bp;const XS=xo.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),an=v.forwardRef(({className:e,...t},n)=>u.jsx(Hp,{ref:n,className:Z(XS(),e),...t}));an.displayName=Hp.displayName;function Up(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 Vs="Switch",[JS,ST]=In(Vs),[ZS,QS]=JS(Vs),Wp=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,[p,h]=v.useState(null),x=We(t,S=>h(S)),y=v.useRef(!1),m=p?d||!!p.closest("form"):!0,[g,b]=xr({prop:o,defaultProp:s??!1,onChange:c,caller:Vs});return u.jsxs(ZS,{scope:n,checked:g,disabled:a,children:[u.jsx(_e.button,{type:"button",role:"switch","aria-checked":g,"aria-required":i,"data-state":Gp(g),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:x,onClick:fe(e.onClick,S=>{b(k=>!k),m&&(y.current=S.isPropagationStopped(),y.current||S.stopPropagation())})}),m&&u.jsx(qp,{control:p,bubbles:!y.current,name:r,value:l,checked:g,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Wp.displayName=Vs;var Vp="SwitchThumb",Kp=v.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=QS(Vp,n);return u.jsx(_e.span,{"data-state":Gp(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Kp.displayName=Vp;var eC="SwitchBubbleInput",qp=v.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=v.useRef(null),a=We(i,s),l=Up(n),c=Jc(t);return v.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&h){const x=new Event("click",{bubbles:r});h.call(d,n),d.dispatchEvent(x)}},[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}})});qp.displayName=eC;function Gp(e){return e?"checked":"unchecked"}var Yp=Wp,tC=Kp;const Un=v.forwardRef(({className:e,...t},n)=>u.jsx(Yp,{className:Z("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:Z("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")})}));Un.displayName=Yp.displayName;var Xp=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(_e.span,{...e,ref:t,style:{...Xp,...e.style}}));rC.displayName=nC;var oC=[" ","Enter","ArrowUp","ArrowDown"],sC=[" ","Enter"],cr="Select",[Ks,qs,iC]=vi(cr),[_r,CT]=In(cr,[iC,Xo]),Gs=Xo(),[aC,Wn]=_r(cr),[lC,cC]=_r(cr),Jp=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:p,required:h,form:x}=e,y=Gs(t),[m,g]=v.useState(null),[b,S]=v.useState(null),[k,T]=v.useState(!1),C=Lo(c),[E,j]=xr({prop:r,defaultProp:o??!1,onChange:s,caller:cr}),[A,N]=xr({prop:i,defaultProp:a,onChange:l,caller:cr}),P=v.useRef(null),F=m?x||!!m.closest("form"):!0,[$,R]=v.useState(new Set),z=Array.from($).map(_=>_.props.value).join(";");return u.jsx(au,{...y,children:u.jsxs(aC,{required:h,scope:t,trigger:m,onTriggerChange:g,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:T,contentId:Nn(),value:A,onValueChange:N,open:E,onOpenChange:j,dir:C,triggerPointerDownPosRef:P,disabled:p,children:[u.jsx(Ks.Provider,{scope:t,children:u.jsx(lC,{scope:e.__scopeSelect,onNativeOptionAdd:v.useCallback(_=>{R(B=>new Set(B).add(_))},[]),onNativeOptionRemove:v.useCallback(_=>{R(B=>{const L=new Set(B);return L.delete(_),L})},[]),children:n})}),F?u.jsxs(wh,{"aria-hidden":!0,required:h,tabIndex:-1,name:d,autoComplete:f,value:A,onChange:_=>N(_.target.value),disabled:p,form:x,children:[A===void 0?u.jsx("option",{value:""}):null,Array.from($)]},z):null]})})};Jp.displayName=cr;var Zp="SelectTrigger",Qp=v.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Gs(n),i=Wn(Zp,n),a=i.disabled||r,l=We(t,i.onTriggerChange),c=qs(n),d=v.useRef("touch"),[f,p,h]=Ch(y=>{const m=c().filter(S=>!S.disabled),g=m.find(S=>S.value===i.value),b=Th(m,y,g);b!==void 0&&i.onValueChange(b.value)}),x=y=>{a||(i.onOpenChange(!0),h()),y&&(i.triggerPointerDownPosRef.current={x:Math.round(y.pageX),y:Math.round(y.pageY)})};return u.jsx(lu,{asChild:!0,...s,children:u.jsx(_e.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":Sh(i.value)?"":void 0,...o,ref:l,onClick:fe(o.onClick,y=>{y.currentTarget.focus(),d.current!=="mouse"&&x(y)}),onPointerDown:fe(o.onPointerDown,y=>{d.current=y.pointerType;const m=y.target;m.hasPointerCapture(y.pointerId)&&m.releasePointerCapture(y.pointerId),y.button===0&&y.ctrlKey===!1&&y.pointerType==="mouse"&&(x(y),y.preventDefault())}),onKeyDown:fe(o.onKeyDown,y=>{const m=f.current!=="";!(y.ctrlKey||y.altKey||y.metaKey)&&y.key.length===1&&p(y.key),!(m&&y.key===" ")&&oC.includes(y.key)&&(x(),y.preventDefault())})})})});Qp.displayName=Zp;var eh="SelectValue",th=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Wn(eh,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,f=We(t,l.onValueNodeChange);return _t(()=>{c(d)},[c,d]),u.jsx(_e.span,{...a,ref:f,style:{pointerEvents:"none"},children:Sh(l.value)?u.jsx(u.Fragment,{children:i}):s})});th.displayName=eh;var uC="SelectIcon",nh=v.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(_e.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});nh.displayName=uC;var dC="SelectPortal",rh=e=>u.jsx(Jo,{asChild:!0,...e});rh.displayName=dC;var ur="SelectContent",oh=v.forwardRef((e,t)=>{const n=Wn(ur,e.__scopeSelect),[r,o]=v.useState();if(_t(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?yo.createPortal(u.jsx(sh,{scope:e.__scopeSelect,children:u.jsx(Ks.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(ih,{...e,ref:t})});oh.displayName=ur;var mn=10,[sh,Vn]=_r(ur),fC="SelectContentImpl",pC=Yn.createSlot("SelectContent.RemoveScroll"),ih=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:p,collisionPadding:h,sticky:x,hideWhenDetached:y,avoidCollisions:m,...g}=e,b=Wn(ur,n),[S,k]=v.useState(null),[T,C]=v.useState(null),E=We(t,W=>k(W)),[j,A]=v.useState(null),[N,P]=v.useState(null),F=qs(n),[$,R]=v.useState(!1),z=v.useRef(!1);v.useEffect(()=>{if(S)return Bi(S)},[S]),Si();const _=v.useCallback(W=>{const[D,...H]=F().map(ne=>ne.ref.current),[te]=H.slice(-1),ae=document.activeElement;for(const ne of W)if(ne===ae||(ne==null||ne.scrollIntoView({block:"nearest"}),ne===D&&T&&(T.scrollTop=0),ne===te&&T&&(T.scrollTop=T.scrollHeight),ne==null||ne.focus(),document.activeElement!==ae))return},[F,T]),B=v.useCallback(()=>_([j,S]),[_,j,S]);v.useEffect(()=>{$&&B()},[$,B]);const{onOpenChange:L,triggerPointerDownPosRef:M}=b;v.useEffect(()=>{if(S){let W={x:0,y:0};const D=te=>{var ae,ne;W={x:Math.abs(Math.round(te.pageX)-(((ae=M.current)==null?void 0:ae.x)??0)),y:Math.abs(Math.round(te.pageY)-(((ne=M.current)==null?void 0:ne.y)??0))}},H=te=>{W.x<=10&&W.y<=10?te.preventDefault():S.contains(te.target)||L(!1),document.removeEventListener("pointermove",D),M.current=null};return M.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",H,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",H,{capture:!0})}}},[S,L,M]),v.useEffect(()=>{const W=()=>L(!1);return window.addEventListener("blur",W),window.addEventListener("resize",W),()=>{window.removeEventListener("blur",W),window.removeEventListener("resize",W)}},[L]);const[J,X]=Ch(W=>{const D=F().filter(ae=>!ae.disabled),H=D.find(ae=>ae.ref.current===document.activeElement),te=Th(D,W,H);te&&setTimeout(()=>te.ref.current.focus())}),pe=v.useCallback((W,D,H)=>{const te=!z.current&&!H;(b.value!==void 0&&b.value===D||te)&&(A(W),te&&(z.current=!0))},[b.value]),Ne=v.useCallback(()=>S==null?void 0:S.focus(),[S]),je=v.useCallback((W,D,H)=>{const te=!z.current&&!H;(b.value!==void 0&&b.value===D||te)&&P(W)},[b.value]),G=r==="popper"?Ba:ah,ee=G===Ba?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:h,sticky:x,hideWhenDetached:y,avoidCollisions:m}:{};return u.jsx(sh,{scope:n,content:S,viewport:T,onViewportChange:C,itemRefCallback:pe,selectedItem:j,onItemLeave:Ne,itemTextRefCallback:je,focusSelectedItem:B,selectedItemText:N,position:r,isPositioned:$,searchRef:J,children:u.jsx(is,{as:pC,allowPinchZoom:!0,children:u.jsx($o,{asChild:!0,trapped:b.open,onMountAutoFocus:W=>{W.preventDefault()},onUnmountAutoFocus:fe(o,W=>{var D;(D=b.trigger)==null||D.focus({preventScroll:!0}),W.preventDefault()}),children:u.jsx(Fo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:W=>W.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx(G,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:W=>W.preventDefault(),...g,...ee,onPlaced:()=>R(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...g.style},onKeyDown:fe(g.onKeyDown,W=>{const D=W.ctrlKey||W.altKey||W.metaKey;if(W.key==="Tab"&&W.preventDefault(),!D&&W.key.length===1&&X(W.key),["ArrowUp","ArrowDown","Home","End"].includes(W.key)){let te=F().filter(ae=>!ae.disabled).map(ae=>ae.ref.current);if(["ArrowUp","End"].includes(W.key)&&(te=te.slice().reverse()),["ArrowUp","ArrowDown"].includes(W.key)){const ae=W.target,ne=te.indexOf(ae);te=te.slice(ne+1)}setTimeout(()=>_(te)),W.preventDefault()}})})})})})})});ih.displayName=fC;var hC="SelectItemAlignedPosition",ah=v.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Wn(ur,n),i=Vn(ur,n),[a,l]=v.useState(null),[c,d]=v.useState(null),f=We(t,E=>d(E)),p=qs(n),h=v.useRef(!1),x=v.useRef(!0),{viewport:y,selectedItem:m,selectedItemText:g,focusSelectedItem:b}=i,S=v.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&y&&m&&g){const E=s.trigger.getBoundingClientRect(),j=c.getBoundingClientRect(),A=s.valueNode.getBoundingClientRect(),N=g.getBoundingClientRect();if(s.dir!=="rtl"){const ae=N.left-j.left,ne=A.left-ae,Le=E.left-ne,Q=E.width+Le,ie=Math.max(Q,j.width),ke=window.innerWidth-mn,Re=Ma(ne,[mn,Math.max(mn,ke-ie)]);a.style.minWidth=Q+"px",a.style.left=Re+"px"}else{const ae=j.right-N.right,ne=window.innerWidth-A.right-ae,Le=window.innerWidth-E.right-ne,Q=E.width+Le,ie=Math.max(Q,j.width),ke=window.innerWidth-mn,Re=Ma(ne,[mn,Math.max(mn,ke-ie)]);a.style.minWidth=Q+"px",a.style.right=Re+"px"}const P=p(),F=window.innerHeight-mn*2,$=y.scrollHeight,R=window.getComputedStyle(c),z=parseInt(R.borderTopWidth,10),_=parseInt(R.paddingTop,10),B=parseInt(R.borderBottomWidth,10),L=parseInt(R.paddingBottom,10),M=z+_+$+L+B,J=Math.min(m.offsetHeight*5,M),X=window.getComputedStyle(y),pe=parseInt(X.paddingTop,10),Ne=parseInt(X.paddingBottom,10),je=E.top+E.height/2-mn,G=F-je,ee=m.offsetHeight/2,W=m.offsetTop+ee,D=z+_+W,H=M-D;if(D<=je){const ae=P.length>0&&m===P[P.length-1].ref.current;a.style.bottom="0px";const ne=c.clientHeight-y.offsetTop-y.offsetHeight,Le=Math.max(G,ee+(ae?Ne:0)+ne+B),Q=D+Le;a.style.height=Q+"px"}else{const ae=P.length>0&&m===P[0].ref.current;a.style.top="0px";const Le=Math.max(je,z+y.offsetTop+(ae?pe:0)+ee)+H;a.style.height=Le+"px",y.scrollTop=D-je+y.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=J+"px",a.style.maxHeight=F+"px",r==null||r(),requestAnimationFrame(()=>h.current=!0)}},[p,s.trigger,s.valueNode,a,c,y,m,g,s.dir,r]);_t(()=>S(),[S]);const[k,T]=v.useState();_t(()=>{c&&T(window.getComputedStyle(c).zIndex)},[c]);const C=v.useCallback(E=>{E&&x.current===!0&&(S(),b==null||b(),x.current=!1)},[S,b]);return u.jsx(gC,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:h,onScrollButtonChange:C,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(_e.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});ah.displayName=hC;var mC="SelectPopperPosition",Ba=v.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...s}=e,i=Gs(n);return u.jsx(cu,{...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)"}})});Ba.displayName=mC;var[gC,Ha]=_r(ur,{}),Ua="SelectViewport",lh=v.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Vn(Ua,n),i=Ha(Ua,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(Ks.Slot,{scope:n,children:u.jsx(_e.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:fe(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:p}=i;if(p!=null&&p.current&&f){const h=Math.abs(l.current-d.scrollTop);if(h>0){const x=window.innerHeight-mn*2,y=parseFloat(f.style.minHeight),m=parseFloat(f.style.height),g=Math.max(y,m);if(g<x){const b=g+h,S=Math.min(x,b),k=b-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});lh.displayName=Ua;var ch="SelectGroup",[xC,yC]=_r(ch),vC=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Nn();return u.jsx(xC,{scope:n,id:o,children:u.jsx(_e.div,{role:"group","aria-labelledby":o,...r,ref:t})})});vC.displayName=ch;var uh="SelectLabel",dh=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=yC(uh,n);return u.jsx(_e.div,{id:o.id,...r,ref:t})});dh.displayName=uh;var Ys="SelectItem",[bC,fh]=_r(Ys),ph=v.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Wn(Ys,n),l=Vn(Ys,n),c=a.value===r,[d,f]=v.useState(s??""),[p,h]=v.useState(!1),x=We(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),y=Nn(),m=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(bC,{scope:n,value:r,disabled:o,textId:y,isSelected:c,onItemTextChange:v.useCallback(b=>{f(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(Ks.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(_e.div,{role:"option","aria-labelledby":y,"data-highlighted":p?"":void 0,"aria-selected":c&&p,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:x,onFocus:fe(i.onFocus,()=>h(!0)),onBlur:fe(i.onBlur,()=>h(!1)),onClick:fe(i.onClick,()=>{m.current!=="mouse"&&g()}),onPointerUp:fe(i.onPointerUp,()=>{m.current==="mouse"&&g()}),onPointerDown:fe(i.onPointerDown,b=>{m.current=b.pointerType}),onPointerMove:fe(i.onPointerMove,b=>{var S;m.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):m.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:fe(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:fe(i.onKeyDown,b=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(sC.includes(b.key)&&g(),b.key===" "&&b.preventDefault())})})})})});ph.displayName=Ys;var mo="SelectItemText",hh=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Wn(mo,n),a=Vn(mo,n),l=fh(mo,n),c=cC(mo,n),[d,f]=v.useState(null),p=We(t,g=>f(g),l.onItemTextChange,g=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,g,l.value,l.disabled)}),h=d==null?void 0:d.textContent,x=v.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:h},l.value),[l.disabled,l.value,h]),{onNativeOptionAdd:y,onNativeOptionRemove:m}=c;return _t(()=>(y(x),()=>m(x)),[y,m,x]),u.jsxs(u.Fragment,{children:[u.jsx(_e.span,{id:l.textId,...s,ref:p}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?yo.createPortal(s.children,i.valueNode):null]})});hh.displayName=mo;var mh="SelectItemIndicator",gh=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return fh(mh,n).isSelected?u.jsx(_e.span,{"aria-hidden":!0,...r,ref:t}):null});gh.displayName=mh;var Wa="SelectScrollUpButton",xh=v.forwardRef((e,t)=>{const n=Vn(Wa,e.__scopeSelect),r=Ha(Wa,e.__scopeSelect),[o,s]=v.useState(!1),i=We(t,r.onScrollButtonChange);return _t(()=>{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(vh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});xh.displayName=Wa;var Va="SelectScrollDownButton",yh=v.forwardRef((e,t)=>{const n=Vn(Va,e.__scopeSelect),r=Ha(Va,e.__scopeSelect),[o,s]=v.useState(!1),i=We(t,r.onScrollButtonChange);return _t(()=>{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(vh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});yh.displayName=Va;var vh=v.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Vn("SelectScrollButton",n),i=v.useRef(null),a=qs(n),l=v.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return v.useEffect(()=>()=>l(),[l]),_t(()=>{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(_e.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:fe(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:fe(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:fe(o.onPointerLeave,()=>{l()})})}),wC="SelectSeparator",bh=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(_e.div,{"aria-hidden":!0,...r,ref:t})});bh.displayName=wC;var Ka="SelectArrow",SC=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Gs(n),s=Wn(Ka,n),i=Vn(Ka,n);return s.open&&i.position==="popper"?u.jsx(uu,{...o,...r,ref:t}):null});SC.displayName=Ka;var CC="SelectBubbleInput",wh=v.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=v.useRef(null),s=We(r,o),i=Up(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(_e.select,{...n,style:{...Xp,...n.style},ref:s,defaultValue:t})});wh.displayName=CC;function Sh(e){return e===""||e===void 0}function Ch(e){const t=Rt(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 Th(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=Jp,kh=Qp,EC=th,IC=nh,NC=rh,Eh=oh,AC=lh,Ih=dh,Nh=ph,jC=hh,_C=gh,Ah=xh,jh=yh,_h=bh;const Rh=kC,Ph=EC,qa=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(kh,{ref:r,className:Z("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(se.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));qa.displayName=kh.displayName;const Oh=v.forwardRef(({className:e,...t},n)=>u.jsx(Ah,{ref:n,className:Z("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(se.ChevronUp,{className:"h-4 w-4"})}));Oh.displayName=Ah.displayName;const Mh=v.forwardRef(({className:e,...t},n)=>u.jsx(jh,{ref:n,className:Z("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(se.ChevronDown,{className:"h-4 w-4"})}));Mh.displayName=jh.displayName;const Ga=v.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(NC,{children:u.jsxs(Eh,{ref:o,className:Z("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(Oh,{}),u.jsx(AC,{className:Z("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(Mh,{})]})}));Ga.displayName=Eh.displayName;const RC=v.forwardRef(({className:e,...t},n)=>u.jsx(Ih,{ref:n,className:Z("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));RC.displayName=Ih.displayName;const dr=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Nh,{ref:r,className:Z("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(se.Check,{className:"h-4 w-4"})})}),u.jsx(jC,{children:t})]}));dr.displayName=Nh.displayName;const PC=v.forwardRef(({className:e,...t},n)=>u.jsx(_h,{ref:n,className:Z("-mx-1 my-1 h-px bg-muted",e),...t}));PC.displayName=_h.displayName;var OC="Separator",Dh="horizontal",MC=["horizontal","vertical"],Lh=v.forwardRef((e,t)=>{const{decorative:n,orientation:r=Dh,...o}=e,s=DC(r)?r:Dh,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(_e.div,{"data-orientation":s,...a,...o,ref:t})});Lh.displayName=OC;function DC(e){return MC.includes(e)}var Fh=Lh;const $h=v.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(Fh,{ref:o,decorative:n,orientation:t,className:Z("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));$h.displayName=Fh.displayName;const LC=qf,FC=Q0,$C=Gf,zh=v.forwardRef(({className:e,...t},n)=>u.jsx(_s,{className:Z("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}));zh.displayName=_s.displayName;const zC=xo.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"}}),Bh=v.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs($C,{children:[u.jsx(zh,{}),u.jsxs(Rs,{ref:o,className:Z(zC({side:e}),t),...r,children:[n,u.jsxs(Yf,{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(se.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Bh.displayName=Rs.displayName;const Hh=({className:e,...t})=>u.jsx("div",{className:Z("flex flex-col space-y-2 text-center sm:text-left",e),...t});Hh.displayName="SheetHeader";const Uh=v.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:Z("text-lg font-semibold text-foreground",e),...t}));Uh.displayName=ar.displayName;const Wh=v.forwardRef(({className:e,...t},n)=>u.jsx(Ps,{ref:n,className:Z("text-sm text-muted-foreground",e),...t}));Wh.displayName=Ps.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]=w.useState(!1),[s,i]=w.useState(!1),[a,l]=w.useState(e),[c,d]=w.useState(!1),{toast:f}=Ea();w.useEffect(()=>{const m=JSON.stringify(a)!==JSON.stringify(e);d(m)},[a,e]),w.useEffect(()=>{l(e)},[e]);const p=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},h=()=>{l(BC),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},x=()=>{l(e),d(!1),o(!1)},y=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(FC,{asChild:!0,children:u.jsxs(tt,{variant:"outline",size:"sm",className:n,children:[u.jsx(se.Settings,{className:"h-4 w-4 mr-2"}),"Settings",c&&u.jsx(Tf,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),u.jsxs(Bh,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[u.jsxs(Hh,{children:[u.jsx(Uh,{children:"Chat Settings"}),u.jsx(Wh,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),u.jsxs("div",{className:"space-y-6 py-6",children:[u.jsxs(io,{children:[u.jsx(ao,{className:"pb-3",children:u.jsxs(lo,{className:"text-lg flex items-center gap-2",children:[u.jsx(se.Server,{className:"h-5 w-5"}),"API Configuration"]})}),u.jsxs(co,{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(an,{htmlFor:"api-url",children:"API Base URL"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(zs,{id:"api-url",value:a.api.baseUrl,onChange:m=>l(g=>({...g,api:{...g.api,baseUrl:m.target.value}})),placeholder:"http://localhost:8000/api"}),u.jsx(tt,{variant:"outline",onClick:y,children:"Test"})]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(an,{htmlFor:"enable-auth",children:"Enable Authentication"}),u.jsx(Un,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:m=>l(g=>({...g,api:{...g.api,enableAuth:m}}))})]}),a.api.enableAuth&&u.jsxs("div",{className:"space-y-2",children:[u.jsx(an,{htmlFor:"auth-token",children:"Authentication Token"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(zs,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:m=>l(g=>({...g,api:{...g.api,authToken:m.target.value}})),placeholder:"Enter your Bearer token"}),u.jsx(tt,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?u.jsx(se.EyeOff,{className:"h-4 w-4"}):u.jsx(se.Eye,{className:"h-4 w-4"})})]})]})]})]}),u.jsxs(io,{children:[u.jsx(ao,{className:"pb-3",children:u.jsxs(lo,{className:"text-lg flex items-center gap-2",children:[u.jsx(se.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),u.jsxs(co,{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(an,{htmlFor:"layout",children:"Layout Style"}),u.jsxs(Rh,{value:a.ui.layout,onValueChange:m=>l(g=>({...g,ui:{...g.ui,layout:m}})),children:[u.jsx(qa,{children:u.jsx(Ph,{})}),u.jsxs(Ga,{children:[u.jsx(dr,{value:"sidebar",children:"Sidebar Layout"}),u.jsx(dr,{value:"fullscreen",children:"Fullscreen"}),u.jsx(dr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(an,{htmlFor:"theme",children:"Theme"}),u.jsxs(Rh,{value:a.ui.theme,onValueChange:m=>l(g=>({...g,ui:{...g.ui,theme:m}})),children:[u.jsx(qa,{children:u.jsx(Ph,{})}),u.jsxs(Ga,{children:[u.jsx(dr,{value:"light",children:"Light"}),u.jsx(dr,{value:"dark",children:"Dark"}),u.jsx(dr,{value:"system",children:"System"})]})]})]}),u.jsx($h,{}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(an,{htmlFor:"show-timestamps",children:"Show Timestamps"}),u.jsx(Un,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:m=>l(g=>({...g,ui:{...g.ui,showTimestamps:m}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(an,{htmlFor:"show-agent-names",children:"Show Agent Names"}),u.jsx(Un,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:m=>l(g=>({...g,ui:{...g.ui,showAgentNames:m}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(an,{htmlFor:"compact-messages",children:"Compact Messages"}),u.jsx(Un,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:m=>l(g=>({...g,ui:{...g.ui,compactMessages:m}}))})]})]})]})]}),u.jsxs(io,{children:[u.jsx(ao,{className:"pb-3",children:u.jsxs(lo,{className:"text-lg flex items-center gap-2",children:[u.jsx(se.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),u.jsxs(co,{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(an,{htmlFor:"auto-save",children:"Auto-save Conversations"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),u.jsx(Un,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:m=>l(g=>({...g,behavior:{...g.behavior,autoSave:m}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(an,{htmlFor:"enable-streaming",children:"Enable Streaming"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),u.jsx(Un,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:m=>l(g=>({...g,behavior:{...g.behavior,enableStreaming:m}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(an,{htmlFor:"typing-indicator",children:"Typing Indicator"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),u.jsx(Un,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:m=>l(g=>({...g,behavior:{...g.behavior,showTypingIndicator:m}}))})]})]})]})]}),u.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[u.jsxs(tt,{variant:"outline",onClick:h,children:[u.jsx(se.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(tt,{variant:"outline",onClick:x,children:"Cancel"}),u.jsxs(tt,{onClick:p,disabled:!c,children:[u.jsx(se.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=w.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(Do,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx($s,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(Do,{...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(za,{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($s,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(Do,{...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(za,{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($s,{onError:s.onError,enableFileUpload:!0})})]})})}Ie.ChatApi=ql,Ie.ChatInput=mc,Ie.ChatInterface=$s,Ie.ChatProviders=Do,Ie.ChatSettings=HC,Ie.MarkdownContent=ho,Ie.MessageComponent=Pa,Ie.MessageList=Oa,Ie.ThreadManager=za,Ie.applySettings=GS,Ie.chatApiClient=Pn,Ie.default=UC,Ie.del=Kl,Ie.get=Qt,Ie.getChatToken=Ul,Ie.getCurrentSettings=qS,Ie.getDefaultApiConfig=Fp,Ie.getDefaultChatSettings=$p,Ie.onChatTokenChanged=Wl,Ie.post=di,Ie.put=Vl,Ie.setChatToken=jo,Ie.useApi=fi,Ie.useChatStream=lc,Ie.useMessagesReducer=ec,Ie.useStream=pc,Ie.useThreadState=Mo,Ie.useThreads=Oo,Object.defineProperties(Ie,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|