teodor-new-chat-ui 4.2.3 → 4.2.5
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/components/ui/command.d.ts +7 -7
- package/dist/index.esm.js +4691 -4499
- package/dist/index.umd.js +43 -43
- package/dist/lib/historyUtils.d.ts +2 -0
- package/dist/types/api.d.ts +8 -2
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(Re,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom"],y):(Re=typeof globalThis<"u"?globalThis:Re||self,y(Re.NewChatUI={},Re.React,Re.LucideReact,Re.reactSlot,Re.classVarianceAuthority,Re.clsx,Re.tailwindMerge,Re.ReactDOM))})(this,function(Re,y,ie,
|
|
1
|
+
(function(Re,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom"],y):(Re=typeof globalThis<"u"?globalThis:Re||self,y(Re.NewChatUI={},Re.React,Re.LucideReact,Re.reactSlot,Re.classVarianceAuthority,Re.clsx,Re.tailwindMerge,Re.ReactDOM))})(this,function(Re,y,ie,Wn,xo,rm,om,Zs){"use strict";var rT=Object.defineProperty;var oT=(Re,y,ie)=>y in Re?rT(Re,y,{enumerable:!0,configurable:!0,writable:!0,value:ie}):Re[y]=ie;var tm=(Re,y,ie)=>oT(Re,typeof y!="symbol"?y+"":y,ie);function il(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const m=il(y),vo=il(Zs);var Qs={exports:{}},Lr={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var al;function sm(){if(al)return Lr;al=1;var e=y,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,l,u){var d,f={},h=null,p=null;u!==void 0&&(h=""+u),l.key!==void 0&&(h=""+l.key),l.ref!==void 0&&(p=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(f[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)f[d]===void 0&&(f[d]=l[d]);return{$$typeof:t,type:a,key:h,ref:p,props:f,_owner:o.current}}return Lr.Fragment=n,Lr.jsx=i,Lr.jsxs=i,Lr}var Fr={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,42 +14,42 @@
|
|
|
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
|
|
18
|
-
`+K+I}}var J=!1,te;{var G=typeof WeakMap=="function"?WeakMap:Map;te=new G}function se(I,
|
|
17
|
+
*/var ll;function im(){return ll||(ll=1,process.env.NODE_ENV!=="production"&&function(){var e=y,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),x=Symbol.iterator,w="@@iterator";function g(I){if(I===null||typeof I!="object")return null;var B=x&&I[x]||I[w];return typeof B=="function"?B:null}var v=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(I){{for(var B=arguments.length,oe=new Array(B>1?B-1:0),ke=1;ke<B;ke++)oe[ke-1]=arguments[ke];S("error",I,oe)}}function S(I,B,oe){{var ke=v.ReactDebugCurrentFrame,Fe=ke.getStackAddendum();Fe!==""&&(B+="%s",oe=oe.concat([Fe]));var qe=oe.map(function(Ue){return String(Ue)});qe.unshift("Warning: "+B),Function.prototype.apply.call(console[I],console,qe)}}var N=!1,C=!1,k=!1,E=!1,A=!1,j;j=Symbol.for("react.module.reference");function P(I){return!!(typeof I=="string"||typeof I=="function"||I===r||I===s||A||I===o||I===u||I===d||E||I===p||N||C||k||typeof I=="object"&&I!==null&&(I.$$typeof===h||I.$$typeof===f||I.$$typeof===i||I.$$typeof===a||I.$$typeof===l||I.$$typeof===j||I.getModuleId!==void 0))}function L(I,B,oe){var ke=I.displayName;if(ke)return ke;var Fe=B.displayName||B.name||"";return Fe!==""?oe+"("+Fe+")":oe}function F(I){return I.displayName||"Context"}function V(I){if(I==null)return null;if(typeof I.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof I=="function")return I.displayName||I.name||null;if(typeof I=="string")return I;switch(I){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case u:return"Suspense";case d:return"SuspenseList"}if(typeof I=="object")switch(I.$$typeof){case a:var B=I;return F(B)+".Consumer";case i:var oe=I;return F(oe._context)+".Provider";case l:return L(I,I.render,"ForwardRef");case f:var ke=I.displayName||null;return ke!==null?ke:V(I.type)||"Memo";case h:{var Fe=I,qe=Fe._payload,Ue=Fe._init;try{return V(Ue(qe))}catch{return null}}}return null}var M=Object.assign,Y=0,q,W,z,$,ue,D,ee;function fe(){}fe.__reactDisabledLog=!0;function ve(){{if(Y===0){q=console.log,W=console.info,z=console.warn,$=console.error,ue=console.group,D=console.groupCollapsed,ee=console.groupEnd;var I={configurable:!0,enumerable:!0,value:fe,writable:!0};Object.defineProperties(console,{info:I,log:I,warn:I,error:I,group:I,groupCollapsed:I,groupEnd:I})}Y++}}function be(){{if(Y--,Y===0){var I={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:M({},I,{value:q}),info:M({},I,{value:W}),warn:M({},I,{value:z}),error:M({},I,{value:$}),group:M({},I,{value:ue}),groupCollapsed:M({},I,{value:D}),groupEnd:M({},I,{value:ee})})}Y<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ye=v.ReactCurrentDispatcher,K;function O(I,B,oe){{if(K===void 0)try{throw Error()}catch(Fe){var ke=Fe.stack.trim().match(/\n( *(at )?)/);K=ke&&ke[1]||""}return`
|
|
18
|
+
`+K+I}}var J=!1,te;{var G=typeof WeakMap=="function"?WeakMap:Map;te=new G}function se(I,B){if(!I||J)return"";{var oe=te.get(I);if(oe!==void 0)return oe}var ke;J=!0;var Fe=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var qe;qe=ye.current,ye.current=null,ve();try{if(B){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(ne){ke=ne}Reflect.construct(I,[],Ue)}else{try{Ue.call()}catch(ne){ke=ne}I.call(Ue.prototype)}}else{try{throw Error()}catch(ne){ke=ne}I()}}catch(ne){if(ne&&ke&&typeof ne.stack=="string"){for(var He=ne.stack.split(`
|
|
19
19
|
`),Ct=ke.stack.split(`
|
|
20
20
|
`),ct=He.length-1,T=Ct.length-1;ct>=1&&T>=0&&He[ct]!==Ct[T];)T--;for(;ct>=1&&T>=0;ct--,T--)if(He[ct]!==Ct[T]){if(ct!==1||T!==1)do if(ct--,T--,T<0||He[ct]!==Ct[T]){var _=`
|
|
21
|
-
`+He[ct].replace(" at new "," at ");return I.displayName&&_.includes("<anonymous>")&&(_=_.replace("<anonymous>",I.displayName)),typeof I=="function"&&te.set(I,_),_}while(ct>=1&&T>=0);break}}}finally{J=!1,ye.current=qe,be(),Error.prepareStackTrace=Fe}var
|
|
21
|
+
`+He[ct].replace(" at new "," at ");return I.displayName&&_.includes("<anonymous>")&&(_=_.replace("<anonymous>",I.displayName)),typeof I=="function"&&te.set(I,_),_}while(ct>=1&&T>=0);break}}}finally{J=!1,ye.current=qe,be(),Error.prepareStackTrace=Fe}var U=I?I.displayName||I.name:"",he=U?O(U):"";return typeof I=="function"&&te.set(I,he),he}function Ve(I,B,oe){return se(I,!1)}function Je(I){var B=I.prototype;return!!(B&&B.isReactComponent)}function nt(I,B,oe){if(I==null)return"";if(typeof I=="function")return se(I,Je(I));if(typeof I=="string")return O(I);switch(I){case u:return O("Suspense");case d:return O("SuspenseList")}if(typeof I=="object")switch(I.$$typeof){case l:return Ve(I.render);case f:return nt(I.type,B,oe);case h:{var ke=I,Fe=ke._payload,qe=ke._init;try{return nt(qe(Fe),B,oe)}catch{}}}return""}var De=Object.prototype.hasOwnProperty,Be={},Ee=v.ReactDebugCurrentFrame;function Ze(I){if(I){var B=I._owner,oe=nt(I.type,I._source,B?B.type:null);Ee.setExtraStackFrame(oe)}else Ee.setExtraStackFrame(null)}function wt(I,B,oe,ke,Fe){{var qe=Function.call.bind(De);for(var Ue in I)if(qe(I,Ue)){var He=void 0;try{if(typeof I[Ue]!="function"){var Ct=Error((ke||"React class")+": "+oe+" 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 Ct.name="Invariant Violation",Ct}He=I[Ue](B,Ue,ke,oe,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ct){He=ct}He&&!(He instanceof Error)&&(Ze(Fe),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",ke||"React class",oe,Ue,typeof He),Ze(null)),He instanceof Error&&!(He.message in Be)&&(Be[He.message]=!0,Ze(Fe),b("Failed %s type: %s",oe,He.message),Ze(null))}}}var ht=Array.isArray;function Z(I){return ht(I)}function re(I){{var B=typeof Symbol=="function"&&Symbol.toStringTag,oe=B&&I[Symbol.toStringTag]||I.constructor.name||"Object";return oe}}function pe(I){try{return Ne(I),!1}catch{return!0}}function Ne(I){return""+I}function we(I){if(pe(I))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",re(I)),Ne(I)}var Ae=v.ReactCurrentOwner,Qe={key:!0,ref:!0,__self:!0,__source:!0},ze,lt;function St(I){if(De.call(I,"ref")){var B=Object.getOwnPropertyDescriptor(I,"ref").get;if(B&&B.isReactWarning)return!1}return I.ref!==void 0}function Ut(I){if(De.call(I,"key")){var B=Object.getOwnPropertyDescriptor(I,"key").get;if(B&&B.isReactWarning)return!1}return I.key!==void 0}function gt(I,B){typeof I.ref=="string"&&Ae.current}function Rr(I,B){{var oe=function(){ze||(ze=!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)",B))};oe.isReactWarning=!0,Object.defineProperty(I,"key",{get:oe,configurable:!0})}}function cr(I,B){{var oe=function(){lt||(lt=!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)",B))};oe.isReactWarning=!0,Object.defineProperty(I,"ref",{get:oe,configurable:!0})}}var bt=function(I,B,oe,ke,Fe,qe,Ue){var He={$$typeof:t,type:I,key:B,ref:oe,props:Ue,_owner:qe};return He._store={},Object.defineProperty(He._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(He,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ke}),Object.defineProperty(He,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Fe}),Object.freeze&&(Object.freeze(He.props),Object.freeze(He)),He};function Sn(I,B,oe,ke,Fe){{var qe,Ue={},He=null,Ct=null;oe!==void 0&&(we(oe),He=""+oe),Ut(B)&&(we(B.key),He=""+B.key),St(B)&&(Ct=B.ref,gt(B,Fe));for(qe in B)De.call(B,qe)&&!Qe.hasOwnProperty(qe)&&(Ue[qe]=B[qe]);if(I&&I.defaultProps){var ct=I.defaultProps;for(qe in ct)Ue[qe]===void 0&&(Ue[qe]=ct[qe])}if(He||Ct){var T=typeof I=="function"?I.displayName||I.name||"Unknown":I;He&&Rr(Ue,T),Ct&&cr(Ue,T)}return bt(I,He,Ct,Fe,ke,Ae.current,Ue)}}var an=v.ReactCurrentOwner,ur=v.ReactDebugCurrentFrame;function Nt(I){if(I){var B=I._owner,oe=nt(I.type,I._source,B?B.type:null);ur.setExtraStackFrame(oe)}else ur.setExtraStackFrame(null)}var ln;ln=!1;function Xt(I){return typeof I=="object"&&I!==null&&I.$$typeof===t}function cn(){{if(an.current){var I=V(an.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 dr(I){return""}var Pr={};function Or(I){{var B=cn();if(!B){var oe=typeof I=="string"?I:I.displayName||I.name;oe&&(B=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+oe+">.")}return
|
|
25
|
+
Check the top-level render call using <`+oe+">.")}return B}}function fr(I,B){{if(!I._store||I._store.validated||I.key!=null)return;I._store.validated=!0;var oe=Or(B);if(Pr[oe])return;Pr[oe]=!0;var ke="";I&&I._owner&&I._owner!==an.current&&(ke=" It was passed a child from "+V(I._owner.type)+"."),Nt(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.',oe,ke),Nt(null)}}function Nn(I,B){{if(typeof I!="object")return;if(Z(I))for(var oe=0;oe<I.length;oe++){var ke=I[oe];Xt(ke)&&fr(ke,B)}else if(Xt(I))I._store&&(I._store.validated=!0);else if(I){var Fe=g(I);if(typeof Fe=="function"&&Fe!==I.entries)for(var qe=Fe.call(I),Ue;!(Ue=qe.next()).done;)Xt(Ue.value)&&fr(Ue.value,B)}}}function Mr(I){{var B=I.type;if(B==null||typeof B=="string")return;var oe;if(typeof B=="function")oe=B.propTypes;else if(typeof B=="object"&&(B.$$typeof===l||B.$$typeof===f))oe=B.propTypes;else return;if(oe){var ke=V(B);wt(oe,I.props,"prop",ke,I)}else if(B.PropTypes!==void 0&&!ln){ln=!0;var Fe=V(B);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Fe||"Unknown")}typeof B.getDefaultProps=="function"&&!B.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function An(I){{for(var B=Object.keys(I.props),oe=0;oe<B.length;oe++){var ke=B[oe];if(ke!=="children"&&ke!=="key"){Nt(I),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ke),Nt(null);break}}I.ref!==null&&(Nt(I),b("Invalid attribute `ref` supplied to `React.Fragment`."),Nt(null))}}var hr={};function ae(I,B,oe,ke,Fe,qe){{var Ue=P(I);if(!Ue){var He="";(I===void 0||typeof I=="object"&&I!==null&&Object.keys(I).length===0)&&(He+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Ct=dr();Ct?He+=Ct:He+=cn();var ct;I===null?ct="null":Z(I)?ct="array":I!==void 0&&I.$$typeof===t?(ct="<"+(V(I.type)||"Unknown")+" />",He=" Did you accidentally export a JSX literal instead of a component?"):ct=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",ct,He)}var T=Sn(I,B,oe,Fe,qe);if(T==null)return T;if(Ue){var _=B.children;if(_!==void 0)if(ke)if(Z(_)){for(var U=0;U<_.length;U++)Nn(_[U],I);Object.freeze&&Object.freeze(_)}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 Nn(_,I)}if(De.call(B,"key")){var he=V(I),ne=Object.keys(B).filter(function(xt){return xt!=="key"}),xe=ne.length>0?"{key: someKey, "+ne.join(": ..., ")+": ...}":"{key: someKey}";if(!hr[he+xe]){var me=ne.length>0?"{"+ne.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} />`,xe,he,me,he),fr[he+xe]=!0}}return I===r?Nn(T):Or(T),T}}function Te(I,H,oe){return ae(I,H,oe,!0)}function Oe(I,H,oe){return ae(I,H,oe,!1)}var rt=Oe,_t=Te;Lr.Fragment=r,Lr.jsx=rt,Lr.jsxs=_t}()),Lr}process.env.NODE_ENV==="production"?Js.exports=em():Js.exports=tm();var c=Js.exports;function al(e,t){return function(){return e.apply(t,arguments)}}const{toString:nm}=Object.prototype,{getPrototypeOf:Zs}=Object,{iterator:xo,toStringTag:ll}=Symbol,vo=(e=>t=>{const n=nm.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Jt=e=>(e=e.toLowerCase(),t=>vo(t)===e),wo=e=>t=>typeof t===e,{isArray:hr}=Array,pr=wo("undefined");function Fr(e){return e!==null&&!pr(e)&&e.constructor!==null&&!pr(e.constructor)&&Rt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const cl=Jt("ArrayBuffer");function rm(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&cl(e.buffer),t}const om=wo("string"),Rt=wo("function"),ul=wo("number"),$r=e=>e!==null&&typeof e=="object",sm=e=>e===!0||e===!1,bo=e=>{if(vo(e)!=="object")return!1;const t=Zs(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ll in e)&&!(xo in e)},im=e=>{if(!$r(e)||Fr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},am=Jt("Date"),lm=Jt("File"),cm=Jt("Blob"),um=Jt("FileList"),dm=e=>$r(e)&&Rt(e.pipe),fm=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Rt(e.append)&&((t=vo(e))==="formdata"||t==="object"&&Rt(e.toString)&&e.toString()==="[object FormData]"))},hm=Jt("URLSearchParams"),[pm,mm,gm,xm]=["ReadableStream","Request","Response","Headers"].map(Jt),vm=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function zr(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(Fr(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 dl(e,t){if(Fr(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Wn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,fl=e=>!pr(e)&&e!==Wn;function Qs(){const{caseless:e,skipUndefined:t}=fl(this)&&this||{},n={},r=(o,s)=>{const i=e&&dl(n,s)||s;bo(n[i])&&bo(o)?n[i]=Qs(n[i],o):bo(o)?n[i]=Qs({},o):hr(o)?n[i]=o.slice():(!t||!pr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&zr(arguments[o],r);return n}const wm=(e,t,n,{allOwnKeys:r}={})=>(zr(t,(o,s)=>{n&&Rt(o)?e[s]=al(o,n):e[s]=o},{allOwnKeys:r}),e),bm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),ym=(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)},Sm=(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&&Zs(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Cm=(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},Tm=e=>{if(!e)return null;if(hr(e))return e;let t=e.length;if(!ul(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},km=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Zs(Uint8Array)),Im=(e,t)=>{const r=(e&&e[xo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Em=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Nm=Jt("HTMLFormElement"),Am=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),hl=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),jm=Jt("RegExp"),pl=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};zr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},_m=e=>{pl(e,(t,n)=>{if(Rt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Rt(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+"'")})}})},Rm=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return hr(e)?r(e):r(String(e).split(t)),n},Pm=()=>{},Om=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Mm(e){return!!(e&&Rt(e.append)&&e[ll]==="FormData"&&e[xo])}const Dm=e=>{const t=new Array(10),n=(r,o)=>{if($r(r)){if(t.indexOf(r)>=0)return;if(Fr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=hr(r)?[]:{};return zr(r,(i,a)=>{const l=n(i,o+1);!pr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},Lm=Jt("AsyncFunction"),Fm=e=>e&&($r(e)||Rt(e))&&Rt(e.then)&&Rt(e.catch),ml=((e,t)=>e?setImmediate:t?((n,r)=>(Wn.addEventListener("message",({source:o,data:s})=>{o===Wn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Wn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Rt(Wn.postMessage)),$m=typeof queueMicrotask<"u"?queueMicrotask.bind(Wn):typeof process<"u"&&process.nextTick||ml,R={isArray:hr,isArrayBuffer:cl,isBuffer:Fr,isFormData:fm,isArrayBufferView:rm,isString:om,isNumber:ul,isBoolean:sm,isObject:$r,isPlainObject:bo,isEmptyObject:im,isReadableStream:pm,isRequest:mm,isResponse:gm,isHeaders:xm,isUndefined:pr,isDate:am,isFile:lm,isBlob:cm,isRegExp:jm,isFunction:Rt,isStream:dm,isURLSearchParams:hm,isTypedArray:km,isFileList:um,forEach:zr,merge:Qs,extend:wm,trim:vm,stripBOM:bm,inherits:ym,toFlatObject:Sm,kindOf:vo,kindOfTest:Jt,endsWith:Cm,toArray:Tm,forEachEntry:Im,matchAll:Em,isHTMLForm:Nm,hasOwnProperty:hl,hasOwnProp:hl,reduceDescriptors:pl,freezeMethods:_m,toObjectSet:Rm,toCamelCase:Am,noop:Pm,toFiniteNumber:Om,findKey:dl,global:Wn,isContextDefined:fl,isSpecCompliantForm:Mm,toJSONObject:Dm,isAsyncFn:Lm,isThenable:Fm,setImmediate:ml,asap:$m,isIterable:e=>e!=null&&Rt(e[xo])};function Me(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}R.inherits(Me,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:R.toJSONObject(this.config),code:this.code,status:this.status}}});const gl=Me.prototype,xl={};["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=>{xl[e]={value:e}}),Object.defineProperties(Me,xl),Object.defineProperty(gl,"isAxiosError",{value:!0}),Me.from=(e,t,n,r,o,s)=>{const i=Object.create(gl);R.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Me.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 zm=null;function ei(e){return R.isPlainObject(e)||R.isArray(e)}function vl(e){return R.endsWith(e,"[]")?e.slice(0,-2):e}function wl(e,t,n){return e?e.concat(t).map(function(o,s){return o=vl(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function Bm(e){return R.isArray(e)&&!e.some(ei)}const Hm=R.toFlatObject(R,{},null,function(t){return/^is[A-Z]/.test(t)});function yo(e,t,n){if(!R.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=R.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(w,g){return!R.isUndefined(g[w])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&R.isSpecCompliantForm(t);if(!R.isFunction(o))throw new TypeError("visitor must be a function");function u(v){if(v===null)return"";if(R.isDate(v))return v.toISOString();if(R.isBoolean(v))return v.toString();if(!l&&R.isBlob(v))throw new Me("Blob is not supported. Use a Buffer instead.");return R.isArrayBuffer(v)||R.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,w,g){let x=v;if(v&&!g&&typeof v=="object"){if(R.endsWith(w,"{}"))w=r?w:w.slice(0,-2),v=JSON.stringify(v);else if(R.isArray(v)&&Bm(v)||(R.isFileList(v)||R.endsWith(w,"[]"))&&(x=R.toArray(v)))return w=vl(w),x.forEach(function(S,N){!(R.isUndefined(S)||S===null)&&t.append(i===!0?wl([w],N,s):i===null?w:w+"[]",u(S))}),!1}return ei(v)?!0:(t.append(wl(g,w,s),u(v)),!1)}const f=[],h=Object.assign(Hm,{defaultVisitor:d,convertValue:u,isVisitable:ei});function p(v,w){if(!R.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+w.join("."));f.push(v),R.forEach(v,function(x,b){(!(R.isUndefined(x)||x===null)&&o.call(t,x,R.isString(b)?b.trim():b,w,h))===!0&&p(x,w?w.concat(b):[b])}),f.pop()}}if(!R.isObject(e))throw new TypeError("data must be an object");return p(e),t}function bl(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function ti(e,t){this._pairs=[],e&&yo(e,this,t)}const yl=ti.prototype;yl.append=function(t,n){this._pairs.push([t,n])},yl.toString=function(t){const n=t?function(r){return t.call(this,r,bl)}:bl;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function Um(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Sl(e,t,n){if(!t)return e;const r=n&&n.encode||Um;R.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=R.isURLSearchParams(t)?t.toString():new ti(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Cl{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){R.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Tl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Wm={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:ti,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},ni=typeof window<"u"&&typeof document<"u",ri=typeof navigator=="object"&&navigator||void 0,Vm=ni&&(!ri||["ReactNative","NativeScript","NS"].indexOf(ri.product)<0),qm=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Km=ni&&window.location.href||"http://localhost",Tt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ni,hasStandardBrowserEnv:Vm,hasStandardBrowserWebWorkerEnv:qm,navigator:ri,origin:Km},Symbol.toStringTag,{value:"Module"})),...Wm};function Gm(e,t){return yo(e,new Tt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Tt.isNode&&R.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Ym(e){return R.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Xm(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 kl(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&R.isArray(o)?o.length:i,l?(R.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!R.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&R.isArray(o[i])&&(o[i]=Xm(o[i])),!a)}if(R.isFormData(e)&&R.isFunction(e.entries)){const n={};return R.forEachEntry(e,(r,o)=>{t(Ym(r),o,n,0)}),n}return null}function Jm(e,t,n){if(R.isString(e))try{return(t||JSON.parse)(e),R.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Br={transitional:Tl,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=R.isObject(t);if(s&&R.isHTMLForm(t)&&(t=new FormData(t)),R.isFormData(t))return o?JSON.stringify(kl(t)):t;if(R.isArrayBuffer(t)||R.isBuffer(t)||R.isStream(t)||R.isFile(t)||R.isBlob(t)||R.isReadableStream(t))return t;if(R.isArrayBufferView(t))return t.buffer;if(R.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Gm(t,this.formSerializer).toString();if((a=R.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return yo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Jm(t)):t}],transformResponse:[function(t){const n=this.transitional||Br.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(R.isResponse(t)||R.isReadableStream(t))return t;if(t&&R.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Me.from(a,Me.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:Tt.classes.FormData,Blob:Tt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};R.forEach(["delete","get","head","post","put","patch"],e=>{Br.headers[e]={}});const Zm=R.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Qm=e=>{const t={};let n,r,o;return e&&e.split(`
|
|
31
|
-
`).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&
|
|
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[Il]=this[Il]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Hr(i);r[a]||(rg(o,i),r[a]=!0)}return R.isArray(t)?t.forEach(s):s(t),this}};Pt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),R.reduceDescriptors(Pt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),R.freezeMethods(Pt);function si(e,t){const n=this||Br,r=t||n,o=Pt.from(r.headers);let s=r.data;return R.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function El(e){return!!(e&&e.__CANCEL__)}function mr(e,t,n){Me.call(this,e??"canceled",Me.ERR_CANCELED,t,n),this.name="CanceledError"}R.inherits(mr,Me,{__CANCEL__:!0});function Nl(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Me("Request failed with status code "+n.status,[Me.ERR_BAD_REQUEST,Me.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function og(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function sg(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const u=Date.now(),d=r[s];i||(i=u),n[o]=l,r[o]=u;let f=s,h=0;for(;f!==o;)h+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const p=d&&u-d;return p?Math.round(h*1e3/p):void 0}}function ig(e,t){let n=0,r=1e3/t,o,s;const i=(u,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...u)};return[(...u)=>{const d=Date.now(),f=d-n;f>=r?i(u,d):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const Co=(e,t,n=3)=>{let r=0;const o=sg(50,250);return ig(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,u=o(l),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:u||void 0,estimated:u&&a&&d?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},Al=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},jl=e=>(...t)=>R.asap(()=>e(...t)),ag=Tt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Tt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Tt.origin),Tt.navigator&&/(msie|trident)/i.test(Tt.navigator.userAgent)):()=>!0,lg=Tt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];R.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),R.isString(r)&&i.push("path="+r),R.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function cg(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function ug(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function _l(e,t,n){let r=!cg(t);return e&&(r||n==!1)?ug(e,t):t}const Rl=e=>e instanceof Pt?{...e}:e;function Vn(e,t){t=t||{};const n={};function r(u,d,f,h){return R.isPlainObject(u)&&R.isPlainObject(d)?R.merge.call({caseless:h},u,d):R.isPlainObject(d)?R.merge({},d):R.isArray(d)?d.slice():d}function o(u,d,f,h){if(R.isUndefined(d)){if(!R.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!R.isUndefined(d))return r(void 0,d)}function i(u,d){if(R.isUndefined(d)){if(!R.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function a(u,d,f){if(f in t)return r(u,d);if(f in e)return r(void 0,u)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(u,d,f)=>o(Rl(u),Rl(d),f,!0)};return R.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,h=f(e[d],t[d],d);R.isUndefined(h)&&f!==a||(n[d]=h)}),n}const Pl=e=>{const t=Vn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Pt.from(i),t.url=Sl(_l(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),R.isFormData(n)){if(Tt.hasStandardBrowserEnv||Tt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(R.isFunction(n.getHeaders)){const l=n.getHeaders(),u=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{u.includes(d.toLowerCase())&&i.set(d,f)})}}if(Tt.hasStandardBrowserEnv&&(r&&R.isFunction(r)&&(r=r(t)),r||r!==!1&&ag(t.url))){const l=o&&s&&lg.read(s);l&&i.set(o,l)}return t},dg=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Pl(e);let s=o.data;const i=Pt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=o,d,f,h,p,v;function w(){p&&p(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function x(){if(!g)return;const S=Pt.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:S,config:e,request:g};Nl(function(E){n(E),w()},function(E){r(E),w()},C),g=null}"onloadend"in g?g.onloadend=x:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(x)},g.onabort=function(){g&&(r(new Me("Request aborted",Me.ECONNABORTED,e,g)),g=null)},g.onerror=function(N){const C=N&&N.message?N.message:"Network Error",k=new Me(C,Me.ERR_NETWORK,e,g);k.event=N||null,r(k),g=null},g.ontimeout=function(){let N=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||Tl;o.timeoutErrorMessage&&(N=o.timeoutErrorMessage),r(new Me(N,C.clarifyTimeoutError?Me.ETIMEDOUT:Me.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&R.forEach(i.toJSON(),function(N,C){g.setRequestHeader(C,N)}),R.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,v]=Co(u,!0),g.addEventListener("progress",h)),l&&g.upload&&([f,p]=Co(l),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=S=>{g&&(r(!S||S.type?new mr(null,e,g):S),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=og(o.url);if(b&&Tt.protocols.indexOf(b)===-1){r(new Me("Unsupported protocol "+b+":",Me.ERR_BAD_REQUEST,e));return}g.send(s||null)})},fg=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(u){if(!o){o=!0,a();const d=u instanceof Error?u:this.reason;r.abort(d instanceof Me?d:new mr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Me(`timeout ${t} of ms exceeded`,Me.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>R.asap(a),l}},hg=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},pg=async function*(e,t){for await(const n of mg(e))yield*hg(n,t)},mg=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()}},Ol=(e,t,n,r)=>{const o=pg(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:u,value:d}=await o.next();if(u){a(),l.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}l.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Ml=64*1024,{isFunction:To}=R,gg=(({Request:e,Response:t})=>({Request:e,Response:t}))(R.global),{ReadableStream:Dl,TextEncoder:Ll}=R.global,Fl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},xg=e=>{e=R.merge.call({skipUndefined:!0},gg,e);const{fetch:t,Request:n,Response:r}=e,o=t?To(t):typeof fetch=="function",s=To(n),i=To(r);if(!o)return!1;const a=o&&To(Dl),l=o&&(typeof Ll=="function"?(v=>w=>v.encode(w))(new Ll):async v=>new Uint8Array(await new n(v).arrayBuffer())),u=s&&a&&Fl(()=>{let v=!1;const w=new n(Tt.origin,{body:new Dl,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!w}),d=i&&a&&Fl(()=>R.isReadableStream(new r("").body)),f={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!f[v]&&(f[v]=(w,g)=>{let x=w&&w[v];if(x)return x.call(w);throw new Me(`Response type '${v}' is not supported`,Me.ERR_NOT_SUPPORT,g)})});const h=async v=>{if(v==null)return 0;if(R.isBlob(v))return v.size;if(R.isSpecCompliantForm(v))return(await new n(Tt.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(R.isArrayBufferView(v)||R.isArrayBuffer(v))return v.byteLength;if(R.isURLSearchParams(v)&&(v=v+""),R.isString(v))return(await l(v)).byteLength},p=async(v,w)=>{const g=R.toFiniteNumber(v.getContentLength());return g??h(w)};return async v=>{let{url:w,method:g,data:x,signal:b,cancelToken:S,timeout:N,onDownloadProgress:C,onUploadProgress:k,responseType:E,headers:A,withCredentials:j="same-origin",fetchOptions:P}=Pl(v),L=t||fetch;E=E?(E+"").toLowerCase():"text";let F=fg([b,S&&S.toAbortSignal()],N),V=null;const M=F&&F.unsubscribe&&(()=>{F.unsubscribe()});let Y;try{if(k&&u&&g!=="get"&&g!=="head"&&(Y=await p(A,x))!==0){let D=new n(w,{method:"POST",body:x,duplex:"half"}),ee;if(R.isFormData(x)&&(ee=D.headers.get("content-type"))&&A.setContentType(ee),D.body){const[fe,ve]=Al(Y,Co(jl(k)));x=Ol(D.body,Ml,fe,ve)}}R.isString(j)||(j=j?"include":"omit");const q=s&&"credentials"in n.prototype,W={...P,signal:F,method:g.toUpperCase(),headers:A.normalize().toJSON(),body:x,duplex:"half",credentials:q?j:void 0};V=s&&new n(w,W);let z=await(s?L(V,P):L(w,W));const $=d&&(E==="stream"||E==="response");if(d&&(C||$&&M)){const D={};["status","statusText","headers"].forEach(be=>{D[be]=z[be]});const ee=R.toFiniteNumber(z.headers.get("content-length")),[fe,ve]=C&&Al(ee,Co(jl(C),!0))||[];z=new r(Ol(z.body,Ml,fe,()=>{ve&&ve(),M&&M()}),D)}E=E||"text";let ue=await f[R.findKey(f,E)||"text"](z,v);return!$&&M&&M(),await new Promise((D,ee)=>{Nl(D,ee,{data:ue,headers:Pt.from(z.headers),status:z.status,statusText:z.statusText,config:v,request:V})})}catch(q){throw M&&M(),q&&q.name==="TypeError"&&/Load failed|fetch/i.test(q.message)?Object.assign(new Me("Network Error",Me.ERR_NETWORK,v,V),{cause:q.cause||q}):Me.from(q,q&&q.code,v,V)}}},vg=new Map,$l=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,u,d=vg;for(;a--;)l=s[a],u=d.get(l),u===void 0&&d.set(l,u=a?new Map:xg(t)),d=u;return u};$l();const ii={http:zm,xhr:dg,fetch:{get:$l}};R.forEach(ii,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const zl=e=>`- ${e}`,wg=e=>R.isFunction(e)||e===null||e===!1,Bl={getAdapter:(e,t)=>{e=R.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){r=e[i];let a;if(o=r,!wg(r)&&(o=ii[(a=String(r)).toLowerCase()],o===void 0))throw new Me(`Unknown adapter '${a}'`);if(o&&(R.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,u])=>`adapter ${l} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
33
|
-
`+i.map(
|
|
34
|
-
`):" "+
|
|
35
|
-
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Vn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Io.assertOptions(r,{silentJSONParsing:ln.transitional(ln.boolean),forcedJSONParsing:ln.transitional(ln.boolean),clarifyTimeoutError:ln.transitional(ln.boolean)},!1),o!=null&&(R.isFunction(o)?n.paramsSerializer={serialize:o}:Io.assertOptions(o,{encode:ln.function,serialize:ln.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Io.assertOptions(n,{baseUrl:ln.spelling("baseURL"),withXsrfToken:ln.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&R.merge(s.common,s[n.method]);s&&R.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Pt.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(w){typeof w.runWhen=="function"&&w.runWhen(n)===!1||(l=l&&w.synchronous,a.unshift(w.fulfilled,w.rejected))});const u=[];this.interceptors.response.forEach(function(w){u.push(w.fulfilled,w.rejected)});let d,f=0,h;if(!l){const v=[Hl.bind(this),void 0];for(v.unshift(...a),v.push(...u),h=v.length,d=Promise.resolve(n);f<h;)d=d.then(v[f++],v[f++]);return d}h=a.length;let p=n;for(;f<h;){const v=a[f++],w=a[f++];try{p=v(p)}catch(g){w.call(this,g);break}}try{d=Hl.call(this,p)}catch(v){return Promise.reject(v)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=Vn(this.defaults,t);const n=_l(t.baseURL,t.url,t.allowAbsoluteUrls);return Sl(n,t.params,t.paramsSerializer)}};R.forEach(["delete","get","head","options"],function(t){qn.prototype[t]=function(n,r){return this.request(Vn(r||{},{method:t,url:n,data:(r||{}).data}))}}),R.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Vn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}qn.prototype[t]=n(),qn.prototype[t+"Form"]=n(!0)});let yg=class Jp{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 mr(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 Jp(function(o){t=o}),cancel:t}}};function Sg(e){return function(n){return e.apply(null,n)}}function Cg(e){return R.isObject(e)&&e.isAxiosError===!0}const li={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(li).forEach(([e,t])=>{li[t]=e});function Vl(e){const t=new qn(e),n=al(qn.prototype.request,t);return R.extend(n,qn.prototype,t,{allOwnKeys:!0}),R.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Vl(Vn(e,o))},n}const dt=Vl(Br);dt.Axios=qn,dt.CanceledError=mr,dt.CancelToken=yg,dt.isCancel=El,dt.VERSION=Ul,dt.toFormData=yo,dt.AxiosError=Me,dt.Cancel=dt.CanceledError,dt.all=function(t){return Promise.all(t)},dt.spread=Sg,dt.isAxiosError=Cg,dt.mergeConfig=Vn,dt.AxiosHeaders=Pt,dt.formToJSON=e=>kl(R.isHTMLForm(e)?new FormData(e):e),dt.getAdapter=Bl.getAdapter,dt.HttpStatusCode=li,dt.default=dt;const{Axios:ZC,AxiosError:QC,CanceledError:eT,isCancel:tT,CancelToken:nT,VERSION:rT,all:oT,Cancel:sT,isAxiosError:iT,spread:aT,toFormData:lT,AxiosHeaders:cT,HttpStatusCode:uT,formToJSON:dT,getAdapter:fT,mergeConfig:hT}=dt,ql=typeof window<"u"?window.__API_BASE_URL__:void 0,Kl=ql?Cn(ql):void 0;function Cn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Eo=null;const ci=new Set;function Gl(){return Eo}function ui(e){Eo=e,ci.forEach(t=>t(e))}function Yl(e){return ci.add(e),()=>ci.delete(e)}const Ut=dt.create({...Kl?{baseURL:Kl}:{},timeout:3e4,withCredentials:!0});Ut.interceptors.request.use(e=>(Eo&&(e.headers.Authorization=`Bearer ${Eo}`),e)),Ut.interceptors.response.use(e=>e,e=>Promise.reject(e));async function Mt(e,t){return Ut.defaults.baseURL?(await Ut.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function di(e,t,n){return Ut.defaults.baseURL?(await Ut.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Xl(e,t,n){return Ut.defaults.baseURL?(await Ut.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Jl(e,t){return Ut.defaults.baseURL?(await Ut.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Dt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Zl{get baseUrl(){const t=Ut.defaults.baseURL;return t?Cn(String(t)):""}updateConfig(t){t.baseUrl&&(Ut.defaults.baseURL=Cn(String(t.baseUrl))),t.authToken!==void 0&&ui(t.authToken)}getAuthToken(){return Gl()}setAuthToken(t){ui(t)}onTokenChange(t){return Yl(t)}async listThreads(){const t=await Mt("/threads"),n=Dt(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 Dt(r)}async updateThread(t,n){const r=await Xl(`/threads/${t}`,{title:n});return Dt(r)}async deleteThread(t){const n=await Jl(`/threads/${t}`);return Dt(n)}async threadInfo(t){const n=await Mt(`/threads/${t}/info`);return Dt(n)}async listAgents(){const t=await Mt("/agents"),n=Dt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Mt(`/agents/${t}`);return Dt(n)}async getAgentSchema(t){const n=await Mt(`/agents/${t}/schema`);return Dt(n)}async getMessages(t){const n=await Mt(`/threads/${t.threadId}/messages`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs,limit:t.limit,before_id:t.beforeId??void 0}});return Dt(n)}async getState(t){const n=await Mt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Dt(n)}async getStateHistory(t){const n=await Mt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Dt(n)}async listCheckpoints(t){const n=await Mt(`/threads/${t}/checkpoints`,{params:{thread_id:t}});return Dt(n)}resumeStream(t){}async resume(t){const n=await di("/runs/resume",{thread_id:t.threadId,value:t.value});return Dt(n)}}const jn=new Zl,Ql=y.createContext(null);function Tg({children:e,apiConfig:t}){const n=jn;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return c.jsx(Ql.Provider,{value:r,children:e})}function fi(){const e=y.useContext(Ql);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function kg(e,t){const n=e==null?void 0:e.checkpoints,r=Array.isArray(n)?n.slice():n?Object.values(n):[],o=i=>i&&typeof i=="object"&&i!==null&&"checkpointId"in i&&"createdAt"in i&&typeof i.checkpointId=="string"&&typeof i.createdAt=="string",s=r.filter(o).map(i=>{const a=i;return{checkpointId:a.checkpointId,checkpointNs:a.checkpointNs??"",createdAt:a.createdAt,messagesLen:a.messagesLen??0,preview:a.preview??"",role:a.role??null,parentId:a.parentId??null,editedMessageId:a.editedMessageId??null,branchLabel:a.branchLabel??null,lastMessageId:a.lastMessageId??null,hasMessages:typeof a.hasMessages=="boolean"?a.hasMessages:void 0}});return{threadId:(e==null?void 0:e.threadId)??t??null,checkpoints:s}}async function Ig(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 Eg(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const u=await Ig(l);a.push({filename:l.name,data:u,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}function Ng(e){return e.type!=="thread_info"&&e.type!=="token"}const Ag={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,messagesStreamMeta:{}};function jg(e,t){var n;switch(t.type){case"reset":{console.log("[MessageReducer] 🔄 RESET action received"),console.log("[MessageReducer] 📊 Before reset - messages count:",e.messages.length);const r={messages:hi(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};return console.log("[MessageReducer] 📊 After reset - messages count:",r.messages.length),r}case"seed":{const r=hi(t.payload.messages),o={...e,messages:r,assemblingId:null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),console.log("[MessageReducer] seed action (REPLACE mode):",{incomingCount:t.payload.messages.length,sanitizedCount:r.length,previousCount:e.messages.length,checkpointId:o.lastCheckpointId}),o}case"prepend":{const r=hi(t.payload.messages);if(!r.length)return console.log("[MessageReducer] No incoming messages after sanitize - skipping"),e;const o=new Set(e.messages.map(i=>i.id)),s=r.filter(i=>!o.has(i.id));return console.log("[MessageReducer] After dedup:",{uniqueCount:s.length,duplicates:r.length-s.length,finalTotal:s.length+e.messages.length}),s.length?{...e,messages:[...s,...e.messages]}:(console.log("[MessageReducer] All messages were duplicates - skipping"),e)}case"user_message":{const r=t.payload.message;return e.messages.some(o=>o.id===r.id)?e:{...e,messages:[...e.messages,r]}}case"event":return 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":{const{interruptId:r}=t.payload,o=e.messages.map(s=>({...s,content:s.content.filter(i=>i.type!=="interrupt")}));return{...e,messages:o,pendingInterrupt:null}}default:return e}}function ec(e=[]){const[t,n]=y.useReducer(jg,{...Ag,messages:e}),r=y.useRef([]),o=y.useRef(null),s=y.useRef(null),i=y.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=y.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=y.useCallback(d=>{r.current.push(d),a()},[a]);y.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const u=y.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:d=>n({type:"user_message",payload:{message:d}}),onEvent:l}),[l]);return{state:t,dispatch:n,...u}}function tc(e,t){var n,r,o,s;if(t.type==="message_start"&&t.role==="assistant"){const i=t.id,a=Pg(t.model);if(e.messages.some(d=>d.id===i)){const d=e.messagesStreamMeta??{},f={...d,[i]:d[i]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:i,messagesStreamMeta:f}}const u={id:i,role:"assistant",name:a||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:i,messages:[...e.messages,u]}}if(t.type==="message_delta"){const i=e.assemblingId??pi(e.messages);if(!i)return e;const a=e.messages,l=a.findIndex(S=>S.id===i&&S.role==="assistant");if(l===-1)return e;const u=a[l],d=e.messagesStreamMeta??{},f=d[i]??{lastSeq:null,lastText:ic(u.content)},h=t.seq??null;if(h!==null&&typeof h=="number"&&typeof f.lastSeq=="number"&&h<=f.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:h,lastSeq:f.lastSeq}),e;const{newParts:p,newMeta:v,changed:w}=_g(u.content,t.delta,f,h);if(!w)return e;const g={...u,content:p},x=nc(a,l,g),b={...d,[i]:v};return{...e,messages:x,messagesStreamMeta:b}}if(t.type==="message_end"){const i=e.assemblingId??pi(e.messages);if(!i)return{...e,assemblingId:null};const a=e.messages,l=a.findIndex(u=>u.id===i&&u.role==="assistant");if(l>=0){const u=a[l];if(!((n=u.content)==null?void 0:n.some(f=>{var h;return(f==null?void 0:f.type)==="text"&&((h=f.text)==null?void 0:h.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:u.id,contentTypes:(r=u.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=u.content)==null?void 0:o.map(h=>(h==null?void 0:h.type)==="text"?String(h.text).slice(0,100):h==null?void 0:h.type)});const f=[...a.slice(0,l),...a.slice(l+1)];return{...e,assemblingId:null,messages:f}}}return e}if(t.type==="tool_start"){const i=t.id??t.call_id,a=t.name??t.tool??"tool";if(!i)return e;const l=`tool-${i}`,u={type:"tool_call",id:i,name:a,args:t.args};if(e.messages.find(h=>h.id===l))return{...e,toolIndex:{...e.toolIndex,[i]:l}};const f={id:l,role:"tool",name:a,createdAt:new Date().toISOString(),content:[u]};return{...e,messages:[...e.messages,f],toolIndex:{...e.toolIndex,[i]:l}}}if(t.type==="tool_end"){const i=t.id??t.call_id;if(!i)return e;const a=e.toolIndex[i]??`tool-${i}`,l={type:"tool_end",toolCallId:i,output:t.output,error:t.error},u=e.messages.find(h=>h.id===a),d={id:a,role:"tool",name:t.name??((s=e.messages.find(h=>h.id===a))==null?void 0:s.name),content:[l],createdAt:new Date().toISOString()},f=u?oc(e.messages,a,[l]):[...e.messages,d];return{...e,messages:f,toolIndex:{...e.toolIndex,[i]:a}}}if(t.type==="checkpoint"){const i=t.checkpointNs??e.lastCheckpointNs??null,a=Rg(e.messages,t.checkpointId,i);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:i,messages:a}}if(t.type==="branch"){const i=t.checkpointId??e.lastCheckpointId,a=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:i??null,lastCheckpointNs:a??null}}if(t.type==="error"){const i={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,i]}}if(t.type==="interrupt"){const i=e.assemblingId??pi(e.messages),a={type:"interrupt",value:t.value,id:t.id};if(i)return{...e,assemblingId:null,messages:oc(e.messages,i,[a]),pendingInterrupt:{id:t.id,value:t.value}};const l=`interrupt-${t.id}`;if(e.messages.findIndex(f=>f.id===l)!==-1)return{...e,assemblingId:null,messages:rc(e.messages,l,f=>({...f,content:sc(f.content??[],[a])})),pendingInterrupt:{id:t.id,value:t.value}};const d={id:l,role:"system",createdAt:new Date().toISOString(),content:[a]};return{...e,messages:[...e.messages,d],pendingInterrupt:{id:t.id,value:t.value}}}return e}function 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 nc(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function pi(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function rc(e,t,n){const r=e.findIndex(i=>i.id===t);if(r===-1)return e;const o=e[r],s=n(o);return s===o?e:[...e.slice(0,r),s,...e.slice(r+1)]}function oc(e,t,n){return rc(e,t,r=>({...r,content:sc(r.content,n)}))}function sc(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1],s=r.text??"";if(!s)continue;if((o==null?void 0:o.type)==="text"){let i=function(p){return p.replace(/\s+/g," ").trim()};const a=o,l=a.text??"";if(console.debug("[MessageReducer] mergeParts",{incomingLength:s.length,previousLength:l.length,incomingSnippet:s.slice(0,100),previousSnippet:l.slice(-100)}),!l){a.text=s;continue}const u=i(s),d=i(l);if(u.startsWith(d)||s.startsWith(l)){console.debug("[MessageReducer] incoming startsWith previous (norm/raw) - replacing",{incomingLength:s.length,previousLength:l.length}),a.text=s;continue}if(u.includes(d)){console.debug("[MessageReducer] incoming includes previous (normalized) - replacing",{incomingLength:s.length,previousLength:l.length}),a.text=s;continue}if(d.includes(u)&&u.length<=3){console.debug("[MessageReducer] previous includes incoming (normalized) - skipping trivial incoming",{incomingLength:s.length,previousLength:l.length});continue}const h=lc(l,s);h?(console.debug("[MessageReducer] suffix computed",{suffixLength:h.length}),a.text=l+h):(console.debug("[MessageReducer] no overlap detected - appending incoming",{incomingLength:s.length}),a.text=l+s)}else n.push({type:"text",text:s})}else n.push(r);return n}function ic(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function _g(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="",u=e.slice();if(s){const f=lc(a,s);if(f===""?l="":f===s?l=s:l=f,l){const h=u[u.length-1];if((h==null?void 0:h.type)==="text"){const p=h.text??"",v={...h,text:p+l};u=[...u.slice(0,u.length-1),v]}else u=[...u,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(u=[...u,...i]);const d=!!(l||i.length);return{newParts:u,newMeta:o,changed:d}}function ac(e){return e.replace(/\s+/g," ").trim()}function lc(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 Rg(e,t,n){for(let r=e.length-1;r>=0;r--)if(e[r].role==="assistant"){const s={...e[r],checkpointId:t,checkpointNs:n??void 0};return nc(e,r,s)}return e}function Pg(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function cc(e={}){const t=y.useMemo(()=>Cn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=y.useState(e.token??null),s=y.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=y.useState(!1),[u,d]=y.useState(null),[f,h]=y.useState(""),[p,v]=y.useState(null),[w,g]=y.useState(0),[x,b]=y.useState(!1),S=y.useRef(null),N=y.useRef(!0),C=y.useRef(0),k=y.useCallback(P=>{o(P)},[]),E=y.useCallback(()=>{var P;(P=S.current)==null||P.abort(),S.current=null,l(!1),b(!1),C.current=0,g(0)},[]),A=y.useCallback(()=>{h(""),v(null),d(null)},[]),j=y.useCallback((P,L,F)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h("");const V=new AbortController;return S.current=V,(async()=>{var Y,q,W,z,$,ue,D,ee;const M=fe=>{var ve;try{const be=JSON.parse(JSON.stringify(fe));return(ve=be==null?void 0:be.payload)!=null&&ve.files_info&&Array.isArray(be.payload.files_info)&&(be.payload.files_info=be.payload.files_info.map(ye=>({...ye,data:ye!=null&&ye.data?`<base64 ${String(ye.data).length} chars>`:ye==null?void 0:ye.data}))),be}catch{return fe}};try{let fe={};try{if(r)fe={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Be=window.__AUTH_TOKEN__,Ee=((Y=window.localStorage)==null?void 0:Y.getItem("authToken"))||null;let Ze=null;try{const ht=(q=window.localStorage)==null?void 0:q.getItem("chat-settings");ht&&(Ze=((W=JSON.parse(ht))==null?void 0:W.apiKey)||null)}catch{}const wt=Be||Ee||Ze||null;wt&&(fe={Authorization:`Bearer ${wt}`})}}catch{}console.debug("[use-chat] POST",t+n,M(P));const ve=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...fe,...s.current},body:JSON.stringify(P),signal:V.signal,credentials:i});if(!ve.ok||!ve.body){const De=await ve.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",ve.status,De==null?void 0:De.slice(0,500)),new Error(`stream ${ve.status}${De?": "+De:""}`)}b(!0);const be=ve.body.getReader(),ye=new TextDecoder;let K="",O=[];C.current=0,g(0);let J=0,te=null;const G=()=>{if(O.length){const De=O.join("");O=[],N.current&&h(Be=>Be+De)}te=null},se=()=>{typeof window<"u"&&te==null&&(te=requestAnimationFrame(G))};let Ve=Date.now();const Je=setInterval(()=>{var De;if(Date.now()-Ve>6e4){const Be="Stream idle timeout";d(Be),V.abort(),(De=F==null?void 0:F.onError)==null||De.call(F,Be)}},5e3),nt=1024*1024;try{const De=ve.headers.get("X-Thread-Id")||ve.headers.get("x-thread-id"),Be=ve.headers.get("X-Thread-Created")||ve.headers.get("x-thread-created"),Ee=De??null,Ze=String(Be??"").toLowerCase()==="true";for((z=F==null?void 0:F.onOpen)==null||z.call(F,{threadId:Ee,created:Ze});;){const{value:wt,done:ht}=await be.read();if(ht)break;K+=ye.decode(wt,{stream:!0}),K.length>nt&&(K="",console.warn("Stream buffer reset: exceeded 1MB"));let Z;for(;(Z=K.indexOf(`
|
|
30
|
+
<%s key={someKey} {...props} />`,xe,he,me,he),hr[he+xe]=!0}}return I===r?An(T):Mr(T),T}}function Te(I,B,oe){return ae(I,B,oe,!0)}function Oe(I,B,oe){return ae(I,B,oe,!1)}var rt=Oe,Rt=Te;Fr.Fragment=r,Fr.jsx=rt,Fr.jsxs=Rt}()),Fr}process.env.NODE_ENV==="production"?Qs.exports=sm():Qs.exports=im();var c=Qs.exports;function cl(e,t){return function(){return e.apply(t,arguments)}}const{toString:am}=Object.prototype,{getPrototypeOf:ei}=Object,{iterator:wo,toStringTag:ul}=Symbol,bo=(e=>t=>{const n=am.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Qt=e=>(e=e.toLowerCase(),t=>bo(t)===e),yo=e=>t=>typeof t===e,{isArray:pr}=Array,mr=yo("undefined");function $r(e){return e!==null&&!mr(e)&&e.constructor!==null&&!mr(e.constructor)&&Pt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const dl=Qt("ArrayBuffer");function lm(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&dl(e.buffer),t}const cm=yo("string"),Pt=yo("function"),fl=yo("number"),zr=e=>e!==null&&typeof e=="object",um=e=>e===!0||e===!1,So=e=>{if(bo(e)!=="object")return!1;const t=ei(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ul in e)&&!(wo in e)},dm=e=>{if(!zr(e)||$r(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},fm=Qt("Date"),hm=Qt("File"),pm=Qt("Blob"),mm=Qt("FileList"),gm=e=>zr(e)&&Pt(e.pipe),xm=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Pt(e.append)&&((t=bo(e))==="formdata"||t==="object"&&Pt(e.toString)&&e.toString()==="[object FormData]"))},vm=Qt("URLSearchParams"),[wm,bm,ym,Sm]=["ReadableStream","Request","Response","Headers"].map(Qt),Cm=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Br(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),pr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if($r(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 hl(e,t){if($r(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Vn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,pl=e=>!mr(e)&&e!==Vn;function ti(){const{caseless:e,skipUndefined:t}=pl(this)&&this||{},n={},r=(o,s)=>{const i=e&&hl(n,s)||s;So(n[i])&&So(o)?n[i]=ti(n[i],o):So(o)?n[i]=ti({},o):pr(o)?n[i]=o.slice():(!t||!mr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Br(arguments[o],r);return n}const Tm=(e,t,n,{allOwnKeys:r}={})=>(Br(t,(o,s)=>{n&&Pt(o)?e[s]=cl(o,n):e[s]=o},{allOwnKeys:r}),e),km=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Im=(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)},Em=(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&&ei(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Nm=(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},Am=e=>{if(!e)return null;if(pr(e))return e;let t=e.length;if(!fl(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},_m=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ei(Uint8Array)),jm=(e,t)=>{const r=(e&&e[wo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Rm=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Pm=Qt("HTMLFormElement"),Om=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),ml=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Mm=Qt("RegExp"),gl=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Br(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Dm=e=>{gl(e,(t,n)=>{if(Pt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Pt(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Lm=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return pr(e)?r(e):r(String(e).split(t)),n},Fm=()=>{},$m=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function zm(e){return!!(e&&Pt(e.append)&&e[ul]==="FormData"&&e[wo])}const Bm=e=>{const t=new Array(10),n=(r,o)=>{if(zr(r)){if(t.indexOf(r)>=0)return;if($r(r))return r;if(!("toJSON"in r)){t[o]=r;const s=pr(r)?[]:{};return Br(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)},Hm=Qt("AsyncFunction"),Um=e=>e&&(zr(e)||Pt(e))&&Pt(e.then)&&Pt(e.catch),xl=((e,t)=>e?setImmediate:t?((n,r)=>(Vn.addEventListener("message",({source:o,data:s})=>{o===Vn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Vn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Pt(Vn.postMessage)),Wm=typeof queueMicrotask<"u"?queueMicrotask.bind(Vn):typeof process<"u"&&process.nextTick||xl,R={isArray:pr,isArrayBuffer:dl,isBuffer:$r,isFormData:xm,isArrayBufferView:lm,isString:cm,isNumber:fl,isBoolean:um,isObject:zr,isPlainObject:So,isEmptyObject:dm,isReadableStream:wm,isRequest:bm,isResponse:ym,isHeaders:Sm,isUndefined:mr,isDate:fm,isFile:hm,isBlob:pm,isRegExp:Mm,isFunction:Pt,isStream:gm,isURLSearchParams:vm,isTypedArray:_m,isFileList:mm,forEach:Br,merge:ti,extend:Tm,trim:Cm,stripBOM:km,inherits:Im,toFlatObject:Em,kindOf:bo,kindOfTest:Qt,endsWith:Nm,toArray:Am,forEachEntry:jm,matchAll:Rm,isHTMLForm:Pm,hasOwnProperty:ml,hasOwnProp:ml,reduceDescriptors:gl,freezeMethods:Dm,toObjectSet:Lm,toCamelCase:Om,noop:Fm,toFiniteNumber:$m,findKey:hl,global:Vn,isContextDefined:pl,isSpecCompliantForm:zm,toJSONObject:Bm,isAsyncFn:Hm,isThenable:Um,setImmediate:xl,asap:Wm,isIterable:e=>e!=null&&Pt(e[wo])};function Me(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}R.inherits(Me,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:R.toJSONObject(this.config),code:this.code,status:this.status}}});const vl=Me.prototype,wl={};["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=>{wl[e]={value:e}}),Object.defineProperties(Me,wl),Object.defineProperty(vl,"isAxiosError",{value:!0}),Me.from=(e,t,n,r,o,s)=>{const i=Object.create(vl);R.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Me.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 Vm=null;function ni(e){return R.isPlainObject(e)||R.isArray(e)}function bl(e){return R.endsWith(e,"[]")?e.slice(0,-2):e}function yl(e,t,n){return e?e.concat(t).map(function(o,s){return o=bl(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function qm(e){return R.isArray(e)&&!e.some(ni)}const Km=R.toFlatObject(R,{},null,function(t){return/^is[A-Z]/.test(t)});function Co(e,t,n){if(!R.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=R.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(w,g){return!R.isUndefined(g[w])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&R.isSpecCompliantForm(t);if(!R.isFunction(o))throw new TypeError("visitor must be a function");function u(x){if(x===null)return"";if(R.isDate(x))return x.toISOString();if(R.isBoolean(x))return x.toString();if(!l&&R.isBlob(x))throw new Me("Blob is not supported. Use a Buffer instead.");return R.isArrayBuffer(x)||R.isTypedArray(x)?l&&typeof Blob=="function"?new Blob([x]):Buffer.from(x):x}function d(x,w,g){let v=x;if(x&&!g&&typeof x=="object"){if(R.endsWith(w,"{}"))w=r?w:w.slice(0,-2),x=JSON.stringify(x);else if(R.isArray(x)&&qm(x)||(R.isFileList(x)||R.endsWith(w,"[]"))&&(v=R.toArray(x)))return w=bl(w),v.forEach(function(S,N){!(R.isUndefined(S)||S===null)&&t.append(i===!0?yl([w],N,s):i===null?w:w+"[]",u(S))}),!1}return ni(x)?!0:(t.append(yl(g,w,s),u(x)),!1)}const f=[],h=Object.assign(Km,{defaultVisitor:d,convertValue:u,isVisitable:ni});function p(x,w){if(!R.isUndefined(x)){if(f.indexOf(x)!==-1)throw Error("Circular reference detected in "+w.join("."));f.push(x),R.forEach(x,function(v,b){(!(R.isUndefined(v)||v===null)&&o.call(t,v,R.isString(b)?b.trim():b,w,h))===!0&&p(v,w?w.concat(b):[b])}),f.pop()}}if(!R.isObject(e))throw new TypeError("data must be an object");return p(e),t}function Sl(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function ri(e,t){this._pairs=[],e&&Co(e,this,t)}const Cl=ri.prototype;Cl.append=function(t,n){this._pairs.push([t,n])},Cl.toString=function(t){const n=t?function(r){return t.call(this,r,Sl)}:Sl;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function Gm(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Tl(e,t,n){if(!t)return e;const r=n&&n.encode||Gm;R.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=R.isURLSearchParams(t)?t.toString():new ri(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class kl{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){R.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Il={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Ym={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:ri,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},oi=typeof window<"u"&&typeof document<"u",si=typeof navigator=="object"&&navigator||void 0,Xm=oi&&(!si||["ReactNative","NativeScript","NS"].indexOf(si.product)<0),Jm=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Zm=oi&&window.location.href||"http://localhost",Tt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:oi,hasStandardBrowserEnv:Xm,hasStandardBrowserWebWorkerEnv:Jm,navigator:si,origin:Zm},Symbol.toStringTag,{value:"Module"})),...Ym};function Qm(e,t){return Co(e,new Tt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Tt.isNode&&R.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function eg(e){return R.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function tg(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 El(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&R.isArray(o)?o.length:i,l?(R.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!R.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&R.isArray(o[i])&&(o[i]=tg(o[i])),!a)}if(R.isFormData(e)&&R.isFunction(e.entries)){const n={};return R.forEachEntry(e,(r,o)=>{t(eg(r),o,n,0)}),n}return null}function ng(e,t,n){if(R.isString(e))try{return(t||JSON.parse)(e),R.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Hr={transitional:Il,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=R.isObject(t);if(s&&R.isHTMLForm(t)&&(t=new FormData(t)),R.isFormData(t))return o?JSON.stringify(El(t)):t;if(R.isArrayBuffer(t)||R.isBuffer(t)||R.isStream(t)||R.isFile(t)||R.isBlob(t)||R.isReadableStream(t))return t;if(R.isArrayBufferView(t))return t.buffer;if(R.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Qm(t,this.formSerializer).toString();if((a=R.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),ng(t)):t}],transformResponse:[function(t){const n=this.transitional||Hr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(R.isResponse(t)||R.isReadableStream(t))return t;if(t&&R.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Me.from(a,Me.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:Tt.classes.FormData,Blob:Tt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};R.forEach(["delete","get","head","post","put","patch"],e=>{Hr.headers[e]={}});const rg=R.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),og=e=>{const t={};let n,r,o;return e&&e.split(`
|
|
31
|
+
`).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&rg[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Nl=Symbol("internals");function Ur(e){return e&&String(e).trim().toLowerCase()}function To(e){return e===!1||e==null?e:R.isArray(e)?e.map(To):String(e)}function sg(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const ig=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function ii(e,t,n,r,o){if(R.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!R.isString(t)){if(R.isString(r))return t.indexOf(r)!==-1;if(R.isRegExp(r))return r.test(t)}}function ag(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function lg(e,t){const n=R.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,i){return this[r].call(this,t,o,s,i)},configurable:!0})})}let Ot=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,u){const d=Ur(l);if(!d)throw new Error("header name must be a non-empty string");const f=R.findKey(o,d);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||l]=To(a))}const i=(a,l)=>R.forEach(a,(u,d)=>s(u,d,l));if(R.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(R.isString(t)&&(t=t.trim())&&!ig(t))i(og(t),n);else if(R.isObject(t)&&R.isIterable(t)){let a={},l,u;for(const d of t){if(!R.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(l=a[u])?R.isArray(l)?[...l,d[1]]:[l,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=Ur(t),t){const r=R.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return sg(o);if(R.isFunction(n))return n.call(this,o,r);if(R.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Ur(t),t){const r=R.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||ii(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Ur(i),i){const a=R.findKey(r,i);a&&(!n||ii(r,r[a],a,n))&&(delete r[a],o=!0)}}return R.isArray(t)?t.forEach(s):s(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const s=n[r];(!t||ii(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return R.forEach(this,(o,s)=>{const i=R.findKey(r,s);if(i){n[i]=To(o),delete n[s];return}const a=t?ag(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 R.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&R.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
|
|
32
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[Nl]=this[Nl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Ur(i);r[a]||(lg(o,i),r[a]=!0)}return R.isArray(t)?t.forEach(s):s(t),this}};Ot.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),R.reduceDescriptors(Ot.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),R.freezeMethods(Ot);function ai(e,t){const n=this||Hr,r=t||n,o=Ot.from(r.headers);let s=r.data;return R.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Al(e){return!!(e&&e.__CANCEL__)}function gr(e,t,n){Me.call(this,e??"canceled",Me.ERR_CANCELED,t,n),this.name="CanceledError"}R.inherits(gr,Me,{__CANCEL__:!0});function _l(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Me("Request failed with status code "+n.status,[Me.ERR_BAD_REQUEST,Me.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function cg(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function ug(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const u=Date.now(),d=r[s];i||(i=u),n[o]=l,r[o]=u;let f=s,h=0;for(;f!==o;)h+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const p=d&&u-d;return p?Math.round(h*1e3/p):void 0}}function dg(e,t){let n=0,r=1e3/t,o,s;const i=(u,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...u)};return[(...u)=>{const d=Date.now(),f=d-n;f>=r?i(u,d):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const ko=(e,t,n=3)=>{let r=0;const o=ug(50,250);return dg(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,u=o(l),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:u||void 0,estimated:u&&a&&d?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},jl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Rl=e=>(...t)=>R.asap(()=>e(...t)),fg=Tt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Tt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Tt.origin),Tt.navigator&&/(msie|trident)/i.test(Tt.navigator.userAgent)):()=>!0,hg=Tt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];R.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),R.isString(r)&&i.push("path="+r),R.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function pg(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function mg(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Pl(e,t,n){let r=!pg(t);return e&&(r||n==!1)?mg(e,t):t}const Ol=e=>e instanceof Ot?{...e}:e;function qn(e,t){t=t||{};const n={};function r(u,d,f,h){return R.isPlainObject(u)&&R.isPlainObject(d)?R.merge.call({caseless:h},u,d):R.isPlainObject(d)?R.merge({},d):R.isArray(d)?d.slice():d}function o(u,d,f,h){if(R.isUndefined(d)){if(!R.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!R.isUndefined(d))return r(void 0,d)}function i(u,d){if(R.isUndefined(d)){if(!R.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function a(u,d,f){if(f in t)return r(u,d);if(f in e)return r(void 0,u)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(u,d,f)=>o(Ol(u),Ol(d),f,!0)};return R.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,h=f(e[d],t[d],d);R.isUndefined(h)&&f!==a||(n[d]=h)}),n}const Ml=e=>{const t=qn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ot.from(i),t.url=Tl(Pl(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),R.isFormData(n)){if(Tt.hasStandardBrowserEnv||Tt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(R.isFunction(n.getHeaders)){const l=n.getHeaders(),u=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{u.includes(d.toLowerCase())&&i.set(d,f)})}}if(Tt.hasStandardBrowserEnv&&(r&&R.isFunction(r)&&(r=r(t)),r||r!==!1&&fg(t.url))){const l=o&&s&&hg.read(s);l&&i.set(o,l)}return t},gg=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Ml(e);let s=o.data;const i=Ot.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=o,d,f,h,p,x;function w(){p&&p(),x&&x(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function v(){if(!g)return;const S=Ot.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:S,config:e,request:g};_l(function(E){n(E),w()},function(E){r(E),w()},C),g=null}"onloadend"in g?g.onloadend=v:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(v)},g.onabort=function(){g&&(r(new Me("Request aborted",Me.ECONNABORTED,e,g)),g=null)},g.onerror=function(N){const C=N&&N.message?N.message:"Network Error",k=new Me(C,Me.ERR_NETWORK,e,g);k.event=N||null,r(k),g=null},g.ontimeout=function(){let N=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||Il;o.timeoutErrorMessage&&(N=o.timeoutErrorMessage),r(new Me(N,C.clarifyTimeoutError?Me.ETIMEDOUT:Me.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&R.forEach(i.toJSON(),function(N,C){g.setRequestHeader(C,N)}),R.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,x]=ko(u,!0),g.addEventListener("progress",h)),l&&g.upload&&([f,p]=ko(l),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=S=>{g&&(r(!S||S.type?new gr(null,e,g):S),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=cg(o.url);if(b&&Tt.protocols.indexOf(b)===-1){r(new Me("Unsupported protocol "+b+":",Me.ERR_BAD_REQUEST,e));return}g.send(s||null)})},xg=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(u){if(!o){o=!0,a();const d=u instanceof Error?u:this.reason;r.abort(d instanceof Me?d:new gr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Me(`timeout ${t} of ms exceeded`,Me.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>R.asap(a),l}},vg=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},wg=async function*(e,t){for await(const n of bg(e))yield*vg(n,t)},bg=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},Dl=(e,t,n,r)=>{const o=wg(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:u,value:d}=await o.next();if(u){a(),l.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}l.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Ll=64*1024,{isFunction:Io}=R,yg=(({Request:e,Response:t})=>({Request:e,Response:t}))(R.global),{ReadableStream:Fl,TextEncoder:$l}=R.global,zl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Sg=e=>{e=R.merge.call({skipUndefined:!0},yg,e);const{fetch:t,Request:n,Response:r}=e,o=t?Io(t):typeof fetch=="function",s=Io(n),i=Io(r);if(!o)return!1;const a=o&&Io(Fl),l=o&&(typeof $l=="function"?(x=>w=>x.encode(w))(new $l):async x=>new Uint8Array(await new n(x).arrayBuffer())),u=s&&a&&zl(()=>{let x=!1;const w=new n(Tt.origin,{body:new Fl,method:"POST",get duplex(){return x=!0,"half"}}).headers.has("Content-Type");return x&&!w}),d=i&&a&&zl(()=>R.isReadableStream(new r("").body)),f={stream:d&&(x=>x.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(x=>{!f[x]&&(f[x]=(w,g)=>{let v=w&&w[x];if(v)return v.call(w);throw new Me(`Response type '${x}' is not supported`,Me.ERR_NOT_SUPPORT,g)})});const h=async x=>{if(x==null)return 0;if(R.isBlob(x))return x.size;if(R.isSpecCompliantForm(x))return(await new n(Tt.origin,{method:"POST",body:x}).arrayBuffer()).byteLength;if(R.isArrayBufferView(x)||R.isArrayBuffer(x))return x.byteLength;if(R.isURLSearchParams(x)&&(x=x+""),R.isString(x))return(await l(x)).byteLength},p=async(x,w)=>{const g=R.toFiniteNumber(x.getContentLength());return g??h(w)};return async x=>{let{url:w,method:g,data:v,signal:b,cancelToken:S,timeout:N,onDownloadProgress:C,onUploadProgress:k,responseType:E,headers:A,withCredentials:j="same-origin",fetchOptions:P}=Ml(x),L=t||fetch;E=E?(E+"").toLowerCase():"text";let F=xg([b,S&&S.toAbortSignal()],N),V=null;const M=F&&F.unsubscribe&&(()=>{F.unsubscribe()});let Y;try{if(k&&u&&g!=="get"&&g!=="head"&&(Y=await p(A,v))!==0){let D=new n(w,{method:"POST",body:v,duplex:"half"}),ee;if(R.isFormData(v)&&(ee=D.headers.get("content-type"))&&A.setContentType(ee),D.body){const[fe,ve]=jl(Y,ko(Rl(k)));v=Dl(D.body,Ll,fe,ve)}}R.isString(j)||(j=j?"include":"omit");const q=s&&"credentials"in n.prototype,W={...P,signal:F,method:g.toUpperCase(),headers:A.normalize().toJSON(),body:v,duplex:"half",credentials:q?j:void 0};V=s&&new n(w,W);let z=await(s?L(V,P):L(w,W));const $=d&&(E==="stream"||E==="response");if(d&&(C||$&&M)){const D={};["status","statusText","headers"].forEach(be=>{D[be]=z[be]});const ee=R.toFiniteNumber(z.headers.get("content-length")),[fe,ve]=C&&jl(ee,ko(Rl(C),!0))||[];z=new r(Dl(z.body,Ll,fe,()=>{ve&&ve(),M&&M()}),D)}E=E||"text";let ue=await f[R.findKey(f,E)||"text"](z,x);return!$&&M&&M(),await new Promise((D,ee)=>{_l(D,ee,{data:ue,headers:Ot.from(z.headers),status:z.status,statusText:z.statusText,config:x,request:V})})}catch(q){throw M&&M(),q&&q.name==="TypeError"&&/Load failed|fetch/i.test(q.message)?Object.assign(new Me("Network Error",Me.ERR_NETWORK,x,V),{cause:q.cause||q}):Me.from(q,q&&q.code,x,V)}}},Cg=new Map,Bl=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,u,d=Cg;for(;a--;)l=s[a],u=d.get(l),u===void 0&&d.set(l,u=a?new Map:Sg(t)),d=u;return u};Bl();const li={http:Vm,xhr:gg,fetch:{get:Bl}};R.forEach(li,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Hl=e=>`- ${e}`,Tg=e=>R.isFunction(e)||e===null||e===!1,Ul={getAdapter:(e,t)=>{e=R.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){r=e[i];let a;if(o=r,!Tg(r)&&(o=li[(a=String(r)).toLowerCase()],o===void 0))throw new Me(`Unknown adapter '${a}'`);if(o&&(R.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,u])=>`adapter ${l} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
33
|
+
`+i.map(Hl).join(`
|
|
34
|
+
`):" "+Hl(i[0]):"as no adapter specified";throw new Me("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:li};function ci(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new gr(null,e)}function Wl(e){return ci(e),e.headers=Ot.from(e.headers),e.data=ai.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Ul.getAdapter(e.adapter||Hr.adapter,e)(e).then(function(r){return ci(e),r.data=ai.call(e,e.transformResponse,r),r.headers=Ot.from(r.headers),r},function(r){return Al(r)||(ci(e),r&&r.response&&(r.response.data=ai.call(e,e.transformResponse,r.response),r.response.headers=Ot.from(r.response.headers))),Promise.reject(r)})}const Vl="1.12.2",Eo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Eo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const ql={};Eo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Vl+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Me(o(i," has been removed"+(n?" in "+n:"")),Me.ERR_DEPRECATED);return n&&!ql[i]&&(ql[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}},Eo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function kg(e,t,n){if(typeof e!="object")throw new Me("options must be an object",Me.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 Me("option "+s+" must be "+l,Me.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Me("Unknown option "+s,Me.ERR_BAD_OPTION)}}const No={assertOptions:kg,validators:Eo},un=No.validators;let Kn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new kl,response:new kl}}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=qn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&No.assertOptions(r,{silentJSONParsing:un.transitional(un.boolean),forcedJSONParsing:un.transitional(un.boolean),clarifyTimeoutError:un.transitional(un.boolean)},!1),o!=null&&(R.isFunction(o)?n.paramsSerializer={serialize:o}:No.assertOptions(o,{encode:un.function,serialize:un.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),No.assertOptions(n,{baseUrl:un.spelling("baseURL"),withXsrfToken:un.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&R.merge(s.common,s[n.method]);s&&R.forEach(["delete","get","head","post","put","patch","common"],x=>{delete s[x]}),n.headers=Ot.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(w){typeof w.runWhen=="function"&&w.runWhen(n)===!1||(l=l&&w.synchronous,a.unshift(w.fulfilled,w.rejected))});const u=[];this.interceptors.response.forEach(function(w){u.push(w.fulfilled,w.rejected)});let d,f=0,h;if(!l){const x=[Wl.bind(this),void 0];for(x.unshift(...a),x.push(...u),h=x.length,d=Promise.resolve(n);f<h;)d=d.then(x[f++],x[f++]);return d}h=a.length;let p=n;for(;f<h;){const x=a[f++],w=a[f++];try{p=x(p)}catch(g){w.call(this,g);break}}try{d=Wl.call(this,p)}catch(x){return Promise.reject(x)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=qn(this.defaults,t);const n=Pl(t.baseURL,t.url,t.allowAbsoluteUrls);return Tl(n,t.params,t.paramsSerializer)}};R.forEach(["delete","get","head","options"],function(t){Kn.prototype[t]=function(n,r){return this.request(qn(r||{},{method:t,url:n,data:(r||{}).data}))}}),R.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(qn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Kn.prototype[t]=n(),Kn.prototype[t+"Form"]=n(!0)});let Ig=class nm{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 nm(function(o){t=o}),cancel:t}}};function Eg(e){return function(n){return e.apply(null,n)}}function Ng(e){return R.isObject(e)&&e.isAxiosError===!0}const ui={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(ui).forEach(([e,t])=>{ui[t]=e});function Kl(e){const t=new Kn(e),n=cl(Kn.prototype.request,t);return R.extend(n,Kn.prototype,t,{allOwnKeys:!0}),R.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Kl(qn(e,o))},n}const dt=Kl(Hr);dt.Axios=Kn,dt.CanceledError=gr,dt.CancelToken=Ig,dt.isCancel=Al,dt.VERSION=Vl,dt.toFormData=Co,dt.AxiosError=Me,dt.Cancel=dt.CanceledError,dt.all=function(t){return Promise.all(t)},dt.spread=Eg,dt.isAxiosError=Ng,dt.mergeConfig=qn,dt.AxiosHeaders=Ot,dt.formToJSON=e=>El(R.isHTMLForm(e)?new FormData(e):e),dt.getAdapter=Ul.getAdapter,dt.HttpStatusCode=ui,dt.default=dt;const{Axios:dT,AxiosError:fT,CanceledError:hT,isCancel:pT,CancelToken:mT,VERSION:gT,all:xT,Cancel:vT,isAxiosError:wT,spread:bT,toFormData:yT,AxiosHeaders:ST,HttpStatusCode:CT,formToJSON:TT,getAdapter:kT,mergeConfig:IT}=dt,Gl=typeof window<"u"?window.__API_BASE_URL__:void 0,Yl=Gl?Tn(Gl):void 0;function Tn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Ao=null;const di=new Set;function Xl(){return Ao}function fi(e){Ao=e,di.forEach(t=>t(e))}function Jl(e){return di.add(e),()=>di.delete(e)}const Wt=dt.create({...Yl?{baseURL:Yl}:{},timeout:3e4,withCredentials:!0});Wt.interceptors.request.use(e=>(Ao&&(e.headers.Authorization=`Bearer ${Ao}`),e)),Wt.interceptors.response.use(e=>e,e=>Promise.reject(e));async function Dt(e,t){return Wt.defaults.baseURL?(await Wt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function hi(e,t,n){return Wt.defaults.baseURL?(await Wt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Zl(e,t,n){return Wt.defaults.baseURL?(await Wt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ql(e,t){return Wt.defaults.baseURL?(await Wt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Lt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class ec{get baseUrl(){const t=Wt.defaults.baseURL;return t?Tn(String(t)):""}updateConfig(t){t.baseUrl&&(Wt.defaults.baseURL=Tn(String(t.baseUrl))),t.authToken!==void 0&&fi(t.authToken)}getAuthToken(){return Xl()}setAuthToken(t){fi(t)}onTokenChange(t){return Jl(t)}async listThreads(){const t=await Dt("/threads"),n=Lt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await hi("/threads",t?{title:t}:void 0);return Lt(r)}async updateThread(t,n){const r=await Zl(`/threads/${t}`,{title:n});return Lt(r)}async deleteThread(t){const n=await Ql(`/threads/${t}`);return Lt(n)}async threadInfo(t){const n=await Dt(`/threads/${t}/info`);return Lt(n)}async listAgents(){const t=await Dt("/agents"),n=Lt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Dt(`/agents/${t}`);return Lt(n)}async getAgentSchema(t){const n=await Dt(`/agents/${t}/schema`);return Lt(n)}async getMessages(t){const n=await Dt(`/threads/${t.threadId}/messages`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs,limit:t.limit,before_id:t.beforeId??void 0}});return Lt(n)}async getState(t){const n=await Dt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Lt(n)}async getStateHistory(t){const n=await Dt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Lt(n)}async listCheckpoints(t){const n=await Dt(`/threads/${t}/checkpoints`,{params:{thread_id:t}});return Lt(n)}resumeStream(t){}async resume(t){const n=await hi("/runs/resume",{thread_id:t.threadId,value:t.value});return Lt(n)}}const jn=new ec,tc=y.createContext(null);function Ag({children:e,apiConfig:t}){const n=jn;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return c.jsx(tc.Provider,{value:r,children:e})}function pi(){const e=y.useContext(tc);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function _g(e,t){const n=e==null?void 0:e.checkpoints,r=Array.isArray(n)?n.slice():n?Object.values(n):[],o=i=>i&&typeof i=="object"&&i!==null&&"checkpointId"in i&&"createdAt"in i&&typeof i.checkpointId=="string"&&typeof i.createdAt=="string",s=r.filter(o).map(i=>{const a=i;return{checkpointId:a.checkpointId,checkpointNs:a.checkpointNs??"",createdAt:a.createdAt,messagesLen:a.messagesLen??0,preview:a.preview??"",role:a.role??null,parentId:a.parentId??null,editedMessageId:a.editedMessageId??null,branchLabel:a.branchLabel??null,lastMessageId:a.lastMessageId??null,hasMessages:typeof a.hasMessages=="boolean"?a.hasMessages:void 0}});return{threadId:(e==null?void 0:e.threadId)??t??null,checkpoints:s}}async function jg(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let l=0;l<a;l++)i+=String.fromCharCode(s[l]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function Rg(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const u=await jg(l);a.push({filename:l.name,data:u,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const Pg={human:"user",user:"user",ai:"assistant",assistant:"assistant",tool:"tool",function:"tool",system:"system"};function Og(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 nc(e){var d;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(!Og(r))return{threadId:n,checkpointId:void 0,checkpointNs:void 0,messages:[],hasMore:!1,nextCursor:null};const o=r.values??{},i=(Array.isArray(o==null?void 0:o.messages)?o.messages:[]).map((f,h)=>Mg(f,h)).filter(f=>!!f),a=Wr((d=r.config)==null?void 0:d.configurable),l=At(a,["checkpoint_id","checkpointId"]),u=At(a,["checkpoint_ns","checkpointNs"]);return{threadId:n,checkpointId:l??void 0,checkpointNs:u??void 0,messages:i,hasMore:!1,nextCursor:null}}function Mg(e,t){if(!e||typeof e!="object")return null;const n=e,r=Wr(n.data)??{},o=String(n.type??r.type??"").toLowerCase(),s=Pg[o];if(!s)return null;const i=r.id??r.message_id??r.run_id??null,a=typeof i=="string"&&i.trim()?i:`history-${s}-${t}`,l=Wr(r.additional_kwargs),u=Wr(r.response_metadata),d=At(l,["createdAt","created_at"])??At(r,["created_at","createdAt"]),f=At(l,["checkpointId","checkpoint_id"]),h=At(l,["checkpointNs","checkpoint_ns"]),p=Dg(r.content),x={id:a,role:s,content:p};d&&(x.createdAt=d),typeof r.name=="string"&&r.name.trim()&&(x.name=r.name),typeof(u==null?void 0:u.model_name)=="string"&&(x.model=String(u.model_name)),f&&(x.checkpointId=f),h&&(x.checkpointNs=h);const w=Bg(l,["createdAt","created_at","checkpointId","checkpoint_id","checkpointNs","checkpoint_ns","tool_calls"]),g=u?{...u}:void 0;w&&Object.keys(w).length&&(x.additionalKwargs=w),g&&Object.keys(g).length&&(x.responseMetadata=g);const v=Lg((l==null?void 0:l.tool_calls)??r.tool_calls);if(v.length&&(x.content=[...x.content,...v]),s==="tool"){const b=$g(r,x.content);b&&(x.content=b)}return x}function Dg(e){if(!e)return[];if(Array.isArray(e))return e.map(t=>rc(t)).filter(t=>!!t);if(typeof e=="string")return e.trim()?[{type:"text",text:e.trim()}]:[];if(typeof e=="object"){const t=rc(e);return t?[t]:[]}return[]}function rc(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=At(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=At(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 Fg(t)??null;if(n==="tool_end"){const o=At(t,["tool_call_id","toolCallId","id"]);if(!o)return null;const s={type:"tool_end",toolCallId:o,output:"output"in t?t.output:t.content};return typeof t.error=="string"&&(s.error=t.error),s}if(n==="interrupt")return{type:"interrupt",value:t.value,...t};if(n==="tool"){const o=At(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 Lg(e){return Array.isArray(e)?e.map((t,n)=>{if(!t||typeof t!="object")return null;const r=t,o=At(r,["id","call_id"]),s=Wr(r.function),i=At(s,["name"])??"tool",a=s==null?void 0:s.arguments,l=oc(a);return{type:"tool_call",id:o??`tool_call_${n}`,name:i,args:l}}).filter(t=>!!t):[]}function Fg(e){const t=At(e,["id","call_id"]),n=At(e,["name"]);if(!t||!n)return null;const r=oc(e.args??e.arguments);return{type:"tool_call",id:t,name:n,args:r}}function $g(e,t){const n=At(e,["tool_call_id","toolCallId","id"]);if(!n)return t;const r=e.content??e.output,o=typeof r=="string"?zg(r):r,s={type:"tool_end",toolCallId:n,output:o};return typeof e.error=="string"&&(s.error=e.error),[s]}function oc(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 zg(e){try{return JSON.parse(e)}catch{return e}}function Wr(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function At(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r}}function Bg(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 Hg(e){return e.type!=="thread_info"&&e.type!=="token"}const Ug={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,messagesStreamMeta:{}};function Wg(e,t){var n;switch(t.type){case"reset":{console.log("[MessageReducer] 🔄 RESET action received"),console.log("[MessageReducer] 📊 Before reset - messages count:",e.messages.length);const r={messages:mi(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};return console.log("[MessageReducer] 📊 After reset - messages count:",r.messages.length),r}case"seed":{const r=mi(t.payload.messages),o={...e,messages:r,assemblingId:null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),console.log("[MessageReducer] seed action (REPLACE mode):",{incomingCount:t.payload.messages.length,sanitizedCount:r.length,previousCount:e.messages.length,checkpointId:o.lastCheckpointId}),o}case"prepend":{const r=mi(t.payload.messages);if(!r.length)return console.log("[MessageReducer] No incoming messages after sanitize - skipping"),e;const o=new Set(e.messages.map(i=>i.id)),s=r.filter(i=>!o.has(i.id));return console.log("[MessageReducer] After dedup:",{uniqueCount:s.length,duplicates:r.length-s.length,finalTotal:s.length+e.messages.length}),s.length?{...e,messages:[...s,...e.messages]}:(console.log("[MessageReducer] All messages were duplicates - skipping"),e)}case"user_message":{const r=t.payload.message;return e.messages.some(o=>o.id===r.id)?e:{...e,messages:[...e.messages,r]}}case"event":return ic(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>ic(o,s),e):e}case"interrupt_response":{const{interruptId:r}=t.payload,o=e.messages.map(s=>({...s,content:s.content.filter(i=>i.type!=="interrupt")}));return{...e,messages:o,pendingInterrupt:null}}default:return e}}function sc(e=[]){const[t,n]=y.useReducer(Wg,{...Ug,messages:e}),r=y.useRef([]),o=y.useRef(null),s=y.useRef(null),i=y.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=y.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=y.useCallback(d=>{r.current.push(d),a()},[a]);y.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const u=y.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:d=>n({type:"user_message",payload:{message:d}}),onEvent:l}),[l]);return{state:t,dispatch:n,...u}}function ic(e,t){var n,r,o,s;if(t.type==="message_start"&&t.role==="assistant"){const i=t.id,a=Kg(t.model);if(e.messages.some(d=>d.id===i)){const d=e.messagesStreamMeta??{},f={...d,[i]:d[i]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:i,messagesStreamMeta:f}}const u={id:i,role:"assistant",name:a||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:i,messages:[...e.messages,u]}}if(t.type==="message_delta"){const i=e.assemblingId??gi(e.messages);if(!i)return e;const a=e.messages,l=a.findIndex(S=>S.id===i&&S.role==="assistant");if(l===-1)return e;const u=a[l],d=e.messagesStreamMeta??{},f=d[i]??{lastSeq:null,lastText:dc(u.content)},h=t.seq??null;if(h!==null&&typeof h=="number"&&typeof f.lastSeq=="number"&&h<=f.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:h,lastSeq:f.lastSeq}),e;const{newParts:p,newMeta:x,changed:w}=Vg(u.content,t.delta,f,h);if(!w)return e;const g={...u,content:p},v=ac(a,l,g),b={...d,[i]:x};return{...e,messages:v,messagesStreamMeta:b}}if(t.type==="message_end"){const i=e.assemblingId??gi(e.messages);if(!i)return{...e,assemblingId:null};const a=e.messages,l=a.findIndex(u=>u.id===i&&u.role==="assistant");if(l>=0){const u=a[l];if(!((n=u.content)==null?void 0:n.some(f=>{var h;return(f==null?void 0:f.type)==="text"&&((h=f.text)==null?void 0:h.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:u.id,contentTypes:(r=u.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=u.content)==null?void 0:o.map(h=>(h==null?void 0:h.type)==="text"?String(h.text).slice(0,100):h==null?void 0:h.type)});const f=[...a.slice(0,l),...a.slice(l+1)];return{...e,assemblingId:null,messages:f}}}return e}if(t.type==="tool_start"){const i=t.id??t.call_id,a=t.name??t.tool??"tool";if(!i)return e;const l=`tool-${i}`,u={type:"tool_call",id:i,name:a,args:t.args};if(e.messages.find(h=>h.id===l))return{...e,toolIndex:{...e.toolIndex,[i]:l}};const f={id:l,role:"tool",name:a,createdAt:new Date().toISOString(),content:[u]};return{...e,messages:[...e.messages,f],toolIndex:{...e.toolIndex,[i]:l}}}if(t.type==="tool_end"){const i=t.id??t.call_id;if(!i)return e;const a=e.toolIndex[i]??`tool-${i}`,l={type:"tool_end",toolCallId:i,output:t.output,error:t.error},u=e.messages.find(h=>h.id===a),d={id:a,role:"tool",name:t.name??((s=e.messages.find(h=>h.id===a))==null?void 0:s.name),content:[l],createdAt:new Date().toISOString()},f=u?cc(e.messages,a,[l]):[...e.messages,d];return{...e,messages:f,toolIndex:{...e.toolIndex,[i]:a}}}if(t.type==="checkpoint"){const i=t.checkpointNs??e.lastCheckpointNs??null,a=qg(e.messages,t.checkpointId,i);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:i,messages:a}}if(t.type==="branch"){const i=t.checkpointId??e.lastCheckpointId,a=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:i??null,lastCheckpointNs:a??null}}if(t.type==="error"){const i={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,i]}}if(t.type==="interrupt"){const i=e.assemblingId??gi(e.messages),a={type:"interrupt",value:t.value,id:t.id};if(i)return{...e,assemblingId:null,messages:cc(e.messages,i,[a]),pendingInterrupt:{id:t.id,value:t.value}};const l=`interrupt-${t.id}`;if(e.messages.findIndex(f=>f.id===l)!==-1)return{...e,assemblingId:null,messages:lc(e.messages,l,f=>({...f,content:uc(f.content??[],[a])})),pendingInterrupt:{id:t.id,value:t.value}};const d={id:l,role:"system",createdAt:new Date().toISOString(),content:[a]};return{...e,messages:[...e.messages,d],pendingInterrupt:{id:t.id,value:t.value}}}return e}function mi(e){return e.filter(t=>{if(t.role!=="assistant")return!0;const n=(t.content||[]).some(o=>{var s;return o&&o.type==="text"&&((s=o.text)==null?void 0:s.trim())}),r=(t.content||[]).some(o=>o&&o.type==="image_url");return!!(n||r)})}function ac(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function gi(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function lc(e,t,n){const r=e.findIndex(i=>i.id===t);if(r===-1)return e;const o=e[r],s=n(o);return s===o?e:[...e.slice(0,r),s,...e.slice(r+1)]}function cc(e,t,n){return lc(e,t,r=>({...r,content:uc(r.content,n)}))}function uc(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1],s=r.text??"";if(!s)continue;if((o==null?void 0:o.type)==="text"){let i=function(p){return p.replace(/\s+/g," ").trim()};const a=o,l=a.text??"";if(console.debug("[MessageReducer] mergeParts",{incomingLength:s.length,previousLength:l.length,incomingSnippet:s.slice(0,100),previousSnippet:l.slice(-100)}),!l){a.text=s;continue}const u=i(s),d=i(l);if(u.startsWith(d)||s.startsWith(l)){console.debug("[MessageReducer] incoming startsWith previous (norm/raw) - replacing",{incomingLength:s.length,previousLength:l.length}),a.text=s;continue}if(u.includes(d)){console.debug("[MessageReducer] incoming includes previous (normalized) - replacing",{incomingLength:s.length,previousLength:l.length}),a.text=s;continue}if(d.includes(u)&&u.length<=3){console.debug("[MessageReducer] previous includes incoming (normalized) - skipping trivial incoming",{incomingLength:s.length,previousLength:l.length});continue}const h=hc(l,s);h?(console.debug("[MessageReducer] suffix computed",{suffixLength:h.length}),a.text=l+h):(console.debug("[MessageReducer] no overlap detected - appending incoming",{incomingLength:s.length}),a.text=l+s)}else n.push({type:"text",text:s})}else n.push(r);return n}function dc(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??dc(e);let l="",u=e.slice();if(s){const f=hc(a,s);if(f===""?l="":f===s?l=s:l=f,l){const h=u[u.length-1];if((h==null?void 0:h.type)==="text"){const p=h.text??"",x={...h,text:p+l};u=[...u.slice(0,u.length-1),x]}else u=[...u,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(u=[...u,...i]);const d=!!(l||i.length);return{newParts:u,newMeta:o,changed:d}}function fc(e){return e.replace(/\s+/g," ").trim()}function hc(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=fc(e),o=fc(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 ac(e,r,s)}return e}function Kg(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function pc(e={}){const t=y.useMemo(()=>Tn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=y.useState(e.token??null),s=y.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=y.useState(!1),[u,d]=y.useState(null),[f,h]=y.useState(""),[p,x]=y.useState(null),[w,g]=y.useState(0),[v,b]=y.useState(!1),S=y.useRef(null),N=y.useRef(!0),C=y.useRef(0),k=y.useCallback(P=>{o(P)},[]),E=y.useCallback(()=>{var P;(P=S.current)==null||P.abort(),S.current=null,l(!1),b(!1),C.current=0,g(0)},[]),A=y.useCallback(()=>{h(""),x(null),d(null)},[]),j=y.useCallback((P,L,F)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h("");const V=new AbortController;return S.current=V,(async()=>{var Y,q,W,z,$,ue,D,ee;const M=fe=>{var ve;try{const be=JSON.parse(JSON.stringify(fe));return(ve=be==null?void 0:be.payload)!=null&&ve.files_info&&Array.isArray(be.payload.files_info)&&(be.payload.files_info=be.payload.files_info.map(ye=>({...ye,data:ye!=null&&ye.data?`<base64 ${String(ye.data).length} chars>`:ye==null?void 0:ye.data}))),be}catch{return fe}};try{let fe={};try{if(r)fe={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Be=window.__AUTH_TOKEN__,Ee=((Y=window.localStorage)==null?void 0:Y.getItem("authToken"))||null;let Ze=null;try{const ht=(q=window.localStorage)==null?void 0:q.getItem("chat-settings");ht&&(Ze=((W=JSON.parse(ht))==null?void 0:W.apiKey)||null)}catch{}const wt=Be||Ee||Ze||null;wt&&(fe={Authorization:`Bearer ${wt}`})}}catch{}console.debug("[use-chat] POST",t+n,M(P));const ve=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...fe,...s.current},body:JSON.stringify(P),signal:V.signal,credentials:i});if(!ve.ok||!ve.body){const De=await ve.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",ve.status,De==null?void 0:De.slice(0,500)),new Error(`stream ${ve.status}${De?": "+De:""}`)}b(!0);const be=ve.body.getReader(),ye=new TextDecoder;let K="",O=[];C.current=0,g(0);let J=0,te=null;const G=()=>{if(O.length){const De=O.join("");O=[],N.current&&h(Be=>Be+De)}te=null},se=()=>{typeof window<"u"&&te==null&&(te=requestAnimationFrame(G))};let Ve=Date.now();const Je=setInterval(()=>{var De;if(Date.now()-Ve>6e4){const Be="Stream idle timeout";d(Be),V.abort(),(De=F==null?void 0:F.onError)==null||De.call(F,Be)}},5e3),nt=1024*1024;try{const De=ve.headers.get("X-Thread-Id")||ve.headers.get("x-thread-id"),Be=ve.headers.get("X-Thread-Created")||ve.headers.get("x-thread-created"),Ee=De??null,Ze=String(Be??"").toLowerCase()==="true";for((z=F==null?void 0:F.onOpen)==null||z.call(F,{threadId:Ee,created:Ze});;){const{value:wt,done:ht}=await be.read();if(ht)break;K+=ye.decode(wt,{stream:!0}),K.length>nt&&(K="",console.warn("Stream buffer reset: exceeded 1MB"));let Z;for(;(Z=K.indexOf(`
|
|
36
36
|
|
|
37
|
-
`))>=0;){const re=K.slice(0,Z);K=K.slice(Z+2);const pe=
|
|
38
|
-
`)}function Dg({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onUnhandledEvent:r,onSequenceGap:o}){const s=y.useRef(null),i=y.useCallback(p=>{const v=p.seq??null;if(v!==null){const w=s.current;if(w!==null){if(v<=w)return;v>w+1&&(o==null||o({from:w,to:v}))}s.current=v}if(p.type==="thread_info"){console.log("[useChatStreamingService] 🎯 Received thread_info event:",p),t(p);return}if(Ng(p)){n(p);return}r==null||r(p)},[n,o,t,r]),{stream:a,stop:l,isStreaming:u,error:d,setToken:f}=cc({baseUrl:e,token:null}),h=y.useCallback((p,v)=>{s.current=null,a(p,i,{onOpen:v==null?void 0:v.onOpen,onError:w=>{var g;(g=v==null?void 0:v.onError)==null||g.call(v,w)},onGap:(v==null?void 0:v.onGap)??o})},[i,o,a]);return y.useMemo(()=>({startStream:h,stop:l,isStreaming:u,error:d,setAuthToken:f}),[h,l,u,d,f])}const uc=y.createContext(null),dc=y.createContext(null),fc=y.createContext(null),Lg=y.createContext(!1),Fg=20,$g="cachedThreads",zg="v1",No=300,mi=200;function hc(e,t){if(!e&&!t)return!0;if(!e||!t||e.id!==t.id)return!1;try{return JSON.stringify(e.value)===JSON.stringify(t.value)}catch{return e.value===t.value}}function Bg(e){var t;for(let n=e.length-1;n>=0;n--){const r=((t=e[n])==null?void 0:t.content)??[];for(let o=r.length-1;o>=0;o--){const s=r[o];if((s==null?void 0:s.type)==="interrupt"){const i=s.id;return{id:(typeof i=="string"?i:null)??`interrupt-${e[n].id??o}`,value:s.value}}}}return null}function Hg(e){if(!e||typeof e!="object")return null;const t=e.tasks;if(!Array.isArray(t))return null;for(const n of t){if(!n||typeof n!="object")continue;const r=n.interrupts;if(!Array.isArray(r)||r.length===0)continue;const o=r[0];if(!o)continue;return{id:(typeof(o==null?void 0:o.id)=="string"?o.id:typeof n.id=="string"?n.id:null)??"interrupt-task",value:o==null?void 0:o.value}}return null}function pc(e){if(typeof window<"u"&&"requestIdleCallback"in window)try{window.requestIdleCallback(e,{timeout:1e3});return}catch{}window.setTimeout(e,No)}function gr(){return typeof window<"u"&&typeof window.localStorage<"u"}function gi(e){if(!gr())return null;try{return window.localStorage.getItem(e)}catch{return null}}function mc(e,t){if(gr())try{window.localStorage.setItem(e,t)}catch{}}function xi(e){if(gr())try{window.localStorage.removeItem(e)}catch{}}function Ug(){const e=gi($g);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>{if(!n||typeof n!="object")return!1;const r=n;return typeof r.threadId=="string"&&typeof r.title=="string"}):[]}catch{return[]}}function Wg(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(36)}function vi(e,t){return`cachedThreads:v1:${e}:${Wg(t||"anon")}`}function Vg(e){const t=gi(e);if(!t)return[];try{const n=JSON.parse(t);return Array.isArray(n)?n.filter(r=>{if(!r||typeof r!="object")return!1;const o=r;return typeof o.threadId=="string"&&typeof o.title=="string"}):[]}catch{return[]}}function wi(e,t){try{mc(e,JSON.stringify(t))}catch{}}function bi(e){const t=Vg(e);if(t.length>0)return t;const n=Ug();if(n.length>0)try{wi(e,n.slice(0,mi))}catch{}return n}function Ao(e){const t={},n=[];for(const r of e)!r||typeof r.threadId!="string"||t[r.threadId]||(t[r.threadId]=r,n.push(r.threadId));return{byId:t,order:n}}function yi(e){return e.order.map(t=>e.byId[t]).filter(Boolean)}function qg({children:e,initialThreadId:t=null,autoLoadInitial:n=!0,disableAutoRestore:r=!1,enableFileAgentRouting:o=!1,fileAgentId:s="invoice_reader",onError:i,onThreadChange:a}){const{api:l,baseUrl:u}=fi(),d=y.useMemo(()=>Cn(u),[u]),f=y.useMemo(()=>{try{return new URL(u).host}catch{return"unknown"}},[u]),h=y.useMemo(()=>`threadPayload:${zg}:${f}:`,[f]),p=y.useCallback(T=>`${h}${T}`,[h]),v=y.useCallback(T=>{if(!T||typeof T!="object")return null;const _=T;return typeof _.threadId!="string"||!Array.isArray(_.messages)?null:{threadId:_.threadId,messages:_.messages,hasMore:!!_.hasMore,nextCursor:_.nextCursor??null,checkpointId:_.checkpointId??null,checkpointNs:_.checkpointNs??null}},[]),w=y.useCallback(T=>{const _=gi(p(T));if(!_)return null;try{const B=JSON.parse(_);return v(B)}catch{return null}},[p,v]),g=y.useCallback((T,_=100)=>{const B={...T,messages:Array.isArray(T.messages)?T.messages.slice(-_):[]};try{mc(p(T.threadId),JSON.stringify(B))}catch{}},[p]),x=y.useCallback(T=>{xi(p(T))},[p]),b=y.useCallback(()=>{if(gr())try{const T=h;for(let _=0;_<window.localStorage.length;_++){const B=window.localStorage.key(_);B&&B.startsWith(T)&&window.localStorage.removeItem(B)}}catch{}},[h]),[S,N]=y.useState(()=>{var T;return vi(f,(T=l.getAuthToken)==null?void 0:T.call(l))}),[C,k]=y.useState(()=>{var _;const T=bi(vi(f,(_=l.getAuthToken)==null?void 0:_.call(l)));return Ao(T)}),E=y.useMemo(()=>yi(C),[C]),[A,j]=y.useState(t),[P,L]=y.useState(!1),[F,V]=y.useState(!1),[M,Y]=y.useState(null),[q,W]=y.useState(null),[z,$]=y.useState(null),ue=y.useCallback(()=>{const T=bi(S);y.startTransition(()=>{k(Ao(T))})},[S]),[D,ee]=y.useState(!1),[fe,ve]=y.useState(!1),[be,ye]=y.useState(null),[K,O]=y.useState(void 0),[J,te]=y.useState(void 0),{state:G,dispatch:se,seed:Ve,prepend:Je,pushUser:nt,onEvent:De,reset:Be}=ec(),Ee=y.useRef(A);y.useEffect(()=>{Ee.current=A},[A]);const Ze=y.useRef(!1),wt=y.useRef([]),ht=y.useRef(null),Z=y.useRef(null),re=y.useRef(new Map),pe=y.useRef(A),Ne=y.useRef(!1),we=y.useRef(null),Ae=y.useRef({threadId:null,checkpointId:null,checkpointNs:null}),Qe=y.useCallback((T,_)=>new Promise((B,he)=>{const ne=async()=>{Ze.current=!0;try{await T(),B()}catch(xe){he(xe)}finally{Ze.current=!1;const xe=wt.current.shift();xe&&xe().catch(()=>{})}};Ze.current?wt.current.push(ne):ne().catch(xe=>{he(xe)})}),[]),ze=y.useRef(E.length),[lt,St]=y.useState(!1),Ht=y.useRef(!1);y.useEffect(()=>{ze.current=E.length},[E.length]),y.useEffect(()=>{const T=Ee.current;if(!T){z!==null&&$(null),Ae.current={threadId:null,checkpointId:null,checkpointNs:null};return}const _=G.pendingInterrupt??Bg(G.messages);if(_){hc(z,_)||$(_),Ae.current={threadId:T,checkpointId:G.lastCheckpointId??null,checkpointNs:G.lastCheckpointNs??null};return}const B={threadId:T,checkpointId:G.lastCheckpointId??null,checkpointNs:G.lastCheckpointNs??null},he=Ae.current.threadId===B.threadId&&Ae.current.checkpointId===B.checkpointId&&Ae.current.checkpointNs===B.checkpointNs;if(!(l!=null&&l.getState)){z!==null&&$(null),Ae.current=B;return}if(he&&z===null)return;let ne=!1;return Ae.current=B,l.getState({threadId:T,checkpointId:B.checkpointId??void 0,checkpointNs:B.checkpointNs??void 0}).then(xe=>{if(ne)return;const me=Hg(xe==null?void 0:xe.state);hc(z,me??null)||$(me??null)}).catch(xe=>{ne||(console.warn("[ChatSessionProvider] Failed to inspect thread state for interrupts:",xe),z!==null&&$(null))}),()=>{ne=!0}},[l,z,G.lastCheckpointId,G.lastCheckpointNs,G.messages,G.pendingInterrupt]);const gt=y.useCallback(async()=>{const T=ze.current>0;T||L(!0);try{const _=await l.listThreads();y.startTransition(()=>{k(B=>{const he=me=>me.map(xt=>`${xt.threadId}:${xt.updatedAt??""}:${xt.messageCount??""}`).join("|"),ne=yi(B);return he(ne)===he(_)||_.length===0&&ne.length>0&&!Ht.current?B:Ao(_)})}),Y(null),Ht.current||(Ht.current=!0,St(!0))}catch(_){i==null||i(String(_)),console.error("[ChatSessionProvider] Failed to refresh threads:",_),Y(String(_))}finally{T||L(!1)}},[l,i]),_r=y.useRef(!1),lr=y.useRef(null),bt=y.useRef(null),bn=y.useRef(""),on=y.useCallback((T,_)=>{if(!gr())return;bt.current!==null&&(window.clearTimeout(bt.current),bt.current=null);const B=T.map(ne=>`${ne.threadId}:${ne.updatedAt??""}:${ne.messageCount??""}`).join("|");if(T.length===0){try{xi(S)}catch{}bn.current="";return}if(B===bn.current)return;const he=()=>{try{const ne=T.slice(0,mi);wi(S,ne),bn.current=B}catch{}finally{bt.current=null}};if(_!=null&&_.immediate){he();return}bt.current=window.setTimeout(()=>{pc(he)},No)},[S]),cr=y.useCallback(()=>{on(E,{immediate:!0})},[on,E]),Nt=y.useCallback((T,_,B)=>{const he=Array.isArray(T==null?void 0:T.messages)?T.messages:[],ne=B??(T==null?void 0:T.threadId)??Ee.current,xe=ne!=null&&ne===Ee.current;if(_==="replace"){if(ne){const me={threadId:ne,messages:he.slice(),hasMore:!!(T!=null&&T.hasMore),nextCursor:(T==null?void 0:T.nextCursor)??null,checkpointId:(T==null?void 0:T.checkpointId)??null,checkpointNs:(T==null?void 0:T.checkpointNs)??null};re.current.set(ne,me),pe.current=ne}if(!xe)return;Ve(he,{checkpointId:(T==null?void 0:T.checkpointId)??null,checkpointNs:(T==null?void 0:T.checkpointNs)??null})}else if(_==="prepend"&&he.length&&ne){const me=re.current.get(ne),xt=(me==null?void 0:me.messages)??[],it=new Set,ut=[...he,...xt].filter(Sn=>{const Xt=Sn==null?void 0:Sn.id;return Xt?it.has(Xt)?!1:(it.add(Xt),!0):!0}),yn={threadId:ne,messages:ut,hasMore:(T==null?void 0:T.hasMore)??(me==null?void 0:me.hasMore)??!1,nextCursor:(T==null?void 0:T.nextCursor)??(me==null?void 0:me.nextCursor)??null,checkpointId:(me==null?void 0:me.checkpointId)??(T==null?void 0:T.checkpointId)??null,checkpointNs:(me==null?void 0:me.checkpointNs)??(T==null?void 0:T.checkpointNs)??null};if(re.current.set(ne,yn),!xe)return;Je(he)}else _==="prepend"&&he.length&&Je(he);xe&&(_==="replace"?(ye((T==null?void 0:T.nextCursor)??null),ee(!!(T!=null&&T.hasMore)),O((T==null?void 0:T.checkpointId)??void 0),te((T==null?void 0:T.checkpointNs)??void 0)):(ye(me=>(T==null?void 0:T.nextCursor)??me??null),ee(me=>(T==null?void 0:T.hasMore)!==void 0?!!(T!=null&&T.hasMore):me),O(me=>(T==null?void 0:T.checkpointId)??me??void 0),te(me=>(T==null?void 0:T.checkpointNs)??me??void 0)))},[Je,Ve]),sn=y.useCallback(T=>{T.threadId!=null&&T.threadId!==Ee.current||(Ve(T.messages,{checkpointId:T.checkpointId,checkpointNs:T.checkpointNs}),ye(T.nextCursor),ee(T.hasMore),O(T.checkpointId??void 0),te(T.checkpointNs??void 0),pe.current=T.threadId)},[Ve]),Yt=y.useCallback(T=>{T&&(re.current.delete(T),x(T),pe.current===T&&(pe.current=null))},[x]),an=y.useCallback(()=>{const T=Ee.current;T&&Yt(T),Be([]),ee(!1),ve(!1),ye(null),O(void 0),te(void 0)},[Yt,Be]),ur=y.useCallback(({from:T,to:_})=>{const B=Ee.current;B&&console.warn(`[ChatSessionProvider] Stream sequence gap detected (${T} -> ${_}) for thread ${B}`)},[]),Rr=y.useCallback(T=>{const _=T.threadId;console.log("[ChatSessionProvider] 📥 Handling thread_info event:",{threadId:_,title:T.title,created:T.created,currentThreads:E.length});const B={threadId:_,title:T.title||`Thread ${_.slice(0,8)}`,createdAt:T.createdAt||new Date().toISOString(),updatedAt:T.updatedAt||new Date().toISOString(),messageCount:T.messageCount||0};Ee.current!==_&&(!Ee.current&&G.messages.length<=1&&(Z.current=_),j(_)),y.startTransition(()=>{k(he=>{const ne=he.byId[_];return ne?ne.title===B.title&&ne.updatedAt===B.updatedAt&&ne.messageCount===B.messageCount?he:{byId:{...he.byId,[_]:B},order:he.order}:{byId:{...he.byId,[_]:B},order:[_,...he.order]}})})},[G.messages.length]),{startStream:Pr,stop:dr,isStreaming:En,error:Or,setAuthToken:Nn}=Dg({baseUrl:d,onThreadInfo:Rr,onMessageEvent:De,onUnhandledEvent:T=>{console.warn(`[ChatSessionProvider] Unhandled stream event: ${T.type}`,T)},onSequenceGap:ur});y.useEffect(()=>{_r.current=En},[En]),y.useEffect(()=>{if(!gr())return;bt.current!==null&&(window.clearTimeout(bt.current),bt.current=null);const T=E.map(B=>`${B.threadId}:${B.updatedAt??""}:${B.messageCount??""}`).join("|");if(E.length===0){try{xi(S)}catch{}bn.current="";return}if(T===bn.current)return;const _=()=>{try{const B=E.slice(0,mi);wi(S,B),bn.current=T}catch{}finally{bt.current=null}};return bt.current=window.setTimeout(()=>{pc(_),bt.current=null},No),()=>{bt.current!==null&&(window.clearTimeout(bt.current),bt.current=null)}},[E,on]),y.useEffect(()=>{var he;const T=l.getAuthToken();Nn(T);const _=ne=>{const xe=vi(f,ne);we.current!==xe&&(we.current=xe,Ne.current=!1),N(xe);const me=bi(xe);y.startTransition(()=>{k(Ao(me))}),Ne.current||(Ne.current=!0,gt().catch(()=>{}))};_(T);const B=(he=l.onTokenChange)==null?void 0:he.call(l,ne=>{Nn(ne),b(),_(ne)});return()=>{B==null||B()}},[l,f,Nn,b,gt]);const fr=y.useCallback(async T=>{var he;const _=`Thread ${(he=crypto.randomUUID)==null?void 0:he.call(crypto)}`,B={threadId:_,title:T||"New Chat",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messageCount:0};k(ne=>({byId:{...ne.byId,[_]:B},order:[_,...ne.order]})),j(_);try{const ne=await l.createThread(T),xe=typeof ne=="string"?ne:ne.threadId;return k(me=>{const xt=me.byId[_];if(!xt)return me;const it={...me.byId};delete it[_],it[xe]={...xt,threadId:xe};const ut=me.order.map(yn=>yn===_?xe:yn);return{byId:it,order:ut}}),j(xe),setTimeout(()=>gt(),10),Y(null),xe}catch(ne){throw k(xe=>{if(!xe.byId[_])return xe;const me={...xe.byId};delete me[_];const xt=xe.order.filter(it=>it!==_);return{byId:me,order:xt}}),j(null),Y(String(ne)),ne}},[l,gt]),ae=y.useCallback(async T=>{try{await l.deleteThread(T);let _=null;k(B=>{if(!B.byId[T])return B;const he={...B.byId};delete he[T];const ne=B.order.filter(me=>me!==T),xe={byId:he,order:ne};return _=yi(xe),xe}),_&&on(_,{immediate:!0}),Yt(T),Ee.current===T&&(Z.current=T,j(null),Ee.current=null,pe.current=null,an()),await gt(),Y(null)}catch(_){throw Y(String(_)),_}},[l,an,Yt,gt,on]),Te=y.useCallback(async(T,_)=>{try{await l.updateThread(T,_),k(B=>{const he=B.byId[T];return he?{byId:{...B.byId,[T]:{...he,title:_}},order:B.order}:B}),Y(null)}catch(B){throw await gt(),Y(String(B)),B}},[l,gt]),Oe=y.useCallback(async(T,_,B,he=!1)=>{await Qe(async()=>{if(Z.current===T&&!he){Z.current=null;return}if(ht.current===T&&!he)return;j(it=>it===T?it:T),Ee.current=T;const ne=!he&&!_&&!B;let xe=!1;if(ne){const it=re.current.get(T);if(it)sn(it),xe=!0;else{const ut=w(T);ut&&(re.current.set(T,ut),sn(ut),xe=!0)}}const me=he||!xe||!!_||!!B,xt=async it=>{it&&V(!0),ht.current=T;try{const ut=await l.getMessages({threadId:T,checkpointId:_,checkpointNs:B});Nt(ut,"replace",T),W(null)}catch(ut){throw(!xe||he||it)&&(i==null||i(String(ut))),W(String(ut)),ut}finally{ht.current=null,it&&V(!1)}};me?await xt(!0):ne&&xe&&xt(!1).catch(it=>{console.warn("[ChatSessionProvider] Background refresh failed:",it)})},`loadThread-${T}`)},[l,sn,Nt,Qe,i]),rt=y.useCallback(async()=>{await Qe(async()=>{const T=Ee.current;T&&Yt(T),Z.current=null,j(null),Ee.current=null,pe.current=null,an(),O(void 0),te(void 0);try{localStorage.removeItem("lastThreadId")}catch(_){console.warn("[ChatSessionProvider] Failed to clear lastThreadId:",_)}},"clearCurrentThread")},[an,Yt,Qe]),_t=y.useCallback(async T=>{const _=await l.listCheckpoints(T);return kg(_,T)},[l]),I=y.useCallback(async(T,_)=>{if(!Ee.current)throw new Error("No active thread");await Oe(Ee.current,T,_??void 0,!0)},[Oe]),H=y.useCallback(async()=>{if(!Ee.current)throw new Error("No active thread");await Oe(Ee.current,void 0,void 0,!0)},[Oe]),oe=y.useCallback(async T=>{if(!Ee.current)throw new Error("No active thread");if(fe||!D)return;const _=be;if(_){ve(!0);try{const B=Ee.current,he=await l.getMessages({threadId:B,checkpointId:K,checkpointNs:J,limit:(T==null?void 0:T.limit)??Fg,beforeId:_});Nt(he,"prepend",B??void 0),W(null)}catch(B){throw W(String(B)),B}finally{ve(!1)}}},[l,Nt,D,K,J,be,fe]),ke=y.useCallback(T=>{if(!(T!=null&&T.threadId))return;const _={threadId:T.threadId,checkpointId:T.checkpointId??void 0,checkpointNs:T.checkpointNs??void 0,messages:T.messages??[],hasMore:T.hasMore,nextCursor:T.nextCursor??null};Nt(_,"replace",T.threadId)},[Nt]),Fe=y.useCallback(async(T,_)=>{var Ys;const B=Ee.current,he=(T==null?void 0:T.text)??"",ne=(T==null?void 0:T.attachments)??[],xe=ne.length?ne:(_==null?void 0:_.attachments)??[],me={...(_==null?void 0:_.payloadExtras)??{},...(T==null?void 0:T.payload)??{}};if(!B&&!Object.keys(me).length&&xe.length===0&&!he.trim()){console.warn("[ChatSessionProvider] Nothing to submit - skipping");return}!B&&!me.messages&&console.warn("[ChatSessionProvider] No thread ID - message will create new thread");const{contentParts:xt,filesInfo:it}=await Eg(l,xe),ut=[...xt];he&&he.trim()&&ut.push({type:"text",text:he.trim()});const yn=!!B,Sn=yn?(_==null?void 0:_.checkpointId)??G.lastCheckpointId??void 0:void 0,Xt=yn?(_==null?void 0:_.checkpointNs)??G.lastCheckpointNs??void 0:void 0,Mr={id:((Ys=crypto.randomUUID)==null?void 0:Ys.call(crypto))||`user-${Date.now()}`,role:"user",content:ut,createdAt:new Date().toISOString(),...Sn!=null?{checkpointId:Sn}:{},...Xt!=null?{checkpointNs:Xt}:{}};ut.length>0&&nt(Mr);const rl={...Mr,content:ut},Ks=xe.length>0,Gs={...B?{threadId:B}:{},payload:{messages:ut.length>0?[rl]:[],files_info:it,...o&&Ks&&s?{active_agent:s}:{},...me},...Sn!=null?{checkpointId:Sn}:{},...Xt!=null?{checkpointNs:Xt}:{},nodeFilter:_==null?void 0:_.nodeFilter,config:_==null?void 0:_.config};Pr(Gs,{onError:An=>{console.warn("[ChatSessionProvider] Stream error:",An)},onOpen:({threadId:An})=>{!Ee.current&&An&&(G.messages.length<=1&&(Z.current=An),j(An))},onGap:ur})},[l,o,s,ur,G.lastCheckpointId,G.lastCheckpointNs,G.messages.length,nt,Pr]),qe=y.useCallback(async(T,_,B)=>{var ne,xe;const he=Ee.current;if(!he)throw new Error("No active thread to handle interrupt");try{const me=_?B??!0:!1;try{se({type:"interrupt_response",payload:{interruptId:T}})}catch(Mr){console.warn("[ChatSessionProvider] optimistic interrupt_response dispatch failed:",Mr)}const xt=`${d}/runs/resume`,it=(ne=l.getAuthToken)==null?void 0:ne.call(l),ut=await fetch(xt,{method:"POST",headers:{"Content-Type":"application/json",...it?{Authorization:`Bearer ${it}`}:{}},body:JSON.stringify({thread_id:he,value:me})});if(!ut.ok)throw new Error(`Resume failed with status ${ut.status}`);const yn=(xe=ut.body)==null?void 0:xe.getReader();if(!yn)throw new Error("No response body for resume stream");const Sn=new TextDecoder;let Xt="";for(;;){const{done:Mr,value:rl}=await yn.read();if(Mr)break;Xt+=Sn.decode(rl,{stream:!0});const Ks=Xt.split(`
|
|
39
|
-
`);Xt=Ks.pop()||"";for(const Gs of Ks)if(Gs.startsWith("data: ")){const Ys=Gs.slice(6);try{const An=JSON.parse(Ys);se({type:"event",payload:{ev:An}})}catch(An){console.warn("[ChatSessionProvider] Failed to parse resume SSE event:",An)}}}$(null)}catch(me){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${T}:`,me),me}},[l,se,d]),Ue=y.useCallback(T=>qe(T.interruptId,T.approved,T.value),[qe]);y.useEffect(()=>{if(a==null||a(A),A)try{localStorage.setItem("lastThreadId",A)}catch(T){console.warn("[ChatSessionProvider] Failed to persist lastThreadId:",T)}},[A,a]),y.useEffect(()=>((async()=>{try{if(gt().catch(_=>{console.error("[ChatSessionProvider] Failed to refresh threads (background):",_),i==null||i(String(_))}),!r&&!t)try{const _=localStorage.getItem("lastThreadId");_&&(j(_),n&&await Oe(_))}catch(_){console.warn("[ChatSessionProvider] Failed to restore last thread:",_)}else t&&n&&await Oe(t)}catch(_){console.error("[ChatSessionProvider] Initialization failed:",_),i==null||i(String(_))}})(),()=>{}),[]),y.useEffect(()=>{const T=Ee.current;if(!T||pe.current!==T)return;const _={threadId:T,messages:G.messages.slice(),hasMore:D,nextCursor:be,checkpointId:G.lastCheckpointId??null,checkpointNs:G.lastCheckpointNs??null},B=re.current.get(T);(!B||B.messages.length!==_.messages.length||B.messages.some((ne,xe)=>{var me;return(ne==null?void 0:ne.id)!==((me=_.messages[xe])==null?void 0:me.id)})||(B==null?void 0:B.hasMore)!==_.hasMore||(B==null?void 0:B.nextCursor)!==_.nextCursor||(B==null?void 0:B.checkpointId)!==_.checkpointId||(B==null?void 0:B.checkpointNs)!==_.checkpointNs)&&(re.current.set(T,_),lr.current&&window.clearTimeout(lr.current),lr.current=window.setTimeout(()=>{try{g(_,100)}catch(ne){console.warn("[ChatSessionProvider] Failed to persist thread payload:",ne)}},No))},[D,be,G.lastCheckpointId,G.lastCheckpointNs,G.messages]);const He=y.useMemo(()=>({threads:E,currentThreadId:A,setCurrentThreadId:j,isLoading:P,error:M,actions:{createThread:fr,deleteThread:ae,renameThread:Te,refreshThreads:()=>gt()},persistThreadsCache:cr,hydrateFromCache:ue}),[E,A,P,M,fr,ae,Te,gt,cr,ue,j]),Ct=y.useMemo(()=>{const T=G.lastBranch??null,_=G.assemblingId??null,B=T||_?{branchLabel:(T==null?void 0:T.branchLabel)??null,lastBranch:T,assemblingMessageId:_}:null;return{threadId:A,messages:G.messages,interrupt:z,checkpoint:{id:G.lastCheckpointId??null,namespace:G.lastCheckpointNs??null},metadata:B,isLoading:F,isHistoryLoading:fe,error:q,hasMore:D,loadOlder:oe,seedFromSnapshot:ke,clearState:an,listCheckpoints:_t,navigateToCheckpoint:I,returnToLatest:H,loadThread:Oe,clearThread:rt,respondToInterrupt:qe}},[rt,an,A,z,D,fe,F,_t,oe,Oe,G.assemblingId,G.lastBranch,G.lastCheckpointId,G.lastCheckpointNs,G.messages,I,qe,H,ke,q]),ct=y.useMemo(()=>({isStreaming:En,error:Or,submit:Fe,stop:dr,resume:Ue,setAuthToken:Nn}),[En,Or,Fe,dr,Ue,Nn]);return c.jsx(Lg.Provider,{value:!0,children:c.jsx(fc.Provider,{value:ct,children:c.jsx(uc.Provider,{value:He,children:c.jsx(dc.Provider,{value:Ct,children:e})})})})}function jo(){const e=y.useContext(uc);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function _o(){const e=y.useContext(dc);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function gc(){const e=y.useContext(fc);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function Ro({children:e,apiConfig:t,initialThreadId:n=null,autoLoadInitial:r=!0,disableAutoRestore:o=!1,enableFileAgentRouting:s=!1,fileAgentId:i="invoice_reader",onError:a,onThreadChange:l}){return c.jsx(Tg,{apiConfig:t,children:c.jsx(qg,{initialThreadId:n,autoLoadInitial:r,disableAutoRestore:o,enableFileAgentRouting:s,fileAgentId:i,onError:a,onThreadChange:l,children:e})})}function Q(...e){return Qp.twMerge(Zp.clsx(e))}const Kg=mo.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"}}),Ge=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Un.Slot:"button";return c.jsx(i,{className:Q(Kg({variant:t,size:n,className:e})),ref:s,...o})});Ge.displayName="Button";const xc=m.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:Q("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));xc.displayName="Textarea";function Gg({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,onSend:i,onCancelEdit:a,onStop:l,className:u="",textareaClassName:d="",allowEmptySend:f=!1}){const[h,p]=y.useState(e),[v,w]=y.useTransition(),g=y.useRef(null);y.useEffect(()=>{p(e??""),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const x=y.useCallback(()=>{const A=g.current;A&&(A.style.height="auto",A.style.height=`${A.scrollHeight}px`)},[]);y.useEffect(()=>{x()},[x]);const b=y.useCallback(async A=>{A&&A.preventDefault();const j=(h??"").trim();!j&&!f||w(()=>{try{const P=i(j);P&&typeof P.then=="function"?P.then(()=>{p(""),g.current&&(g.current.style.height="auto")}).catch(()=>{}):(p(""),g.current&&(g.current.style.height="auto"))}catch{}})},[h,i,f]),S=y.useCallback(A=>{p(A.target.value),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),N=y.useCallback(A=>{A.key==="Enter"&&!A.shiftKey?(A.preventDefault(),b()):A.key==="Escape"&&t&&(A.preventDefault(),a==null||a())},[b,t,a]),E=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${d}`;return c.jsx("form",{onSubmit:A=>void b(A),className:`w-full ${u}`,children:c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsx("div",{className:"flex-1",children:c.jsx(xc,{ref:g,value:h,onChange:S,onKeyDown:N,placeholder:t?"Edit your message...":n,className:E,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),c.jsx("div",{children:r?c.jsx(Ge,{type:"button",onClick:()=>{l==null||l()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!l,children:c.jsx(ie.Square,{size:16})}):c.jsx(Ge,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||v,children:c.jsx(ie.Send,{size:16})})})]})})}const Yg=y.memo(Gg),Po=0,_n=1,xr=2,vc=4;function wc(e){return()=>e}function Xg(e){e()}function bc(e,t){return n=>e(t(n))}function yc(e,t){return()=>e(t)}function Jg(e,t){return n=>e(t,n)}function Si(e){return e!==void 0}function Zg(...e){return()=>{e.map(Xg)}}function vr(){}function Oo(e,t){return t(e),e}function Qg(e,t){return t(e)}function ot(...e){return e}function Xe(e,t){return e(_n,t)}function Le(e,t){e(Po,t)}function Ci(e){e(xr)}function ft(e){return e(vc)}function ge(e,t){return Xe(e,Jg(t,Po))}function Zt(e,t){const n=e(_n,r=>{n(),t(r)});return n}function Sc(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Cc(e,t){return e===t}function st(e=Cc){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function je(e){return t=>n=>{e(n)&&t(n)}}function le(e){return t=>bc(t,e)}function cn(e){return t=>()=>{t(e)}}function U(e,...t){const n=ex(...t);return(r,o)=>{switch(r){case xr:Ci(e);return;case _n:return Xe(e,n(o))}}}function un(e,t){return n=>r=>{n(t=e(t,r))}}function Kn(e){return t=>n=>{e>0?e--:t(n)}}function Tn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function $e(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Xe(s,l=>{const u=n;n=n|a,t[i]=l,u!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function ex(...e){return t=>e.reduceRight(Qg,t)}function tx(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case _n:return s?n===s?void 0:(r(),n=s,t=Xe(e,s),t):(r(),vr);case xr:r(),n=null;return}}}function X(e){let t=e;const n=Ke();return(r,o)=>{switch(r){case Po:t=o;break;case _n:{o(t);break}case vc:return t}return n(r,o)}}function kt(e,t){return Oo(X(t),n=>ge(e,n))}function Ke(){const e=[];return(t,n)=>{switch(t){case Po:e.slice().forEach(r=>{r(n)});return;case xr:e.splice(0,e.length);return;case _n:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Lt(e){return Oo(Ke(),t=>ge(e,t))}function Ye(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:nx(),singleton:n}}const nx=()=>Symbol();function rx(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 pt(...e){const t=Ke(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Xe(s,l=>{n[i]=l,r=r|a,r===o&&Le(t,n)})}),function(s,i){switch(s){case xr:{Ci(t);return}case _n:return r===o&&i(n),Xe(t,i)}}}function Ie(e,t=Cc){return U(e,st(t))}function Ti(...e){return function(t,n){switch(t){case xr:return;case _n:return Zg(...e.map(r=>Xe(r,n)))}}}var Ot=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ot||{});const ox={0:"debug",3:"error",1:"log",2:"warn"},sx=()=>typeof globalThis>"u"?window:globalThis,Rn=Ye(()=>{const e=X(3);return{log:X((t,n,r=1)=>{var o;const s=(o=sx().VIRTUOSO_LOG_LEVEL)!=null?o:ft(e);r>=s&&console[ox[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Gn(e,t,n){return ki(e,t,n).callbackRef}function ki(e,t,n){const r=y.useRef(null);let o=i=>{};const s=y.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function ix(e,t,n,r,o,s,i,a,l){const u=y.useCallback(d=>{const f=ax(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const p=h.lastElementChild.dataset.viewportType==="window";let v;p&&(v=h.ownerDocument.defaultView);const w=i?a?i.scrollLeft:i.scrollTop:p?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:p?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,x=i?a?i.offsetWidth:i.offsetHeight:p?a?v.innerWidth:v.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(w,0),viewportHeight:x}),s==null||s(a?Tc("column-gap",getComputedStyle(d).columnGap,o):Tc("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return ki(u,n,l)}function ax(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),u=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Ot.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Tc(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ot.WARN),t==="normal"?0:parseInt(t??"0",10)}function kc(e,t,n){const r=y.useRef(null),o=y.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const u=l.getBoundingClientRect(),d=u.width;let f,h;if(t){const p=t.getBoundingClientRect(),v=u.top-p.top;h=p.height-Math.max(0,v),f=v+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;h=p.innerHeight-Math.max(0,u.top),f=u.top+p.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=ki(o,!0,n),a=y.useCallback(()=>{o(i.current)},[o,i]);return y.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const u=new ResizeObserver(()=>{requestAnimationFrame(a)});return u.observe(t),()=>{t.removeEventListener("scroll",a),u.unobserve(t)}}else{const u=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return u==null||u.addEventListener("scroll",a),u==null||u.addEventListener("resize",a),()=>{u==null||u.removeEventListener("scroll",a),u==null||u.removeEventListener("resize",a)}}},[a,t,i]),s}const At=Ye(()=>{const e=Ke(),t=Ke(),n=X(0),r=Ke(),o=X(0),s=Ke(),i=Ke(),a=X(0),l=X(0),u=X(0),d=X(0),f=Ke(),h=Ke(),p=X(!1),v=X(!1),w=X(!1);return ge(U(e,le(({scrollTop:g})=>g)),t),ge(U(e,le(({scrollHeight:g})=>g)),i),ge(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:w,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Ur={lvl:0};function Ic(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 et(e){return e===Ur}function Wr(e,t){if(!et(e))return t===e.k?e.v:t<e.k?Wr(e.l,t):Wr(e.r,t)}function Qt(e,t,n="k"){if(et(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=Qt(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return Qt(e.l,t,n)}function Ft(e,t,n){return et(e)?Ac(t,n,1):t===e.k?mt(e,{k:t,v:n}):t<e.k?jc(mt(e,{l:Ft(e.l,t,n)})):jc(mt(e,{r:Ft(e.r,t,n)}))}function wr(){return Ur}function Mo(e,t,n){if(et(e))return[];const r=Qt(e,t)[0];return lx(Ei(e,r,n))}function Ii(e,t){if(et(e))return Ur;const{k:n,l:r,r:o}=e;if(t===n){if(et(r))return o;if(et(o))return r;{const[s,i]=Nc(r);return Do(mt(e,{k:s,l:Ec(r),v:i}))}}else return t<n?Do(mt(e,{l:Ii(r,t)})):Do(mt(e,{r:Ii(o,t)}))}function Yn(e){return et(e)?[]:[...Yn(e.l),{k:e.k,v:e.v},...Yn(e.r)]}function Ei(e,t,n){if(et(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Ei(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Ei(s,t,n))),a}function Do(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(Ni(t))return _c(mt(e,{lvl:n-1}));if(!et(t)&&!et(t.r))return mt(t.r,{l:mt(t,{r:t.r.l}),lvl:n,r:mt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Ni(e))return Ai(mt(e,{lvl:n-1}));if(!et(r)&&!et(r.l)){const o=r.l,s=Ni(o)?r.lvl-1:r.lvl;return mt(o,{l:mt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Ai(mt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function mt(e,t){return Ac(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 Ec(e){return et(e.r)?e.l:Do(mt(e,{r:Ec(e.r)}))}function Ni(e){return et(e)||e.lvl>e.r.lvl}function Nc(e){return et(e.r)?[e.k,e.v]:Nc(e.r)}function Ac(e,t,n,r=Ur,o=Ur){return{k:e,l:r,lvl:n,r:o,v:t}}function jc(e){return Ai(_c(e))}function _c(e){const{l:t}=e;return!et(t)&&t.lvl===e.lvl?mt(t,{r:mt(e,{l:t.r})}):e}function Ai(e){const{lvl:t,r:n}=e;return!et(n)&&!et(n.r)&&n.lvl===t&&n.r.lvl===t?mt(n,{l:mt(e,{r:n.l}),lvl:t+1}):e}function lx(e){return Ic(e,({k:t,v:n})=>({index:t,value:n}))}function Rc(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Vr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const ji=Ye(()=>({recalcInProgress:X(!1)}),[],{singleton:!0});function Pc(e,t,n){return e[Lo(e,t,n)]}function Lo(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 cx(e,t,n,r){const o=Lo(e,t,r),s=Lo(e,n,r,o);return e.slice(o,s+1)}function Pn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Fo(e){return!et(e.groupOffsetTree)}function _i({index:e},t){return t===e?0:t<e?-1:1}function ux(){return{groupIndices:[],groupOffsetTree:wr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:wr()}}function dx(e,t){let n=et(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),et(e)){e=Ft(e,0,s);continue}const a=Mo(e,i-1,o+1);if(a.some(vx(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=Ii(e,f)):(u=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=Ft(e,o+1,h));u&&(e=Ft(e,i,s))}return[e,n]}function fx(e){return typeof e.groupIndex<"u"}function hx({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}=Pc(t,e,_i),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Oc(e,t){if(!Fo(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Mc(e,t,n){if(fx(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Oc(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function px(e,t,n,r=0){return r>0&&(t=Math.max(t,Pc(e,r,_i).offset)),Ic(cx(e,t,n,hx),xx)}function mx(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ot.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&et(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((v,w)=>Ft(Ft(v,w,h),w+1,p),i)}else[i,a]=dx(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=Ri(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>Ft(h,p,qr(p,f,o)),wr()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function gx(e){return Yn(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function Dc(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function Ri(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=Lo(o,t-1,_i),a=o[l].offset;const u=Qt(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===Qt(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:u,value:d}of Mo(n,t,1/0)){const f=u-s,h=f*i+a+f*r;o.push({index:u,offset:h,size:d}),s=u,a=h,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function xx(e){return{index:e.index,value:e}}function vx(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 wx={offsetHeight:"height",offsetWidth:"width"},dn=Ye(([{log:e},{recalcInProgress:t}])=>{const n=Ke(),r=Ke(),o=kt(r,0),s=Ke(),i=Ke(),a=X(0),l=X([]),u=X(void 0),d=X(void 0),f=X((C,k)=>Pn(C,wx[k])),h=X(void 0),p=X(0),v=ux(),w=kt(U(n,$e(l,e,p),un(mx,v),st()),v),g=kt(U(l,st(),un((C,k)=>({current:k,prev:C.current}),{current:[],prev:[]}),le(({prev:C})=>C)),[]);ge(U(l,je(C=>C.length>0),$e(w,p),le(([C,k,E])=>{const A=C.reduce((j,P,L)=>Ft(j,P,qr(P,k.offsetTree,E)||L),wr());return{...k,groupIndices:C,groupOffsetTree:A}})),w),ge(U(r,$e(w),je(([C,{lastIndex:k}])=>C<k),le(([C,{lastIndex:k,lastSize:E}])=>[{endIndex:k,size:E,startIndex:C}])),n),ge(u,d);const x=kt(U(u,le(C=>C===void 0)),!0);ge(U(d,je(C=>C!==void 0&&et(ft(w).sizeTree)),le(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=Lt(U(n,$e(w),un(({sizes:C},[k,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:v}),le(C=>C.changed)));Xe(U(a,un((C,k)=>({diff:C.prev-k,prev:k}),{diff:0,prev:0}),le(C=>C.diff)),C=>{const{groupIndices:k}=ft(w);if(C>0)Le(t,!0),Le(s,C+Dc(C,k));else if(C<0){const E=ft(g);E.length>0&&(C-=Dc(-C,E)),Le(i,C)}}),Xe(U(a,$e(e)),([C,k])=>{C<0&&k("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Ot.ERROR)});const S=Lt(s);ge(U(s,$e(w),le(([C,k])=>{const E=k.groupIndices.length>0,A=[],j=k.lastSize;if(E){const P=Wr(k.sizeTree,0);let L=0,F=0;for(;L<C;){const M=k.groupIndices[F],Y=k.groupIndices.length===F+1?1/0:k.groupIndices[F+1]-M-1;A.push({endIndex:M,size:P,startIndex:M}),A.push({endIndex:M+1+Y-1,size:j,startIndex:M+1}),F++,L+=Y+1}const V=Yn(k.sizeTree);return L!==C&&V.shift(),V.reduce((M,{k:Y,v:q})=>{let W=M.ranges;return M.prevSize!==0&&(W=[...M.ranges,{endIndex:Y+C-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:Y+C,prevSize:q,ranges:W}},{prevIndex:C,prevSize:0,ranges:A}).ranges}return Yn(k.sizeTree).reduce((P,{k:L,v:F})=>({prevIndex:L+C,prevSize:F,ranges:[...P.ranges,{endIndex:L+C-1,size:P.prevSize,startIndex:P.prevIndex}]}),{prevIndex:0,prevSize:j,ranges:[]}).ranges})),n);const N=Lt(U(i,$e(w,p),le(([C,{offsetTree:k},E])=>{const A=-C;return qr(A,k,E)})));return ge(U(i,$e(w,p),le(([C,k,E])=>{if(k.groupIndices.length>0){if(et(k.sizeTree))return k;let A=wr();const j=ft(g);let P=0,L=0,F=0;for(;P<-C;){F=j[L];const V=j[L+1]-F-1;L++,P+=V+1}if(A=Yn(k.sizeTree).reduce((V,{k:M,v:Y})=>Ft(V,Math.max(0,M+C),Y),A),P!==-C){const V=Wr(k.sizeTree,F);A=Ft(A,0,V);const M=Qt(k.sizeTree,-C+1)[1];A=Ft(A,1,M)}return{...k,sizeTree:A,...Ri(k.offsetTree,0,A,E)}}else{const A=Yn(k.sizeTree).reduce((j,{k:P,v:L})=>Ft(j,Math.max(0,P+C),L),wr());return{...k,sizeTree:A,...Ri(k.offsetTree,0,A,E)}}})),w),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:N,sizeRanges:n,sizes:w,statefulTotalCount:o,totalCount:r,trackItemSizes:x,unshiftWith:s}},ot(Rn,ji),{singleton:!0});function bx(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Lc=Ye(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Ke(),i=Ke(),a=Lt(U(s,le(bx)));return ge(U(a,le(l=>l.totalCount)),n),ge(U(a,le(l=>l.groupIndices)),e),ge(U(pt(o,t,r),je(([l,u])=>Fo(u)),le(([l,u,d])=>Qt(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),st(),le(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},ot(dn,At)),On=Ye(([{log:e}])=>{const t=X(!1),n=Lt(U(t,je(r=>r),st()));return Xe(t,r=>{r&&ft(e)("props updated",{},Ot.DEBUG)}),{didMount:n,propsReady:t}},ot(Rn),{singleton:!0}),yx=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Fc(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!yx)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Kr=Ye(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const p=Ke(),v=Ke(),w=X(0);let g=null,x=null,b=null;function S(){g&&(g(),g=null),b&&(b(),b=null),x&&(clearTimeout(x),x=null),Le(l,!1)}return ge(U(p,$e(n,f,r,w,a,i,h),$e(e,s,o),le(([[N,C,k,E,A,j,P,L],F,V,M])=>{const Y=Fc(N),{align:q,behavior:W,offset:z}=Y,$=E-1,ue=Mc(Y,C,$);let D=qr(ue,C.offsetTree,F)+j;q==="end"?(D+=V+Qt(C.sizeTree,ue)[1]-k+M,ue===$&&(D+=P)):q==="center"?D+=(V+Qt(C.sizeTree,ue)[1]-k+M)/2:D-=A,z&&(D+=z);const ee=fe=>{S(),fe?(L("retrying to scroll to",{location:N},Ot.DEBUG),Le(p,N)):(Le(v,!0),L("list did not change, scroll successful",{},Ot.DEBUG))};if(S(),W==="smooth"){let fe=!1;b=Xe(t,ve=>{fe=fe||ve}),g=Zt(d,()=>{ee(fe)})}else g=Zt(U(t,Sx(150)),ee);return x=setTimeout(()=>{S()},1200),Le(l,!0),L("scrolling from index to",{behavior:W,index:ue,top:D},Ot.DEBUG),{behavior:W,top:D}})),u),{scrollTargetReached:v,scrollToIndex:p,topListHeight:w}},ot(dn,At,Rn),{singleton:!0});function Sx(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Pi(e,t){e==0?t():requestAnimationFrame(()=>{Pi(e-1,t)})}function Oi(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Gr=Ye(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=X(!0),l=X(0),u=X(!0);return ge(U(i,$e(l),je(([d,f])=>!!f),cn(!1)),a),ge(U(i,$e(l),je(([d,f])=>!!f),cn(!1)),u),Xe(U(pt(t,i),$e(a,n,e,u),je(([[,d],f,{sizeTree:h},p,v])=>d&&(!et(h)||Si(p))&&!f&&!v),$e(l)),([,d])=>{Zt(o,()=>{Le(u,!0)}),Pi(4,()=>{Zt(r,()=>{Le(a,!0)}),Le(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},ot(dn,At,Kr,On),{singleton:!0});function $c(e,t){return Math.abs(e-t)<1.01}const Yr="up",Xr="down",Cx="none",Tx={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},kx=0,Jr=Ye(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=X(!1),a=X(!0),l=Ke(),u=Ke(),d=X(4),f=X(kx),h=kt(U(Ti(U(Ie(o),Kn(1),cn(!0)),U(Ie(o),Kn(1),cn(!1),Sc(100))),st()),!1),p=kt(U(Ti(U(n,cn(!0)),U(n,cn(!1),Sc(200))),st()),!1);ge(U(pt(Ie(o),Ie(f)),le(([b,S])=>b<=S),st()),a),ge(U(a,Tn(50)),u);const v=Lt(U(pt(r,Ie(s),Ie(t),Ie(e),Ie(d)),un((b,[{scrollHeight:S,scrollTop:N},C,k,E,A])=>{const j=N+C-S>-A,P={scrollHeight:S,scrollTop:N,viewportHeight:C};if(j){let F,V;return N>b.state.scrollTop?(F="SCROLLED_DOWN",V=b.state.scrollTop-N):(F="SIZE_DECREASED",V=b.state.scrollTop-N||b.scrollTopDelta),{atBottom:!0,atBottomBecause:F,scrollTopDelta:V,state:P}}let L;return P.scrollHeight>b.state.scrollHeight?L="SIZE_INCREASED":C<b.state.viewportHeight?L="VIEWPORT_HEIGHT_DECREASING":N<b.state.scrollTop?L="SCROLLING_UPWARDS":L="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:L,state:P}},Tx),st((b,S)=>b&&b.atBottom===S.atBottom))),w=kt(U(r,un((b,{scrollHeight:S,scrollTop:N,viewportHeight:C})=>{if($c(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:N};{const k=S-(N+C)<1;return b.scrollTop!==N&&k?{changed:!0,jump:b.scrollTop-N,scrollHeight:S,scrollTop:N}:{changed:!0,jump:0,scrollHeight:S,scrollTop:N}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),je(b=>b.changed),le(b=>b.jump)),0);ge(U(v,le(b=>b.atBottom)),i),ge(U(i,Tn(50)),l);const g=X(Xr);ge(U(r,le(({scrollTop:b})=>b),st(),un((b,S)=>ft(p)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?Yr:Xr,prevScrollTop:S},{direction:Xr,prevScrollTop:0}),le(b=>b.direction)),g),ge(U(r,Tn(50),cn(Cx)),g);const x=X(0);return ge(U(h,je(b=>!b),cn(0)),x),ge(U(o,Tn(100),$e(h),je(([b,S])=>!!S),un(([b,S],[N])=>[S,N],[0,0]),le(([b,S])=>S-b)),x),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:w,scrollDirection:g,scrollVelocity:x}},ot(At)),$o="top",zo="bottom",zc="none";function Bc(e,t,n){return typeof e=="number"?n===Yr&&t===$o||n===Xr&&t===zo?e:0:n===Yr?t===$o?e.main:e.reverse:t===zo?e.main:e.reverse}function Hc(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Mi=Ye(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Ke(),i=X(0),a=X(0),l=X(0),u=kt(U(pt(Ie(r),Ie(o),Ie(n),Ie(s,Vr),Ie(l),Ie(i),Ie(t),Ie(e),Ie(a)),le(([d,f,h,[p,v],w,g,x,b,S])=>{const N=d-b,C=g+x,k=Math.max(h-N,0);let E=zc;const A=Hc(S,$o),j=Hc(S,zo);return p-=b,p+=h+x,v+=h+x,v-=b,p>d+C-A&&(E=Yr),v<d-k+f+j&&(E=Xr),E!==zc?[Math.max(N-h-Bc(w,$o,E)-A,0),N-k-x+f+Bc(w,zo,E)+j]:null}),je(d=>d!=null),st(Vr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},ot(At),{singleton:!0});function Ix(e,t,n){if(Fo(t)){const r=Oc(e,t);return[{index:Qt(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 Di={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Bo(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const w=e[e.length-1];d=w.offset+w.size}const f=n-i,h=a+f*l+(f-1)*r,p=u,v=h-d;return{bottom:d,firstItemIndex:s,items:Wc(e,o,s),offsetBottom:v,offsetTop:u,top:p,topItems:Wc(t,o,s),topListHeight:t.reduce((w,g)=>g.size+w,0),totalCount:n}}function Uc(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=Oi(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return Bo(u,[],a,o,n,r)}function Wc(e,t,n){if(e.length===0)return[];if(!Fo(t))return e.map(u=>({...u,index:u.index+n,originalIndex:u.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=Mo(t.groupOffsetTree,r,o);let a,l=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:u.index-(l+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const Xn=Ye(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:p},{recalcInProgress:v}])=>{const w=X([]),g=X(0),x=Ke();ge(s.topItemsIndexes,w);const b=kt(U(pt(p,v,Ie(l,Vr),Ie(o),Ie(r),Ie(u),d,Ie(w),Ie(t),Ie(n),e),je(([k,E,,A,,,,,,,j])=>{const P=j&&j.length!==A;return k&&!E&&!P}),le(([,,[k,E],A,j,P,L,F,V,M,Y])=>{const q=j,{offsetTree:W,sizeTree:z}=q,$=ft(g);if(A===0)return{...Di,totalCount:A};if(k===0&&E===0)return $===0?{...Di,totalCount:A}:Uc($,P,j,V,M,Y||[]);if(et(z))return $>0?null:Bo(Ix(Oi(P,A),q,Y),[],A,M,q,V);const ue=[];if(F.length>0){const be=F[0],ye=F[F.length-1];let K=0;for(const O of Mo(z,be,ye)){const J=O.value,te=Math.max(O.start,be),G=Math.min(O.end,ye);for(let se=te;se<=G;se++)ue.push({data:Y==null?void 0:Y[se],index:se,offset:K,size:J}),K+=J}}if(!L)return Bo([],ue,A,M,q,V);const D=F.length>0?F[F.length-1]+1:0,ee=px(W,k,E,D);if(ee.length===0)return null;const fe=A-1,ve=Oo([],be=>{for(const ye of ee){const K=ye.value;let O=K.offset,J=ye.start;const te=K.size;if(K.offset<k){J+=Math.floor((k-K.offset+M)/(te+M));const se=J-ye.start;O+=se*te+se*M}J<D&&(O+=(D-J)*te,J=D);const G=Math.min(ye.end,fe);for(let se=J;se<=G&&!(O>=E);se++)be.push({data:Y==null?void 0:Y[se],index:se,offset:O,size:te}),O+=te+M}});return Bo(ve,ue,A,M,q,V)}),je(k=>k!==null),st()),Di);ge(U(e,je(Si),le(k=>k==null?void 0:k.length)),o),ge(U(b,le(k=>k.topListHeight)),f),ge(f,a),ge(U(b,le(k=>[k.top,k.bottom])),i),ge(U(b,le(k=>k.items)),x);const S=Lt(U(b,je(({items:k})=>k.length>0),$e(o,e),je(([{items:k},E])=>k[k.length-1].originalIndex===E-1),le(([,k,E])=>[k-1,E]),st(Vr),le(([k])=>k))),N=Lt(U(b,Tn(200),je(({items:k,topItems:E})=>k.length>0&&k[0].originalIndex===E.length),le(({items:k})=>k[0].index),st())),C=Lt(U(b,je(({items:k})=>k.length>0),le(({items:k})=>{let E=0,A=k.length-1;for(;k[E].type==="group"&&E<A;)E++;for(;k[A].type==="group"&&A>E;)A--;return{endIndex:k[A].index,startIndex:k[E].index}}),st(Rc)));return{endReached:S,initialItemCount:g,itemsRendered:x,listState:b,rangeChanged:C,startReached:N,topItemsIndexes:w,...h}},ot(dn,Lc,Mi,Gr,Kr,Jr,On,ji),{singleton:!0}),Vc=Ye(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Ke(),i=kt(U(pt(n,e,r,t,o),le(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return ge(Ie(i),s),{totalListHeight:i,totalListHeightChanged:s}},ot(At,Xn),{singleton:!0}),Ex=Ye(([{viewportHeight:e},{totalListHeight:t}])=>{const n=X(!1),r=kt(U(pt(n,e,t),je(([o])=>o),le(([,o,s])=>Math.max(0,o-s)),Tn(0),st()),0);return{alignToBottom:n,paddingTopAddition:r}},ot(At,Vc),{singleton:!0}),qc=Ye(()=>({context:X(null)})),Nx=({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,Kc=Ye(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:u}])=>{const d=Ke();return ge(U(d,$e(t,l,n,s,o,r,a),$e(e),le(([[f,h,p,v,w,g,x,b],S])=>{const{align:N,behavior:C,calculateViewLocation:k=Nx,done:E,...A}=f,j=Mc(f,h,v-1),P=qr(j,h.offsetTree,S)+w+g,L=P+Qt(h.sizeTree,j)[1],F=b+g,V=b+p-x,M=k({itemBottom:L,itemTop:P,locationParams:{align:N,behavior:C,...A},viewportBottom:V,viewportTop:F});return M?E&&Zt(U(i,je(Y=>!Y),Kn(ft(i)?1:2)),E):E&&E(),M}),je(f=>f!==null)),u),{scrollIntoView:d}},ot(dn,At,Kr,Xn,Rn),{singleton:!0});function Gc(e){return e?e==="smooth"?"smooth":"auto":!1}const Ax=(e,t)=>typeof e=="function"?Gc(e(t)):t&&Gc(e),jx=Ye(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:u},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:p}])=>{const v=X(!1),w=Ke();let g=null;function x(C){Le(i,{align:"end",behavior:C,index:"LAST"})}Xe(U(pt(U(Ie(t),Kn(1)),l),$e(Ie(v),s,a,f),le(([[C,k],E,A,j,P])=>{let L=k&&j,F="auto";return L&&(F=Ax(E,A||P),L=L&&!!F),{followOutputBehavior:F,shouldFollow:L,totalCount:C}}),je(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:k})=>{g&&(g(),g=null),ft(n)?requestAnimationFrame(()=>{ft(d)("following output to ",{totalCount:k},Ot.DEBUG),x(C)}):g=Zt(e,()=>{ft(d)("following output to ",{totalCount:k},Ot.DEBUG),x(C),g=null})});function b(C){const k=Zt(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(ft(d)("scrolling to bottom due to increased size",{},Ot.DEBUG),x("auto"))});setTimeout(k,100)}Xe(U(pt(Ie(v),t,u),je(([C,,k])=>C&&k),un(({value:C},[,k])=>({refreshed:C===k,value:k}),{refreshed:!1,value:0}),je(({refreshed:C})=>C),$e(v,t)),([,C])=>{ft(a)&&b(C!==!1)}),Xe(w,()=>{b(ft(v)!==!1)}),Xe(pt(Ie(v),o),([C,k])=>{C&&!k.atBottom&&k.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&x("auto")});const S=X(null),N=Ke();return ge(Ti(U(Ie(r),le(C=>{var k;return(k=C==null?void 0:C.length)!=null?k:0})),U(Ie(t))),N),Xe(U(pt(U(N,Kn(1)),l),$e(Ie(S),a,f,h),le(([[C,k],E,A,j,P])=>k&&A&&(E==null?void 0:E({context:P,totalCount:C,scrollingInProgress:j}))),je(C=>!!C),Tn(0)),C=>{g&&(g(),g=null),ft(n)?requestAnimationFrame(()=>{ft(d)("scrolling into view",{}),Le(p,C)}):g=Zt(e,()=>{ft(d)("scrolling into view",{}),Le(p,C),g=null})}),{autoscrollToBottom:w,followOutput:v,scrollIntoViewOnChange:S}},ot(dn,Jr,Kr,Gr,On,Rn,At,qc,Kc)),_x=Ye(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ge(U(a,$e(s),je(([,l])=>l!==0),$e(o,r,t,n,e),le(([[,l],u,d,f,h,p=[]])=>Uc(l,u,d,f,h,p))),i),{}),ot(dn,Gr,Xn,On),{singleton:!0}),Rx=Ye(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=X(0);return Xe(U(e,$e(r),je(([,o])=>o!==0),le(([,o])=>({top:o}))),o=>{Zt(U(n,Kn(1),je(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Le(t,o)})})}),{initialScrollTop:r}},ot(On,At,Xn),{singleton:!0}),Yc=Ye(([{scrollVelocity:e}])=>{const t=X(!1),n=Ke(),r=X(!1);return ge(U(e,$e(r,t,n),je(([o,s])=>!!s),le(([o,s,i,a])=>{const{enter:l,exit:u}=s;if(i){if(u(o,a))return!1}else if(l(o,a))return!0;return i}),st()),t),Xe(U(pt(t,e,n),$e(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},ot(Jr),{singleton:!0}),Li=Ye(([{scrollContainerState:e,scrollTo:t}])=>{const n=Ke(),r=Ke(),o=Ke(),s=X(!1),i=X(void 0);return ge(U(pt(n,r),le(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),ge(U(t,$e(r),le(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},ot(At)),Px=Ye(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=Ke(),d=X(void 0),f=X(null),h=X(null);return ge(a,f),ge(l,h),Xe(U(u,$e(t,r,i,f,h,n)),([p,v,w,g,x,b,S])=>{const N=gx(v.sizeTree);g&&x!==null&&b!==null&&(w=x.scrollTop-b.offsetTop),w-=S,p({ranges:N,scrollTop:w})}),ge(U(d,je(Si),le(Ox)),o),ge(U(s,$e(d),je(([,p])=>p!==void 0),st(),le(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},ot(dn,At,Gr,On,Li));function Ox(e){return{align:"start",index:0,offset:e.scrollTop}}const Mx=Ye(([{topItemsIndexes:e}])=>{const t=X(0);return ge(U(t,je(n=>n>=0),le(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ot(Xn));function Xc(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const Dx=Xc(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Lx=Ye(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:h},{log:p},{recalcInProgress:v}])=>{const w=Lt(U(l,$e(i),un(([,x,b,S],[{bottom:N,items:C,offsetBottom:k,totalCount:E},A])=>{const j=N+k;let P=0;return b===E&&x.length>0&&C.length>0&&(C[0].originalIndex===0&&x[0].originalIndex===0||(P=j-S,P!==0&&(P+=A))),[P,C,E,j]},[0,[],0,0]),je(([x])=>x!==0),$e(r,a,n,o,p,v),je(([,x,b,S,,,N])=>!N&&!S&&x!==0&&b===Yr),le(([[x],,,,,b])=>(b("Upward scrolling compensation",{amount:x},Ot.DEBUG),x))));function g(x){x>0?(Le(t,{behavior:"auto",top:-x}),Le(e,0)):(Le(e,0),Le(t,{behavior:"auto",top:-x}))}return Xe(U(w,$e(e,s)),([x,b,S])=>{S&&Dx()?Le(e,b-x):g(-x)}),Xe(U(pt(kt(s,!1),e,v),je(([x,b,S])=>!x&&!S&&b!==0),le(([x,b])=>b),Tn(1)),g),ge(U(f,le(x=>({top:-x}))),t),Xe(U(u,$e(h,d),le(([x,{groupIndices:b,lastSize:S,sizeTree:N},C])=>{function k(E){return E*(S+C)}if(b.length===0)return k(x);{let E=0;const A=Wr(N,0);let j=0,P=0;for(;j<x;){j++,E+=A;let L=b.length===P+1?1/0:b[P+1]-b[P]-1;j+L>x&&(E-=A,L=x-j+1),j+=L,E+=k(L),P++}return E}})),x=>{Le(e,x),requestAnimationFrame(()=>{Le(t,{top:x}),requestAnimationFrame(()=>{Le(e,0),Le(v,!1)})})}),{deviation:e}},ot(At,Jr,Xn,dn,Rn,ji)),Fx=Ye(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),ot(Mi,_x,On,Yc,Vc,Rx,Ex,Li,Kc,Rn,qc)),Jc=Ye(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:v},w,g,x,{listState:b,topItemsIndexes:S,...N},{scrollToIndex:C},k,{topItemCount:E},{groupCounts:A},j])=>(ge(N.rangeChanged,j.scrollSeekRangeChanged),ge(U(j.windowViewportRect,le(P=>P.visibleHeight)),w.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...x,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...N,...j,...w,sizes:l,...g}),ot(dn,Gr,At,Px,jx,Xn,Kr,Lx,Mx,Lc,Fx));function $x(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 Ho=typeof document<"u"?y.useLayoutEffect:y.useEffect;function Zc(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=y.createContext({});function l(g,x){g.propsReady&&Le(g.propsReady,!1);for(const b of r){const S=g[t.required[b]];Le(S,x[b])}for(const b of o)if(b in x){const S=g[t.optional[b]];Le(S,x[b])}g.propsReady&&Le(g.propsReady,!0)}function u(g){return s.reduce((x,b)=>(x[b]=S=>{const N=g[t.methods[b]];Le(N,S)},x),{})}function d(g){return i.reduce((x,b)=>(x[b]=tx(g[t.events[b]]),x),{})}const f=y.forwardRef((g,x)=>{const{children:b,...S}=g,[N]=y.useState(()=>Oo(rx(e),E=>{l(E,S)})),[C]=y.useState(yc(d,N));Ho(()=>{for(const E of i)E in S&&Xe(C[E],S[E]);return()=>{Object.values(C).map(Ci)}},[S,C,N]),Ho(()=>{l(N,S)}),y.useImperativeHandle(x,wc(u(N)));const k=n;return c.jsx(a.Provider,{value:N,children:n?c.jsx(k,{...$x([...r,...o,...i],S),children:b}):b})}),h=g=>{const x=y.useContext(a);return y.useCallback(b=>{Le(x[g],b)},[x,g])},p=g=>{const x=y.useContext(a)[g],b=y.useCallback(S=>Xe(x,S),[x]);return y.useSyncExternalStore(b,()=>ft(x),()=>ft(x))},v=g=>{const x=y.useContext(a)[g],[b,S]=y.useState(yc(ft,x));return Ho(()=>Xe(x,N=>{N!==b&&S(wc(N))}),[x,b]),b},w=y.version.startsWith("18")?p:v;return{Component:f,useEmitter:(g,x)=>{const b=y.useContext(a)[g];Ho(()=>Xe(b,x),[x,b])},useEmitterValue:w,usePublisher:h}}const Qc=y.createContext(void 0),eu=y.createContext(void 0),tu=typeof document<"u"?y.useLayoutEffect:y.useEffect;function Fi(e){return"self"in e}function zx(e){return"body"in e}function nu(e,t,n,r=vr,o,s){const i=y.useRef(null),a=y.useRef(null),l=y.useRef(null),u=y.useCallback(h=>{let p,v,w;const g=h.target;if(zx(g)||Fi(g)){const b=Fi(g)?g:g.defaultView;w=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,v=s?b.innerWidth:b.innerHeight}else w=s?g.scrollLeft:g.scrollTop,p=s?g.scrollWidth:g.scrollHeight,v=s?g.offsetWidth:g.offsetHeight;const x=()=>{e({scrollHeight:p,scrollTop:Math.max(w,0),viewportHeight:v})};h.suppressFlushSync?x():Xs.flushSync(x),a.current!==null&&(w===a.current||w<=0||w===p-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);y.useEffect(()=>{const h=o||i.current;return r(o||i.current),u({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",u,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",u)}},[i,u,n,r,o]);function d(h){const p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const v=h.behavior==="smooth";let w,g,x;Fi(p)?(g=Math.max(Pn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),w=s?p.innerWidth:p.innerHeight,x=s?window.scrollX:window.scrollY):(g=p[s?"scrollWidth":"scrollHeight"],w=Pn(p,s?"width":"height"),x=p[s?"scrollLeft":"scrollTop"]);const b=g-w;if(h.top=Math.ceil(Math.max(Math.min(b,h.top),0)),$c(w,g)||h.top===x){e({scrollHeight:g,scrollTop:x,viewportHeight:w}),v&&t(!0);return}v?(a.current=h.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(h={behavior:h.behavior,left:h.top}),p.scrollTo(h)}function f(h){s&&(h={behavior:h.behavior,left:h.top}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const $i="-webkit-sticky",ru="sticky",zi=Xc(()=>{if(typeof document>"u")return ru;const e=document.createElement("div");return e.style.position=$i,e.style.position===$i?$i:ru});function Bi(e){return e}const Bx=Ye(()=>{const e=X(a=>`Item ${a}`),t=X(a=>`Group ${a}`),n=X({}),r=X(Bi),o=X("div"),s=X(vr),i=(a,l=null)=>kt(U(n,le(u=>u[a]),st()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),Hx=Ye(([e,t])=>({...e,...t}),ot(Jc,Bx)),Ux=({height:e})=>c.jsx("div",{style:{height:e}}),Wx={overflowAnchor:"none",position:zi(),zIndex:1},ou={overflowAnchor:"none"},Vx={...ou,display:"inline-block",height:"100%"},su=y.memo(function({showTopList:e=!1}){const t=Pe("listState"),n=Wt("sizeRanges"),r=Pe("useWindowScroll"),o=Pe("customScrollParent"),s=Wt("windowScrollContainerState"),i=Wt("scrollContainerState"),a=o||r?s:i,l=Pe("itemContent"),u=Pe("context"),d=Pe("groupContent"),f=Pe("trackItemSizes"),h=Pe("itemSize"),p=Pe("log"),v=Wt("gap"),w=Pe("horizontalDirection"),{callbackRef:g}=ix(n,h,f,e?vr:a,p,v,o,w,Pe("skipAnimationFrameInResizeObserver")),[x,b]=y.useState(0);Hi("deviation",M=>{x!==M&&b(M)});const S=Pe("EmptyPlaceholder"),N=Pe("ScrollSeekPlaceholder")||Ux,C=Pe("ListComponent"),k=Pe("ItemComponent"),E=Pe("GroupComponent"),A=Pe("computeItemKey"),j=Pe("isSeeking"),P=Pe("groupIndices").length>0,L=Pe("alignToBottom"),F=Pe("initialItemFinalLocationReached"),V=e?{}:{boxSizing:"border-box",...w?{display:"inline-block",height:"100%",marginLeft:x!==0?x:L?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:x!==0?x:L?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...F?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?c.jsx(S,{...It(S,u)}):c.jsx(C,{...It(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:V,children:(e?t.topItems:t.items).map(M=>{const Y=M.originalIndex,q=A(Y+t.firstItemIndex,M.data,u);return j?y.createElement(N,{...It(N,u),height:M.size,index:M.index,key:q,type:M.type||"item",...M.type==="group"?{}:{groupIndex:M.groupIndex}}):M.type==="group"?y.createElement(E,{...It(E,u),"data-index":Y,"data-item-index":M.index,"data-known-size":M.size,key:q,style:Wx},d(M.index,u)):y.createElement(k,{...It(k,u),...Yx(k,M.data),"data-index":Y,"data-item-group-index":M.groupIndex,"data-item-index":M.index,"data-known-size":M.size,key:q,style:w?Vx:ou},P?l(M.index,M.groupIndex,M.data,u):l(M.index,M.data,u))})})}),qx={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Kx={outline:"none",overflowX:"auto",position:"relative"},Uo=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Gx={position:zi(),top:0,width:"100%",zIndex:1};function It(e,t){if(typeof e!="string")return{context:t}}function Yx(e,t){return{item:typeof e=="string"?void 0:t}}const Xx=y.memo(function(){const e=Pe("HeaderComponent"),t=Wt("headerHeight"),n=Pe("HeaderFooterTag"),r=Gn(y.useMemo(()=>s=>{t(Pn(s,"height"))},[t]),!0,Pe("skipAnimationFrameInResizeObserver")),o=Pe("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...It(e,o)})}):null}),Jx=y.memo(function(){const e=Pe("FooterComponent"),t=Wt("footerHeight"),n=Pe("HeaderFooterTag"),r=Gn(y.useMemo(()=>s=>{t(Pn(s,"height"))},[t]),!0,Pe("skipAnimationFrameInResizeObserver")),o=Pe("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...It(e,o)})}):null});function iu({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:v}=nu(a,u,l,d,void 0,f);return e("scrollTo",v),e("scrollBy",h),c.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?Kx:qx,...o},tabIndex:0,...i,...It(l,s),children:r})})}function au({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=y.useRef(null),v=t("scrollerRef"),{scrollByCallback:w,scrollerRef:g,scrollToCallback:x}=nu(a,u,l,v,h);return tu(()=>{var b;return g.current=h||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",x),e("scrollBy",w),c.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...It(l,s),children:r})})}const Zx=({children:e})=>{const t=y.useContext(Qc),n=Wt("viewportHeight"),r=Wt("fixedItemHeight"),o=Pe("alignToBottom"),s=Pe("horizontalDirection"),i=y.useMemo(()=>bc(n,l=>Pn(l,s?"width":"height")),[n,s]),a=Gn(i,!0,Pe("skipAnimationFrameInResizeObserver"));return y.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),c.jsx("div",{"data-viewport-type":"element",ref:a,style:Uo(o),children:e})},Qx=({children:e})=>{const t=y.useContext(Qc),n=Wt("windowViewportRect"),r=Wt("fixedItemHeight"),o=Pe("customScrollParent"),s=kc(n,o,Pe("skipAnimationFrameInResizeObserver")),i=Pe("alignToBottom");return y.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),c.jsx("div",{"data-viewport-type":"window",ref:s,style:Uo(i),children:e})},ev=({children:e})=>{const t=Pe("TopItemListComponent")||"div",n=Pe("headerHeight"),r={...Gx,marginTop:`${n}px`},o=Pe("context");return c.jsx(t,{style:r,...It(t,o),children:e})},tv=y.memo(function(e){const t=Pe("useWindowScroll"),n=Pe("topItemsIndexes").length>0,r=Pe("customScrollParent"),o=Pe("context");return c.jsxs(r||t?ov:rv,{...e,context:o,children:[n&&c.jsx(ev,{children:c.jsx(su,{showTopList:!0})}),c.jsxs(r||t?Qx:Zx,{children:[c.jsx(Xx,{}),c.jsx(su,{}),c.jsx(Jx,{})]})]})}),{Component:nv,useEmitter:Hi,useEmitterValue:Pe,usePublisher:Wt}=Zc(Hx,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},tv),rv=iu({useEmitter:Hi,useEmitterValue:Pe,usePublisher:Wt}),ov=au({useEmitter:Hi,useEmitterValue:Pe,usePublisher:Wt}),sv=nv;ot(Jc,Ye(()=>{const e=X(u=>c.jsxs("td",{children:["Item $",u]})),t=X(null),n=X(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=X(null),o=X(null),s=X({}),i=X(Bi),a=X(vr),l=(u,d=null)=>kt(U(s,le(f=>f[u]),st()),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")}})),zi();const lu={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},iv={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:cu,floor:Wo,max:Zr,min:Ui,round:uu}=Math;function du(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function av(e){return{...iv,items:e}}function Vo(e,t){return e&&e.width===t.width&&e.height===t.height}function lv(e,t){return e&&e.column===t.column&&e.row===t.row}const cv=Ye(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},h,p,{didMount:v,propsReady:w},{customScrollParent:g,useWindowScroll:x,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:N},C])=>{const k=X(0),E=X(0),A=X(lu),j=X({height:0,width:0}),P=X({height:0,width:0}),L=Ke(),F=Ke(),V=X(0),M=X(null),Y=X({column:0,row:0}),q=Ke(),W=Ke(),z=X(!1),$=X(0),ue=X(!0),D=X(!1),ee=X(!1);Xe(U(v,$e($),je(([O,J])=>!!J)),()=>{Le(ue,!1)}),Xe(U(pt(v,ue,P,j,$,D),je(([O,J,te,G,,se])=>O&&!J&&te.height!==0&&G.height!==0&&!se)),([,,,,O])=>{Le(D,!0),Pi(1,()=>{Le(L,O)}),Zt(U(u),()=>{Le(t,[0,0]),Le(ue,!0)})}),ge(U(W,je(O=>O!=null&&O.scrollTop>0),cn(0)),E),Xe(U(v,$e(W),je(([,O])=>O!=null)),([,O])=>{O&&(Le(j,O.viewport),Le(P,O.item),Le(Y,O.gap),O.scrollTop>0&&(Le(z,!0),Zt(U(u,Kn(1)),J=>{Le(z,!1)}),Le(l,{top:O.scrollTop})))}),ge(U(j,le(({height:O})=>O)),f),ge(U(pt(Ie(j,Vo),Ie(P,Vo),Ie(Y,(O,J)=>O&&O.column===J.column&&O.row===J.row),Ie(u)),le(([O,J,te,G])=>({gap:te,item:J,scrollTop:G,viewport:O}))),q),ge(U(pt(Ie(k),r,Ie(Y,lv),Ie(P,Vo),Ie(j,Vo),Ie(M),Ie(E),Ie(z),Ie(ue),Ie($)),je(([,,,,,,,O])=>!O),le(([O,[J,te],G,se,Ve,Je,nt,,De,Be])=>{const{column:Ee,row:Ze}=G,{height:wt,width:ht}=se,{width:Z}=Ve;if(nt===0&&(O===0||Z===0))return lu;if(ht===0){const St=Oi(Be,O),Ht=St+Math.max(nt-1,0);return av(du(St,Ht,Je))}const re=fu(Z,ht,Ee);let pe,Ne;De?J===0&&te===0&&nt>0?(pe=0,Ne=nt-1):(pe=re*Wo((J+Ze)/(wt+Ze)),Ne=re*cu((te+Ze)/(wt+Ze))-1,Ne=Ui(O-1,Zr(Ne,re-1)),pe=Ui(Ne,Zr(0,pe))):(pe=0,Ne=-1);const we=du(pe,Ne,Je),{bottom:Ae,top:Qe}=hu(Ve,G,se,we),ze=cu(O/re),lt=ze*wt+(ze-1)*Ze-Ae;return{bottom:Ae,itemHeight:wt,items:we,itemWidth:ht,offsetBottom:lt,offsetTop:Qe,top:Qe}})),A),ge(U(M,je(O=>O!==null),le(O=>O.length)),k),ge(U(pt(j,P,A,Y),je(([O,J,{items:te}])=>te.length>0&&J.height!==0&&O.height!==0),le(([O,J,{items:te},G])=>{const{bottom:se,top:Ve}=hu(O,G,J,te);return[Ve,se]}),st(Vr)),t);const fe=X(!1);ge(U(u,$e(fe),le(([O,J])=>J||O!==0)),fe);const ve=Lt(U(pt(A,k),je(([{items:O}])=>O.length>0),$e(fe),je(([[O,J],te])=>{const G=O.items[O.items.length-1].index===J-1;return(te||O.bottom>0&&O.itemHeight>0&&O.offsetBottom===0&&O.items.length===J)&&G}),le(([[,O]])=>O-1),st())),be=Lt(U(Ie(A),je(({items:O})=>O.length>0&&O[0].index===0),cn(0),st())),ye=Lt(U(Ie(A),$e(z),je(([{items:O},J])=>O.length>0&&!J),le(([{items:O}])=>({endIndex:O[O.length-1].index,startIndex:O[0].index})),st(Rc),Tn(0)));ge(ye,p.scrollSeekRangeChanged),ge(U(L,$e(j,P,k,Y),le(([O,J,te,G,se])=>{const Ve=Fc(O),{align:Je,behavior:nt,offset:De}=Ve;let Be=Ve.index;Be==="LAST"&&(Be=G-1),Be=Zr(0,Be,Ui(G-1,Be));let Ee=Wi(J,se,te,Be);return Je==="end"?Ee=uu(Ee-J.height+te.height):Je==="center"&&(Ee=uu(Ee-J.height/2+te.height/2)),De&&(Ee+=De),{behavior:nt,top:Ee}})),l);const K=kt(U(A,le(O=>O.offsetBottom+O.bottom)),0);return ge(U(N,le(O=>({height:O.visibleHeight,width:O.visibleWidth}))),j),{customScrollParent:g,data:M,deviation:V,footerHeight:o,gap:Y,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:P,overscan:n,restoreStateFrom:W,scrollBy:i,scrollContainerState:a,scrollHeight:F,scrollTo:l,scrollToIndex:L,scrollTop:u,smoothScrollTargetReached:d,totalCount:k,useWindowScroll:x,viewportDimensions:j,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:N,...p,gridState:A,horizontalDirection:ee,initialTopMostItemIndex:$,totalListHeight:K,...h,endReached:ve,propsReady:w,rangeChanged:ye,startReached:be,stateChanged:q,stateRestoreInProgress:z,...C}},ot(Mi,At,Jr,Yc,On,Li,Rn));function fu(e,t,n){return Zr(1,Wo((e+n)/(Wo(t)+n)))}function hu(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Wi(e,t,n,r[0].index);return{bottom:Wi(e,t,n,r[r.length-1].index)+o,top:s}}function Wi(e,t,n,r){const o=fu(e.width,n.width,t.column),s=Wo(r/o),i=s*n.height+Zr(0,s-1)*t.row;return i>0?i+t.row:i}const uv=Ye(()=>{const e=X(f=>`Item ${f}`),t=X({}),n=X(null),r=X("virtuoso-grid-item"),o=X("virtuoso-grid-list"),s=X(Bi),i=X("div"),a=X(vr),l=(f,h=null)=>kt(U(t,le(p=>p[f]),st()),h),u=X(!1),d=X(!1);return ge(Ie(d),u),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:u,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),dv=Ye(([e,t])=>({...e,...t}),ot(cv,uv)),fv=y.memo(function(){const e=at("gridState"),t=at("listClassName"),n=at("itemClassName"),r=at("itemContent"),o=at("computeItemKey"),s=at("isSeeking"),i=Vt("scrollHeight"),a=at("ItemComponent"),l=at("ListComponent"),u=at("ScrollSeekPlaceholder"),d=at("context"),f=Vt("itemDimensions"),h=Vt("gap"),p=at("log"),v=at("stateRestoreInProgress"),w=Vt("reportReadyState"),g=Gn(y.useMemo(()=>x=>{const b=x.parentElement.parentElement.scrollHeight;i(b);const S=x.firstChild;if(S){const{height:N,width:C}=S.getBoundingClientRect();f({height:N,width:C})}h({column:mu("column-gap",getComputedStyle(x).columnGap,p),row:mu("row-gap",getComputedStyle(x).rowGap,p)})},[i,f,h,p]),!0,!1);return tu(()=>{e.itemHeight>0&&e.itemWidth>0&&w(!0)},[e]),v?null:c.jsx(l,{className:t,ref:g,...It(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(x=>{const b=o(x.index,x.data,d);return s?c.jsx(u,{...It(u,d),height:e.itemHeight,index:x.index,width:e.itemWidth},b):y.createElement(a,{...It(a,d),className:n,"data-index":x.index,key:b},r(x.index,x.data,d))})})}),hv=y.memo(function(){const e=at("HeaderComponent"),t=Vt("headerHeight"),n=at("headerFooterTag"),r=Gn(y.useMemo(()=>s=>{t(Pn(s,"height"))},[t]),!0,!1),o=at("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...It(e,o)})}):null}),pv=y.memo(function(){const e=at("FooterComponent"),t=Vt("footerHeight"),n=at("headerFooterTag"),r=Gn(y.useMemo(()=>s=>{t(Pn(s,"height"))},[t]),!0,!1),o=at("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...It(e,o)})}):null}),mv=({children:e})=>{const t=y.useContext(eu),n=Vt("itemDimensions"),r=Vt("viewportDimensions"),o=Gn(y.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return y.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),c.jsx("div",{ref:o,style:Uo(!1),children:e})},gv=({children:e})=>{const t=y.useContext(eu),n=Vt("windowViewportRect"),r=Vt("itemDimensions"),o=at("customScrollParent"),s=kc(n,o,!1);return y.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),c.jsx("div",{ref:s,style:Uo(!1),children:e})},xv=y.memo(function({...e}){const t=at("useWindowScroll"),n=at("customScrollParent"),r=n||t?wv:vv,o=n||t?gv:mv,s=at("context");return c.jsx(r,{...e,...It(r,s),children:c.jsxs(o,{children:[c.jsx(hv,{}),c.jsx(fv,{}),c.jsx(pv,{})]})})}),{useEmitter:pu,useEmitterValue:at,usePublisher:Vt}=Zc(dv,{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"}},xv),vv=iu({useEmitter:pu,useEmitterValue:at,usePublisher:Vt}),wv=au({useEmitter:pu,useEmitterValue:at,usePublisher:Vt});function mu(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ot.WARN),t==="normal"?0:parseInt(t??"0",10)}const bv=mo.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 Vi({className:e,variant:t,...n}){return c.jsx("div",{className:Q(bv({variant:t}),e),...n})}function de(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 yv(e,t){const n=m.createContext(t),r=s=>{const{children:i,...a}=s,l=m.useMemo(()=>a,Object.values(a));return c.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=m.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function fn(e,t=[]){let n=[];function r(s,i){const a=m.createContext(i),l=n.length;n=[...n,i];const u=f=>{var x;const{scope:h,children:p,...v}=f,w=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,g=m.useMemo(()=>v,Object.values(v));return c.jsx(w.Provider,{value:g,children:p})};u.displayName=s+"Provider";function d(f,h){var w;const p=((w=h==null?void 0:h[e])==null?void 0:w[l])||a,v=m.useContext(p);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>m.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Sv(o,...t)]}function Sv(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:u})=>{const f=l(s)[`__scope${u}`];return{...a,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var vt=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},Cv=m[" useInsertionEffect ".trim().toString()]||vt;function Jn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Tv({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=m.useRef(e!==void 0);m.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const u=m.useCallback(d=>{var f;if(a){const h=kv(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[l,u]}function Tv({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return Cv(()=>{s.current=t},[t]),m.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function kv(e){return typeof e=="function"}function gu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function qi(...e){return t=>{let n=!1;const r=e.map(o=>{const s=gu(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():gu(e[o],null)}}}}function We(...e){return m.useCallback(qi(...e),e)}var Iv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],_e=Iv.reduce((e,t)=>{const n=Un.createSlot(`Primitive.${t}`),r=m.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function xu(e,t){e&&go.flushSync(()=>e.dispatchEvent(t))}function Ev(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var $t=e=>{const{present:t,children:n}=e,r=Nv(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=We(r.ref,Av(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};$t.displayName="Presence";function Nv(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Ev(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=qo(r.current);s.current=a==="mounted"?u:"none"},[a]),vt(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,p=qo(u);e?l("MOUNT"):p==="none"||(u==null?void 0:u.display)==="none"?l("UNMOUNT"):l(d&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),vt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const w=qo(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&w&&(l("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},h=p=>{p.target===t&&(s.current=qo(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function qo(e){return(e==null?void 0:e.animationName)||"none"}function Av(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var jv=m[" useId ".trim().toString()]||(()=>{}),_v=0;function hn(e){const[t,n]=m.useState(jv());return vt(()=>{n(r=>r??String(_v++))},[e]),e||(t?`radix-${t}`:"")}var Ko="Collapsible",[Rv,mT]=fn(Ko),[Pv,Ki]=Rv(Ko),vu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,u]=Jn({prop:r,defaultProp:o??!1,onChange:i,caller:Ko});return c.jsx(Pv,{scope:n,disabled:s,contentId:hn(),open:l,onOpenToggle:m.useCallback(()=>u(d=>!d),[u]),children:c.jsx(_e.div,{"data-state":Yi(l),"data-disabled":s?"":void 0,...a,ref:t})})});vu.displayName=Ko;var wu="CollapsibleTrigger",bu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=Ki(wu,n);return c.jsx(_e.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Yi(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:de(e.onClick,o.onOpenToggle)})});bu.displayName=wu;var Gi="CollapsibleContent",Ov=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ki(Gi,e.__scopeCollapsible);return c.jsx($t,{present:n||o.open,children:({present:s})=>c.jsx(Mv,{...r,ref:t,present:s})})});Ov.displayName=Gi;var Mv=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=Ki(Gi,n),[a,l]=m.useState(r),u=m.useRef(null),d=We(t,u),f=m.useRef(0),h=f.current,p=m.useRef(0),v=p.current,w=i.open||a,g=m.useRef(w),x=m.useRef(void 0);return m.useEffect(()=>{const b=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(b)},[]),vt(()=>{const b=u.current;if(b){x.current=x.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const S=b.getBoundingClientRect();f.current=S.height,p.current=S.width,g.current||(b.style.transitionDuration=x.current.transitionDuration,b.style.animationName=x.current.animationName),l(r)}},[i.open,r]),c.jsx(_e.div,{"data-state":Yi(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!w,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style},children:w&&o})});function Yi(e){return e?"open":"closed"}var Dv=vu;const yu=Dv,Su=bu,Qr=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Q("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Qr.displayName="Card";const eo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Q("flex flex-col space-y-1.5 p-6",e),...t}));eo.displayName="CardHeader";const to=m.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:Q("text-2xl font-semibold leading-none tracking-tight",e),...t}));to.displayName="CardTitle";const Cu=m.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:Q("text-sm text-muted-foreground",e),...t}));Cu.displayName="CardDescription";const Go=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Q("p-6 pt-0",e),...t}));Go.displayName="CardContent";const Tu=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Q("flex items-center p-6 pt-0",e),...t}));Tu.displayName="CardFooter";function ku(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let Zn=ku();function Lv(e){Zn=e}const Iu=/[&<>"']/,Fv=new RegExp(Iu.source,"g"),Eu=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,$v=new RegExp(Eu.source,"g"),zv={"&":"&","<":"<",">":">",'"':""","'":"'"},Nu=e=>zv[e];function Et(e,t){if(t){if(Iu.test(e))return e.replace(Fv,Nu)}else if(Eu.test(e))return e.replace($v,Nu);return e}const Bv=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Au(e){return e.replace(Bv,(t,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const Hv=/(^|[^\[])\^/g;function tt(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(Hv,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const Uv=/[^\w:]/g,Wv=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function ju(e,t,n){if(e){let r;try{r=decodeURIComponent(Au(n)).replace(Uv,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!Wv.test(n)&&(n=Gv(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Yo={},Vv=/^[^:]+:\/*[^/]*$/,qv=/^([^:]+:)[\s\S]*$/,Kv=/^([^:]+:\/*[^/]*)[\s\S]*$/;function Gv(e,t){Yo[" "+e]||(Vv.test(e)?Yo[" "+e]=e+"/":Yo[" "+e]=Jo(e,"/",!0)),e=Yo[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(qv,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(Kv,"$1")+t:e+t}const Xo={exec:function(){}};function _u(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,u=i;for(;--u>=0&&a[u]==="\\";)l=!l;return l?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function Jo(e,t,n){const r=e.length;if(r===0)return"";let o=0;for(;o<r;){const s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function Yv(e,t){if(e.indexOf(t[1])===-1)return-1;const n=e.length;let r=0,o=0;for(;o<n;o++)if(e[o]==="\\")o++;else if(e[o]===t[0])r++;else if(e[o]===t[1]&&(r--,r<0))return o;return-1}function Xv(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function Ru(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Pu(e,t,n,r){const o=t.href,s=t.title?Et(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:Et(i)}}function Jv(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
37
|
+
`))>=0;){const re=K.slice(0,Z);K=K.slice(Z+2);const pe=Yg(re);if(!pe)continue;let Ne;try{Ne=JSON.parse(pe)}catch{console.debug("[use-chat] malformed SSE:",pe.slice(0,200));continue}const we=Gg(Ne)?Ne.data:Ne;Ve=Date.now();const Ae=we.seq;if(Ae!==void 0){if(Ae<=J){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:Ae,lastProcessedSeq:J,type:we.type});continue}J>0&&Ae>J+1&&(($=F==null?void 0:F.onGap)==null||$.call(F,{from:J,to:Ae})),J=Ae,C.current=Ae,g(Ae)}if(console.debug("[use-chat] received event",{seq:we.seq,type:we.type,preview:(()=>{var Qe;try{return we.type==="message_delta"?{deltaTypes:(Qe=we.delta)==null?void 0:Qe.map(ze=>ze.type),textLen:(we.delta||[]).filter(ze=>ze.type==="text").map(ze=>String(ze.text||"").length)}:we.content||we.delta?{hasContent:!0}:{}}catch(ze){return{err:String(ze)}}})()}),L==null||L(we),we.type==="token"&&e.autoAppendAssistant!==!1)O.push(we.content),se();else if(we.type==="message_delta"){const Qe=we.delta.filter(ze=>ze.type==="text").map(ze=>ze.text).join("");Qe&&e.autoAppendAssistant!==!1&&(O.push(Qe),se())}else we.type==="heartbeat"?console.debug("[use-chat] heartbeat received"):(te!==null&&cancelAnimationFrame(te),G(),we.type==="checkpoint"?x(we.checkpointId):we.type==="error"&&d(we.message))}}G()}catch(De){if(De.name!=="AbortError"){const Be=De.message||String(De);d(Be),(ue=F==null?void 0:F.onError)==null||ue.call(F,Be)}}finally{try{await be.cancel()}catch{}finally{(D=be.releaseLock)==null||D.call(be)}te!==null&&typeof window<"u"&&window.cancelAnimationFrame(te),clearInterval(Je),l(!1),b(!1),S.current=null,C.current=0,g(0)}}catch(fe){if(fe.name!=="AbortError"){const ve=fe.message||String(fe);d(ve),(ee=F==null?void 0:F.onError)==null||ee.call(F,ve)}}finally{l(!1),b(!1),S.current=null,C.current=0,g(0)}})(),{close:()=>V.abort()}},[t,n,r,e.autoAppendAssistant]);return y.useEffect(()=>()=>{var P;N.current=!1,(P=S.current)==null||P.abort()},[]),{isStreaming:a,error:u,assistantText:f,lastCheckpointId:p,lastSeq:w,connected:v,stream:j,stop:E,clear:A,setToken:k}}function Gg(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function Yg(e){const t=e.split(/\r?\n/),n=[];for(const r of t)if(r&&!r.startsWith(":")&&r.startsWith("data:")){const o=r.slice(5);n.push(o.startsWith(" ")?o.slice(1):o)}return n.length===0?null:n.join(`
|
|
38
|
+
`)}function Xg({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onUnhandledEvent:r,onSequenceGap:o}){const s=y.useRef(null),i=y.useCallback(p=>{const x=p.seq??null;if(x!==null){const w=s.current;if(w!==null){if(x<=w)return;x>w+1&&(o==null||o({from:w,to:x}))}s.current=x}if(p.type==="thread_info"){console.log("[useChatStreamingService] 🎯 Received thread_info event:",p),t(p);return}if(Hg(p)){n(p);return}r==null||r(p)},[n,o,t,r]),{stream:a,stop:l,isStreaming:u,error:d,setToken:f}=pc({baseUrl:e,token:null}),h=y.useCallback((p,x)=>{s.current=null,a(p,i,{onOpen:x==null?void 0:x.onOpen,onError:w=>{var g;(g=x==null?void 0:x.onError)==null||g.call(x,w)},onGap:(x==null?void 0:x.onGap)??o})},[i,o,a]);return y.useMemo(()=>({startStream:h,stop:l,isStreaming:u,error:d,setAuthToken:f}),[h,l,u,d,f])}const mc=y.createContext(null),gc=y.createContext(null),xc=y.createContext(null),Jg=y.createContext(!1),Zg="cachedThreads",Qg="v1",_o=300,xi=200;function vc(e,t){if(!e&&!t)return!0;if(!e||!t||e.id!==t.id)return!1;try{return JSON.stringify(e.value)===JSON.stringify(t.value)}catch{return e.value===t.value}}function ex(e){var t;for(let n=e.length-1;n>=0;n--){const r=((t=e[n])==null?void 0:t.content)??[];for(let o=r.length-1;o>=0;o--){const s=r[o];if((s==null?void 0:s.type)==="interrupt"){const i=s.id;return{id:(typeof i=="string"?i:null)??`interrupt-${e[n].id??o}`,value:s.value}}}}return null}function tx(e){if(!e||typeof e!="object")return null;const t=e.tasks;if(!Array.isArray(t))return null;for(const n of t){if(!n||typeof n!="object")continue;const r=n.interrupts;if(!Array.isArray(r)||r.length===0)continue;const o=r[0];if(!o)continue;return{id:(typeof(o==null?void 0:o.id)=="string"?o.id:typeof n.id=="string"?n.id:null)??"interrupt-task",value:o==null?void 0:o.value}}return null}function wc(e){if(typeof window<"u"&&"requestIdleCallback"in window)try{window.requestIdleCallback(e,{timeout:1e3});return}catch{}window.setTimeout(e,_o)}function xr(){return typeof window<"u"&&typeof window.localStorage<"u"}function vi(e){if(!xr())return null;try{return window.localStorage.getItem(e)}catch{return null}}function bc(e,t){if(xr())try{window.localStorage.setItem(e,t)}catch{}}function wi(e){if(xr())try{window.localStorage.removeItem(e)}catch{}}function nx(){const e=vi(Zg);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>{if(!n||typeof n!="object")return!1;const r=n;return typeof r.threadId=="string"&&typeof r.title=="string"}):[]}catch{return[]}}function rx(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(36)}function bi(e,t){return`cachedThreads:v1:${e}:${rx(t||"anon")}`}function ox(e){const t=vi(e);if(!t)return[];try{const n=JSON.parse(t);return Array.isArray(n)?n.filter(r=>{if(!r||typeof r!="object")return!1;const o=r;return typeof o.threadId=="string"&&typeof o.title=="string"}):[]}catch{return[]}}function yi(e,t){try{bc(e,JSON.stringify(t))}catch{}}function Si(e){const t=ox(e);if(t.length>0)return t;const n=nx();if(n.length>0)try{yi(e,n.slice(0,xi))}catch{}return n}function jo(e){const t={},n=[];for(const r of e)!r||typeof r.threadId!="string"||t[r.threadId]||(t[r.threadId]=r,n.push(r.threadId));return{byId:t,order:n}}function Ci(e){return e.order.map(t=>e.byId[t]).filter(Boolean)}function sx({children:e,initialThreadId:t=null,autoLoadInitial:n=!0,disableAutoRestore:r=!1,enableFileAgentRouting:o=!1,fileAgentId:s="invoice_reader",onError:i,onThreadChange:a}){const{api:l,baseUrl:u}=pi(),d=y.useMemo(()=>Tn(u),[u]),f=y.useMemo(()=>{try{return new URL(u).host}catch{return"unknown"}},[u]),h=y.useMemo(()=>`threadPayload:${Qg}:${f}:`,[f]),p=y.useCallback(T=>`${h}${T}`,[h]),x=y.useCallback(T=>{if(!T||typeof T!="object")return null;const _=T;return typeof _.threadId!="string"||!Array.isArray(_.messages)?null:{threadId:_.threadId,messages:_.messages,hasMore:!!_.hasMore,nextCursor:_.nextCursor??null,checkpointId:_.checkpointId??null,checkpointNs:_.checkpointNs??null}},[]),w=y.useCallback(T=>{const _=vi(p(T));if(!_)return null;try{const U=JSON.parse(_);return x(U)}catch{return null}},[p,x]),g=y.useCallback((T,_=100)=>{const U={...T,messages:Array.isArray(T.messages)?T.messages.slice(-_):[]};try{bc(p(T.threadId),JSON.stringify(U))}catch{}},[p]),v=y.useCallback(T=>{wi(p(T))},[p]),b=y.useCallback(()=>{if(xr())try{const T=h;for(let _=0;_<window.localStorage.length;_++){const U=window.localStorage.key(_);U&&U.startsWith(T)&&window.localStorage.removeItem(U)}}catch{}},[h]),[S,N]=y.useState(()=>{var T;return bi(f,(T=l.getAuthToken)==null?void 0:T.call(l))}),[C,k]=y.useState(()=>{var _;const T=Si(bi(f,(_=l.getAuthToken)==null?void 0:_.call(l)));return jo(T)}),E=y.useMemo(()=>Ci(C),[C]),[A,j]=y.useState(t),[P,L]=y.useState(!1),[F,V]=y.useState(!1),[M,Y]=y.useState(null),[q,W]=y.useState(null),[z,$]=y.useState(null),ue=y.useCallback(()=>{const T=Si(S);y.startTransition(()=>{k(jo(T))})},[S]),[D,ee]=y.useState(!1),[fe,ve]=y.useState(!1),[be,ye]=y.useState(null),[K,O]=y.useState(void 0),[J,te]=y.useState(void 0),{state:G,dispatch:se,seed:Ve,prepend:Je,pushUser:nt,onEvent:De,reset:Be}=sc(),Ee=y.useRef(A);y.useEffect(()=>{Ee.current=A},[A]);const Ze=y.useRef(!1),wt=y.useRef([]),ht=y.useRef(null),Z=y.useRef(null),re=y.useRef(new Map),pe=y.useRef(A),Ne=y.useRef(!1),we=y.useRef(null),Ae=y.useRef({threadId:null,checkpointId:null,checkpointNs:null}),Qe=y.useCallback((T,_)=>new Promise((U,he)=>{const ne=async()=>{Ze.current=!0;try{await T(),U()}catch(xe){he(xe)}finally{Ze.current=!1;const xe=wt.current.shift();xe&&xe().catch(()=>{})}};Ze.current?wt.current.push(ne):ne().catch(xe=>{he(xe)})}),[]),ze=y.useRef(E.length),[lt,St]=y.useState(!1),Ut=y.useRef(!1);y.useEffect(()=>{ze.current=E.length},[E.length]),y.useEffect(()=>{const T=Ee.current;if(!T){z!==null&&$(null),Ae.current={threadId:null,checkpointId:null,checkpointNs:null};return}const _=G.pendingInterrupt??ex(G.messages);if(_){vc(z,_)||$(_),Ae.current={threadId:T,checkpointId:G.lastCheckpointId??null,checkpointNs:G.lastCheckpointNs??null};return}const U={threadId:T,checkpointId:G.lastCheckpointId??null,checkpointNs:G.lastCheckpointNs??null},he=Ae.current.threadId===U.threadId&&Ae.current.checkpointId===U.checkpointId&&Ae.current.checkpointNs===U.checkpointNs;if(!(l!=null&&l.getState)){z!==null&&$(null),Ae.current=U;return}if(he&&z===null)return;let ne=!1;return Ae.current=U,l.getState({threadId:T,checkpointId:U.checkpointId??void 0,checkpointNs:U.checkpointNs??void 0}).then(xe=>{if(ne)return;const me=tx(xe==null?void 0:xe.state);vc(z,me??null)||$(me??null)}).catch(xe=>{ne||(console.warn("[ChatSessionProvider] Failed to inspect thread state for interrupts:",xe),z!==null&&$(null))}),()=>{ne=!0}},[l,z,G.lastCheckpointId,G.lastCheckpointNs,G.messages,G.pendingInterrupt]);const gt=y.useCallback(async()=>{const T=ze.current>0;T||L(!0);try{const _=await l.listThreads();y.startTransition(()=>{k(U=>{const he=me=>me.map(xt=>`${xt.threadId}:${xt.updatedAt??""}:${xt.messageCount??""}`).join("|"),ne=Ci(U);return he(ne)===he(_)||_.length===0&&ne.length>0&&!Ut.current?U:jo(_)})}),Y(null),Ut.current||(Ut.current=!0,St(!0))}catch(_){i==null||i(String(_)),console.error("[ChatSessionProvider] Failed to refresh threads:",_),Y(String(_))}finally{T||L(!1)}},[l,i]),Rr=y.useRef(!1),cr=y.useRef(null),bt=y.useRef(null),Sn=y.useRef(""),an=y.useCallback((T,_)=>{if(!xr())return;bt.current!==null&&(window.clearTimeout(bt.current),bt.current=null);const U=T.map(ne=>`${ne.threadId}:${ne.updatedAt??""}:${ne.messageCount??""}`).join("|");if(T.length===0){try{wi(S)}catch{}Sn.current="";return}if(U===Sn.current)return;const he=()=>{try{const ne=T.slice(0,xi);yi(S,ne),Sn.current=U}catch{}finally{bt.current=null}};if(_!=null&&_.immediate){he();return}bt.current=window.setTimeout(()=>{wc(he)},_o)},[S]),ur=y.useCallback(()=>{an(E,{immediate:!0})},[an,E]),Nt=y.useCallback((T,_,U)=>{const he=Array.isArray(T==null?void 0:T.messages)?T.messages:[],ne=U??(T==null?void 0:T.threadId)??Ee.current,xe=ne!=null&&ne===Ee.current;if(_==="replace"){if(ne){const me={threadId:ne,messages:he.slice(),hasMore:!!(T!=null&&T.hasMore),nextCursor:(T==null?void 0:T.nextCursor)??null,checkpointId:(T==null?void 0:T.checkpointId)??null,checkpointNs:(T==null?void 0:T.checkpointNs)??null};re.current.set(ne,me),pe.current=ne}if(!xe)return;Ve(he,{checkpointId:(T==null?void 0:T.checkpointId)??null,checkpointNs:(T==null?void 0:T.checkpointNs)??null})}else if(_==="prepend"&&he.length&&ne){const me=re.current.get(ne),xt=(me==null?void 0:me.messages)??[],it=new Set,ut=[...he,...xt].filter(Cn=>{const Zt=Cn==null?void 0:Cn.id;return Zt?it.has(Zt)?!1:(it.add(Zt),!0):!0}),Jt={threadId:ne,messages:ut,hasMore:(T==null?void 0:T.hasMore)??(me==null?void 0:me.hasMore)??!1,nextCursor:(T==null?void 0:T.nextCursor)??(me==null?void 0:me.nextCursor)??null,checkpointId:(me==null?void 0:me.checkpointId)??(T==null?void 0:T.checkpointId)??null,checkpointNs:(me==null?void 0:me.checkpointNs)??(T==null?void 0:T.checkpointNs)??null};if(re.current.set(ne,Jt),!xe)return;Je(he)}else _==="prepend"&&he.length&&Je(he);xe&&(_==="replace"?(ye((T==null?void 0:T.nextCursor)??null),ee(!!(T!=null&&T.hasMore)),O((T==null?void 0:T.checkpointId)??void 0),te((T==null?void 0:T.checkpointNs)??void 0)):(ye(me=>(T==null?void 0:T.nextCursor)??me??null),ee(me=>(T==null?void 0:T.hasMore)!==void 0?!!(T!=null&&T.hasMore):me),O(me=>(T==null?void 0:T.checkpointId)??me??void 0),te(me=>(T==null?void 0:T.checkpointNs)??me??void 0)))},[Je,Ve]),ln=y.useCallback(T=>{T.threadId!=null&&T.threadId!==Ee.current||(Ve(T.messages,{checkpointId:T.checkpointId,checkpointNs:T.checkpointNs}),ye(T.nextCursor),ee(T.hasMore),O(T.checkpointId??void 0),te(T.checkpointNs??void 0),pe.current=T.threadId)},[Ve]),Xt=y.useCallback(T=>{T&&(re.current.delete(T),v(T),pe.current===T&&(pe.current=null))},[v]),cn=y.useCallback(()=>{const T=Ee.current;T&&Xt(T),Be([]),ee(!1),ve(!1),ye(null),O(void 0),te(void 0)},[Xt,Be]),dr=y.useCallback(({from:T,to:_})=>{const U=Ee.current;U&&console.warn(`[ChatSessionProvider] Stream sequence gap detected (${T} -> ${_}) for thread ${U}`)},[]),Pr=y.useCallback(T=>{const _=T.threadId;console.log("[ChatSessionProvider] 📥 Handling thread_info event:",{threadId:_,title:T.title,created:T.created,currentThreads:E.length});const U={threadId:_,title:T.title||`Thread ${_.slice(0,8)}`,createdAt:T.createdAt||new Date().toISOString(),updatedAt:T.updatedAt||new Date().toISOString(),messageCount:T.messageCount||0};Ee.current!==_&&(!Ee.current&&G.messages.length<=1&&(Z.current=_),j(_)),y.startTransition(()=>{k(he=>{const ne=he.byId[_];return ne?ne.title===U.title&&ne.updatedAt===U.updatedAt&&ne.messageCount===U.messageCount?he:{byId:{...he.byId,[_]:U},order:he.order}:{byId:{...he.byId,[_]:U},order:[_,...he.order]}})})},[G.messages.length]),{startStream:Or,stop:fr,isStreaming:Nn,error:Mr,setAuthToken:An}=Xg({baseUrl:d,onThreadInfo:Pr,onMessageEvent:De,onUnhandledEvent:T=>{console.warn(`[ChatSessionProvider] Unhandled stream event: ${T.type}`,T)},onSequenceGap:dr});y.useEffect(()=>{Rr.current=Nn},[Nn]),y.useEffect(()=>{if(!xr())return;bt.current!==null&&(window.clearTimeout(bt.current),bt.current=null);const T=E.map(U=>`${U.threadId}:${U.updatedAt??""}:${U.messageCount??""}`).join("|");if(E.length===0){try{wi(S)}catch{}Sn.current="";return}if(T===Sn.current)return;const _=()=>{try{const U=E.slice(0,xi);yi(S,U),Sn.current=T}catch{}finally{bt.current=null}};return bt.current=window.setTimeout(()=>{wc(_),bt.current=null},_o),()=>{bt.current!==null&&(window.clearTimeout(bt.current),bt.current=null)}},[E,an]),y.useEffect(()=>{var he;const T=l.getAuthToken();An(T);const _=ne=>{const xe=bi(f,ne);we.current!==xe&&(we.current=xe,Ne.current=!1),N(xe);const me=Si(xe);y.startTransition(()=>{k(jo(me))}),Ne.current||(Ne.current=!0,gt().catch(()=>{}))};_(T);const U=(he=l.onTokenChange)==null?void 0:he.call(l,ne=>{An(ne),b(),_(ne)});return()=>{U==null||U()}},[l,f,An,b,gt]);const hr=y.useCallback(async T=>{var he;const _=`Thread ${(he=crypto.randomUUID)==null?void 0:he.call(crypto)}`,U={threadId:_,title:T||"New Chat",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messageCount:0};k(ne=>({byId:{...ne.byId,[_]:U},order:[_,...ne.order]})),j(_);try{const ne=await l.createThread(T),xe=typeof ne=="string"?ne:ne.threadId;return k(me=>{const xt=me.byId[_];if(!xt)return me;const it={...me.byId};delete it[_],it[xe]={...xt,threadId:xe};const ut=me.order.map(Jt=>Jt===_?xe:Jt);return{byId:it,order:ut}}),j(xe),setTimeout(()=>gt(),10),Y(null),xe}catch(ne){throw k(xe=>{if(!xe.byId[_])return xe;const me={...xe.byId};delete me[_];const xt=xe.order.filter(it=>it!==_);return{byId:me,order:xt}}),j(null),Y(String(ne)),ne}},[l,gt]),ae=y.useCallback(async T=>{try{await l.deleteThread(T);let _=null;k(U=>{if(!U.byId[T])return U;const he={...U.byId};delete he[T];const ne=U.order.filter(me=>me!==T),xe={byId:he,order:ne};return _=Ci(xe),xe}),_&&an(_,{immediate:!0}),Xt(T),Ee.current===T&&(Z.current=T,j(null),Ee.current=null,pe.current=null,cn()),await gt(),Y(null)}catch(_){throw Y(String(_)),_}},[l,cn,Xt,gt,an]),Te=y.useCallback(async(T,_)=>{try{await l.updateThread(T,_),k(U=>{const he=U.byId[T];return he?{byId:{...U.byId,[T]:{...he,title:_}},order:U.order}:U}),Y(null)}catch(U){throw await gt(),Y(String(U)),U}},[l,gt]),Oe=y.useCallback(async(T,_,U,he=!1)=>{await Qe(async()=>{if(Z.current===T&&!he){Z.current=null;return}if(ht.current===T&&!he)return;j(it=>it===T?it:T),Ee.current=T;const ne=!he&&!_&&!U;let xe=!1;if(ne){const it=re.current.get(T);if(it)ln(it),xe=!0;else{const ut=w(T);ut&&(re.current.set(T,ut),ln(ut),xe=!0)}}const me=he||!xe||!!_||!!U,xt=async it=>{it&&V(!0),ht.current=T;try{const ut=await l.getStateHistory({threadId:T,checkpointId:_,checkpointNs:U}),Jt=nc(ut);Nt(Jt,"replace",T),W(null)}catch(ut){throw(!xe||he||it)&&(i==null||i(String(ut))),W(String(ut)),ut}finally{ht.current=null,it&&V(!1)}};me?await xt(!0):ne&&xe&&xt(!1).catch(it=>{console.warn("[ChatSessionProvider] Background refresh failed:",it)})},`loadThread-${T}`)},[l,ln,Nt,Qe,i]),rt=y.useCallback(async()=>{await Qe(async()=>{const T=Ee.current;T&&Xt(T),Z.current=null,j(null),Ee.current=null,pe.current=null,cn(),O(void 0),te(void 0);try{localStorage.removeItem("lastThreadId")}catch(_){console.warn("[ChatSessionProvider] Failed to clear lastThreadId:",_)}},"clearCurrentThread")},[cn,Xt,Qe]),Rt=y.useCallback(async T=>{const _=await l.listCheckpoints(T);return _g(_,T)},[l]),I=y.useCallback(async(T,_)=>{if(!Ee.current)throw new Error("No active thread");await Oe(Ee.current,T,_??void 0,!0)},[Oe]),B=y.useCallback(async()=>{if(!Ee.current)throw new Error("No active thread");await Oe(Ee.current,void 0,void 0,!0)},[Oe]),oe=y.useCallback(async()=>{if(!Ee.current)throw new Error("No active thread");if(fe||!D)return;const T=be;if(T){ve(!0);try{const _=Ee.current,U=await l.getStateHistory({threadId:_,checkpointId:T??K,checkpointNs:J}),he=nc(U);Nt(he,"prepend",_??void 0),W(null)}catch(_){throw W(String(_)),_}finally{ve(!1)}}},[l,Nt,D,K,J,be,fe]),ke=y.useCallback(T=>{if(!(T!=null&&T.threadId))return;const _={threadId:T.threadId,checkpointId:T.checkpointId??void 0,checkpointNs:T.checkpointNs??void 0,messages:T.messages??[],hasMore:T.hasMore,nextCursor:T.nextCursor??null};Nt(_,"replace",T.threadId)},[Nt]),Fe=y.useCallback(async(T,_)=>{var Js;const U=Ee.current,he=(T==null?void 0:T.text)??"",ne=(T==null?void 0:T.attachments)??[],xe=ne.length?ne:(_==null?void 0:_.attachments)??[],me={...(_==null?void 0:_.payloadExtras)??{},...(T==null?void 0:T.payload)??{}};if(!U&&!Object.keys(me).length&&xe.length===0&&!he.trim()){console.warn("[ChatSessionProvider] Nothing to submit - skipping");return}!U&&!me.messages&&console.warn("[ChatSessionProvider] No thread ID - message will create new thread");const{contentParts:xt,filesInfo:it}=await Rg(l,xe),ut=[...xt];he&&he.trim()&&ut.push({type:"text",text:he.trim()});const Jt=!!U,Cn=Jt?(_==null?void 0:_.checkpointId)??G.lastCheckpointId??void 0:void 0,Zt=Jt?(_==null?void 0:_.checkpointNs)??G.lastCheckpointNs??void 0:void 0,Dr={id:((Js=crypto.randomUUID)==null?void 0:Js.call(crypto))||`user-${Date.now()}`,role:"user",content:ut,createdAt:new Date().toISOString(),...Cn!=null?{checkpointId:Cn}:{},...Zt!=null?{checkpointNs:Zt}:{}};ut.length>0&&nt(Dr);const sl={...Dr,content:ut},Ys=xe.length>0,Xs={...U?{threadId:U}:{},payload:{messages:ut.length>0?[sl]:[],files_info:it,...o&&Ys&&s?{active_agent:s}:{},...me},...Cn!=null?{checkpointId:Cn}:{},...Zt!=null?{checkpointNs:Zt}:{},nodeFilter:_==null?void 0:_.nodeFilter,config:_==null?void 0:_.config};Or(Xs,{onError:_n=>{console.warn("[ChatSessionProvider] Stream error:",_n)},onOpen:({threadId:_n})=>{!Ee.current&&_n&&(G.messages.length<=1&&(Z.current=_n),j(_n))},onGap:dr})},[l,o,s,dr,G.lastCheckpointId,G.lastCheckpointNs,G.messages.length,nt,Or]),qe=y.useCallback(async(T,_,U)=>{var ne,xe;const he=Ee.current;if(!he)throw new Error("No active thread to handle interrupt");try{const me=_?U??!0:!1;try{se({type:"interrupt_response",payload:{interruptId:T}})}catch(Dr){console.warn("[ChatSessionProvider] optimistic interrupt_response dispatch failed:",Dr)}const xt=`${d}/runs/resume`,it=(ne=l.getAuthToken)==null?void 0:ne.call(l),ut=await fetch(xt,{method:"POST",headers:{"Content-Type":"application/json",...it?{Authorization:`Bearer ${it}`}:{}},body:JSON.stringify({thread_id:he,value:me})});if(!ut.ok)throw new Error(`Resume failed with status ${ut.status}`);const Jt=(xe=ut.body)==null?void 0:xe.getReader();if(!Jt)throw new Error("No response body for resume stream");const Cn=new TextDecoder;let Zt="";for(;;){const{done:Dr,value:sl}=await Jt.read();if(Dr)break;Zt+=Cn.decode(sl,{stream:!0});const Ys=Zt.split(`
|
|
39
|
+
`);Zt=Ys.pop()||"";for(const Xs of Ys)if(Xs.startsWith("data: ")){const Js=Xs.slice(6);try{const _n=JSON.parse(Js);se({type:"event",payload:{ev:_n}})}catch(_n){console.warn("[ChatSessionProvider] Failed to parse resume SSE event:",_n)}}}$(null)}catch(me){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${T}:`,me),me}},[l,se,d]),Ue=y.useCallback(T=>qe(T.interruptId,T.approved,T.value),[qe]);y.useEffect(()=>{if(a==null||a(A),A)try{localStorage.setItem("lastThreadId",A)}catch(T){console.warn("[ChatSessionProvider] Failed to persist lastThreadId:",T)}},[A,a]),y.useEffect(()=>((async()=>{try{if(gt().catch(_=>{console.error("[ChatSessionProvider] Failed to refresh threads (background):",_),i==null||i(String(_))}),!r&&!t)try{const _=localStorage.getItem("lastThreadId");_&&(j(_),n&&await Oe(_))}catch(_){console.warn("[ChatSessionProvider] Failed to restore last thread:",_)}else t&&n&&await Oe(t)}catch(_){console.error("[ChatSessionProvider] Initialization failed:",_),i==null||i(String(_))}})(),()=>{}),[]),y.useEffect(()=>{const T=Ee.current;if(!T||pe.current!==T)return;const _={threadId:T,messages:G.messages.slice(),hasMore:D,nextCursor:be,checkpointId:G.lastCheckpointId??null,checkpointNs:G.lastCheckpointNs??null},U=re.current.get(T);(!U||U.messages.length!==_.messages.length||U.messages.some((ne,xe)=>{var me;return(ne==null?void 0:ne.id)!==((me=_.messages[xe])==null?void 0:me.id)})||(U==null?void 0:U.hasMore)!==_.hasMore||(U==null?void 0:U.nextCursor)!==_.nextCursor||(U==null?void 0:U.checkpointId)!==_.checkpointId||(U==null?void 0:U.checkpointNs)!==_.checkpointNs)&&(re.current.set(T,_),cr.current&&window.clearTimeout(cr.current),cr.current=window.setTimeout(()=>{try{g(_,100)}catch(ne){console.warn("[ChatSessionProvider] Failed to persist thread payload:",ne)}},_o))},[D,be,G.lastCheckpointId,G.lastCheckpointNs,G.messages]);const He=y.useMemo(()=>({threads:E,currentThreadId:A,setCurrentThreadId:j,isLoading:P,error:M,actions:{createThread:hr,deleteThread:ae,renameThread:Te,refreshThreads:()=>gt()},persistThreadsCache:ur,hydrateFromCache:ue}),[E,A,P,M,hr,ae,Te,gt,ur,ue,j]),Ct=y.useMemo(()=>{const T=G.lastBranch??null,_=G.assemblingId??null,U=T||_?{branchLabel:(T==null?void 0:T.branchLabel)??null,lastBranch:T,assemblingMessageId:_}:null;return{threadId:A,messages:G.messages,interrupt:z,checkpoint:{id:G.lastCheckpointId??null,namespace:G.lastCheckpointNs??null},metadata:U,isLoading:F,isHistoryLoading:fe,error:q,hasMore:D,loadOlder:oe,seedFromSnapshot:ke,clearState:cn,listCheckpoints:Rt,navigateToCheckpoint:I,returnToLatest:B,loadThread:Oe,clearThread:rt,respondToInterrupt:qe}},[rt,cn,A,z,D,fe,F,Rt,oe,Oe,G.assemblingId,G.lastBranch,G.lastCheckpointId,G.lastCheckpointNs,G.messages,I,qe,B,ke,q]),ct=y.useMemo(()=>({isStreaming:Nn,error:Mr,submit:Fe,stop:fr,resume:Ue,setAuthToken:An}),[Nn,Mr,Fe,fr,Ue,An]);return c.jsx(Jg.Provider,{value:!0,children:c.jsx(xc.Provider,{value:ct,children:c.jsx(mc.Provider,{value:He,children:c.jsx(gc.Provider,{value:Ct,children:e})})})})}function Ro(){const e=y.useContext(mc);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Po(){const e=y.useContext(gc);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function yc(){const e=y.useContext(xc);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function Oo({children:e,apiConfig:t,initialThreadId:n=null,autoLoadInitial:r=!0,disableAutoRestore:o=!1,enableFileAgentRouting:s=!1,fileAgentId:i="invoice_reader",onError:a,onThreadChange:l}){return c.jsx(Ag,{apiConfig:t,children:c.jsx(sx,{initialThreadId:n,autoLoadInitial:r,disableAutoRestore:o,enableFileAgentRouting:s,fileAgentId:i,onError:a,onThreadChange:l,children:e})})}function Q(...e){return om.twMerge(rm.clsx(e))}const ix=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"}}),Ge=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Wn.Slot:"button";return c.jsx(i,{className:Q(ix({variant:t,size:n,className:e})),ref:s,...o})});Ge.displayName="Button";const Sc=m.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:Q("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Sc.displayName="Textarea";function ax({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,onSend:i,onCancelEdit:a,onStop:l,className:u="",textareaClassName:d="",allowEmptySend:f=!1}){const[h,p]=y.useState(e),[x,w]=y.useTransition(),g=y.useRef(null);y.useEffect(()=>{p(e??""),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const v=y.useCallback(()=>{const A=g.current;A&&(A.style.height="auto",A.style.height=`${A.scrollHeight}px`)},[]);y.useEffect(()=>{v()},[v]);const b=y.useCallback(async A=>{A&&A.preventDefault();const j=(h??"").trim();!j&&!f||w(()=>{try{const P=i(j);P&&typeof P.then=="function"?P.then(()=>{p(""),g.current&&(g.current.style.height="auto")}).catch(()=>{}):(p(""),g.current&&(g.current.style.height="auto"))}catch{}})},[h,i,f]),S=y.useCallback(A=>{p(A.target.value),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),N=y.useCallback(A=>{A.key==="Enter"&&!A.shiftKey?(A.preventDefault(),b()):A.key==="Escape"&&t&&(A.preventDefault(),a==null||a())},[b,t,a]),E=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${d}`;return c.jsx("form",{onSubmit:A=>void b(A),className:`w-full ${u}`,children:c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsx("div",{className:"flex-1",children:c.jsx(Sc,{ref:g,value:h,onChange:S,onKeyDown:N,placeholder:t?"Edit your message...":n,className:E,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),c.jsx("div",{children:r?c.jsx(Ge,{type:"button",onClick:()=>{l==null||l()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!l,children:c.jsx(ie.Square,{size:16})}):c.jsx(Ge,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||x,children:c.jsx(ie.Send,{size:16})})})]})})}const lx=y.memo(ax),Mo=0,Rn=1,vr=2,Cc=4;function Tc(e){return()=>e}function cx(e){e()}function kc(e,t){return n=>e(t(n))}function Ic(e,t){return()=>e(t)}function ux(e,t){return n=>e(t,n)}function Ti(e){return e!==void 0}function dx(...e){return()=>{e.map(cx)}}function wr(){}function Do(e,t){return t(e),e}function fx(e,t){return t(e)}function ot(...e){return e}function Xe(e,t){return e(Rn,t)}function Le(e,t){e(Mo,t)}function ki(e){e(vr)}function ft(e){return e(Cc)}function ge(e,t){return Xe(e,ux(t,Mo))}function en(e,t){const n=e(Rn,r=>{n(),t(r)});return n}function Ec(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Nc(e,t){return e===t}function st(e=Nc){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function _e(e){return t=>n=>{e(n)&&t(n)}}function le(e){return t=>kc(t,e)}function dn(e){return t=>()=>{t(e)}}function H(e,...t){const n=hx(...t);return(r,o)=>{switch(r){case vr:ki(e);return;case Rn:return Xe(e,n(o))}}}function fn(e,t){return n=>r=>{n(t=e(t,r))}}function Gn(e){return t=>n=>{e>0?e--:t(n)}}function kn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function $e(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Xe(s,l=>{const u=n;n=n|a,t[i]=l,u!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function hx(...e){return t=>e.reduceRight(fx,t)}function px(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Rn:return s?n===s?void 0:(r(),n=s,t=Xe(e,s),t):(r(),wr);case vr:r(),n=null;return}}}function X(e){let t=e;const n=Ke();return(r,o)=>{switch(r){case Mo:t=o;break;case Rn:{o(t);break}case Cc:return t}return n(r,o)}}function kt(e,t){return Do(X(t),n=>ge(e,n))}function Ke(){const e=[];return(t,n)=>{switch(t){case Mo:e.slice().forEach(r=>{r(n)});return;case vr:e.splice(0,e.length);return;case Rn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Ft(e){return Do(Ke(),t=>ge(e,t))}function Ye(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:mx(),singleton:n}}const mx=()=>Symbol();function gx(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 pt(...e){const t=Ke(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Xe(s,l=>{n[i]=l,r=r|a,r===o&&Le(t,n)})}),function(s,i){switch(s){case vr:{ki(t);return}case Rn:return r===o&&i(n),Xe(t,i)}}}function Ie(e,t=Nc){return H(e,st(t))}function Ii(...e){return function(t,n){switch(t){case vr:return;case Rn:return dx(...e.map(r=>Xe(r,n)))}}}var Mt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Mt||{});const xx={0:"debug",3:"error",1:"log",2:"warn"},vx=()=>typeof globalThis>"u"?window:globalThis,Pn=Ye(()=>{const e=X(3);return{log:X((t,n,r=1)=>{var o;const s=(o=vx().VIRTUOSO_LOG_LEVEL)!=null?o:ft(e);r>=s&&console[xx[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Yn(e,t,n){return Ei(e,t,n).callbackRef}function Ei(e,t,n){const r=y.useRef(null);let o=i=>{};const s=y.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function wx(e,t,n,r,o,s,i,a,l){const u=y.useCallback(d=>{const f=bx(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const p=h.lastElementChild.dataset.viewportType==="window";let x;p&&(x=h.ownerDocument.defaultView);const w=i?a?i.scrollLeft:i.scrollTop:p?a?x.scrollX||x.document.documentElement.scrollLeft:x.scrollY||x.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:p?a?x.document.documentElement.scrollWidth:x.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,v=i?a?i.offsetWidth:i.offsetHeight:p?a?x.innerWidth:x.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(w,0),viewportHeight:v}),s==null||s(a?Ac("column-gap",getComputedStyle(d).columnGap,o):Ac("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return Ei(u,n,l)}function bx(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),u=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Mt.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Ac(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Mt.WARN),t==="normal"?0:parseInt(t??"0",10)}function _c(e,t,n){const r=y.useRef(null),o=y.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const u=l.getBoundingClientRect(),d=u.width;let f,h;if(t){const p=t.getBoundingClientRect(),x=u.top-p.top;h=p.height-Math.max(0,x),f=x+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;h=p.innerHeight-Math.max(0,u.top),f=u.top+p.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Ei(o,!0,n),a=y.useCallback(()=>{o(i.current)},[o,i]);return y.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const u=new ResizeObserver(()=>{requestAnimationFrame(a)});return u.observe(t),()=>{t.removeEventListener("scroll",a),u.unobserve(t)}}else{const u=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return u==null||u.addEventListener("scroll",a),u==null||u.addEventListener("resize",a),()=>{u==null||u.removeEventListener("scroll",a),u==null||u.removeEventListener("resize",a)}}},[a,t,i]),s}const _t=Ye(()=>{const e=Ke(),t=Ke(),n=X(0),r=Ke(),o=X(0),s=Ke(),i=Ke(),a=X(0),l=X(0),u=X(0),d=X(0),f=Ke(),h=Ke(),p=X(!1),x=X(!1),w=X(!1);return ge(H(e,le(({scrollTop:g})=>g)),t),ge(H(e,le(({scrollHeight:g})=>g)),i),ge(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:x,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:w,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Vr={lvl:0};function jc(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 et(e){return e===Vr}function qr(e,t){if(!et(e))return t===e.k?e.v:t<e.k?qr(e.l,t):qr(e.r,t)}function tn(e,t,n="k"){if(et(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=tn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return tn(e.l,t,n)}function $t(e,t,n){return et(e)?Oc(t,n,1):t===e.k?mt(e,{k:t,v:n}):t<e.k?Mc(mt(e,{l:$t(e.l,t,n)})):Mc(mt(e,{r:$t(e.r,t,n)}))}function br(){return Vr}function Lo(e,t,n){if(et(e))return[];const r=tn(e,t)[0];return yx(Ai(e,r,n))}function Ni(e,t){if(et(e))return Vr;const{k:n,l:r,r:o}=e;if(t===n){if(et(r))return o;if(et(o))return r;{const[s,i]=Pc(r);return Fo(mt(e,{k:s,l:Rc(r),v:i}))}}else return t<n?Fo(mt(e,{l:Ni(r,t)})):Fo(mt(e,{r:Ni(o,t)}))}function Xn(e){return et(e)?[]:[...Xn(e.l),{k:e.k,v:e.v},...Xn(e.r)]}function Ai(e,t,n){if(et(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Ai(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Ai(s,t,n))),a}function Fo(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(_i(t))return Dc(mt(e,{lvl:n-1}));if(!et(t)&&!et(t.r))return mt(t.r,{l:mt(t,{r:t.r.l}),lvl:n,r:mt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(_i(e))return ji(mt(e,{lvl:n-1}));if(!et(r)&&!et(r.l)){const o=r.l,s=_i(o)?r.lvl-1:r.lvl;return mt(o,{l:mt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:ji(mt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function mt(e,t){return Oc(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function Rc(e){return et(e.r)?e.l:Fo(mt(e,{r:Rc(e.r)}))}function _i(e){return et(e)||e.lvl>e.r.lvl}function Pc(e){return et(e.r)?[e.k,e.v]:Pc(e.r)}function Oc(e,t,n,r=Vr,o=Vr){return{k:e,l:r,lvl:n,r:o,v:t}}function Mc(e){return ji(Dc(e))}function Dc(e){const{l:t}=e;return!et(t)&&t.lvl===e.lvl?mt(t,{r:mt(e,{l:t.r})}):e}function ji(e){const{lvl:t,r:n}=e;return!et(n)&&!et(n.r)&&n.lvl===t&&n.r.lvl===t?mt(n,{l:mt(e,{r:n.l}),lvl:t+1}):e}function yx(e){return jc(e,({k:t,v:n})=>({index:t,value:n}))}function Lc(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Kr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ri=Ye(()=>({recalcInProgress:X(!1)}),[],{singleton:!0});function Fc(e,t,n){return e[$o(e,t,n)]}function $o(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 Sx(e,t,n,r){const o=$o(e,t,r),s=$o(e,n,r,o);return e.slice(o,s+1)}function On(e,t){return Math.round(e.getBoundingClientRect()[t])}function zo(e){return!et(e.groupOffsetTree)}function Pi({index:e},t){return t===e?0:t<e?-1:1}function Cx(){return{groupIndices:[],groupOffsetTree:br(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:br()}}function Tx(e,t){let n=et(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),et(e)){e=$t(e,0,s);continue}const a=Lo(e,i-1,o+1);if(a.some(jx(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=Ni(e,f)):(u=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=$t(e,o+1,h));u&&(e=$t(e,i,s))}return[e,n]}function kx(e){return typeof e.groupIndex<"u"}function Ix({offset:e},t){return t===e?0:t<e?-1:1}function Gr(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Fc(t,e,Pi),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function $c(e,t){if(!zo(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function zc(e,t,n){if(kx(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=$c(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function Ex(e,t,n,r=0){return r>0&&(t=Math.max(t,Fc(e,r,Pi).offset)),jc(Sx(e,t,n,Ix),_x)}function Nx(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Mt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&et(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((x,w)=>$t($t(x,w,h),w+1,p),i)}else[i,a]=Tx(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=Oi(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>$t(h,p,Gr(p,f,o)),br()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function Ax(e){return Xn(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 Bc(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 Oi(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=$o(o,t-1,Pi),a=o[l].offset;const u=tn(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===tn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:u,value:d}of Lo(n,t,1/0)){const f=u-s,h=f*i+a+f*r;o.push({index:u,offset:h,size:d}),s=u,a=h,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function _x(e){return{index:e.index,value:e}}function jx(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 Rx={offsetHeight:"height",offsetWidth:"width"},hn=Ye(([{log:e},{recalcInProgress:t}])=>{const n=Ke(),r=Ke(),o=kt(r,0),s=Ke(),i=Ke(),a=X(0),l=X([]),u=X(void 0),d=X(void 0),f=X((C,k)=>On(C,Rx[k])),h=X(void 0),p=X(0),x=Cx(),w=kt(H(n,$e(l,e,p),fn(Nx,x),st()),x),g=kt(H(l,st(),fn((C,k)=>({current:k,prev:C.current}),{current:[],prev:[]}),le(({prev:C})=>C)),[]);ge(H(l,_e(C=>C.length>0),$e(w,p),le(([C,k,E])=>{const A=C.reduce((j,P,L)=>$t(j,P,Gr(P,k.offsetTree,E)||L),br());return{...k,groupIndices:C,groupOffsetTree:A}})),w),ge(H(r,$e(w),_e(([C,{lastIndex:k}])=>C<k),le(([C,{lastIndex:k,lastSize:E}])=>[{endIndex:k,size:E,startIndex:C}])),n),ge(u,d);const v=kt(H(u,le(C=>C===void 0)),!0);ge(H(d,_e(C=>C!==void 0&&et(ft(w).sizeTree)),le(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=Ft(H(n,$e(w),fn(({sizes:C},[k,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:x}),le(C=>C.changed)));Xe(H(a,fn((C,k)=>({diff:C.prev-k,prev:k}),{diff:0,prev:0}),le(C=>C.diff)),C=>{const{groupIndices:k}=ft(w);if(C>0)Le(t,!0),Le(s,C+Bc(C,k));else if(C<0){const E=ft(g);E.length>0&&(C-=Bc(-C,E)),Le(i,C)}}),Xe(H(a,$e(e)),([C,k])=>{C<0&&k("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Mt.ERROR)});const S=Ft(s);ge(H(s,$e(w),le(([C,k])=>{const E=k.groupIndices.length>0,A=[],j=k.lastSize;if(E){const P=qr(k.sizeTree,0);let L=0,F=0;for(;L<C;){const M=k.groupIndices[F],Y=k.groupIndices.length===F+1?1/0:k.groupIndices[F+1]-M-1;A.push({endIndex:M,size:P,startIndex:M}),A.push({endIndex:M+1+Y-1,size:j,startIndex:M+1}),F++,L+=Y+1}const V=Xn(k.sizeTree);return L!==C&&V.shift(),V.reduce((M,{k:Y,v:q})=>{let W=M.ranges;return M.prevSize!==0&&(W=[...M.ranges,{endIndex:Y+C-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:Y+C,prevSize:q,ranges:W}},{prevIndex:C,prevSize:0,ranges:A}).ranges}return Xn(k.sizeTree).reduce((P,{k:L,v:F})=>({prevIndex:L+C,prevSize:F,ranges:[...P.ranges,{endIndex:L+C-1,size:P.prevSize,startIndex:P.prevIndex}]}),{prevIndex:0,prevSize:j,ranges:[]}).ranges})),n);const N=Ft(H(i,$e(w,p),le(([C,{offsetTree:k},E])=>{const A=-C;return Gr(A,k,E)})));return ge(H(i,$e(w,p),le(([C,k,E])=>{if(k.groupIndices.length>0){if(et(k.sizeTree))return k;let A=br();const j=ft(g);let P=0,L=0,F=0;for(;P<-C;){F=j[L];const V=j[L+1]-F-1;L++,P+=V+1}if(A=Xn(k.sizeTree).reduce((V,{k:M,v:Y})=>$t(V,Math.max(0,M+C),Y),A),P!==-C){const V=qr(k.sizeTree,F);A=$t(A,0,V);const M=tn(k.sizeTree,-C+1)[1];A=$t(A,1,M)}return{...k,sizeTree:A,...Oi(k.offsetTree,0,A,E)}}else{const A=Xn(k.sizeTree).reduce((j,{k:P,v:L})=>$t(j,Math.max(0,P+C),L),br());return{...k,sizeTree:A,...Oi(k.offsetTree,0,A,E)}}})),w),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:N,sizeRanges:n,sizes:w,statefulTotalCount:o,totalCount:r,trackItemSizes:v,unshiftWith:s}},ot(Pn,Ri),{singleton:!0});function Px(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Hc=Ye(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Ke(),i=Ke(),a=Ft(H(s,le(Px)));return ge(H(a,le(l=>l.totalCount)),n),ge(H(a,le(l=>l.groupIndices)),e),ge(H(pt(o,t,r),_e(([l,u])=>zo(u)),le(([l,u,d])=>tn(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),st(),le(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},ot(hn,_t)),Mn=Ye(([{log:e}])=>{const t=X(!1),n=Ft(H(t,_e(r=>r),st()));return Xe(t,r=>{r&&ft(e)("props updated",{},Mt.DEBUG)}),{didMount:n,propsReady:t}},ot(Pn),{singleton:!0}),Ox=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Uc(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Ox)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Yr=Ye(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const p=Ke(),x=Ke(),w=X(0);let g=null,v=null,b=null;function S(){g&&(g(),g=null),b&&(b(),b=null),v&&(clearTimeout(v),v=null),Le(l,!1)}return ge(H(p,$e(n,f,r,w,a,i,h),$e(e,s,o),le(([[N,C,k,E,A,j,P,L],F,V,M])=>{const Y=Uc(N),{align:q,behavior:W,offset:z}=Y,$=E-1,ue=zc(Y,C,$);let D=Gr(ue,C.offsetTree,F)+j;q==="end"?(D+=V+tn(C.sizeTree,ue)[1]-k+M,ue===$&&(D+=P)):q==="center"?D+=(V+tn(C.sizeTree,ue)[1]-k+M)/2:D-=A,z&&(D+=z);const ee=fe=>{S(),fe?(L("retrying to scroll to",{location:N},Mt.DEBUG),Le(p,N)):(Le(x,!0),L("list did not change, scroll successful",{},Mt.DEBUG))};if(S(),W==="smooth"){let fe=!1;b=Xe(t,ve=>{fe=fe||ve}),g=en(d,()=>{ee(fe)})}else g=en(H(t,Mx(150)),ee);return v=setTimeout(()=>{S()},1200),Le(l,!0),L("scrolling from index to",{behavior:W,index:ue,top:D},Mt.DEBUG),{behavior:W,top:D}})),u),{scrollTargetReached:x,scrollToIndex:p,topListHeight:w}},ot(hn,_t,Pn),{singleton:!0});function Mx(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Mi(e,t){e==0?t():requestAnimationFrame(()=>{Mi(e-1,t)})}function Di(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Xr=Ye(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=X(!0),l=X(0),u=X(!0);return ge(H(i,$e(l),_e(([d,f])=>!!f),dn(!1)),a),ge(H(i,$e(l),_e(([d,f])=>!!f),dn(!1)),u),Xe(H(pt(t,i),$e(a,n,e,u),_e(([[,d],f,{sizeTree:h},p,x])=>d&&(!et(h)||Ti(p))&&!f&&!x),$e(l)),([,d])=>{en(o,()=>{Le(u,!0)}),Mi(4,()=>{en(r,()=>{Le(a,!0)}),Le(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},ot(hn,_t,Yr,Mn),{singleton:!0});function Wc(e,t){return Math.abs(e-t)<1.01}const Jr="up",Zr="down",Dx="none",Lx={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Fx=0,Qr=Ye(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=X(!1),a=X(!0),l=Ke(),u=Ke(),d=X(4),f=X(Fx),h=kt(H(Ii(H(Ie(o),Gn(1),dn(!0)),H(Ie(o),Gn(1),dn(!1),Ec(100))),st()),!1),p=kt(H(Ii(H(n,dn(!0)),H(n,dn(!1),Ec(200))),st()),!1);ge(H(pt(Ie(o),Ie(f)),le(([b,S])=>b<=S),st()),a),ge(H(a,kn(50)),u);const x=Ft(H(pt(r,Ie(s),Ie(t),Ie(e),Ie(d)),fn((b,[{scrollHeight:S,scrollTop:N},C,k,E,A])=>{const j=N+C-S>-A,P={scrollHeight:S,scrollTop:N,viewportHeight:C};if(j){let F,V;return N>b.state.scrollTop?(F="SCROLLED_DOWN",V=b.state.scrollTop-N):(F="SIZE_DECREASED",V=b.state.scrollTop-N||b.scrollTopDelta),{atBottom:!0,atBottomBecause:F,scrollTopDelta:V,state:P}}let L;return P.scrollHeight>b.state.scrollHeight?L="SIZE_INCREASED":C<b.state.viewportHeight?L="VIEWPORT_HEIGHT_DECREASING":N<b.state.scrollTop?L="SCROLLING_UPWARDS":L="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:L,state:P}},Lx),st((b,S)=>b&&b.atBottom===S.atBottom))),w=kt(H(r,fn((b,{scrollHeight:S,scrollTop:N,viewportHeight:C})=>{if(Wc(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:N};{const k=S-(N+C)<1;return b.scrollTop!==N&&k?{changed:!0,jump:b.scrollTop-N,scrollHeight:S,scrollTop:N}:{changed:!0,jump:0,scrollHeight:S,scrollTop:N}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),_e(b=>b.changed),le(b=>b.jump)),0);ge(H(x,le(b=>b.atBottom)),i),ge(H(i,kn(50)),l);const g=X(Zr);ge(H(r,le(({scrollTop:b})=>b),st(),fn((b,S)=>ft(p)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?Jr:Zr,prevScrollTop:S},{direction:Zr,prevScrollTop:0}),le(b=>b.direction)),g),ge(H(r,kn(50),dn(Dx)),g);const v=X(0);return ge(H(h,_e(b=>!b),dn(0)),v),ge(H(o,kn(100),$e(h),_e(([b,S])=>!!S),fn(([b,S],[N])=>[S,N],[0,0]),le(([b,S])=>S-b)),v),{atBottomState:x,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:w,scrollDirection:g,scrollVelocity:v}},ot(_t)),Bo="top",Ho="bottom",Vc="none";function qc(e,t,n){return typeof e=="number"?n===Jr&&t===Bo||n===Zr&&t===Ho?e:0:n===Jr?t===Bo?e.main:e.reverse:t===Ho?e.main:e.reverse}function Kc(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Li=Ye(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Ke(),i=X(0),a=X(0),l=X(0),u=kt(H(pt(Ie(r),Ie(o),Ie(n),Ie(s,Kr),Ie(l),Ie(i),Ie(t),Ie(e),Ie(a)),le(([d,f,h,[p,x],w,g,v,b,S])=>{const N=d-b,C=g+v,k=Math.max(h-N,0);let E=Vc;const A=Kc(S,Bo),j=Kc(S,Ho);return p-=b,p+=h+v,x+=h+v,x-=b,p>d+C-A&&(E=Jr),x<d-k+f+j&&(E=Zr),E!==Vc?[Math.max(N-h-qc(w,Bo,E)-A,0),N-k-v+f+qc(w,Ho,E)+j]:null}),_e(d=>d!=null),st(Kr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},ot(_t),{singleton:!0});function $x(e,t,n){if(zo(t)){const r=$c(e,t);return[{index:tn(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 Fi={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Uo(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const w=e[e.length-1];d=w.offset+w.size}const f=n-i,h=a+f*l+(f-1)*r,p=u,x=h-d;return{bottom:d,firstItemIndex:s,items:Yc(e,o,s),offsetBottom:x,offsetTop:u,top:p,topItems:Yc(t,o,s),topListHeight:t.reduce((w,g)=>g.size+w,0),totalCount:n}}function Gc(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=Di(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return Uo(u,[],a,o,n,r)}function Yc(e,t,n){if(e.length===0)return[];if(!zo(t))return e.map(u=>({...u,index:u.index+n,originalIndex:u.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=Lo(t.groupOffsetTree,r,o);let a,l=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:u.index-(l+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const Jn=Ye(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:p},{recalcInProgress:x}])=>{const w=X([]),g=X(0),v=Ke();ge(s.topItemsIndexes,w);const b=kt(H(pt(p,x,Ie(l,Kr),Ie(o),Ie(r),Ie(u),d,Ie(w),Ie(t),Ie(n),e),_e(([k,E,,A,,,,,,,j])=>{const P=j&&j.length!==A;return k&&!E&&!P}),le(([,,[k,E],A,j,P,L,F,V,M,Y])=>{const q=j,{offsetTree:W,sizeTree:z}=q,$=ft(g);if(A===0)return{...Fi,totalCount:A};if(k===0&&E===0)return $===0?{...Fi,totalCount:A}:Gc($,P,j,V,M,Y||[]);if(et(z))return $>0?null:Uo($x(Di(P,A),q,Y),[],A,M,q,V);const ue=[];if(F.length>0){const be=F[0],ye=F[F.length-1];let K=0;for(const O of Lo(z,be,ye)){const J=O.value,te=Math.max(O.start,be),G=Math.min(O.end,ye);for(let se=te;se<=G;se++)ue.push({data:Y==null?void 0:Y[se],index:se,offset:K,size:J}),K+=J}}if(!L)return Uo([],ue,A,M,q,V);const D=F.length>0?F[F.length-1]+1:0,ee=Ex(W,k,E,D);if(ee.length===0)return null;const fe=A-1,ve=Do([],be=>{for(const ye of ee){const K=ye.value;let O=K.offset,J=ye.start;const te=K.size;if(K.offset<k){J+=Math.floor((k-K.offset+M)/(te+M));const se=J-ye.start;O+=se*te+se*M}J<D&&(O+=(D-J)*te,J=D);const G=Math.min(ye.end,fe);for(let se=J;se<=G&&!(O>=E);se++)be.push({data:Y==null?void 0:Y[se],index:se,offset:O,size:te}),O+=te+M}});return Uo(ve,ue,A,M,q,V)}),_e(k=>k!==null),st()),Fi);ge(H(e,_e(Ti),le(k=>k==null?void 0:k.length)),o),ge(H(b,le(k=>k.topListHeight)),f),ge(f,a),ge(H(b,le(k=>[k.top,k.bottom])),i),ge(H(b,le(k=>k.items)),v);const S=Ft(H(b,_e(({items:k})=>k.length>0),$e(o,e),_e(([{items:k},E])=>k[k.length-1].originalIndex===E-1),le(([,k,E])=>[k-1,E]),st(Kr),le(([k])=>k))),N=Ft(H(b,kn(200),_e(({items:k,topItems:E})=>k.length>0&&k[0].originalIndex===E.length),le(({items:k})=>k[0].index),st())),C=Ft(H(b,_e(({items:k})=>k.length>0),le(({items:k})=>{let E=0,A=k.length-1;for(;k[E].type==="group"&&E<A;)E++;for(;k[A].type==="group"&&A>E;)A--;return{endIndex:k[A].index,startIndex:k[E].index}}),st(Lc)));return{endReached:S,initialItemCount:g,itemsRendered:v,listState:b,rangeChanged:C,startReached:N,topItemsIndexes:w,...h}},ot(hn,Hc,Li,Xr,Yr,Qr,Mn,Ri),{singleton:!0}),Xc=Ye(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Ke(),i=kt(H(pt(n,e,r,t,o),le(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return ge(Ie(i),s),{totalListHeight:i,totalListHeightChanged:s}},ot(_t,Jn),{singleton:!0}),zx=Ye(([{viewportHeight:e},{totalListHeight:t}])=>{const n=X(!1),r=kt(H(pt(n,e,t),_e(([o])=>o),le(([,o,s])=>Math.max(0,o-s)),kn(0),st()),0);return{alignToBottom:n,paddingTopAddition:r}},ot(_t,Xc),{singleton:!0}),Jc=Ye(()=>({context:X(null)})),Bx=({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,Zc=Ye(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:u}])=>{const d=Ke();return ge(H(d,$e(t,l,n,s,o,r,a),$e(e),le(([[f,h,p,x,w,g,v,b],S])=>{const{align:N,behavior:C,calculateViewLocation:k=Bx,done:E,...A}=f,j=zc(f,h,x-1),P=Gr(j,h.offsetTree,S)+w+g,L=P+tn(h.sizeTree,j)[1],F=b+g,V=b+p-v,M=k({itemBottom:L,itemTop:P,locationParams:{align:N,behavior:C,...A},viewportBottom:V,viewportTop:F});return M?E&&en(H(i,_e(Y=>!Y),Gn(ft(i)?1:2)),E):E&&E(),M}),_e(f=>f!==null)),u),{scrollIntoView:d}},ot(hn,_t,Yr,Jn,Pn),{singleton:!0});function Qc(e){return e?e==="smooth"?"smooth":"auto":!1}const Hx=(e,t)=>typeof e=="function"?Qc(e(t)):t&&Qc(e),Ux=Ye(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:u},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:p}])=>{const x=X(!1),w=Ke();let g=null;function v(C){Le(i,{align:"end",behavior:C,index:"LAST"})}Xe(H(pt(H(Ie(t),Gn(1)),l),$e(Ie(x),s,a,f),le(([[C,k],E,A,j,P])=>{let L=k&&j,F="auto";return L&&(F=Hx(E,A||P),L=L&&!!F),{followOutputBehavior:F,shouldFollow:L,totalCount:C}}),_e(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:k})=>{g&&(g(),g=null),ft(n)?requestAnimationFrame(()=>{ft(d)("following output to ",{totalCount:k},Mt.DEBUG),v(C)}):g=en(e,()=>{ft(d)("following output to ",{totalCount:k},Mt.DEBUG),v(C),g=null})});function b(C){const k=en(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(ft(d)("scrolling to bottom due to increased size",{},Mt.DEBUG),v("auto"))});setTimeout(k,100)}Xe(H(pt(Ie(x),t,u),_e(([C,,k])=>C&&k),fn(({value:C},[,k])=>({refreshed:C===k,value:k}),{refreshed:!1,value:0}),_e(({refreshed:C})=>C),$e(x,t)),([,C])=>{ft(a)&&b(C!==!1)}),Xe(w,()=>{b(ft(x)!==!1)}),Xe(pt(Ie(x),o),([C,k])=>{C&&!k.atBottom&&k.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&v("auto")});const S=X(null),N=Ke();return ge(Ii(H(Ie(r),le(C=>{var k;return(k=C==null?void 0:C.length)!=null?k:0})),H(Ie(t))),N),Xe(H(pt(H(N,Gn(1)),l),$e(Ie(S),a,f,h),le(([[C,k],E,A,j,P])=>k&&A&&(E==null?void 0:E({context:P,totalCount:C,scrollingInProgress:j}))),_e(C=>!!C),kn(0)),C=>{g&&(g(),g=null),ft(n)?requestAnimationFrame(()=>{ft(d)("scrolling into view",{}),Le(p,C)}):g=en(e,()=>{ft(d)("scrolling into view",{}),Le(p,C),g=null})}),{autoscrollToBottom:w,followOutput:x,scrollIntoViewOnChange:S}},ot(hn,Qr,Yr,Xr,Mn,Pn,_t,Jc,Zc)),Wx=Ye(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ge(H(a,$e(s),_e(([,l])=>l!==0),$e(o,r,t,n,e),le(([[,l],u,d,f,h,p=[]])=>Gc(l,u,d,f,h,p))),i),{}),ot(hn,Xr,Jn,Mn),{singleton:!0}),Vx=Ye(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=X(0);return Xe(H(e,$e(r),_e(([,o])=>o!==0),le(([,o])=>({top:o}))),o=>{en(H(n,Gn(1),_e(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Le(t,o)})})}),{initialScrollTop:r}},ot(Mn,_t,Jn),{singleton:!0}),eu=Ye(([{scrollVelocity:e}])=>{const t=X(!1),n=Ke(),r=X(!1);return ge(H(e,$e(r,t,n),_e(([o,s])=>!!s),le(([o,s,i,a])=>{const{enter:l,exit:u}=s;if(i){if(u(o,a))return!1}else if(l(o,a))return!0;return i}),st()),t),Xe(H(pt(t,e,n),$e(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},ot(Qr),{singleton:!0}),$i=Ye(([{scrollContainerState:e,scrollTo:t}])=>{const n=Ke(),r=Ke(),o=Ke(),s=X(!1),i=X(void 0);return ge(H(pt(n,r),le(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),ge(H(t,$e(r),le(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},ot(_t)),qx=Ye(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=Ke(),d=X(void 0),f=X(null),h=X(null);return ge(a,f),ge(l,h),Xe(H(u,$e(t,r,i,f,h,n)),([p,x,w,g,v,b,S])=>{const N=Ax(x.sizeTree);g&&v!==null&&b!==null&&(w=v.scrollTop-b.offsetTop),w-=S,p({ranges:N,scrollTop:w})}),ge(H(d,_e(Ti),le(Kx)),o),ge(H(s,$e(d),_e(([,p])=>p!==void 0),st(),le(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},ot(hn,_t,Xr,Mn,$i));function Kx(e){return{align:"start",index:0,offset:e.scrollTop}}const Gx=Ye(([{topItemsIndexes:e}])=>{const t=X(0);return ge(H(t,_e(n=>n>=0),le(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ot(Jn));function tu(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const Yx=tu(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Xx=Ye(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:h},{log:p},{recalcInProgress:x}])=>{const w=Ft(H(l,$e(i),fn(([,v,b,S],[{bottom:N,items:C,offsetBottom:k,totalCount:E},A])=>{const j=N+k;let P=0;return b===E&&v.length>0&&C.length>0&&(C[0].originalIndex===0&&v[0].originalIndex===0||(P=j-S,P!==0&&(P+=A))),[P,C,E,j]},[0,[],0,0]),_e(([v])=>v!==0),$e(r,a,n,o,p,x),_e(([,v,b,S,,,N])=>!N&&!S&&v!==0&&b===Jr),le(([[v],,,,,b])=>(b("Upward scrolling compensation",{amount:v},Mt.DEBUG),v))));function g(v){v>0?(Le(t,{behavior:"auto",top:-v}),Le(e,0)):(Le(e,0),Le(t,{behavior:"auto",top:-v}))}return Xe(H(w,$e(e,s)),([v,b,S])=>{S&&Yx()?Le(e,b-v):g(-v)}),Xe(H(pt(kt(s,!1),e,x),_e(([v,b,S])=>!v&&!S&&b!==0),le(([v,b])=>b),kn(1)),g),ge(H(f,le(v=>({top:-v}))),t),Xe(H(u,$e(h,d),le(([v,{groupIndices:b,lastSize:S,sizeTree:N},C])=>{function k(E){return E*(S+C)}if(b.length===0)return k(v);{let E=0;const A=qr(N,0);let j=0,P=0;for(;j<v;){j++,E+=A;let L=b.length===P+1?1/0:b[P+1]-b[P]-1;j+L>v&&(E-=A,L=v-j+1),j+=L,E+=k(L),P++}return E}})),v=>{Le(e,v),requestAnimationFrame(()=>{Le(t,{top:v}),requestAnimationFrame(()=>{Le(e,0),Le(x,!1)})})}),{deviation:e}},ot(_t,Qr,Jn,hn,Pn,Ri)),Jx=Ye(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),ot(Li,Wx,Mn,eu,Xc,Vx,zx,$i,Zc,Pn,Jc)),nu=Ye(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:x},w,g,v,{listState:b,topItemsIndexes:S,...N},{scrollToIndex:C},k,{topItemCount:E},{groupCounts:A},j])=>(ge(N.rangeChanged,j.scrollSeekRangeChanged),ge(H(j.windowViewportRect,le(P=>P.visibleHeight)),w.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:x,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...v,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...N,...j,...w,sizes:l,...g}),ot(hn,Xr,_t,qx,Ux,Jn,Yr,Xx,Gx,Hc,Jx));function Zx(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 Wo=typeof document<"u"?y.useLayoutEffect:y.useEffect;function ru(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=y.createContext({});function l(g,v){g.propsReady&&Le(g.propsReady,!1);for(const b of r){const S=g[t.required[b]];Le(S,v[b])}for(const b of o)if(b in v){const S=g[t.optional[b]];Le(S,v[b])}g.propsReady&&Le(g.propsReady,!0)}function u(g){return s.reduce((v,b)=>(v[b]=S=>{const N=g[t.methods[b]];Le(N,S)},v),{})}function d(g){return i.reduce((v,b)=>(v[b]=px(g[t.events[b]]),v),{})}const f=y.forwardRef((g,v)=>{const{children:b,...S}=g,[N]=y.useState(()=>Do(gx(e),E=>{l(E,S)})),[C]=y.useState(Ic(d,N));Wo(()=>{for(const E of i)E in S&&Xe(C[E],S[E]);return()=>{Object.values(C).map(ki)}},[S,C,N]),Wo(()=>{l(N,S)}),y.useImperativeHandle(v,Tc(u(N)));const k=n;return c.jsx(a.Provider,{value:N,children:n?c.jsx(k,{...Zx([...r,...o,...i],S),children:b}):b})}),h=g=>{const v=y.useContext(a);return y.useCallback(b=>{Le(v[g],b)},[v,g])},p=g=>{const v=y.useContext(a)[g],b=y.useCallback(S=>Xe(v,S),[v]);return y.useSyncExternalStore(b,()=>ft(v),()=>ft(v))},x=g=>{const v=y.useContext(a)[g],[b,S]=y.useState(Ic(ft,v));return Wo(()=>Xe(v,N=>{N!==b&&S(Tc(N))}),[v,b]),b},w=y.version.startsWith("18")?p:x;return{Component:f,useEmitter:(g,v)=>{const b=y.useContext(a)[g];Wo(()=>Xe(b,v),[v,b])},useEmitterValue:w,usePublisher:h}}const ou=y.createContext(void 0),su=y.createContext(void 0),iu=typeof document<"u"?y.useLayoutEffect:y.useEffect;function zi(e){return"self"in e}function Qx(e){return"body"in e}function au(e,t,n,r=wr,o,s){const i=y.useRef(null),a=y.useRef(null),l=y.useRef(null),u=y.useCallback(h=>{let p,x,w;const g=h.target;if(Qx(g)||zi(g)){const b=zi(g)?g:g.defaultView;w=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,x=s?b.innerWidth:b.innerHeight}else w=s?g.scrollLeft:g.scrollTop,p=s?g.scrollWidth:g.scrollHeight,x=s?g.offsetWidth:g.offsetHeight;const v=()=>{e({scrollHeight:p,scrollTop:Math.max(w,0),viewportHeight:x})};h.suppressFlushSync?v():Zs.flushSync(v),a.current!==null&&(w===a.current||w<=0||w===p-x)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);y.useEffect(()=>{const h=o||i.current;return r(o||i.current),u({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",u,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",u)}},[i,u,n,r,o]);function d(h){const p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const x=h.behavior==="smooth";let w,g,v;zi(p)?(g=Math.max(On(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),w=s?p.innerWidth:p.innerHeight,v=s?window.scrollX:window.scrollY):(g=p[s?"scrollWidth":"scrollHeight"],w=On(p,s?"width":"height"),v=p[s?"scrollLeft":"scrollTop"]);const b=g-w;if(h.top=Math.ceil(Math.max(Math.min(b,h.top),0)),Wc(w,g)||h.top===v){e({scrollHeight:g,scrollTop:v,viewportHeight:w}),x&&t(!0);return}x?(a.current=h.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(h={behavior:h.behavior,left:h.top}),p.scrollTo(h)}function f(h){s&&(h={behavior:h.behavior,left:h.top}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const Bi="-webkit-sticky",lu="sticky",Hi=tu(()=>{if(typeof document>"u")return lu;const e=document.createElement("div");return e.style.position=Bi,e.style.position===Bi?Bi:lu});function Ui(e){return e}const ev=Ye(()=>{const e=X(a=>`Item ${a}`),t=X(a=>`Group ${a}`),n=X({}),r=X(Ui),o=X("div"),s=X(wr),i=(a,l=null)=>kt(H(n,le(u=>u[a]),st()),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")}}),tv=Ye(([e,t])=>({...e,...t}),ot(nu,ev)),nv=({height:e})=>c.jsx("div",{style:{height:e}}),rv={overflowAnchor:"none",position:Hi(),zIndex:1},cu={overflowAnchor:"none"},ov={...cu,display:"inline-block",height:"100%"},uu=y.memo(function({showTopList:e=!1}){const t=Pe("listState"),n=Vt("sizeRanges"),r=Pe("useWindowScroll"),o=Pe("customScrollParent"),s=Vt("windowScrollContainerState"),i=Vt("scrollContainerState"),a=o||r?s:i,l=Pe("itemContent"),u=Pe("context"),d=Pe("groupContent"),f=Pe("trackItemSizes"),h=Pe("itemSize"),p=Pe("log"),x=Vt("gap"),w=Pe("horizontalDirection"),{callbackRef:g}=wx(n,h,f,e?wr:a,p,x,o,w,Pe("skipAnimationFrameInResizeObserver")),[v,b]=y.useState(0);Wi("deviation",M=>{v!==M&&b(M)});const S=Pe("EmptyPlaceholder"),N=Pe("ScrollSeekPlaceholder")||nv,C=Pe("ListComponent"),k=Pe("ItemComponent"),E=Pe("GroupComponent"),A=Pe("computeItemKey"),j=Pe("isSeeking"),P=Pe("groupIndices").length>0,L=Pe("alignToBottom"),F=Pe("initialItemFinalLocationReached"),V=e?{}:{boxSizing:"border-box",...w?{display:"inline-block",height:"100%",marginLeft:v!==0?v:L?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:v!==0?v:L?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...F?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?c.jsx(S,{...It(S,u)}):c.jsx(C,{...It(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:V,children:(e?t.topItems:t.items).map(M=>{const Y=M.originalIndex,q=A(Y+t.firstItemIndex,M.data,u);return j?y.createElement(N,{...It(N,u),height:M.size,index:M.index,key:q,type:M.type||"item",...M.type==="group"?{}:{groupIndex:M.groupIndex}}):M.type==="group"?y.createElement(E,{...It(E,u),"data-index":Y,"data-item-index":M.index,"data-known-size":M.size,key:q,style:rv},d(M.index,u)):y.createElement(k,{...It(k,u),...lv(k,M.data),"data-index":Y,"data-item-group-index":M.groupIndex,"data-item-index":M.index,"data-known-size":M.size,key:q,style:w?ov:cu},P?l(M.index,M.groupIndex,M.data,u):l(M.index,M.data,u))})})}),sv={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},iv={outline:"none",overflowX:"auto",position:"relative"},Vo=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),av={position:Hi(),top:0,width:"100%",zIndex:1};function It(e,t){if(typeof e!="string")return{context:t}}function lv(e,t){return{item:typeof e=="string"?void 0:t}}const cv=y.memo(function(){const e=Pe("HeaderComponent"),t=Vt("headerHeight"),n=Pe("HeaderFooterTag"),r=Yn(y.useMemo(()=>s=>{t(On(s,"height"))},[t]),!0,Pe("skipAnimationFrameInResizeObserver")),o=Pe("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...It(e,o)})}):null}),uv=y.memo(function(){const e=Pe("FooterComponent"),t=Vt("footerHeight"),n=Pe("HeaderFooterTag"),r=Yn(y.useMemo(()=>s=>{t(On(s,"height"))},[t]),!0,Pe("skipAnimationFrameInResizeObserver")),o=Pe("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...It(e,o)})}):null});function du({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:x}=au(a,u,l,d,void 0,f);return e("scrollTo",x),e("scrollBy",h),c.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?iv:sv,...o},tabIndex:0,...i,...It(l,s),children:r})})}function fu({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=y.useRef(null),x=t("scrollerRef"),{scrollByCallback:w,scrollerRef:g,scrollToCallback:v}=au(a,u,l,x,h);return iu(()=>{var b;return g.current=h||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",v),e("scrollBy",w),c.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...It(l,s),children:r})})}const dv=({children:e})=>{const t=y.useContext(ou),n=Vt("viewportHeight"),r=Vt("fixedItemHeight"),o=Pe("alignToBottom"),s=Pe("horizontalDirection"),i=y.useMemo(()=>kc(n,l=>On(l,s?"width":"height")),[n,s]),a=Yn(i,!0,Pe("skipAnimationFrameInResizeObserver"));return y.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),c.jsx("div",{"data-viewport-type":"element",ref:a,style:Vo(o),children:e})},fv=({children:e})=>{const t=y.useContext(ou),n=Vt("windowViewportRect"),r=Vt("fixedItemHeight"),o=Pe("customScrollParent"),s=_c(n,o,Pe("skipAnimationFrameInResizeObserver")),i=Pe("alignToBottom");return y.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),c.jsx("div",{"data-viewport-type":"window",ref:s,style:Vo(i),children:e})},hv=({children:e})=>{const t=Pe("TopItemListComponent")||"div",n=Pe("headerHeight"),r={...av,marginTop:`${n}px`},o=Pe("context");return c.jsx(t,{style:r,...It(t,o),children:e})},pv=y.memo(function(e){const t=Pe("useWindowScroll"),n=Pe("topItemsIndexes").length>0,r=Pe("customScrollParent"),o=Pe("context");return c.jsxs(r||t?xv:gv,{...e,context:o,children:[n&&c.jsx(hv,{children:c.jsx(uu,{showTopList:!0})}),c.jsxs(r||t?fv:dv,{children:[c.jsx(cv,{}),c.jsx(uu,{}),c.jsx(uv,{})]})]})}),{Component:mv,useEmitter:Wi,useEmitterValue:Pe,usePublisher:Vt}=ru(tv,{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"}},pv),gv=du({useEmitter:Wi,useEmitterValue:Pe,usePublisher:Vt}),xv=fu({useEmitter:Wi,useEmitterValue:Pe,usePublisher:Vt}),vv=mv;ot(nu,Ye(()=>{const e=X(u=>c.jsxs("td",{children:["Item $",u]})),t=X(null),n=X(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=X(null),o=X(null),s=X({}),i=X(Ui),a=X(wr),l=(u,d=null)=>kt(H(s,le(f=>f[u]),st()),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")}})),Hi();const hu={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},wv={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:pu,floor:qo,max:eo,min:Vi,round:mu}=Math;function gu(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function bv(e){return{...wv,items:e}}function Ko(e,t){return e&&e.width===t.width&&e.height===t.height}function yv(e,t){return e&&e.column===t.column&&e.row===t.row}const Sv=Ye(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},h,p,{didMount:x,propsReady:w},{customScrollParent:g,useWindowScroll:v,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:N},C])=>{const k=X(0),E=X(0),A=X(hu),j=X({height:0,width:0}),P=X({height:0,width:0}),L=Ke(),F=Ke(),V=X(0),M=X(null),Y=X({column:0,row:0}),q=Ke(),W=Ke(),z=X(!1),$=X(0),ue=X(!0),D=X(!1),ee=X(!1);Xe(H(x,$e($),_e(([O,J])=>!!J)),()=>{Le(ue,!1)}),Xe(H(pt(x,ue,P,j,$,D),_e(([O,J,te,G,,se])=>O&&!J&&te.height!==0&&G.height!==0&&!se)),([,,,,O])=>{Le(D,!0),Mi(1,()=>{Le(L,O)}),en(H(u),()=>{Le(t,[0,0]),Le(ue,!0)})}),ge(H(W,_e(O=>O!=null&&O.scrollTop>0),dn(0)),E),Xe(H(x,$e(W),_e(([,O])=>O!=null)),([,O])=>{O&&(Le(j,O.viewport),Le(P,O.item),Le(Y,O.gap),O.scrollTop>0&&(Le(z,!0),en(H(u,Gn(1)),J=>{Le(z,!1)}),Le(l,{top:O.scrollTop})))}),ge(H(j,le(({height:O})=>O)),f),ge(H(pt(Ie(j,Ko),Ie(P,Ko),Ie(Y,(O,J)=>O&&O.column===J.column&&O.row===J.row),Ie(u)),le(([O,J,te,G])=>({gap:te,item:J,scrollTop:G,viewport:O}))),q),ge(H(pt(Ie(k),r,Ie(Y,yv),Ie(P,Ko),Ie(j,Ko),Ie(M),Ie(E),Ie(z),Ie(ue),Ie($)),_e(([,,,,,,,O])=>!O),le(([O,[J,te],G,se,Ve,Je,nt,,De,Be])=>{const{column:Ee,row:Ze}=G,{height:wt,width:ht}=se,{width:Z}=Ve;if(nt===0&&(O===0||Z===0))return hu;if(ht===0){const St=Di(Be,O),Ut=St+Math.max(nt-1,0);return bv(gu(St,Ut,Je))}const re=xu(Z,ht,Ee);let pe,Ne;De?J===0&&te===0&&nt>0?(pe=0,Ne=nt-1):(pe=re*qo((J+Ze)/(wt+Ze)),Ne=re*pu((te+Ze)/(wt+Ze))-1,Ne=Vi(O-1,eo(Ne,re-1)),pe=Vi(Ne,eo(0,pe))):(pe=0,Ne=-1);const we=gu(pe,Ne,Je),{bottom:Ae,top:Qe}=vu(Ve,G,se,we),ze=pu(O/re),lt=ze*wt+(ze-1)*Ze-Ae;return{bottom:Ae,itemHeight:wt,items:we,itemWidth:ht,offsetBottom:lt,offsetTop:Qe,top:Qe}})),A),ge(H(M,_e(O=>O!==null),le(O=>O.length)),k),ge(H(pt(j,P,A,Y),_e(([O,J,{items:te}])=>te.length>0&&J.height!==0&&O.height!==0),le(([O,J,{items:te},G])=>{const{bottom:se,top:Ve}=vu(O,G,J,te);return[Ve,se]}),st(Kr)),t);const fe=X(!1);ge(H(u,$e(fe),le(([O,J])=>J||O!==0)),fe);const ve=Ft(H(pt(A,k),_e(([{items:O}])=>O.length>0),$e(fe),_e(([[O,J],te])=>{const G=O.items[O.items.length-1].index===J-1;return(te||O.bottom>0&&O.itemHeight>0&&O.offsetBottom===0&&O.items.length===J)&&G}),le(([[,O]])=>O-1),st())),be=Ft(H(Ie(A),_e(({items:O})=>O.length>0&&O[0].index===0),dn(0),st())),ye=Ft(H(Ie(A),$e(z),_e(([{items:O},J])=>O.length>0&&!J),le(([{items:O}])=>({endIndex:O[O.length-1].index,startIndex:O[0].index})),st(Lc),kn(0)));ge(ye,p.scrollSeekRangeChanged),ge(H(L,$e(j,P,k,Y),le(([O,J,te,G,se])=>{const Ve=Uc(O),{align:Je,behavior:nt,offset:De}=Ve;let Be=Ve.index;Be==="LAST"&&(Be=G-1),Be=eo(0,Be,Vi(G-1,Be));let Ee=qi(J,se,te,Be);return Je==="end"?Ee=mu(Ee-J.height+te.height):Je==="center"&&(Ee=mu(Ee-J.height/2+te.height/2)),De&&(Ee+=De),{behavior:nt,top:Ee}})),l);const K=kt(H(A,le(O=>O.offsetBottom+O.bottom)),0);return ge(H(N,le(O=>({height:O.visibleHeight,width:O.visibleWidth}))),j),{customScrollParent:g,data:M,deviation:V,footerHeight:o,gap:Y,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:P,overscan:n,restoreStateFrom:W,scrollBy:i,scrollContainerState:a,scrollHeight:F,scrollTo:l,scrollToIndex:L,scrollTop:u,smoothScrollTargetReached:d,totalCount:k,useWindowScroll:v,viewportDimensions:j,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:N,...p,gridState:A,horizontalDirection:ee,initialTopMostItemIndex:$,totalListHeight:K,...h,endReached:ve,propsReady:w,rangeChanged:ye,startReached:be,stateChanged:q,stateRestoreInProgress:z,...C}},ot(Li,_t,Qr,eu,Mn,$i,Pn));function xu(e,t,n){return eo(1,qo((e+n)/(qo(t)+n)))}function vu(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=qi(e,t,n,r[0].index);return{bottom:qi(e,t,n,r[r.length-1].index)+o,top:s}}function qi(e,t,n,r){const o=xu(e.width,n.width,t.column),s=qo(r/o),i=s*n.height+eo(0,s-1)*t.row;return i>0?i+t.row:i}const Cv=Ye(()=>{const e=X(f=>`Item ${f}`),t=X({}),n=X(null),r=X("virtuoso-grid-item"),o=X("virtuoso-grid-list"),s=X(Ui),i=X("div"),a=X(wr),l=(f,h=null)=>kt(H(t,le(p=>p[f]),st()),h),u=X(!1),d=X(!1);return ge(Ie(d),u),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:u,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),Tv=Ye(([e,t])=>({...e,...t}),ot(Sv,Cv)),kv=y.memo(function(){const e=at("gridState"),t=at("listClassName"),n=at("itemClassName"),r=at("itemContent"),o=at("computeItemKey"),s=at("isSeeking"),i=qt("scrollHeight"),a=at("ItemComponent"),l=at("ListComponent"),u=at("ScrollSeekPlaceholder"),d=at("context"),f=qt("itemDimensions"),h=qt("gap"),p=at("log"),x=at("stateRestoreInProgress"),w=qt("reportReadyState"),g=Yn(y.useMemo(()=>v=>{const b=v.parentElement.parentElement.scrollHeight;i(b);const S=v.firstChild;if(S){const{height:N,width:C}=S.getBoundingClientRect();f({height:N,width:C})}h({column:bu("column-gap",getComputedStyle(v).columnGap,p),row:bu("row-gap",getComputedStyle(v).rowGap,p)})},[i,f,h,p]),!0,!1);return iu(()=>{e.itemHeight>0&&e.itemWidth>0&&w(!0)},[e]),x?null:c.jsx(l,{className:t,ref:g,...It(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(v=>{const b=o(v.index,v.data,d);return s?c.jsx(u,{...It(u,d),height:e.itemHeight,index:v.index,width:e.itemWidth},b):y.createElement(a,{...It(a,d),className:n,"data-index":v.index,key:b},r(v.index,v.data,d))})})}),Iv=y.memo(function(){const e=at("HeaderComponent"),t=qt("headerHeight"),n=at("headerFooterTag"),r=Yn(y.useMemo(()=>s=>{t(On(s,"height"))},[t]),!0,!1),o=at("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...It(e,o)})}):null}),Ev=y.memo(function(){const e=at("FooterComponent"),t=qt("footerHeight"),n=at("headerFooterTag"),r=Yn(y.useMemo(()=>s=>{t(On(s,"height"))},[t]),!0,!1),o=at("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...It(e,o)})}):null}),Nv=({children:e})=>{const t=y.useContext(su),n=qt("itemDimensions"),r=qt("viewportDimensions"),o=Yn(y.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return y.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),c.jsx("div",{ref:o,style:Vo(!1),children:e})},Av=({children:e})=>{const t=y.useContext(su),n=qt("windowViewportRect"),r=qt("itemDimensions"),o=at("customScrollParent"),s=_c(n,o,!1);return y.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),c.jsx("div",{ref:s,style:Vo(!1),children:e})},_v=y.memo(function({...e}){const t=at("useWindowScroll"),n=at("customScrollParent"),r=n||t?Rv:jv,o=n||t?Av:Nv,s=at("context");return c.jsx(r,{...e,...It(r,s),children:c.jsxs(o,{children:[c.jsx(Iv,{}),c.jsx(kv,{}),c.jsx(Ev,{})]})})}),{useEmitter:wu,useEmitterValue:at,usePublisher:qt}=ru(Tv,{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"}},_v),jv=du({useEmitter:wu,useEmitterValue:at,usePublisher:qt}),Rv=fu({useEmitter:wu,useEmitterValue:at,usePublisher:qt});function bu(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Mt.WARN),t==="normal"?0:parseInt(t??"0",10)}const Pv=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 Ki({className:e,variant:t,...n}){return c.jsx("div",{className:Q(Pv({variant:t}),e),...n})}function de(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 Ov(e,t){const n=m.createContext(t),r=s=>{const{children:i,...a}=s,l=m.useMemo(()=>a,Object.values(a));return c.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=m.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function pn(e,t=[]){let n=[];function r(s,i){const a=m.createContext(i),l=n.length;n=[...n,i];const u=f=>{var v;const{scope:h,children:p,...x}=f,w=((v=h==null?void 0:h[e])==null?void 0:v[l])||a,g=m.useMemo(()=>x,Object.values(x));return c.jsx(w.Provider,{value:g,children:p})};u.displayName=s+"Provider";function d(f,h){var w;const p=((w=h==null?void 0:h[e])==null?void 0:w[l])||a,x=m.useContext(p);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>m.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Mv(o,...t)]}function Mv(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:u})=>{const f=l(s)[`__scope${u}`];return{...a,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var vt=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},Dv=m[" useInsertionEffect ".trim().toString()]||vt;function Zn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Lv({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=m.useRef(e!==void 0);m.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const u=m.useCallback(d=>{var f;if(a){const h=Fv(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[l,u]}function Lv({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return Dv(()=>{s.current=t},[t]),m.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Fv(e){return typeof e=="function"}function yu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Gi(...e){return t=>{let n=!1;const r=e.map(o=>{const s=yu(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():yu(e[o],null)}}}}function We(...e){return m.useCallback(Gi(...e),e)}var $v=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],je=$v.reduce((e,t)=>{const n=Wn.createSlot(`Primitive.${t}`),r=m.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Su(e,t){e&&vo.flushSync(()=>e.dispatchEvent(t))}function zv(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var zt=e=>{const{present:t,children:n}=e,r=Bv(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=We(r.ref,Hv(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};zt.displayName="Presence";function Bv(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=zv(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=Go(r.current);s.current=a==="mounted"?u:"none"},[a]),vt(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,p=Go(u);e?l("MOUNT"):p==="none"||(u==null?void 0:u.display)==="none"?l("UNMOUNT"):l(d&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),vt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const w=Go(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&w&&(l("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},h=p=>{p.target===t&&(s.current=Go(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function Go(e){return(e==null?void 0:e.animationName)||"none"}function Hv(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 Uv=m[" useId ".trim().toString()]||(()=>{}),Wv=0;function mn(e){const[t,n]=m.useState(Uv());return vt(()=>{n(r=>r??String(Wv++))},[e]),e||(t?`radix-${t}`:"")}var Yo="Collapsible",[Vv,NT]=pn(Yo),[qv,Yi]=Vv(Yo),Cu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,u]=Zn({prop:r,defaultProp:o??!1,onChange:i,caller:Yo});return c.jsx(qv,{scope:n,disabled:s,contentId:mn(),open:l,onOpenToggle:m.useCallback(()=>u(d=>!d),[u]),children:c.jsx(je.div,{"data-state":Ji(l),"data-disabled":s?"":void 0,...a,ref:t})})});Cu.displayName=Yo;var Tu="CollapsibleTrigger",ku=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=Yi(Tu,n);return c.jsx(je.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Ji(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:de(e.onClick,o.onOpenToggle)})});ku.displayName=Tu;var Xi="CollapsibleContent",Kv=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Yi(Xi,e.__scopeCollapsible);return c.jsx(zt,{present:n||o.open,children:({present:s})=>c.jsx(Gv,{...r,ref:t,present:s})})});Kv.displayName=Xi;var Gv=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=Yi(Xi,n),[a,l]=m.useState(r),u=m.useRef(null),d=We(t,u),f=m.useRef(0),h=f.current,p=m.useRef(0),x=p.current,w=i.open||a,g=m.useRef(w),v=m.useRef(void 0);return m.useEffect(()=>{const b=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(b)},[]),vt(()=>{const b=u.current;if(b){v.current=v.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const S=b.getBoundingClientRect();f.current=S.height,p.current=S.width,g.current||(b.style.transitionDuration=v.current.transitionDuration,b.style.animationName=v.current.animationName),l(r)}},[i.open,r]),c.jsx(je.div,{"data-state":Ji(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!w,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":x?`${x}px`:void 0,...e.style},children:w&&o})});function Ji(e){return e?"open":"closed"}var Yv=Cu;const Iu=Yv,Eu=ku,to=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Q("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));to.displayName="Card";const no=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Q("flex flex-col space-y-1.5 p-6",e),...t}));no.displayName="CardHeader";const ro=m.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:Q("text-2xl font-semibold leading-none tracking-tight",e),...t}));ro.displayName="CardTitle";const Nu=m.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:Q("text-sm text-muted-foreground",e),...t}));Nu.displayName="CardDescription";const Xo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Q("p-6 pt-0",e),...t}));Xo.displayName="CardContent";const Au=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Q("flex items-center p-6 pt-0",e),...t}));Au.displayName="CardFooter";function _u(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let Qn=_u();function Xv(e){Qn=e}const ju=/[&<>"']/,Jv=new RegExp(ju.source,"g"),Ru=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Zv=new RegExp(Ru.source,"g"),Qv={"&":"&","<":"<",">":">",'"':""","'":"'"},Pu=e=>Qv[e];function Et(e,t){if(t){if(ju.test(e))return e.replace(Jv,Pu)}else if(Ru.test(e))return e.replace(Zv,Pu);return e}const ew=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Ou(e){return e.replace(ew,(t,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const tw=/(^|[^\[])\^/g;function tt(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(tw,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const nw=/[^\w:]/g,rw=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Mu(e,t,n){if(e){let r;try{r=decodeURIComponent(Ou(n)).replace(nw,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!rw.test(n)&&(n=aw(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Jo={},ow=/^[^:]+:\/*[^/]*$/,sw=/^([^:]+:)[\s\S]*$/,iw=/^([^:]+:\/*[^/]*)[\s\S]*$/;function aw(e,t){Jo[" "+e]||(ow.test(e)?Jo[" "+e]=e+"/":Jo[" "+e]=Qo(e,"/",!0)),e=Jo[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(sw,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(iw,"$1")+t:e+t}const Zo={exec:function(){}};function Du(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,u=i;for(;--u>=0&&a[u]==="\\";)l=!l;return l?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function Qo(e,t,n){const r=e.length;if(r===0)return"";let o=0;for(;o<r;){const s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function lw(e,t){if(e.indexOf(t[1])===-1)return-1;const n=e.length;let r=0,o=0;for(;o<n;o++)if(e[o]==="\\")o++;else if(e[o]===t[0])r++;else if(e[o]===t[1]&&(r--,r<0))return o;return-1}function cw(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function Lu(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Fu(e,t,n,r){const o=t.href,s=t.title?Et(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:Et(i)}}function uw(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
40
40
|
`).map(o=>{const s=o.match(/^\s+/);if(s===null)return o;const[i]=s;return i.length>=r.length?o.slice(r.length):o}).join(`
|
|
41
|
-
`)}class
|
|
42
|
-
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=
|
|
41
|
+
`)}class Zi{constructor(t){this.options=t||Qn}space(t){const n=this.rules.block.newline.exec(t);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(t){const n=this.rules.block.code.exec(t);if(n){const r=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:Qo(r,`
|
|
42
|
+
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=uw(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:o}}}heading(t){const n=this.rules.block.heading.exec(t);if(n){let r=n[2].trim();if(/#$/.test(r)){const o=Qo(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,l,u,d,f,h,p,x,w=n[1].trim();const g=w.length>1,v={type:"list",raw:"",ordered:g,start:g?+w.slice(0,-1):"",loose:!1,items:[]};w=g?`\\d{1,9}\\${w.slice(-1)}`:`\\${w}`,this.options.pedantic&&(w=g?w:"[*+-]");const b=new RegExp(`^( {0,3}${w})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(x=!1,!(!(n=b.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
|
|
43
43
|
`,1)[0].replace(/^\t+/,N=>" ".repeat(3*N.length)),f=t.split(`
|
|
44
44
|
`,1)[0],this.options.pedantic?(i=2,p=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,p=d.slice(i),i+=n[1].length),l=!1,!d&&/^ *$/.test(f)&&(r+=f+`
|
|
45
|
-
`,t=t.substring(f.length+1),
|
|
45
|
+
`,t=t.substring(f.length+1),x=!0),!x){const N=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),C=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),E=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(h=t.split(`
|
|
46
46
|
`,1)[0],f=h,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(k.test(f)||E.test(f)||N.test(f)||C.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())p+=`
|
|
47
47
|
`+f.slice(i);else{if(l||d.search(/[^ ]/)>=4||k.test(d)||E.test(d)||C.test(d))break;p+=`
|
|
48
48
|
`+f}!l&&!f.trim()&&(l=!0),r+=h+`
|
|
49
|
-
`,t=t.substring(h.length+1),d=f.slice(i)}}
|
|
50
|
-
`):[]};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]=
|
|
51
|
-
`?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:Et(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]):Et(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=
|
|
52
|
-
]`).replace("lheading",Se.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ce={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:
|
|
49
|
+
`,t=t.substring(h.length+1),d=f.slice(i)}}v.loose||(u?v.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),v.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),v.raw+=r}v.items[v.items.length-1].raw=r.trimRight(),v.items[v.items.length-1].text=p.trimRight(),v.raw=v.raw.trimRight();const S=v.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,v.items[a].tokens=this.lexer.blockTokens(v.items[a].text,[]),!v.loose){const N=v.items[a].tokens.filter(k=>k.type==="space"),C=N.length>0&&N.some(k=>/\n.*\n/.test(k.raw));v.loose=C}if(v.loose)for(a=0;a<S;a++)v.items[a].loose=!0;return v}}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]):Et(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:Du(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
|
|
50
|
+
`):[]};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]=Du(r.rows[s],r.header.length).map(u=>({text:u}));for(o=r.header.length,i=0;i<o;i++)r.header[i].tokens=this.lexer.inline(r.header[i].text);for(o=r.rows.length,i=0;i<o;i++)for(l=r.rows[i],a=0;a<l.length;a++)l[a].tokens=this.lexer.inline(l[a].text);return r}}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const r=n[1].charAt(n[1].length-1)===`
|
|
51
|
+
`?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:Et(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]):Et(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=Qo(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=lw(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)),Fu(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 Fu(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,l,u=i,d=0;const f=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*t.length+i);(o=f.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(l=a.length,o[3]||o[4]){u+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(u-=l,u>0)continue;l=Math.min(l,l+u+d);const h=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const x=h.slice(1,-1);return{type:"em",raw:h,text:x,tokens:this.lexer.inlineTokens(x)}}const p=h.slice(2,-2);return{type:"strong",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=Et(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=Et(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Et(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=Et(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=Et(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]):Et(r[0]):r[0]:o=Et(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const Se={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:Zo,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Se._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Se._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,Se.def=tt(Se.def).replace("label",Se._label).replace("title",Se._title).getRegex(),Se.bullet=/(?:[*+-]|\d{1,9}[.)])/,Se.listItemStart=tt(/^( *)(bull) */).replace("bull",Se.bullet).getRegex(),Se.list=tt(Se.list).replace(/bull/g,Se.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Se.def.source+")").getRegex(),Se._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Se._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,Se.html=tt(Se.html,"i").replace("comment",Se._comment).replace("tag",Se._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Se.paragraph=tt(Se._paragraph).replace("hr",Se.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Se._tag).getRegex(),Se.blockquote=tt(Se.blockquote).replace("paragraph",Se.paragraph).getRegex(),Se.normal={...Se},Se.gfm={...Se.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},Se.gfm.table=tt(Se.gfm.table).replace("hr",Se.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Se._tag).getRegex(),Se.gfm.paragraph=tt(Se._paragraph).replace("hr",Se.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Se.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Se._tag).getRegex(),Se.pedantic={...Se.normal,html:tt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Se._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Zo,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:tt(Se.normal._paragraph).replace("hr",Se.hr).replace("heading",` *#{1,6} *[^
|
|
52
|
+
]`).replace("lheading",Se.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ce={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Zo,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:Zo,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};ce._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",ce.punctuation=tt(ce.punctuation).replace(/punctuation/g,ce._punctuation).getRegex(),ce.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,ce.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,ce._comment=tt(Se._comment).replace("(?:-->|$)","-->").getRegex(),ce.emStrong.lDelim=tt(ce.emStrong.lDelim).replace(/punct/g,ce._punctuation).getRegex(),ce.emStrong.rDelimAst=tt(ce.emStrong.rDelimAst,"g").replace(/punct/g,ce._punctuation).getRegex(),ce.emStrong.rDelimUnd=tt(ce.emStrong.rDelimUnd,"g").replace(/punct/g,ce._punctuation).getRegex(),ce._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,ce._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,ce._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])?)+(?![-_])/,ce.autolink=tt(ce.autolink).replace("scheme",ce._scheme).replace("email",ce._email).getRegex(),ce._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,ce.tag=tt(ce.tag).replace("comment",ce._comment).replace("attribute",ce._attribute).getRegex(),ce._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ce._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,ce._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ce.link=tt(ce.link).replace("label",ce._label).replace("href",ce._href).replace("title",ce._title).getRegex(),ce.reflink=tt(ce.reflink).replace("label",ce._label).replace("ref",Se._label).getRegex(),ce.nolink=tt(ce.nolink).replace("ref",Se._label).getRegex(),ce.reflinkSearch=tt(ce.reflinkSearch,"g").replace("reflink",ce.reflink).replace("nolink",ce.nolink).getRegex(),ce.normal={...ce},ce.pedantic={...ce.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:tt(/^!?\[(label)\]\((.*?)\)/).replace("label",ce._label).getRegex(),reflink:tt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ce._label).getRegex()},ce.gfm={...ce.normal,escape:tt(ce.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},ce.gfm.url=tt(ce.gfm.url,"i").replace("email",ce.gfm._extended_email).getRegex(),ce.breaks={...ce.gfm,br:tt(ce.br).replace("{2,}","*").getRegex(),text:tt(ce.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function dw(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 $u(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 Dn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Qn,this.options.tokenizer=this.options.tokenizer||new Zi,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:Se.normal,inline:ce.normal};this.options.pedantic?(n.block=Se.pedantic,n.inline=ce.pedantic):this.options.gfm&&(n.block=Se.gfm,this.options.breaks?n.inline=ce.breaks:n.inline=ce.gfm),this.tokenizer.rules=n}static get rules(){return{block:Se,inline:ce}}static lex(t,n){return new Dn(n).lex(t)}static lexInline(t,n){return new Dn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
|
|
53
53
|
`),this.blockTokens(t,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(t,n=[]){this.options.pedantic?t=t.replace(/\t/g," ").replace(/^ +$/gm,""):t=t.replace(/^( *)(\t+)/gm,(a,l,u)=>l+" ".repeat(u.length));let r,o,s,i;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(r=a.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=`
|
|
54
54
|
`: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+=`
|
|
55
55
|
`+r.raw,o.text+=`
|
|
@@ -59,7 +59,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
59
59
|
`+r.raw,o.text+=`
|
|
60
60
|
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r),i=s.length!==t.length,t=t.substring(r.raw.length);continue}if(r=this.tokenizer.text(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&o.type==="text"?(o.raw+=`
|
|
61
61
|
`+r.raw,o.text+=`
|
|
62
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,l,u;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+
|
|
62
|
+
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,l,u;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+Lu("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)i=i.slice(0,a.index)+"["+Lu("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.escapedEmSt.exec(i))!=null;)i=i.slice(0,a.index+a[0].length-2)+"++"+i.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;t;)if(l||(u=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(t,i,u)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(t,$u)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,$u))){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const f=t.slice(1);let h;this.options.extensions.startInline.forEach(function(p){h=p.call({lexer:this},f),typeof h=="number"&&h>=0&&(d=Math.min(d,h))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,dw)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(u=r.raw.slice(-1)),l=!0,o=n[n.length-1],o&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(t){const d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return n}}class Qi{constructor(t){this.options=t||Qn}code(t,n,r){const o=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(t,o);s!=null&&s!==t&&(r=!0,t=s)}return t=t.replace(/\n$/,"")+`
|
|
63
63
|
`,o?'<pre><code class="'+this.options.langPrefix+Et(o)+'">'+(r?t:Et(t,!0))+`</code></pre>
|
|
64
64
|
`:"<pre><code>"+(r?t:Et(t,!0))+`</code></pre>
|
|
65
65
|
`}blockquote(t){return`<blockquote>
|
|
@@ -79,14 +79,14 @@ ${t}</blockquote>
|
|
|
79
79
|
`}tablerow(t){return`<tr>
|
|
80
80
|
${t}</tr>
|
|
81
81
|
`}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
|
|
82
|
-
`}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=
|
|
83
|
-
`+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const A='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class
|
|
84
|
-
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Et(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function Lu(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...Ce.defaults,...s};const i=Qv(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(Xv(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(f){return i(f)}const u=function(f){let h;if(!f)try{r.walkTokens&&Ce.walkTokens(l,r.walkTokens),h=t(l,r),r.hooks&&(h=r.hooks.postprocess(h))}catch(p){f=p}return r.highlight=a,f?i(f):o(null,h)};if(!a||a.length<3||(delete r.highlight,!l.length))return u();let d=0;Ce.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(h,p){if(h)return u(h);p!=null&&p!==f.text&&(f.text=p,f.escaped=!0),d--,d===0&&u()})},0))}),d===0&&u();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(Ce.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&Ce.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function Ce(e,t,n){return Lu(Mn.lex,Dn.parse)(e,t,n)}Ce.options=Ce.setOptions=function(e){return Ce.defaults={...Ce.defaults,...e},Lv(Ce.defaults),Ce},Ce.getDefaults=ku,Ce.defaults=Zn,Ce.use=function(...e){const t=Ce.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=Ce.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=Ce.defaults.renderer||new Ji;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=Ce.defaults.tokenizer||new Xi;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=Ce.defaults.hooks||new Zo;for(const s in n.hooks){const i=o[s];Zo.passThroughHooks.has(s)?o[s]=a=>{if(Ce.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(u=>i.call(o,u));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=Ce.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}Ce.setOptions(r)})},Ce.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(Ce,r)),r.type){case"table":{for(const o of r.header)n=n.concat(Ce.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(Ce.walkTokens(s.tokens,t));break}case"list":{n=n.concat(Ce.walkTokens(r.items,t));break}default:Ce.defaults.extensions&&Ce.defaults.extensions.childTokens&&Ce.defaults.extensions.childTokens[r.type]?Ce.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(Ce.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(Ce.walkTokens(r.tokens,t)))}return n},Ce.parseInline=Lu(Mn.lexInline,Dn.parseInline),Ce.Parser=Dn,Ce.parser=Dn.parse,Ce.Renderer=Ji,Ce.TextRenderer=Mu,Ce.Lexer=Mn,Ce.lexer=Mn.lex,Ce.Tokenizer=Xi,Ce.Slugger=Du,Ce.Hooks=Zo,Ce.parse=Ce,Ce.options,Ce.setOptions,Ce.use,Ce.walkTokens,Ce.parseInline,Dn.parse,Mn.lex;function Zi({content:e,className:t="",allowHtml:n=!1,style:r}){const o=y.useMemo(()=>{try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return Ce.parse(i)}return Ce.parse(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre>Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=y.useMemo(()=>{if(r&&r.color){const i=r.color;return{...r,"--tw-prose-body":i,"--tw-prose-headings":i,"--tw-prose-links":i,"--tw-prose-bold":i,"--tw-prose-counters":i,"--tw-prose-bullets":i,"--tw-prose-hr":i,"--tw-prose-quotes":i,"--tw-prose-quote-borders":i,"--tw-prose-captions":i,"--tw-prose-code":i,"--tw-prose-pre-code":i,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":i,"--tw-prose-td-borders":i}}return r},[r]);return c.jsx("div",{className:Q("markdown prose max-w-none break-words dark:prose-invert",t),style:s,dangerouslySetInnerHTML:{__html:o}})}async function Fu(e,t){return await Mt(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function $u(e,t){return await(await Fu(`/files/${e}/view`,t)).text()}async function ew(e,t){const n=await Fu(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Mt(`/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 tw(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Mt("/files",{params:r})}const nw=1,rw=1e6;let Qi=0;function ow(){return Qi=(Qi+1)%Number.MAX_SAFE_INTEGER,Qi.toString()}const ea=new Map,zu=e=>{if(ea.has(e))return;const t=setTimeout(()=>{ea.delete(e),no({type:"REMOVE_TOAST",toastId:e})},rw);ea.set(e,t)},sw=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,nw)};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?zu(n):e.toasts.forEach(r=>{zu(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)}}},Qo=[];let es={toasts:[]};function no(e){es=sw(es,e),Qo.forEach(t=>{t(es)})}function iw({...e}){const t=ow(),n=o=>no({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>no({type:"DISMISS_TOAST",toastId:t});return no({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function ta(){const[e,t]=m.useState(es);return m.useEffect(()=>(Qo.push(t),()=>{const n=Qo.indexOf(t);n>-1&&Qo.splice(n,1)}),[e]),{...e,toast:iw,dismiss:n=>no({type:"DISMISS_TOAST",toastId:n})}}function yt(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function aw(e,t=globalThis==null?void 0:globalThis.document){const n=yt(e);m.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var lw="DismissableLayer",na="dismissableLayer.update",cw="dismissableLayer.pointerDownOutside",uw="dismissableLayer.focusOutside",Bu,Hu=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ts=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=m.useContext(Hu),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),v=We(t,E=>f(E)),w=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=w.indexOf(g),b=d?w.indexOf(d):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,N=b>=x,C=hw(E=>{const A=E.target,j=[...u.branches].some(P=>P.contains(A));!N||j||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},h),k=pw(E=>{const A=E.target;[...u.branches].some(P=>P.contains(A))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},h);return aw(E=>{b===u.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},h),m.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Bu=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),Uu(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Bu)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),Uu())},[d,u]),m.useEffect(()=>{const E=()=>p({});return document.addEventListener(na,E),()=>document.removeEventListener(na,E)},[]),c.jsx(_e.div,{...l,ref:v,style:{pointerEvents:S?N?"auto":"none":void 0,...e.style},onFocusCapture:de(e.onFocusCapture,k.onFocusCapture),onBlurCapture:de(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:de(e.onPointerDownCapture,C.onPointerDownCapture)})});ts.displayName=lw;var dw="DismissableLayerBranch",fw=m.forwardRef((e,t)=>{const n=m.useContext(Hu),r=m.useRef(null),o=We(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(_e.div,{...e,ref:o})});fw.displayName=dw;function hw(e,t=globalThis==null?void 0:globalThis.document){const n=yt(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Wu(cw,n,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function pw(e,t=globalThis==null?void 0:globalThis.document){const n=yt(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&Wu(uw,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 Uu(){const e=new CustomEvent(na);document.dispatchEvent(e)}function Wu(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?xu(o,s):o.dispatchEvent(s)}var ra="focusScope.autoFocusOnMount",oa="focusScope.autoFocusOnUnmount",Vu={bubbles:!1,cancelable:!0},mw="FocusScope",ns=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=m.useState(null),u=yt(o),d=yt(s),f=m.useRef(null),h=We(t,w=>l(w)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let w=function(S){if(p.paused||!a)return;const N=S.target;a.contains(N)?f.current=N:Ln(f.current,{select:!0})},g=function(S){if(p.paused||!a)return;const N=S.relatedTarget;N!==null&&(a.contains(N)||Ln(f.current,{select:!0}))},x=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Ln(a)};document.addEventListener("focusin",w),document.addEventListener("focusout",g);const b=new MutationObserver(x);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",g),b.disconnect()}}},[r,a,p.paused]),m.useEffect(()=>{if(a){Gu.add(p);const w=document.activeElement;if(!a.contains(w)){const x=new CustomEvent(ra,Vu);a.addEventListener(ra,u),a.dispatchEvent(x),x.defaultPrevented||(gw(yw(qu(a)),{select:!0}),document.activeElement===w&&Ln(a))}return()=>{a.removeEventListener(ra,u),setTimeout(()=>{const x=new CustomEvent(oa,Vu);a.addEventListener(oa,d),a.dispatchEvent(x),x.defaultPrevented||Ln(w??document.body,{select:!0}),a.removeEventListener(oa,d),Gu.remove(p)},0)}}},[a,u,d,p]);const v=m.useCallback(w=>{if(!n&&!r||p.paused)return;const g=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,x=document.activeElement;if(g&&x){const b=w.currentTarget,[S,N]=xw(b);S&&N?!w.shiftKey&&x===N?(w.preventDefault(),n&&Ln(S,{select:!0})):w.shiftKey&&x===S&&(w.preventDefault(),n&&Ln(N,{select:!0})):x===b&&w.preventDefault()}},[n,r,p.paused]);return c.jsx(_e.div,{tabIndex:-1,...i,ref:h,onKeyDown:v})});ns.displayName=mw;function gw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ln(r,{select:t}),document.activeElement!==n)return}function xw(e){const t=qu(e),n=Ku(t,e),r=Ku(t.reverse(),e);return[n,r]}function qu(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 Ku(e,t){for(const n of e)if(!vw(n,{upTo:t}))return n}function vw(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function ww(e){return e instanceof HTMLInputElement&&"select"in e}function Ln(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&ww(e)&&t&&e.select()}}var Gu=bw();function bw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Yu(e,t),e.unshift(t)},remove(t){var n;e=Yu(e,t),(n=e[0])==null||n.resume()}}}function Yu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function yw(e){return e.filter(t=>t.tagName!=="A")}var Sw="Portal",rs=m.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=m.useState(!1);vt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Xs.createPortal(c.jsx(_e.div,{...r,ref:t}),i):null});rs.displayName=Sw;var sa=0;function ia(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Xu()),document.body.insertAdjacentElement("beforeend",e[1]??Xu()),sa++,()=>{sa===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),sa--}},[])}function Xu(){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 pn=function(){return pn=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},pn.apply(this,arguments)};function Ju(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 Cw(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 os="right-scroll-bar-position",ss="width-before-scroll-bar",Tw="with-scroll-bars-hidden",kw="--removed-body-scroll-bar-size";function aa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Iw(e,t){var n=y.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Ew=typeof window<"u"?m.useLayoutEffect:m.useEffect,Zu=new WeakMap;function Nw(e,t){var n=Iw(null,function(r){return e.forEach(function(o){return aa(o,r)})});return Ew(function(){var r=Zu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||aa(a,null)}),s.forEach(function(a){o.has(a)||aa(a,i)})}Zu.set(n,e)},[e]),n}function Aw(e){return e}function jw(e,t){t===void 0&&(t=Aw);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},u=function(){return Promise.resolve().then(l)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return o}function _w(e){e===void 0&&(e={});var t=jw(null);return t.options=pn({async:!0,ssr:!1},e),t}var Qu=function(e){var t=e.sideCar,n=Ju(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return m.createElement(r,pn({},n))};Qu.isSideCarExport=!0;function Rw(e,t){return e.useMedium(t),Qu}var ed=_w(),la=function(){},is=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:la,onWheelCapture:la,onTouchMoveCapture:la}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,p=e.noRelative,v=e.noIsolation,w=e.inert,g=e.allowPinchZoom,x=e.as,b=x===void 0?"div":x,S=e.gapMode,N=Ju(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,k=Nw([n,t]),E=pn(pn({},N),o);return m.createElement(m.Fragment,null,d&&m.createElement(C,{sideCar:ed,removeScrollBar:u,shards:f,noRelative:p,noIsolation:v,inert:w,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:S}),i?m.cloneElement(m.Children.only(a),pn(pn({},E),{ref:k})):m.createElement(b,pn({},E,{className:l,ref:k}),a))});is.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},is.classNames={fullWidth:ss,zeroRight:os};var Pw=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Ow(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Pw();return t&&e.setAttribute("nonce",t),e}function Mw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Dw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Lw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Ow())&&(Mw(t,n),Dw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Fw=function(){var e=Lw();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},td=function(){var e=Fw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},$w={left:0,top:0,right:0,gap:0},ca=function(e){return parseInt(e||"",10)||0},zw=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[ca(n),ca(r),ca(o)]},Bw=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return $w;var t=zw(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Hw=td(),br="data-scroll-locked",Uw=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
85
|
-
.`.concat(
|
|
82
|
+
`}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=Mu(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=Mu(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 zu{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 Bu{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 Ln{constructor(t){this.options=t||Qn,this.options.renderer=this.options.renderer||new Qi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new zu,this.slugger=new Bu}static parse(t,n){return new Ln(n).parse(t)}static parseInline(t,n){return new Ln(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,u,d,f,h,p,x,w,g,v,b,S,N,C,k;const E=t.length;for(o=0;o<E;o++){if(p=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[p.type]&&(k=this.options.extensions.renderers[p.type].call({parser:this},p),k!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type))){r+=k||"";continue}switch(p.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(p.tokens),p.depth,Ou(this.parseInline(p.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(p.text,p.lang,p.escaped);continue}case"table":{for(f="",d="",a=p.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(p.header[s].tokens),{header:!0,align:p.align[s]});for(f+=this.renderer.tablerow(d),h="",a=p.rows.length,s=0;s<a;s++){for(u=p.rows[s],d="",l=u.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(u[i].tokens),{header:!1,align:p.align[i]});h+=this.renderer.tablerow(d)}r+=this.renderer.table(f,h);continue}case"blockquote":{h=this.parse(p.tokens),r+=this.renderer.blockquote(h);continue}case"list":{for(x=p.ordered,w=p.start,g=p.loose,a=p.items.length,h="",s=0;s<a;s++)b=p.items[s],S=b.checked,N=b.task,v="",b.task&&(C=this.renderer.checkbox(S),g?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=C+" "+b.tokens[0].text,b.tokens[0].tokens&&b.tokens[0].tokens.length>0&&b.tokens[0].tokens[0].type==="text"&&(b.tokens[0].tokens[0].text=C+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:C}):v+=C),v+=this.parse(b.tokens,g),h+=this.renderer.listitem(v,N,S);r+=this.renderer.list(h,x,w);continue}case"html":{r+=this.renderer.html(p.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(p.tokens));continue}case"text":{for(h=p.tokens?this.parseInline(p.tokens):p.text;o+1<E&&t[o+1].type==="text";)p=t[++o],h+=`
|
|
83
|
+
`+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const A='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class es{constructor(t){this.options=t||Qn}preprocess(t){return t}postprocess(t){return t}}tm(es,"passThroughHooks",new Set(["preprocess","postprocess"]));function fw(e,t,n){return r=>{if(r.message+=`
|
|
84
|
+
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Et(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 Hu(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...Ce.defaults,...s};const i=fw(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(cw(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(f){return i(f)}const u=function(f){let h;if(!f)try{r.walkTokens&&Ce.walkTokens(l,r.walkTokens),h=t(l,r),r.hooks&&(h=r.hooks.postprocess(h))}catch(p){f=p}return r.highlight=a,f?i(f):o(null,h)};if(!a||a.length<3||(delete r.highlight,!l.length))return u();let d=0;Ce.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(h,p){if(h)return u(h);p!=null&&p!==f.text&&(f.text=p,f.escaped=!0),d--,d===0&&u()})},0))}),d===0&&u();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(Ce.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&Ce.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function Ce(e,t,n){return Hu(Dn.lex,Ln.parse)(e,t,n)}Ce.options=Ce.setOptions=function(e){return Ce.defaults={...Ce.defaults,...e},Xv(Ce.defaults),Ce},Ce.getDefaults=_u,Ce.defaults=Qn,Ce.use=function(...e){const t=Ce.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=Ce.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=Ce.defaults.renderer||new Qi;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=Ce.defaults.tokenizer||new Zi;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=Ce.defaults.hooks||new es;for(const s in n.hooks){const i=o[s];es.passThroughHooks.has(s)?o[s]=a=>{if(Ce.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(u=>i.call(o,u));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=Ce.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}Ce.setOptions(r)})},Ce.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(Ce,r)),r.type){case"table":{for(const o of r.header)n=n.concat(Ce.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(Ce.walkTokens(s.tokens,t));break}case"list":{n=n.concat(Ce.walkTokens(r.items,t));break}default:Ce.defaults.extensions&&Ce.defaults.extensions.childTokens&&Ce.defaults.extensions.childTokens[r.type]?Ce.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(Ce.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(Ce.walkTokens(r.tokens,t)))}return n},Ce.parseInline=Hu(Dn.lexInline,Ln.parseInline),Ce.Parser=Ln,Ce.parser=Ln.parse,Ce.Renderer=Qi,Ce.TextRenderer=zu,Ce.Lexer=Dn,Ce.lexer=Dn.lex,Ce.Tokenizer=Zi,Ce.Slugger=Bu,Ce.Hooks=es,Ce.parse=Ce,Ce.options,Ce.setOptions,Ce.use,Ce.walkTokens,Ce.parseInline,Ln.parse,Dn.lex;function ea({content:e,className:t="",allowHtml:n=!1,style:r}){const o=y.useMemo(()=>{try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return Ce.parse(i)}return Ce.parse(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre>Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=y.useMemo(()=>{if(r&&r.color){const i=r.color;return{...r,"--tw-prose-body":i,"--tw-prose-headings":i,"--tw-prose-links":i,"--tw-prose-bold":i,"--tw-prose-counters":i,"--tw-prose-bullets":i,"--tw-prose-hr":i,"--tw-prose-quotes":i,"--tw-prose-quote-borders":i,"--tw-prose-captions":i,"--tw-prose-code":i,"--tw-prose-pre-code":i,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":i,"--tw-prose-td-borders":i}}return r},[r]);return c.jsx("div",{className:Q("markdown prose max-w-none break-words dark:prose-invert",t),style:s,dangerouslySetInnerHTML:{__html:o}})}async function Uu(e,t){return await Dt(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function Wu(e,t){return await(await Uu(`/files/${e}/view`,t)).text()}async function hw(e,t){const n=await Uu(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Dt(`/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 pw(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Dt("/files",{params:r})}const mw=1,gw=1e6;let ta=0;function xw(){return ta=(ta+1)%Number.MAX_SAFE_INTEGER,ta.toString()}const na=new Map,Vu=e=>{if(na.has(e))return;const t=setTimeout(()=>{na.delete(e),oo({type:"REMOVE_TOAST",toastId:e})},gw);na.set(e,t)},vw=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,mw)};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?Vu(n):e.toasts.forEach(r=>{Vu(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)}}},ts=[];let ns={toasts:[]};function oo(e){ns=vw(ns,e),ts.forEach(t=>{t(ns)})}function ww({...e}){const t=xw(),n=o=>oo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>oo({type:"DISMISS_TOAST",toastId:t});return oo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function ra(){const[e,t]=m.useState(ns);return m.useEffect(()=>(ts.push(t),()=>{const n=ts.indexOf(t);n>-1&&ts.splice(n,1)}),[e]),{...e,toast:ww,dismiss:n=>oo({type:"DISMISS_TOAST",toastId:n})}}function yt(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function bw(e,t=globalThis==null?void 0:globalThis.document){const n=yt(e);m.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var yw="DismissableLayer",oa="dismissableLayer.update",Sw="dismissableLayer.pointerDownOutside",Cw="dismissableLayer.focusOutside",qu,Ku=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),rs=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=m.useContext(Ku),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),x=We(t,E=>f(E)),w=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=w.indexOf(g),b=d?w.indexOf(d):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,N=b>=v,C=Iw(E=>{const A=E.target,j=[...u.branches].some(P=>P.contains(A));!N||j||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},h),k=Ew(E=>{const A=E.target;[...u.branches].some(P=>P.contains(A))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},h);return bw(E=>{b===u.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},h),m.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(qu=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),Gu(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=qu)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),Gu())},[d,u]),m.useEffect(()=>{const E=()=>p({});return document.addEventListener(oa,E),()=>document.removeEventListener(oa,E)},[]),c.jsx(je.div,{...l,ref:x,style:{pointerEvents:S?N?"auto":"none":void 0,...e.style},onFocusCapture:de(e.onFocusCapture,k.onFocusCapture),onBlurCapture:de(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:de(e.onPointerDownCapture,C.onPointerDownCapture)})});rs.displayName=yw;var Tw="DismissableLayerBranch",kw=m.forwardRef((e,t)=>{const n=m.useContext(Ku),r=m.useRef(null),o=We(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(je.div,{...e,ref:o})});kw.displayName=Tw;function Iw(e,t=globalThis==null?void 0:globalThis.document){const n=yt(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Yu(Sw,n,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Ew(e,t=globalThis==null?void 0:globalThis.document){const n=yt(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&Yu(Cw,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 Gu(){const e=new CustomEvent(oa);document.dispatchEvent(e)}function Yu(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?Su(o,s):o.dispatchEvent(s)}var sa="focusScope.autoFocusOnMount",ia="focusScope.autoFocusOnUnmount",Xu={bubbles:!1,cancelable:!0},Nw="FocusScope",os=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=m.useState(null),u=yt(o),d=yt(s),f=m.useRef(null),h=We(t,w=>l(w)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let w=function(S){if(p.paused||!a)return;const N=S.target;a.contains(N)?f.current=N:Fn(f.current,{select:!0})},g=function(S){if(p.paused||!a)return;const N=S.relatedTarget;N!==null&&(a.contains(N)||Fn(f.current,{select:!0}))},v=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Fn(a)};document.addEventListener("focusin",w),document.addEventListener("focusout",g);const b=new MutationObserver(v);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",g),b.disconnect()}}},[r,a,p.paused]),m.useEffect(()=>{if(a){Qu.add(p);const w=document.activeElement;if(!a.contains(w)){const v=new CustomEvent(sa,Xu);a.addEventListener(sa,u),a.dispatchEvent(v),v.defaultPrevented||(Aw(Ow(Ju(a)),{select:!0}),document.activeElement===w&&Fn(a))}return()=>{a.removeEventListener(sa,u),setTimeout(()=>{const v=new CustomEvent(ia,Xu);a.addEventListener(ia,d),a.dispatchEvent(v),v.defaultPrevented||Fn(w??document.body,{select:!0}),a.removeEventListener(ia,d),Qu.remove(p)},0)}}},[a,u,d,p]);const x=m.useCallback(w=>{if(!n&&!r||p.paused)return;const g=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,v=document.activeElement;if(g&&v){const b=w.currentTarget,[S,N]=_w(b);S&&N?!w.shiftKey&&v===N?(w.preventDefault(),n&&Fn(S,{select:!0})):w.shiftKey&&v===S&&(w.preventDefault(),n&&Fn(N,{select:!0})):v===b&&w.preventDefault()}},[n,r,p.paused]);return c.jsx(je.div,{tabIndex:-1,...i,ref:h,onKeyDown:x})});os.displayName=Nw;function Aw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Fn(r,{select:t}),document.activeElement!==n)return}function _w(e){const t=Ju(e),n=Zu(t,e),r=Zu(t.reverse(),e);return[n,r]}function Ju(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 Zu(e,t){for(const n of e)if(!jw(n,{upTo:t}))return n}function jw(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 Rw(e){return e instanceof HTMLInputElement&&"select"in e}function Fn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Rw(e)&&t&&e.select()}}var Qu=Pw();function Pw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=ed(e,t),e.unshift(t)},remove(t){var n;e=ed(e,t),(n=e[0])==null||n.resume()}}}function ed(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Ow(e){return e.filter(t=>t.tagName!=="A")}var Mw="Portal",ss=m.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=m.useState(!1);vt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Zs.createPortal(c.jsx(je.div,{...r,ref:t}),i):null});ss.displayName=Mw;var aa=0;function la(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??td()),document.body.insertAdjacentElement("beforeend",e[1]??td()),aa++,()=>{aa===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),aa--}},[])}function td(){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 gn=function(){return gn=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},gn.apply(this,arguments)};function nd(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 Dw(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 is="right-scroll-bar-position",as="width-before-scroll-bar",Lw="with-scroll-bars-hidden",Fw="--removed-body-scroll-bar-size";function ca(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function $w(e,t){var n=y.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var zw=typeof window<"u"?m.useLayoutEffect:m.useEffect,rd=new WeakMap;function Bw(e,t){var n=$w(null,function(r){return e.forEach(function(o){return ca(o,r)})});return zw(function(){var r=rd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||ca(a,null)}),s.forEach(function(a){o.has(a)||ca(a,i)})}rd.set(n,e)},[e]),n}function Hw(e){return e}function Uw(e,t){t===void 0&&(t=Hw);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},u=function(){return Promise.resolve().then(l)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return o}function Ww(e){e===void 0&&(e={});var t=Uw(null);return t.options=gn({async:!0,ssr:!1},e),t}var od=function(e){var t=e.sideCar,n=nd(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return m.createElement(r,gn({},n))};od.isSideCarExport=!0;function Vw(e,t){return e.useMedium(t),od}var sd=Ww(),ua=function(){},ls=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:ua,onWheelCapture:ua,onTouchMoveCapture:ua}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,p=e.noRelative,x=e.noIsolation,w=e.inert,g=e.allowPinchZoom,v=e.as,b=v===void 0?"div":v,S=e.gapMode,N=nd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,k=Bw([n,t]),E=gn(gn({},N),o);return m.createElement(m.Fragment,null,d&&m.createElement(C,{sideCar:sd,removeScrollBar:u,shards:f,noRelative:p,noIsolation:x,inert:w,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:S}),i?m.cloneElement(m.Children.only(a),gn(gn({},E),{ref:k})):m.createElement(b,gn({},E,{className:l,ref:k}),a))});ls.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ls.classNames={fullWidth:as,zeroRight:is};var qw=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Kw(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=qw();return t&&e.setAttribute("nonce",t),e}function Gw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Yw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Xw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Kw())&&(Gw(t,n),Yw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Jw=function(){var e=Xw();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},id=function(){var e=Jw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Zw={left:0,top:0,right:0,gap:0},da=function(e){return parseInt(e||"",10)||0},Qw=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[da(n),da(r),da(o)]},eb=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Zw;var t=Qw(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])}},tb=id(),yr="data-scroll-locked",nb=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
85
|
+
.`.concat(Lw,` {
|
|
86
86
|
overflow: hidden `).concat(r,`;
|
|
87
87
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
88
88
|
}
|
|
89
|
-
body[`).concat(
|
|
89
|
+
body[`).concat(yr,`] {
|
|
90
90
|
overflow: hidden `).concat(r,`;
|
|
91
91
|
overscroll-behavior: contain;
|
|
92
92
|
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
@@ -99,37 +99,37 @@ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An err
|
|
|
99
99
|
`),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
.`).concat(
|
|
102
|
+
.`).concat(is,` {
|
|
103
103
|
right: `).concat(a,"px ").concat(r,`;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
.`).concat(
|
|
106
|
+
.`).concat(as,` {
|
|
107
107
|
margin-right: `).concat(a,"px ").concat(r,`;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
.`).concat(
|
|
110
|
+
.`).concat(is," .").concat(is,` {
|
|
111
111
|
right: 0 `).concat(r,`;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
.`).concat(
|
|
114
|
+
.`).concat(as," .").concat(as,` {
|
|
115
115
|
margin-right: 0 `).concat(r,`;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
body[`).concat(
|
|
119
|
-
`).concat(
|
|
118
|
+
body[`).concat(yr,`] {
|
|
119
|
+
`).concat(Fw,": ").concat(a,`px;
|
|
120
120
|
}
|
|
121
|
-
`)},
|
|
121
|
+
`)},ad=function(){var e=parseInt(document.body.getAttribute(yr)||"0",10);return isFinite(e)?e:0},rb=function(){m.useEffect(function(){return document.body.setAttribute(yr,(ad()+1).toString()),function(){var e=ad()-1;e<=0?document.body.removeAttribute(yr):document.body.setAttribute(yr,e.toString())}},[])},ob=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;rb();var s=m.useMemo(function(){return eb(o)},[o]);return m.createElement(tb,{styles:nb(s,!t,o,n?"":"!important")})},fa=!1;if(typeof window<"u")try{var cs=Object.defineProperty({},"passive",{get:function(){return fa=!0,!0}});window.addEventListener("test",cs,cs),window.removeEventListener("test",cs,cs)}catch{fa=!1}var Sr=fa?{passive:!1}:!1,sb=function(e){return e.tagName==="TEXTAREA"},ld=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!sb(e)&&n[t]==="visible")},ib=function(e){return ld(e,"overflowY")},ab=function(e){return ld(e,"overflowX")},cd=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=ud(e,r);if(o){var s=dd(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},lb=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},cb=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},ud=function(e,t){return e==="v"?ib(t):ab(t)},dd=function(e,t){return e==="v"?lb(t):cb(t)},ub=function(e,t){return e==="h"&&t==="rtl"?-1:1},db=function(e,t,n,r,o){var s=ub(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),u=!1,d=i>0,f=0,h=0;do{if(!a)break;var p=dd(e,a),x=p[0],w=p[1],g=p[2],v=w-g-s*x;(x||v)&&ud(e,a)&&(f+=v,h+=x);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},us=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},fd=function(e){return[e.deltaX,e.deltaY]},hd=function(e){return e&&"current"in e?e.current:e},fb=function(e,t){return e[0]===t[0]&&e[1]===t[1]},hb=function(e){return`
|
|
122
122
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
123
123
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
124
|
-
`)},
|
|
124
|
+
`)},pb=0,Cr=[];function mb(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(pb++)[0],s=m.useState(id)[0],i=m.useRef(e);m.useEffect(function(){i.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var w=Dw([e.lockRef.current],(e.shards||[]).map(hd),!0).filter(Boolean);return w.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),w.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=m.useCallback(function(w,g){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!i.current.allowPinchZoom;var v=us(w),b=n.current,S="deltaX"in w?w.deltaX:b[0]-v[0],N="deltaY"in w?w.deltaY:b[1]-v[1],C,k=w.target,E=Math.abs(S)>Math.abs(N)?"h":"v";if("touches"in w&&E==="h"&&k.type==="range")return!1;var A=cd(E,k);if(!A)return!0;if(A?C=E:(C=E==="v"?"h":"v",A=cd(E,k)),!A)return!1;if(!r.current&&"changedTouches"in w&&(S||N)&&(r.current=C),!C)return!0;var j=r.current||C;return db(j,g,w,j==="h"?S:N)},[]),l=m.useCallback(function(w){var g=w;if(!(!Cr.length||Cr[Cr.length-1]!==s)){var v="deltaY"in g?fd(g):us(g),b=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&fb(C.delta,v)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(hd).filter(Boolean).filter(function(C){return C.contains(g.target)}),N=S.length>0?a(g,S[0]):!i.current.noIsolation;N&&g.cancelable&&g.preventDefault()}}},[]),u=m.useCallback(function(w,g,v,b){var S={name:w,delta:g,target:v,should:b,shadowParent:gb(v)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(N){return N!==S})},1)},[]),d=m.useCallback(function(w){n.current=us(w),r.current=void 0},[]),f=m.useCallback(function(w){u(w.type,fd(w),w.target,a(w,e.lockRef.current))},[]),h=m.useCallback(function(w){u(w.type,us(w),w.target,a(w,e.lockRef.current))},[]);m.useEffect(function(){return Cr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,Sr),document.addEventListener("touchmove",l,Sr),document.addEventListener("touchstart",d,Sr),function(){Cr=Cr.filter(function(w){return w!==s}),document.removeEventListener("wheel",l,Sr),document.removeEventListener("touchmove",l,Sr),document.removeEventListener("touchstart",d,Sr)}},[]);var p=e.removeScrollBar,x=e.inert;return m.createElement(m.Fragment,null,x?m.createElement(s,{styles:hb(o)}):null,p?m.createElement(ob,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function gb(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const xb=Vw(sd,mb);var ds=m.forwardRef(function(e,t){return m.createElement(ls,gn({},e,{ref:t,sideCar:xb}))});ds.classNames=ls.classNames;var vb=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Tr=new WeakMap,fs=new WeakMap,hs={},ha=0,pd=function(e){return e&&(e.host||pd(e.parentNode))},wb=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=pd(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})},bb=function(e,t,n,r){var o=wb(t,Array.isArray(e)?e:[e]);hs[n]||(hs[n]=new WeakMap);var s=hs[n],i=[],a=new Set,l=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var d=function(f){!f||l.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))d(h);else try{var p=h.getAttribute(r),x=p!==null&&p!=="false",w=(Tr.get(h)||0)+1,g=(s.get(h)||0)+1;Tr.set(h,w),s.set(h,g),i.push(h),w===1&&x&&fs.set(h,!0),g===1&&h.setAttribute(n,"true"),x||h.setAttribute(r,"true")}catch(v){console.error("aria-hidden: cannot operate on ",h,v)}})};return d(t),a.clear(),ha++,function(){i.forEach(function(f){var h=Tr.get(f)-1,p=s.get(f)-1;Tr.set(f,h),s.set(f,p),h||(fs.has(f)||f.removeAttribute(r),fs.delete(f)),p||f.removeAttribute(n)}),ha--,ha||(Tr=new WeakMap,Tr=new WeakMap,fs=new WeakMap,hs={})}},pa=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=vb(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),bb(r,o,n,"aria-hidden")):function(){return null}},ps="Dialog",[md,AT]=pn(ps),[yb,nn]=md(ps),gd=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=m.useRef(null),l=m.useRef(null),[u,d]=Zn({prop:r,defaultProp:o??!1,onChange:s,caller:ps});return c.jsx(yb,{scope:t,triggerRef:a,contentRef:l,contentId:mn(),titleId:mn(),descriptionId:mn(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};gd.displayName=ps;var xd="DialogTrigger",vd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=nn(xd,n),s=We(t,o.triggerRef);return c.jsx(je.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":xa(o.open),...r,ref:s,onClick:de(e.onClick,o.onOpenToggle)})});vd.displayName=xd;var ma="DialogPortal",[Sb,wd]=md(ma,{forceMount:void 0}),bd=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=nn(ma,t);return c.jsx(Sb,{scope:t,forceMount:n,children:m.Children.map(r,i=>c.jsx(zt,{present:n||s.open,children:c.jsx(ss,{asChild:!0,container:o,children:i})}))})};bd.displayName=ma;var ms="DialogOverlay",yd=m.forwardRef((e,t)=>{const n=wd(ms,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=nn(ms,e.__scopeDialog);return s.modal?c.jsx(zt,{present:r||s.open,children:c.jsx(Tb,{...o,ref:t})}):null});yd.displayName=ms;var Cb=Wn.createSlot("DialogOverlay.RemoveScroll"),Tb=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=nn(ms,n);return c.jsx(ds,{as:Cb,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(je.div,{"data-state":xa(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),er="DialogContent",Sd=m.forwardRef((e,t)=>{const n=wd(er,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=nn(er,e.__scopeDialog);return c.jsx(zt,{present:r||s.open,children:s.modal?c.jsx(kb,{...o,ref:t}):c.jsx(Ib,{...o,ref:t})})});Sd.displayName=er;var kb=m.forwardRef((e,t)=>{const n=nn(er,e.__scopeDialog),r=m.useRef(null),o=We(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return pa(s)},[]),c.jsx(Cd,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:de(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:de(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:de(e.onFocusOutside,s=>s.preventDefault())})}),Ib=m.forwardRef((e,t)=>{const n=nn(er,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return c.jsx(Cd,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var l,u;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((u=n.triggerRef.current)==null?void 0:u.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Cd=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=nn(er,n),l=m.useRef(null),u=We(t,l);return la(),c.jsxs(c.Fragment,{children:[c.jsx(os,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(rs,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":xa(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(Eb,{titleId:a.titleId}),c.jsx(Ab,{contentRef:l,descriptionId:a.descriptionId})]})]})}),ga="DialogTitle",Td=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=nn(ga,n);return c.jsx(je.h2,{id:o.titleId,...r,ref:t})});Td.displayName=ga;var kd="DialogDescription",Id=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=nn(kd,n);return c.jsx(je.p,{id:o.descriptionId,...r,ref:t})});Id.displayName=kd;var Ed="DialogClose",Nd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=nn(Ed,n);return c.jsx(je.button,{type:"button",...r,ref:t,onClick:de(e.onClick,()=>o.onOpenChange(!1))})});Nd.displayName=Ed;function xa(e){return e?"open":"closed"}var Ad="DialogTitleWarning",[_T,_d]=Ov(Ad,{contentName:er,titleName:ga,docsSlug:"dialog"}),Eb=({titleId:e})=>{const t=_d(Ad),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
125
125
|
|
|
126
126
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
127
127
|
|
|
128
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},
|
|
129
|
-
… [truncated ${i.length-o} chars]`}catch{return""}},n=e.filter(r=>r.type==="tool_end");if(n.length)try{return n.length===1?t(n[0].output):t(n.map(r=>({toolCallId:r.toolCallId,output:r.output})))}catch{}return t(e)}function
|
|
130
|
-
… [truncated ${K.length-
|
|
131
|
-
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[L[re]?c.jsx(ie.Loader,{className:"h-4 w-4 animate-spin"}):null,c.jsxs("span",{className:"truncate max-w-[180px]",children:[Ne,L[re]?" (processing)":""]})]},re)}return Z.type==="interrupt"?c.jsx(
|
|
132
|
-
… [truncated ${we.length-tr} chars]`:we,Qe=N==="expanded";return c.jsxs(yu,{open:Qe,onOpenChange:ze=>C(ze?"expanded":"preview"),children:[c.jsx("div",{className:"flex items-center gap-2 text-xs",children:c.jsx(Vi,{variant:"outline",children:(pe.name??"tool")+(pe.toolCallId?` • ${pe.toolCallId.slice(0,8)}`:"")})}),c.jsx("div",{className:"font-mono text-sm mt-1",children:c.jsx("pre",{className:"whitespace-pre-wrap break-words",children:Qe?Ae:Ae.slice(0,d)+(Ae.length>d?"...":"")})}),c.jsx(Su,{asChild:!0,children:c.jsx(Ge,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:Qe?c.jsxs(c.Fragment,{children:[" ",c.jsx(ie.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ie.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},pe.toolCallId??Ne)})})}if(!$){const re=c.jsx("div",{className:"space-y-2",children:t.content.map((pe,Ne)=>c.jsx(Ee,{part:pe,i:Ne},Ne))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[re,c.jsx(Nb,{className:D})]}):re}},[ee,ve.length,be.length,ye.length,r,t.model,$,fe.name,K,N,u,Ze,D]),ht=y.useMemo(()=>Eb(t),[t]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:Q(Je(),p.container),children:c.jsxs("div",{className:Q(nt(),p.content),children:[(i||a||$)&&c.jsxs("div",{className:Q("flex items-center justify-between mb-2 pb-2 border-b border-current/10",W&&"mb-1 pb-1",D,p.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[Ve(),a&&ht&&c.jsx("span",{className:Q("font-medium",W?"text-xs":"text-sm"),children:ht}),$&&fe.name&&c.jsxs(Vi,{variant:"outline",className:Q("text-xs flex items-center gap-1 cursor-pointer",D,"border border-current/40",W&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":N!=="collapsed",onKeyDown:Z=>{(Z.key==="Enter"||Z.key===" ")&&(Z.preventDefault(),C(re=>re==="collapsed"?"preview":"collapsed"))},onClick:()=>C(Z=>Z==="collapsed"?"preview":"collapsed"),children:[c.jsx("span",{children:fe.name}),c.jsx("span",{className:"inline-flex items-center",children:N!=="collapsed"?c.jsx(ie.ChevronUp,{className:"h-3 w-3"}):c.jsx(ie.ChevronDown,{className:"h-3 w-3"})})]}),$&&!fe.name&&c.jsx(Ge,{variant:"ghost",size:"sm",className:Q("h-6 px-1",D,"hover:bg-foreground/10"),onClick:()=>C(Z=>Z==="collapsed"?"preview":"collapsed"),children:c.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",N!=="collapsed"?c.jsx(ie.ChevronUp,{className:"h-3 w-3"}):c.jsx(ie.ChevronDown,{className:"h-3 w-3"})]})})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.createdAt&&c.jsx("time",{className:Q("text-xs opacity-60",D,W&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&c.jsxs("div",{className:Q("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsxs("div",{className:"relative",children:[c.jsx(Ge,{variant:"ghost",size:"sm",onClick:()=>J($?"visible":"all"),className:Q("h-6 w-6 p-0 hover:bg-foreground/10",D,W&&"h-5 w-5"),"aria-label":$?"Copy visible":"Copy message",title:$?"Copy visible portion":"Copy message",children:c.jsx(ie.Copy,{className:Q(b?"text-success":D,W?"h-3 w-3":"h-4 w-4")})}),$&&c.jsx(Ge,{variant:"ghost",size:"sm",onClick:()=>J("all"),className:Q("h-6 px-1 text-xs hover:bg-foreground/10",D),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),z==="user"&&v&&c.jsx(Ge,{variant:"ghost",size:"sm",onClick:te,className:Q("h-6 w-6 p-0 hover:bg-foreground/10",D,W&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(ie.Edit,{className:Q(D,W?"h-3 w-3":"h-4 w-4")})}),z==="assistant"&&w&&c.jsx(Ge,{variant:"ghost",size:"sm",onClick:G,className:Q("h-6 w-6 p-0 hover:bg-foreground/10",D,W&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(ie.RotateCcw,{className:Q(D,W?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsx("div",{className:"relative",children:wt()}),$&&N==="expanded"&&(fe.toolCallId||fe.name)&&c.jsxs("div",{className:Q("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",W&&"text-xs"),children:[fe.name&&c.jsxs("div",{children:["Function: ",fe.name]}),fe.toolCallId&&c.jsxs("div",{children:["Call ID: ",fe.toolCallId]})]}),!(i||a||$)&&s&&!o&&c.jsxs("div",{className:Q("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsx(Ge,{variant:"ghost",size:"sm",onClick:()=>J(),className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",W&&"h-5 w-5"),children:c.jsx(ie.Copy,{className:Q(b?"text-success":"text-current",W?"h-3 w-3":"h-4 w-4")})}),z==="user"&&v&&c.jsx(Ge,{variant:"ghost",size:"sm",onClick:te,className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",W&&"h-5 w-5"),children:c.jsx(ie.Edit,{className:Q("text-current",W?"h-3 w-3":"h-4 w-4")})}),z==="assistant"&&w&&c.jsx(Ge,{variant:"ghost",size:"sm",onClick:G,className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",W&&"h-5 w-5"),children:c.jsx(ie.RotateCcw,{className:Q("text-current",W?"h-3 w-3":"h-4 w-4")})})]})]})}),Y&&c.jsx(yb,{isOpen:V,onClose:()=>{M(!1),q(null)},fileId:Y.id,fileName:Y.name,mimeType:Y.mimeType})]})},(e,t)=>{var i,a,l,u,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&Dd(e.message)===Dd(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(v=>e[v]===t[v]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((l=e.customStyles)==null?void 0:l.content)===((u=t.customStyles)==null?void 0:u.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((h=e.customStyles)==null?void 0:h.header)===((p=t.customStyles)==null?void 0:p.header);return o&&s});function Ab({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?c.jsx("div",{className:xs,children:c.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>c.jsx("li",{children:String(n)},r))})}):c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:ga(e)});if(e&&typeof e=="object"){const t=Array.isArray(e.distilled_facts)?e.distilled_facts:null,n=Array.isArray(e.follow_up_queries)?e.follow_up_queries:null,r=typeof e.is_sufficient=="boolean"?e.is_sufficient:void 0;if(t||n||typeof r=="boolean")return c.jsxs("div",{className:xs,children:[typeof r=="boolean"&&c.jsxs("p",{children:[c.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Follow-up queries:"})}),c.jsx("ul",{className:"list-disc pl-5",children:n.map((s,i)=>c.jsx("li",{children:String(s)},i))})]}),t&&t.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Facts:"})}),c.jsx("ul",{className:"list-disc pl-5",children:t.map((s,i)=>c.jsx("li",{children:String(s)},i))})]})]});const o=Object.entries(e);return c.jsx("div",{className:xs,children:c.jsx("dl",{className:"mt-0",children:o.map(([s,i])=>c.jsxs("div",{className:"mb-1",children:[c.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),c.jsx("dd",{className:"inline",children:jb(i)})]},s))})})}return c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:ga(e)})}function jb(e){if(e==null)return String(e);const t=typeof e;if(t==="string"||t==="number"||t==="boolean")return String(e);if(Array.isArray(e)&&e.every(r=>r===null||["string","number","boolean"].includes(typeof r)))return e.join(", ");try{return c.jsx("code",{className:"text-xs",children:JSON.stringify(ro(e))})}catch{return String(e)}}function _b({interruptPart:e,onApprove:t,onReject:n}){const r=e.title??"Approve the result?";return c.jsxs(Qr,{className:"border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10",children:[c.jsxs(eo,{className:"pb-3",children:[c.jsx(to,{className:"text-blue-900 dark:text-blue-100 text-base",children:r}),c.jsx(Cu,{className:"text-blue-700 dark:text-blue-300",children:"Please approve or reject this action to continue."})]}),c.jsx(Tu,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(Ge,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",children:"Reject"}),c.jsx(Ge,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",children:"Approve"})]})})]})}function Rb({data:e}){return c.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>c.jsxs("div",{className:"flex",children:[c.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),c.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>c.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function Pb({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return c.jsx("div",{className:xs,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:c.jsxs("div",{className:"mb-4",children:[c.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),c.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>c.jsxs("li",{children:[c.jsx("div",{className:"font-medium",children:o.title}),c.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const Fd=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,xa=y.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:v=!0,isNavigatingCheckpoint:w=!1,onScrollAway:g,onAtBottom:x},b)=>{const S=y.useRef(null),N=y.useRef(null),C=y.useRef(!1),[k,E]=y.useState(!0),A=y.useCallback(L=>{E(L),g&&g(!L),x&&x(L)},[g,x]),j=y.useMemo(()=>{if(a)return async()=>{if(!C.current){C.current=!0;try{await a()}finally{C.current=!1}}}},[a]),P=y.useMemo(()=>!v||w?!1:k?"auto":!1,[k,v,w]);return e.length===0?c.jsx("div",{className:f,style:h,children:c.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:p||"No messages yet. Start a conversation!"})}):c.jsx("div",{className:f,style:h,children:c.jsx(sv,{ref:L=>{S.current=L},scrollerRef:L=>{N.current=L instanceof HTMLDivElement?L:null},data:e,followOutput:P,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{j&&j()},atBottomStateChange:A,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(L,F)=>Fd(F,L),itemContent:(L,F)=>{const V=Fd(F,L);return c.jsx("div",{className:"mb-4 last:mb-0","data-message-id":V,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(Ld,{message:F,messageIndex:L,isStreamingMessage:t&&n===F.id,streamingDebounceMs:r,isEditing:i===F.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:l,onRegenerate:()=>u(L),onCancelEdit:d})})}})})});xa.displayName="MessageList";const vs=1e4;function Ob(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,`
|
|
128
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Nb="DialogDescriptionWarning",Ab=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${_d(Nb).contentName}}.`;return m.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},jd=gd,_b=vd,Rd=bd,gs=yd,xs=Sd,tr=Td,vs=Id,Pd=Nd;const jb=jd,Rb=Rd,Od=m.forwardRef(({className:e,...t},n)=>c.jsx(gs,{ref:n,className:Q("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Od.displayName=gs.displayName;const Md=m.forwardRef(({className:e,children:t,...n},r)=>{const o=m.useMemo(()=>{let s=!1;function i(a){m.Children.forEach(a,l=>{if(s||!m.isValidElement(l))return;const u=l.type;if(u===tr||(u==null?void 0:u.displayName)===tr.displayName||(u==null?void 0:u.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return c.jsxs(Rb,{children:[c.jsx(Od,{}),c.jsxs(xs,{ref:r,className:Q("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&c.jsx(tr,{className:"sr-only",children:"Dialog"}),t,c.jsxs(Pd,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[c.jsx(ie.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Md.displayName=xs.displayName;const Dd=({className:e,...t})=>c.jsx("div",{className:Q("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Dd.displayName="DialogHeader";const Ld=m.forwardRef(({className:e,...t},n)=>c.jsx(tr,{ref:n,className:Q("text-lg font-semibold leading-none tracking-tight",e),...t}));Ld.displayName=tr.displayName;const Pb=m.forwardRef(({className:e,...t},n)=>c.jsx(vs,{ref:n,className:Q("text-sm text-muted-foreground",e),...t}));Pb.displayName=vs.displayName;function Ob({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=y.useState(!1),[a,l]=y.useState(null),[u,d]=y.useState(null),{toast:f}=ra(),h=y.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const v=await Wu(n);l(v)}catch(v){console.error("Failed to load file:",v),d(v instanceof Error?v.message:"Failed to load file")}finally{i(!1)}}},[n]);y.useEffect(()=>{e&&n&&h()},[e,n,h]);const p=async()=>{if(n)try{await hw(n),f({title:"Download started",description:`Downloading ${r}`})}catch(v){console.error("Failed to download file:",v),f({title:"Download failed",description:String(v),variant:"destructive"})}},x=async()=>{if(n)try{const v=await Wu(n),b=new Blob([v],{type:o}),S=URL.createObjectURL(b);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(v){console.error("Failed to open file externally:",v),f({title:"Failed to open file",description:String(v),variant:"destructive"})}},w=()=>s?c.jsxs("div",{className:"flex items-center justify-center py-12",children:[c.jsx(ie.Loader,{className:"h-8 w-8 animate-spin mr-3"}),c.jsx("span",{children:"Loading file..."})]}):u?c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),c.jsx("p",{className:"text-red-600 mb-4",children:u}),c.jsx(Ge,{onClick:h,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?c.jsx("div",{className:"flex justify-center",children:c.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?c.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:c.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?c.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:c.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx(ie.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),c.jsx("p",{className:"text-lg font-medium mb-2",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),g=()=>o.startsWith("image/")?c.jsx(ie.Image,{className:"h-5 w-5"}):c.jsx(ie.FileText,{className:"h-5 w-5"});return c.jsx(jb,{open:e,onOpenChange:t,children:c.jsxs(Md,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[c.jsx(Dd,{children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[g(),c.jsxs("div",{children:[c.jsx(Ld,{className:"text-left",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Ge,{variant:"outline",size:"sm",onClick:x,className:"flex items-center gap-2",children:[c.jsx(ie.ExternalLink,{className:"h-4 w-4"}),"External"]}),c.jsxs(Ge,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[c.jsx(ie.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),c.jsx("div",{className:"flex-1 overflow-hidden",children:w()})]})})}function Fd(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 $d(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function so(e){if(typeof e=="string")return e.length>2e3?e.slice(0,2e3)+"... [truncated]":e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(so).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if($d(e)){try{console.debug("[message-utils] sanitizeForDisplay - dropping file-like object",{sampleFilename:e&&(e.filename||e.name)?e.filename||e.name:void 0,keys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - dropped file-like (unable to inspect)",{err:String(n)})}return}const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=so(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function va(e){if(typeof e=="string")return e;if($d(e))return"";try{const t=so(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function zd(e){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){if(e.desirability||e.feasibility||e.viability||e.other)return{desirability:Array.isArray(e.desirability)?e.desirability:[],feasibility:Array.isArray(e.feasibility)?e.feasibility:[],viability:Array.isArray(e.viability)?e.viability:[],other:Array.isArray(e.other)?e.other:[]};if(e.output&&typeof e.output!="object")e=e.output;else if(e.output&&typeof e.output=="object")return zd(e.output)}const t=String(e),n={desirability:[],feasibility:[],viability:[],other:[]};let r=t;const o=Math.min(...["desirability=","feasibility=","viability=","other="].map(i=>{const a=r.toLowerCase().indexOf(i);return a===-1?Number.MAX_SAFE_INTEGER:a}));o!==Number.MAX_SAFE_INTEGER&&(r=r.slice(o));for(const i of Object.keys(n)){const l=new RegExp(i+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(r);if(!l)continue;const u=l[1],d=/Issue\(([\s\S]*?)\)(?:,|$)/g;let f=null;for(;(f=d.exec(u))!==null;){const h=f[1],p=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(h),x=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(h),w=p?p[2].trim():"",g=x?x[2].trim():"";n[i].push({title:w,description:g})}}return Object.values(n).some(i=>i.length>0)?n:null}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",nr=1e5;function Mb(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Db(e){const t=e.find(r=>r.type==="tool_call"),n=e.find(r=>r.type==="tool_end");return{name:t==null?void 0:t.name,toolCallId:(n==null?void 0:n.toolCallId)??(t==null?void 0:t.id)}}function Lb(e){const t=e.filter(r=>r.type==="tool_call");return e.filter(r=>r.type==="tool_end").map(r=>{var o;return{name:(o=t.find(s=>s.id===r.toolCallId))==null?void 0:o.name,toolCallId:r.toolCallId,output:r.output}})}function Fb(e){const t=(r,o=nr)=>{try{const s=so(r),i=typeof s=="string"?s:JSON.stringify(s??"");return i.length<=o?i:i.slice(0,o)+`
|
|
129
|
+
… [truncated ${i.length-o} chars]`}catch{return""}},n=e.filter(r=>r.type==="tool_end");if(n.length)try{return n.length===1?t(n[0].output):t(n.map(r=>({toolCallId:r.toolCallId,output:r.output})))}catch{}return t(e)}function $b(e){const t=e.find(r=>r.type==="tool_end");if(!t)return null;const n=t.output;return typeof n=="string"?n:null}function zb(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function Bd(e){const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(r=>{switch(r.type){case"text":return`t:${r.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"tool_end":return"end";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function Bb({className:e}){const[t,n]=y.useState(0);return y.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),c.jsxs("span",{"aria-live":"polite",className:Q("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const Hd=y.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateToolMessages:u=!0,toolMessagePreviewLength:d=200,truncateUserMessages:f=!0,userMessagePreviewLength:h=200,customStyles:p={},onEdit:x,onRegenerate:w,onCancelEdit:g,onCopy:v}){const[b,S]=y.useState(!1),[N,C]=y.useState("collapsed"),[k,E]=y.useState(!1),{currentThreadId:A}=Ro(),{respondToInterrupt:j}=Po(),{toast:P}=ra(),[L,F]=y.useState({}),[V,M]=y.useState(!1),[Y,q]=y.useState(null),W=l==="phone"||l==="half-screen",z=t.role,$=z==="tool",ue=!(r&&z!=="user"),D=y.useMemo(()=>{switch(z){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[z]),ee=y.useMemo(()=>Mb(t.content),[t.content]),fe=y.useMemo(()=>Db(t.content),[t.content]),ve=y.useMemo(()=>t.content.filter(Z=>Z.type==="image_url"),[t.content]),be=y.useMemo(()=>t.content.filter(Z=>Z.type==="file"),[t.content]),ye=y.useMemo(()=>t.content.filter(Z=>Z.type==="interrupt"),[t.content]),K=y.useMemo(()=>Fb(t.content),[t.content]);y.useMemo(()=>$b(t.content),[t.content]);const O=y.useMemo(()=>K.length<=nr?K:`${K.slice(0,nr)}
|
|
130
|
+
… [truncated ${K.length-nr} chars]`,[K]),J=y.useCallback(async(Z="all")=>{const pe=Z==="visible"&&$?O:$?K:ee;async function Ne(we){try{await navigator.clipboard.writeText(we)}catch{try{const Ae=document.createElement("textarea");Ae.value=we,Ae.setAttribute("readonly",""),Ae.style.position="absolute",Ae.style.left="-9999px",document.body.appendChild(Ae),Ae.select(),document.execCommand("copy"),document.body.removeChild(Ae)}catch(Ae){throw console.error("Failed to copy:",Ae),Ae}}}try{await Ne(pe),S(!0),setTimeout(()=>S(!1),2e3),v==null||v(pe)}catch(we){console.error("Failed to copy:",we)}},[$,K,ee,O,v]),te=y.useCallback(()=>{if(!x)return;const Z=$?K:ee;x(t.id,Z)},[x,t.id,$,K,ee]),G=y.useCallback(()=>{w==null||w(n)},[w,n]),se=y.useCallback(async(Z,re,pe)=>{if(!ue){Z.preventDefault();return}if(L[pe]){Z.preventDefault();return}try{const Ne=String(re.url??""),we=Ne.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(we){Z.preventDefault();const Ae=we[1],Qe=re.name||`file_${Ae}`,ze=re.mimeType||"application/octet-stream";q({id:Ae,name:Qe,mimeType:ze}),M(!0);return}if(Ne.startsWith("data:")){Z.preventDefault(),F(ze=>({...ze,[pe]:!0}));const Ae=`${re.name}_${re.size}_${Date.now()}`,Qe=P({title:"Fetching file...",description:"",open:!0});try{const ze=await pw(A??void 0);if(!ze||!Array.isArray(ze))throw new Error("Invalid file list response");const lt=ze.find(St=>!St||typeof St!="object"||!((St.filename??"")===(re.name??""))?!1:typeof re.size=="number"&&typeof St.size=="number"?St.size===re.size:!0);if(!(lt!=null&<.id))throw new Error(`File "${re.name}" is not yet available on the server`);if(!lt.id||!lt.filename)throw new Error("Invalid file data received from server");q({id:lt.id,name:re.name||lt.filename||`file_${lt.id}`,mimeType:re.mimeType||lt.mime_type||"application/octet-stream"}),M(!0),Qe.update({id:Qe.id,title:"Success",description:`Opened ${re.name}`,open:!0})}catch(ze){console.error("Failed to fetch server file:",ze);const lt=ze instanceof Error?ze.message:"Unknown error occurred";Qe.update({id:Qe.id,title:"Failed",description:lt}),P({title:"Failed to fetch file",description:lt,open:!0})}finally{F(ze=>({...ze,[pe]:!1}))}}}catch(Ne){console.error("File click error:",Ne),F(we=>({...we,[pe]:!1}))}},[ue,L,P,A]),Ve=y.useCallback(()=>{const re=Q(W?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",D);switch(z){case"user":return c.jsx(ie.User,{className:re});case"assistant":return c.jsx(ie.Bot,{className:re});case"tool":return c.jsx(ie.Wrench,{className:re});default:return c.jsx(ie.Bot,{className:re})}},[W,D,z]),Je=y.useCallback(()=>{const Z="group relative mb-4 flex w-full";switch(z){case"user":return Q(Z,"justify-end");case"assistant":case"tool":case"system":return Q(Z,"justify-start");default:return Z}},[z]),nt=y.useCallback(()=>{const Z=Q("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",W&&"px-3 py-2 text-sm");switch(z){case"user":return Q(Z,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return Q(Z,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return Q(Z,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return Q(Z,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return Q(Z,"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")}},[W,z]),De=y.useCallback(async Z=>{try{const re=(Z==null?void 0:Z.id)||(Z==null?void 0:Z.interrupt_id);if(!re){console.warn("Interrupt part missing id",Z);return}await j(re,!0)}catch(re){console.error("Failed to approve interrupt:",re)}},[j]),Be=y.useCallback(async Z=>{try{const re=(Z==null?void 0:Z.id)||(Z==null?void 0:Z.interrupt_id);if(!re){console.warn("Interrupt part missing id",Z);return}await j(re,!1)}catch(re){console.error("Failed to reject interrupt:",re)}},[j]),Ee=y.useCallback(({part:Z,i:re})=>{if(Z.type==="text"){const pe=Z.text??"",Ne=pe.trim(),we=Fd(Ne);return we&&z!=="tool"?c.jsx(Hb,{data:we},re):z==="user"&&f&&Ne.length>h?c.jsxs(Iu,{open:k,onOpenChange:E,children:[c.jsx("div",{className:Q("text-sm text-[hsl(var(--chat-bubble-user-text))]",W&&"text-xs"),children:k?c.jsx(ea,{content:Ne,allowHtml:!1}):c.jsxs("pre",{className:Q("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",W&&"text-xs"),children:[Ne.substring(0,h),"..."]})}),c.jsx(Eu,{asChild:!0,children:c.jsx(Ge,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:k?c.jsxs(c.Fragment,{children:[c.jsx(ie.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ie.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",Ne.length-h," chars)"]})})})]},re):c.jsx(ea,{content:pe,allowHtml:!1},re)}if(Z.type==="image_url"){const pe=Z;return c.jsx("div",{className:"my-2",children:c.jsx("img",{src:pe.url,alt:pe.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},re)}if(Z.type==="file"){const pe=Z,Ne=pe.name||"file";return c.jsxs("a",{href:pe.url,onClick:we=>se(we,pe,re),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
131
|
+
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[L[re]?c.jsx(ie.Loader,{className:"h-4 w-4 animate-spin"}):null,c.jsxs("span",{className:"truncate max-w-[180px]",children:[Ne,L[re]?" (processing)":""]})]},re)}return Z.type==="interrupt"?c.jsx(Wb,{interruptPart:Z,onApprove:De,onReject:Be},re):null},[se,L,De,Be,z,f,h,k,W]),Ze=y.useCallback(()=>c.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[c.jsx(ie.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),wt=y.useCallback(()=>{const Z=ee.trim().length>0||ve.length>0||be.length>0||ye.length>0;if(!$&&!Z&&!r)return Ze();if(t.model==="reflection"){const re=ee.trim(),pe=Fd(re);if(pe&&typeof pe=="object")return c.jsx(Vb,{data:pe})}if($&&fe.name==="get_issues"){const re=t.content.find(we=>we.type==="tool_end"),pe=(re==null?void 0:re.output)??K,Ne=zd(pe);if(Ne)return c.jsx(qb,{issues:Ne})}if($){const re=Lb(t.content);if(re.length>0)return c.jsx("div",{className:"space-y-2",children:re.map((pe,Ne)=>{const we=typeof pe.output=="string"?pe.output:va(pe.output),Ae=we.length>nr?`${we.slice(0,nr)}
|
|
132
|
+
… [truncated ${we.length-nr} chars]`:we,Qe=N==="expanded";return c.jsxs(Iu,{open:Qe,onOpenChange:ze=>C(ze?"expanded":"preview"),children:[c.jsx("div",{className:"flex items-center gap-2 text-xs",children:c.jsx(Ki,{variant:"outline",children:(pe.name??"tool")+(pe.toolCallId?` • ${pe.toolCallId.slice(0,8)}`:"")})}),c.jsx("div",{className:"font-mono text-sm mt-1",children:c.jsx("pre",{className:"whitespace-pre-wrap break-words",children:Qe?Ae:Ae.slice(0,d)+(Ae.length>d?"...":"")})}),c.jsx(Eu,{asChild:!0,children:c.jsx(Ge,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:Qe?c.jsxs(c.Fragment,{children:[" ",c.jsx(ie.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ie.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},pe.toolCallId??Ne)})})}if(!$){const re=c.jsx("div",{className:"space-y-2",children:t.content.map((pe,Ne)=>c.jsx(Ee,{part:pe,i:Ne},Ne))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[re,c.jsx(Bb,{className:D})]}):re}},[ee,ve.length,be.length,ye.length,r,t.model,$,fe.name,K,N,u,Ze,D]),ht=y.useMemo(()=>zb(t),[t]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:Q(Je(),p.container),children:c.jsxs("div",{className:Q(nt(),p.content),children:[(i||a||$)&&c.jsxs("div",{className:Q("flex items-center justify-between mb-2 pb-2 border-b border-current/10",W&&"mb-1 pb-1",D,p.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[Ve(),a&&ht&&c.jsx("span",{className:Q("font-medium",W?"text-xs":"text-sm"),children:ht}),$&&fe.name&&c.jsxs(Ki,{variant:"outline",className:Q("text-xs flex items-center gap-1 cursor-pointer",D,"border border-current/40",W&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":N!=="collapsed",onKeyDown:Z=>{(Z.key==="Enter"||Z.key===" ")&&(Z.preventDefault(),C(re=>re==="collapsed"?"preview":"collapsed"))},onClick:()=>C(Z=>Z==="collapsed"?"preview":"collapsed"),children:[c.jsx("span",{children:fe.name}),c.jsx("span",{className:"inline-flex items-center",children:N!=="collapsed"?c.jsx(ie.ChevronUp,{className:"h-3 w-3"}):c.jsx(ie.ChevronDown,{className:"h-3 w-3"})})]}),$&&!fe.name&&c.jsx(Ge,{variant:"ghost",size:"sm",className:Q("h-6 px-1",D,"hover:bg-foreground/10"),onClick:()=>C(Z=>Z==="collapsed"?"preview":"collapsed"),children:c.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",N!=="collapsed"?c.jsx(ie.ChevronUp,{className:"h-3 w-3"}):c.jsx(ie.ChevronDown,{className:"h-3 w-3"})]})})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.createdAt&&c.jsx("time",{className:Q("text-xs opacity-60",D,W&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&c.jsxs("div",{className:Q("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsxs("div",{className:"relative",children:[c.jsx(Ge,{variant:"ghost",size:"sm",onClick:()=>J($?"visible":"all"),className:Q("h-6 w-6 p-0 hover:bg-foreground/10",D,W&&"h-5 w-5"),"aria-label":$?"Copy visible":"Copy message",title:$?"Copy visible portion":"Copy message",children:c.jsx(ie.Copy,{className:Q(b?"text-success":D,W?"h-3 w-3":"h-4 w-4")})}),$&&c.jsx(Ge,{variant:"ghost",size:"sm",onClick:()=>J("all"),className:Q("h-6 px-1 text-xs hover:bg-foreground/10",D),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),z==="user"&&x&&c.jsx(Ge,{variant:"ghost",size:"sm",onClick:te,className:Q("h-6 w-6 p-0 hover:bg-foreground/10",D,W&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(ie.Edit,{className:Q(D,W?"h-3 w-3":"h-4 w-4")})}),z==="assistant"&&w&&c.jsx(Ge,{variant:"ghost",size:"sm",onClick:G,className:Q("h-6 w-6 p-0 hover:bg-foreground/10",D,W&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(ie.RotateCcw,{className:Q(D,W?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsx("div",{className:"relative",children:wt()}),$&&N==="expanded"&&(fe.toolCallId||fe.name)&&c.jsxs("div",{className:Q("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",W&&"text-xs"),children:[fe.name&&c.jsxs("div",{children:["Function: ",fe.name]}),fe.toolCallId&&c.jsxs("div",{children:["Call ID: ",fe.toolCallId]})]}),!(i||a||$)&&s&&!o&&c.jsxs("div",{className:Q("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsx(Ge,{variant:"ghost",size:"sm",onClick:()=>J(),className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",W&&"h-5 w-5"),children:c.jsx(ie.Copy,{className:Q(b?"text-success":"text-current",W?"h-3 w-3":"h-4 w-4")})}),z==="user"&&x&&c.jsx(Ge,{variant:"ghost",size:"sm",onClick:te,className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",W&&"h-5 w-5"),children:c.jsx(ie.Edit,{className:Q("text-current",W?"h-3 w-3":"h-4 w-4")})}),z==="assistant"&&w&&c.jsx(Ge,{variant:"ghost",size:"sm",onClick:G,className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",W&&"h-5 w-5"),children:c.jsx(ie.RotateCcw,{className:Q("text-current",W?"h-3 w-3":"h-4 w-4")})})]})]})}),Y&&c.jsx(Ob,{isOpen:V,onClose:()=>{M(!1),q(null)},fileId:Y.id,fileName:Y.name,mimeType:Y.mimeType})]})},(e,t)=>{var i,a,l,u,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&Bd(e.message)===Bd(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(x=>e[x]===t[x]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((l=e.customStyles)==null?void 0:l.content)===((u=t.customStyles)==null?void 0:u.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((h=e.customStyles)==null?void 0:h.header)===((p=t.customStyles)==null?void 0:p.header);return o&&s});function Hb({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?c.jsx("div",{className:ws,children:c.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>c.jsx("li",{children:String(n)},r))})}):c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:va(e)});if(e&&typeof e=="object"){const t=Array.isArray(e.distilled_facts)?e.distilled_facts:null,n=Array.isArray(e.follow_up_queries)?e.follow_up_queries:null,r=typeof e.is_sufficient=="boolean"?e.is_sufficient:void 0;if(t||n||typeof r=="boolean")return c.jsxs("div",{className:ws,children:[typeof r=="boolean"&&c.jsxs("p",{children:[c.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Follow-up queries:"})}),c.jsx("ul",{className:"list-disc pl-5",children:n.map((s,i)=>c.jsx("li",{children:String(s)},i))})]}),t&&t.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Facts:"})}),c.jsx("ul",{className:"list-disc pl-5",children:t.map((s,i)=>c.jsx("li",{children:String(s)},i))})]})]});const o=Object.entries(e);return c.jsx("div",{className:ws,children:c.jsx("dl",{className:"mt-0",children:o.map(([s,i])=>c.jsxs("div",{className:"mb-1",children:[c.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),c.jsx("dd",{className:"inline",children:Ub(i)})]},s))})})}return c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:va(e)})}function Ub(e){if(e==null)return String(e);const t=typeof e;if(t==="string"||t==="number"||t==="boolean")return String(e);if(Array.isArray(e)&&e.every(r=>r===null||["string","number","boolean"].includes(typeof r)))return e.join(", ");try{return c.jsx("code",{className:"text-xs",children:JSON.stringify(so(e))})}catch{return String(e)}}function Wb({interruptPart:e,onApprove:t,onReject:n}){const r=e.title??"Approve the result?";return c.jsxs(to,{className:"border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10",children:[c.jsxs(no,{className:"pb-3",children:[c.jsx(ro,{className:"text-blue-900 dark:text-blue-100 text-base",children:r}),c.jsx(Nu,{className:"text-blue-700 dark:text-blue-300",children:"Please approve or reject this action to continue."})]}),c.jsx(Au,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(Ge,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",children:"Reject"}),c.jsx(Ge,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",children:"Approve"})]})})]})}function Vb({data:e}){return c.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>c.jsxs("div",{className:"flex",children:[c.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),c.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>c.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function qb({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return c.jsx("div",{className:ws,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:c.jsxs("div",{className:"mb-4",children:[c.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),c.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>c.jsxs("li",{children:[c.jsx("div",{className:"font-medium",children:o.title}),c.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const Ud=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,wa=y.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:x=!0,isNavigatingCheckpoint:w=!1,onScrollAway:g,onAtBottom:v},b)=>{const S=y.useRef(null),N=y.useRef(null),C=y.useRef(!1),[k,E]=y.useState(!0),A=y.useCallback(L=>{E(L),g&&g(!L),v&&v(L)},[g,v]),j=y.useMemo(()=>{if(a)return async()=>{if(!C.current){C.current=!0;try{await a()}finally{C.current=!1}}}},[a]),P=y.useMemo(()=>!x||w?!1:k?"auto":!1,[k,x,w]);return e.length===0?c.jsx("div",{className:f,style:h,children:c.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:p||"No messages yet. Start a conversation!"})}):c.jsx("div",{className:f,style:h,children:c.jsx(vv,{ref:L=>{S.current=L},scrollerRef:L=>{N.current=L instanceof HTMLDivElement?L:null},data:e,followOutput:P,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{j&&j()},atBottomStateChange:A,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(L,F)=>Ud(F,L),itemContent:(L,F)=>{const V=Ud(F,L);return c.jsx("div",{className:"mb-4 last:mb-0","data-message-id":V,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(Hd,{message:F,messageIndex:L,isStreamingMessage:t&&n===F.id,streamingDebounceMs:r,isEditing:i===F.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:l,onRegenerate:()=>u(L),onCancelEdit:d})})}})})});wa.displayName="MessageList";const bs=1e4;function Kb(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,`
|
|
133
133
|
`).replace(/<p>(.*?)<\/p>/gi,`$1
|
|
134
134
|
|
|
135
135
|
`).replace(/<h([1-6])>(.*?)<\/h[1-6]>/gi,(o,s,i)=>`${"#".repeat(parseInt(s))} ${i}
|
|
@@ -137,4 +137,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
137
137
|
`).replace(/<ul>/gi,"").replace(/<\/ul>/gi,`
|
|
138
138
|
`).replace(/<ol>/gi,"").replace(/<\/ol>/gi,`
|
|
139
139
|
`).replace(/<li>(.*?)<\/li>/gi,`- $1
|
|
140
|
-
`).trim():n.replace(/</g,"<").replace(/>/g,">").trim()}function Mb(e,t=vs){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 Db(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),Mb(t),Ob(t)}function va(e){const t=e+"CollectionProvider",[n,r]=fn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=w=>{const{scope:g,children:x}=w,b=y.useRef(null),S=y.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:S,collectionRef:b,children:x})};i.displayName=t;const a=e+"CollectionSlot",l=Un.createSlot(a),u=y.forwardRef((w,g)=>{const{scope:x,children:b}=w,S=s(a,x),N=We(g,S.collectionRef);return c.jsx(l,{ref:N,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=Un.createSlot(d),p=y.forwardRef((w,g)=>{const{scope:x,children:b,...S}=w,N=y.useRef(null),C=We(g,N),k=s(d,x);return y.useEffect(()=>(k.itemMap.set(N,{ref:N,...S}),()=>void k.itemMap.delete(N))),c.jsx(h,{[f]:"",ref:C,children:b})});p.displayName=d;function v(w){const g=s(e+"CollectionConsumer",w);return y.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const S=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((k,E)=>S.indexOf(k.ref.current)-S.indexOf(E.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},v,r]}var Lb=m.createContext(void 0);function ws(e){const t=m.useContext(Lb);return e||t||"ltr"}const Fb=["top","right","bottom","left"],Fn=Math.min,zt=Math.max,bs=Math.round,ys=Math.floor,mn=e=>({x:e,y:e}),$b={left:"right",right:"left",bottom:"top",top:"bottom"},zb={start:"end",end:"start"};function wa(e,t,n){return zt(e,Fn(t,n))}function kn(e,t){return typeof e=="function"?e(t):e}function In(e){return e.split("-")[0]}function Tr(e){return e.split("-")[1]}function ba(e){return e==="x"?"y":"x"}function ya(e){return e==="y"?"height":"width"}const Bb=new Set(["top","bottom"]);function gn(e){return Bb.has(In(e))?"y":"x"}function Sa(e){return ba(gn(e))}function Hb(e,t,n){n===void 0&&(n=!1);const r=Tr(e),o=Sa(e),s=ya(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Ss(i)),[i,Ss(i)]}function Ub(e){const t=Ss(e);return[Ca(e),t,Ca(t)]}function Ca(e){return e.replace(/start|end/g,t=>zb[t])}const $d=["left","right"],zd=["right","left"],Wb=["top","bottom"],Vb=["bottom","top"];function qb(e,t,n){switch(e){case"top":case"bottom":return n?t?zd:$d:t?$d:zd;case"left":case"right":return t?Wb:Vb;default:return[]}}function Kb(e,t,n,r){const o=Tr(e);let s=qb(In(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ca)))),s}function Ss(e){return e.replace(/left|right|bottom|top/g,t=>$b[t])}function Gb(e){return{top:0,right:0,bottom:0,left:0,...e}}function Bd(e){return typeof e!="number"?Gb(e):{top:e,right:e,bottom:e,left:e}}function Cs(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Hd(e,t,n){let{reference:r,floating:o}=e;const s=gn(t),i=Sa(t),a=ya(i),l=In(t),u=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(Tr(t)){case"start":p[i]-=h*(n&&u?-1:1);break;case"end":p[i]+=h*(n&&u?-1:1);break}return p}const Yb=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=Hd(u,r,l),h=r,p={},v=0;for(let w=0;w<a.length;w++){const{name:g,fn:x}=a[w],{x:b,y:S,data:N,reset:C}=await x({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});d=b??d,f=S??f,p={...p,[g]:{...p[g],...N}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=Hd(u,h,l)),w=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function oo(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=kn(t,e),v=Bd(p),g=a[h?f==="floating"?"reference":"floating":f],x=Cs(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:l})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),N=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=Cs(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(x.top-C.top+v.top)/N.y,bottom:(C.bottom-x.bottom+v.bottom)/N.y,left:(x.left-C.left+v.left)/N.x,right:(C.right-x.right+v.right)/N.x}}const Xb=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:u,padding:d=0}=kn(e,t)||{};if(u==null)return{};const f=Bd(d),h={x:n,y:r},p=Sa(o),v=ya(p),w=await i.getDimensions(u),g=p==="y",x=g?"top":"left",b=g?"bottom":"right",S=g?"clientHeight":"clientWidth",N=s.reference[v]+s.reference[p]-h[p]-s.floating[v],C=h[p]-s.reference[p],k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let E=k?k[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(k)))&&(E=a.floating[S]||s.floating[v]);const A=N/2-C/2,j=E/2-w[v]/2-1,P=Fn(f[x],j),L=Fn(f[b],j),F=P,V=E-w[v]-L,M=E/2-w[v]/2+A,Y=wa(F,M,V),q=!l.arrow&&Tr(o)!=null&&M!==Y&&s.reference[v]/2-(M<F?P:L)-w[v]/2<0,W=q?M<F?M-F:M-V:0;return{[p]:h[p]+W,data:{[p]:Y,centerOffset:M-Y-W,...q&&{alignmentOffset:W}},reset:q}}}),Jb=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:w=!0,...g}=kn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=In(o),b=gn(a),S=In(a)===a,N=await(l.isRTL==null?void 0:l.isRTL(u.floating)),C=h||(S||!w?[Ss(a)]:Ub(a)),k=v!=="none";!h&&k&&C.push(...Kb(a,w,v,N));const E=[a,...C],A=await oo(t,g),j=[];let P=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&j.push(A[x]),f){const M=Hb(o,i,N);j.push(A[M[0]],A[M[1]])}if(P=[...P,{placement:o,overflows:j}],!j.every(M=>M<=0)){var L,F;const M=(((L=s.flip)==null?void 0:L.index)||0)+1,Y=E[M];if(Y&&(!(f==="alignment"?b!==gn(Y):!1)||P.every(z=>gn(z.placement)===b?z.overflows[0]>0:!0)))return{data:{index:M,overflows:P},reset:{placement:Y}};let q=(F=P.filter(W=>W.overflows[0]<=0).sort((W,z)=>W.overflows[1]-z.overflows[1])[0])==null?void 0:F.placement;if(!q)switch(p){case"bestFit":{var V;const W=(V=P.filter(z=>{if(k){const $=gn(z.placement);return $===b||$==="y"}return!0}).map(z=>[z.placement,z.overflows.filter($=>$>0).reduce(($,ue)=>$+ue,0)]).sort((z,$)=>z[1]-$[1])[0])==null?void 0:V[0];W&&(q=W);break}case"initialPlacement":q=a;break}if(o!==q)return{reset:{placement:q}}}return{}}}};function Ud(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Wd(e){return Fb.some(t=>e[t]>=0)}const Zb=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=kn(e,t);switch(r){case"referenceHidden":{const s=await oo(t,{...o,elementContext:"reference"}),i=Ud(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Wd(i)}}}case"escaped":{const s=await oo(t,{...o,altBoundary:!0}),i=Ud(s,n.floating);return{data:{escapedOffsets:i,escaped:Wd(i)}}}default:return{}}}}},Vd=new Set(["left","top"]);async function Qb(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=In(n),a=Tr(n),l=gn(n)==="y",u=Vd.has(i)?-1:1,d=s&&l?-1:1,f=kn(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof v=="number"&&(p=a==="end"?v*-1:v),l?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const ey=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 Qb(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}}}}},ty=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x,y:b}=g;return{x,y:b}}},...l}=kn(e,t),u={x:n,y:r},d=await oo(t,l),f=gn(In(o)),h=ba(f);let p=u[h],v=u[f];if(s){const g=h==="y"?"top":"left",x=h==="y"?"bottom":"right",b=p+d[g],S=p-d[x];p=wa(b,p,S)}if(i){const g=f==="y"?"top":"left",x=f==="y"?"bottom":"right",b=v+d[g],S=v-d[x];v=wa(b,v,S)}const w=a.fn({...t,[h]:p,[f]:v});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[h]:s,[f]:i}}}}}},ny=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:u=!0}=kn(e,t),d={x:n,y:r},f=gn(o),h=ba(f);let p=d[h],v=d[f];const w=kn(a,t),g=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(l){const S=h==="y"?"height":"width",N=s.reference[h]-s.floating[S]+g.mainAxis,C=s.reference[h]+s.reference[S]-g.mainAxis;p<N?p=N:p>C&&(p=C)}if(u){var x,b;const S=h==="y"?"width":"height",N=Vd.has(In(o)),C=s.reference[f]-s.floating[S]+(N&&((x=i.offset)==null?void 0:x[f])||0)+(N?0:g.crossAxis),k=s.reference[f]+s.reference[S]+(N?0:((b=i.offset)==null?void 0:b[f])||0)-(N?g.crossAxis:0);v<C?v=C:v>k&&(v=k)}return{[h]:p,[f]:v}}}},ry=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...u}=kn(e,t),d=await oo(t,u),f=In(o),h=Tr(o),p=gn(o)==="y",{width:v,height:w}=s.floating;let g,x;f==="top"||f==="bottom"?(g=f,x=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=f,g=h==="end"?"top":"bottom");const b=w-d.top-d.bottom,S=v-d.left-d.right,N=Fn(w-d[g],b),C=Fn(v-d[x],S),k=!t.middlewareData.shift;let E=N,A=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),k&&!h){const P=zt(d.left,0),L=zt(d.right,0),F=zt(d.top,0),V=zt(d.bottom,0);p?A=v-2*(P!==0||L!==0?P+L:zt(d.left,d.right)):E=w-2*(F!==0||V!==0?F+V:zt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:E});const j=await i.getDimensions(a.floating);return v!==j.width||w!==j.height?{reset:{rects:!0}}:{}}}};function Ts(){return typeof window<"u"}function kr(e){return qd(e)?(e.nodeName||"").toLowerCase():"#document"}function Bt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function xn(e){var t;return(t=(qd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function qd(e){return Ts()?e instanceof Node||e instanceof Bt(e).Node:!1}function tn(e){return Ts()?e instanceof Element||e instanceof Bt(e).Element:!1}function vn(e){return Ts()?e instanceof HTMLElement||e instanceof Bt(e).HTMLElement:!1}function Kd(e){return!Ts()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Bt(e).ShadowRoot}const oy=new Set(["inline","contents"]);function so(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=nn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!oy.has(o)}const sy=new Set(["table","td","th"]);function iy(e){return sy.has(kr(e))}const ay=[":popover-open",":modal"];function ks(e){return ay.some(t=>{try{return e.matches(t)}catch{return!1}})}const ly=["transform","translate","scale","rotate","perspective"],cy=["transform","translate","scale","rotate","perspective","filter"],uy=["paint","layout","strict","content"];function Ta(e){const t=ka(),n=tn(e)?nn(e):e;return ly.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)||cy.some(r=>(n.willChange||"").includes(r))||uy.some(r=>(n.contain||"").includes(r))}function dy(e){let t=$n(e);for(;vn(t)&&!Ir(t);){if(Ta(t))return t;if(ks(t))return null;t=$n(t)}return null}function ka(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const fy=new Set(["html","body","#document"]);function Ir(e){return fy.has(kr(e))}function nn(e){return Bt(e).getComputedStyle(e)}function Is(e){return tn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function $n(e){if(kr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Kd(e)&&e.host||xn(e);return Kd(t)?t.host:t}function Gd(e){const t=$n(e);return Ir(t)?e.ownerDocument?e.ownerDocument.body:e.body:vn(t)&&so(t)?t:Gd(t)}function io(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Gd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Bt(o);if(s){const a=Ia(i);return t.concat(i,i.visualViewport||[],so(o)?o:[],a&&n?io(a):[])}return t.concat(o,io(o,[],n))}function Ia(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Yd(e){const t=nn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=vn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=bs(n)!==s||bs(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Ea(e){return tn(e)?e:e.contextElement}function Er(e){const t=Ea(e);if(!vn(t))return mn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Yd(t);let i=(s?bs(n.width):n.width)/r,a=(s?bs(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const hy=mn(0);function Xd(e){const t=Bt(e);return!ka()||!t.visualViewport?hy:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function py(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Bt(e)?!1:t}function nr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Ea(e);let i=mn(1);t&&(r?tn(r)&&(i=Er(r)):i=Er(e));const a=py(s,n,r)?Xd(s):mn(0);let l=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=Bt(s),p=r&&tn(r)?Bt(r):r;let v=h,w=Ia(v);for(;w&&r&&p!==v;){const g=Er(w),x=w.getBoundingClientRect(),b=nn(w),S=x.left+(w.clientLeft+parseFloat(b.paddingLeft))*g.x,N=x.top+(w.clientTop+parseFloat(b.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=S,u+=N,v=Bt(w),w=Ia(v)}}return Cs({width:d,height:f,x:l,y:u})}function Es(e,t){const n=Is(e).scrollLeft;return t?t.left+n:nr(xn(e)).left+n}function Jd(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Es(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function my(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=xn(r),a=t?ks(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=mn(1);const d=mn(0),f=vn(r);if((f||!f&&!s)&&((kr(r)!=="body"||so(i))&&(l=Is(r)),vn(r))){const p=nr(r);u=Er(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?Jd(i,l):mn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-l.scrollTop*u.y+d.y+h.y}}function gy(e){return Array.from(e.getClientRects())}function xy(e){const t=xn(e),n=Is(e),r=e.ownerDocument.body,o=zt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=zt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Es(e);const a=-n.scrollTop;return nn(r).direction==="rtl"&&(i+=zt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Zd=25;function vy(e,t){const n=Bt(e),r=xn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=ka();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const u=Es(r);if(u<=0){const d=r.ownerDocument,f=d.body,h=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-p);v<=Zd&&(s-=v)}else u<=Zd&&(s+=u);return{width:s,height:i,x:a,y:l}}const wy=new Set(["absolute","fixed"]);function by(e,t){const n=nr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=vn(e)?Er(e):mn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,u=r*s.y;return{width:i,height:a,x:l,y:u}}function Qd(e,t,n){let r;if(t==="viewport")r=vy(e,n);else if(t==="document")r=xy(xn(e));else if(tn(t))r=by(t,n);else{const o=Xd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Cs(r)}function ef(e,t){const n=$n(e);return n===t||!tn(n)||Ir(n)?!1:nn(n).position==="fixed"||ef(n,t)}function yy(e,t){const n=t.get(e);if(n)return n;let r=io(e,[],!1).filter(a=>tn(a)&&kr(a)!=="body"),o=null;const s=nn(e).position==="fixed";let i=s?$n(e):e;for(;tn(i)&&!Ir(i);){const a=nn(i),l=Ta(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&wy.has(o.position)||so(i)&&!l&&ef(e,i))?r=r.filter(d=>d!==i):o=a,i=$n(i)}return t.set(e,r),r}function Sy(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?ks(t)?[]:yy(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=Qd(t,d,o);return u.top=zt(f.top,u.top),u.right=Fn(f.right,u.right),u.bottom=Fn(f.bottom,u.bottom),u.left=zt(f.left,u.left),u},Qd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Cy(e){const{width:t,height:n}=Yd(e);return{width:t,height:n}}function Ty(e,t,n){const r=vn(t),o=xn(t),s=n==="fixed",i=nr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=mn(0);function u(){l.x=Es(o)}if(r||!r&&!s)if((kr(t)!=="body"||so(o))&&(a=Is(t)),r){const p=nr(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?Jd(o,a):mn(0),f=i.left+a.scrollLeft-l.x-d.x,h=i.top+a.scrollTop-l.y-d.y;return{x:f,y:h,width:i.width,height:i.height}}function Na(e){return nn(e).position==="static"}function tf(e,t){if(!vn(e)||nn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return xn(e)===n&&(n=n.ownerDocument.body),n}function nf(e,t){const n=Bt(e);if(ks(e))return n;if(!vn(e)){let o=$n(e);for(;o&&!Ir(o);){if(tn(o)&&!Na(o))return o;o=$n(o)}return n}let r=tf(e,t);for(;r&&iy(r)&&Na(r);)r=tf(r,t);return r&&Ir(r)&&Na(r)&&!Ta(r)?n:r||dy(e)||n}const ky=async function(e){const t=this.getOffsetParent||nf,n=this.getDimensions,r=await n(e.floating);return{reference:Ty(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Iy(e){return nn(e).direction==="rtl"}const Ey={convertOffsetParentRelativeRectToViewportRelativeRect:my,getDocumentElement:xn,getClippingRect:Sy,getOffsetParent:nf,getElementRects:ky,getClientRects:gy,getDimensions:Cy,getScale:Er,isElement:tn,isRTL:Iy};function rf(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Ny(e,t){let n=null,r;const o=xn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:p}=u;if(a||t(),!h||!p)return;const v=ys(f),w=ys(o.clientWidth-(d+h)),g=ys(o.clientHeight-(f+p)),x=ys(d),S={rootMargin:-v+"px "+-w+"px "+-g+"px "+-x+"px",threshold:zt(0,Fn(1,l))||1};let N=!0;function C(k){const E=k[0].intersectionRatio;if(E!==l){if(!N)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!rf(u,e.getBoundingClientRect())&&i(),N=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function Ay(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=Ea(e),d=o||s?[...u?io(u):[],...io(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const f=u&&a?Ny(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(x=>{let[b]=x;b&&b.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let v,w=l?nr(e):null;l&&g();function g(){const x=nr(e);w&&!rf(w,x)&&n(),w=x,v=requestAnimationFrame(g)}return n(),()=>{var x;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(x=p)==null||x.disconnect(),p=null,l&&cancelAnimationFrame(v)}}const jy=ey,_y=ty,Ry=Jb,Py=ry,Oy=Zb,of=Xb,My=ny,Dy=(e,t,n)=>{const r=new Map,o={platform:Ey,...n},s={...o.platform,_c:r};return Yb(e,t,{...o,platform:s})};var Ly=typeof document<"u",Fy=function(){},Ns=Ly?y.useLayoutEffect:Fy;function As(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(!As(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)&&!As(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function sf(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function af(e,t){const n=sf(e);return Math.round(t*n)/n}function Aa(e){const t=m.useRef(e);return Ns(()=>{t.current=e}),t}function $y(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=m.useState(r);As(h,r)||p(r);const[v,w]=m.useState(null),[g,x]=m.useState(null),b=m.useCallback(z=>{z!==k.current&&(k.current=z,w(z))},[]),S=m.useCallback(z=>{z!==E.current&&(E.current=z,x(z))},[]),N=s||v,C=i||g,k=m.useRef(null),E=m.useRef(null),A=m.useRef(d),j=l!=null,P=Aa(l),L=Aa(o),F=Aa(u),V=m.useCallback(()=>{if(!k.current||!E.current)return;const z={placement:t,strategy:n,middleware:h};L.current&&(z.platform=L.current),Dy(k.current,E.current,z).then($=>{const ue={...$,isPositioned:F.current!==!1};M.current&&!As(A.current,ue)&&(A.current=ue,go.flushSync(()=>{f(ue)}))})},[h,t,n,L,F]);Ns(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(z=>({...z,isPositioned:!1})))},[u]);const M=m.useRef(!1);Ns(()=>(M.current=!0,()=>{M.current=!1}),[]),Ns(()=>{if(N&&(k.current=N),C&&(E.current=C),N&&C){if(P.current)return P.current(N,C,V);V()}},[N,C,V,P,j]);const Y=m.useMemo(()=>({reference:k,floating:E,setReference:b,setFloating:S}),[b,S]),q=m.useMemo(()=>({reference:N,floating:C}),[N,C]),W=m.useMemo(()=>{const z={position:n,left:0,top:0};if(!q.floating)return z;const $=af(q.floating,d.x),ue=af(q.floating,d.y);return a?{...z,transform:"translate("+$+"px, "+ue+"px)",...sf(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:$,top:ue}},[n,a,q.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:V,refs:Y,elements:q,floatingStyles:W}),[d,V,Y,q,W])}const zy=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?of({element:r.current,padding:o}).fn(n):{}:r?of({element:r,padding:o}).fn(n):{}}}},By=(e,t)=>({...jy(e),options:[e,t]}),Hy=(e,t)=>({..._y(e),options:[e,t]}),Uy=(e,t)=>({...My(e),options:[e,t]}),Wy=(e,t)=>({...Ry(e),options:[e,t]}),Vy=(e,t)=>({...Py(e),options:[e,t]}),qy=(e,t)=>({...Oy(e),options:[e,t]}),Ky=(e,t)=>({...zy(e),options:[e,t]});var Gy="Arrow",lf=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(_e.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});lf.displayName=Gy;var Yy=lf;function cf(e){const[t,n]=m.useState(void 0);return vt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,u=Array.isArray(l)?l[0]:l;i=u.inlineSize,a=u.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var ja="Popper",[uf,js]=fn(ja),[Xy,df]=uf(ja),ff=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(Xy,{scope:t,anchor:r,onAnchorChange:o,children:n})};ff.displayName=ja;var hf="PopperAnchor",pf=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=df(hf,n),i=m.useRef(null),a=We(t,i),l=m.useRef(null);return m.useEffect(()=>{const u=l.current;l.current=(r==null?void 0:r.current)||i.current,u!==l.current&&s.onAnchorChange(l.current)}),r?null:c.jsx(_e.div,{...o,ref:a})});pf.displayName=hf;var _a="PopperContent",[Jy,Zy]=uf(_a),mf=m.forwardRef((e,t)=>{var K,O,J,te,G,se;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:v,...w}=e,g=df(_a,n),[x,b]=m.useState(null),S=We(t,Ve=>b(Ve)),[N,C]=m.useState(null),k=cf(N),E=(k==null?void 0:k.width)??0,A=(k==null?void 0:k.height)??0,j=r+(s!=="center"?"-"+s:""),P=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},L=Array.isArray(u)?u:[u],F=L.length>0,V={padding:P,boundary:L.filter(eS),altBoundary:F},{refs:M,floatingStyles:Y,placement:q,isPositioned:W,middlewareData:z}=$y({strategy:"fixed",placement:j,whileElementsMounted:(...Ve)=>Ay(...Ve,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[By({mainAxis:o+A,alignmentAxis:i}),l&&Hy({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Uy():void 0,...V}),l&&Wy({...V}),Vy({...V,apply:({elements:Ve,rects:Je,availableWidth:nt,availableHeight:De})=>{const{width:Be,height:Ee}=Je.reference,Ze=Ve.floating.style;Ze.setProperty("--radix-popper-available-width",`${nt}px`),Ze.setProperty("--radix-popper-available-height",`${De}px`),Ze.setProperty("--radix-popper-anchor-width",`${Be}px`),Ze.setProperty("--radix-popper-anchor-height",`${Ee}px`)}}),N&&Ky({element:N,padding:a}),tS({arrowWidth:E,arrowHeight:A}),h&&qy({strategy:"referenceHidden",...V})]}),[$,ue]=vf(q),D=yt(v);vt(()=>{W&&(D==null||D())},[W,D]);const ee=(K=z.arrow)==null?void 0:K.x,fe=(O=z.arrow)==null?void 0:O.y,ve=((J=z.arrow)==null?void 0:J.centerOffset)!==0,[be,ye]=m.useState();return vt(()=>{x&&ye(window.getComputedStyle(x).zIndex)},[x]),c.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:W?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:be,"--radix-popper-transform-origin":[(te=z.transformOrigin)==null?void 0:te.x,(G=z.transformOrigin)==null?void 0:G.y].join(" "),...((se=z.hide)==null?void 0:se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(Jy,{scope:n,placedSide:$,onArrowChange:C,arrowX:ee,arrowY:fe,shouldHideArrow:ve,children:c.jsx(_e.div,{"data-side":$,"data-align":ue,...w,ref:S,style:{...w.style,animation:W?void 0:"none"}})})})});mf.displayName=_a;var gf="PopperArrow",Qy={top:"bottom",right:"left",bottom:"top",left:"right"},xf=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Zy(gf,r),i=Qy[s.placedSide];return c.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:c.jsx(Yy,{...o,ref:n,style:{...o.style,display:"block"}})})});xf.displayName=gf;function eS(e){return e!==null}var tS=e=>({name:"transformOrigin",options:e,fn(t){var g,x,b;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[u,d]=vf(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((x=o.arrow)==null?void 0:x.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let v="",w="";return u==="bottom"?(v=i?f:`${h}px`,w=`${-l}px`):u==="top"?(v=i?f:`${h}px`,w=`${r.floating.height+l}px`):u==="right"?(v=`${-l}px`,w=i?f:`${p}px`):u==="left"&&(v=`${r.floating.width+l}px`,w=i?f:`${p}px`),{data:{x:v,y:w}}}});function vf(e){const[t,n="center"]=e.split("-");return[t,n]}var wf=ff,bf=pf,yf=mf,Sf=xf,Ra="rovingFocusGroup.onEntryFocus",nS={bubbles:!1,cancelable:!0},ao="RovingFocusGroup",[Pa,Cf,rS]=va(ao),[oS,Tf]=fn(ao,[rS]),[sS,iS]=oS(ao),kf=m.forwardRef((e,t)=>c.jsx(Pa.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Pa.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(aS,{...e,ref:t})})}));kf.displayName=ao;var aS=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=m.useRef(null),p=We(t,h),v=ws(s),[w,g]=Jn({prop:i,defaultProp:a??null,onChange:l,caller:ao}),[x,b]=m.useState(!1),S=yt(u),N=Cf(n),C=m.useRef(!1),[k,E]=m.useState(0);return m.useEffect(()=>{const A=h.current;if(A)return A.addEventListener(Ra,S),()=>A.removeEventListener(Ra,S)},[S]),c.jsx(sS,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:w,onItemFocus:m.useCallback(A=>g(A),[g]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>E(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>E(A=>A-1),[]),children:c.jsx(_e.div,{tabIndex:x||k===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:de(e.onMouseDown,()=>{C.current=!0}),onFocus:de(e.onFocus,A=>{const j=!C.current;if(A.target===A.currentTarget&&j&&!x){const P=new CustomEvent(Ra,nS);if(A.currentTarget.dispatchEvent(P),!P.defaultPrevented){const L=N().filter(q=>q.focusable),F=L.find(q=>q.active),V=L.find(q=>q.id===w),Y=[F,V,...L].filter(Boolean).map(q=>q.ref.current);Nf(Y,d)}}C.current=!1}),onBlur:de(e.onBlur,()=>b(!1))})})}),If="RovingFocusGroupItem",Ef=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=hn(),u=s||l,d=iS(If,n),f=d.currentTabStopId===u,h=Cf(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:w}=d;return m.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),c.jsx(Pa.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(_e.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:de(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:de(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:de(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=uS(g,d.orientation,d.dir);if(x!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let S=h().filter(N=>N.focusable).map(N=>N.ref.current);if(x==="last")S.reverse();else if(x==="prev"||x==="next"){x==="prev"&&S.reverse();const N=S.indexOf(g.currentTarget);S=d.loop?dS(S,N+1):S.slice(N+1)}setTimeout(()=>Nf(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:w!=null}):i})})});Ef.displayName=If;var lS={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function cS(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function uS(e,t,n){const r=cS(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return lS[r]}function Nf(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function dS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var fS=kf,hS=Ef,Oa=["Enter"," "],pS=["ArrowDown","PageUp","Home"],Af=["ArrowUp","PageDown","End"],mS=[...pS,...Af],gS={ltr:[...Oa,"ArrowRight"],rtl:[...Oa,"ArrowLeft"]},xS={ltr:["ArrowLeft"],rtl:["ArrowRight"]},lo="Menu",[co,vS,wS]=va(lo),[rr,jf]=fn(lo,[wS,js,Tf]),_s=js(),_f=Tf(),[bS,or]=rr(lo),[yS,uo]=rr(lo),Rf=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=_s(t),[l,u]=m.useState(null),d=m.useRef(!1),f=yt(s),h=ws(o);return m.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),c.jsx(wf,{...a,children:c.jsx(bS,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(yS,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};Rf.displayName=lo;var SS="MenuAnchor",Ma=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=_s(n);return c.jsx(bf,{...o,...r,ref:t})});Ma.displayName=SS;var Da="MenuPortal",[CS,Pf]=rr(Da,{forceMount:void 0}),Of=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=or(Da,t);return c.jsx(CS,{scope:t,forceMount:n,children:c.jsx($t,{present:n||s.open,children:c.jsx(rs,{asChild:!0,container:o,children:r})})})};Of.displayName=Da;var qt="MenuContent",[TS,La]=rr(qt),Mf=m.forwardRef((e,t)=>{const n=Pf(qt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=or(qt,e.__scopeMenu),i=uo(qt,e.__scopeMenu);return c.jsx(co.Provider,{scope:e.__scopeMenu,children:c.jsx($t,{present:r||s.open,children:c.jsx(co.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(kS,{...o,ref:t}):c.jsx(IS,{...o,ref:t})})})})}),kS=m.forwardRef((e,t)=>{const n=or(qt,e.__scopeMenu),r=m.useRef(null),o=We(t,r);return m.useEffect(()=>{const s=r.current;if(s)return fa(s)},[]),c.jsx(Fa,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:de(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),IS=m.forwardRef((e,t)=>{const n=or(qt,e.__scopeMenu);return c.jsx(Fa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),ES=Un.createSlot("MenuContent.ScrollLock"),Fa=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:v,...w}=e,g=or(qt,n),x=uo(qt,n),b=_s(n),S=_f(n),N=vS(n),[C,k]=m.useState(null),E=m.useRef(null),A=We(t,E,g.onContentChange),j=m.useRef(0),P=m.useRef(""),L=m.useRef(0),F=m.useRef(null),V=m.useRef("right"),M=m.useRef(0),Y=v?cs:m.Fragment,q=v?{as:ES,allowPinchZoom:!0}:void 0,W=$=>{var K,O;const ue=P.current+$,D=N().filter(J=>!J.disabled),ee=document.activeElement,fe=(K=D.find(J=>J.ref.current===ee))==null?void 0:K.textValue,ve=D.map(J=>J.textValue),be=$S(ve,ue,fe),ye=(O=D.find(J=>J.textValue===be))==null?void 0:O.ref.current;(function J(te){P.current=te,window.clearTimeout(j.current),te!==""&&(j.current=window.setTimeout(()=>J(""),1e3))})(ue),ye&&setTimeout(()=>ye.focus())};m.useEffect(()=>()=>window.clearTimeout(j.current),[]),ia();const z=m.useCallback($=>{var D,ee;return V.current===((D=F.current)==null?void 0:D.side)&&BS($,(ee=F.current)==null?void 0:ee.area)},[]);return c.jsx(TS,{scope:n,searchRef:P,onItemEnter:m.useCallback($=>{z($)&&$.preventDefault()},[z]),onItemLeave:m.useCallback($=>{var ue;z($)||((ue=E.current)==null||ue.focus(),k(null))},[z]),onTriggerLeave:m.useCallback($=>{z($)&&$.preventDefault()},[z]),pointerGraceTimerRef:L,onPointerGraceIntentChange:m.useCallback($=>{F.current=$},[]),children:c.jsx(Y,{...q,children:c.jsx(ns,{asChild:!0,trapped:o,onMountAutoFocus:de(s,$=>{var ue;$.preventDefault(),(ue=E.current)==null||ue.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(ts,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:c.jsx(fS,{asChild:!0,...S,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:de(l,$=>{x.isUsingKeyboardRef.current||$.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(yf,{role:"menu","aria-orientation":"vertical","data-state":Zf(g.open),"data-radix-menu-content":"",dir:x.dir,...b,...w,ref:A,style:{outline:"none",...w.style},onKeyDown:de(w.onKeyDown,$=>{const D=$.target.closest("[data-radix-menu-content]")===$.currentTarget,ee=$.ctrlKey||$.altKey||$.metaKey,fe=$.key.length===1;D&&($.key==="Tab"&&$.preventDefault(),!ee&&fe&&W($.key));const ve=E.current;if($.target!==ve||!mS.includes($.key))return;$.preventDefault();const ye=N().filter(K=>!K.disabled).map(K=>K.ref.current);Af.includes($.key)&&ye.reverse(),LS(ye)}),onBlur:de(e.onBlur,$=>{$.currentTarget.contains($.target)||(window.clearTimeout(j.current),P.current="")}),onPointerMove:de(e.onPointerMove,ho($=>{const ue=$.target,D=M.current!==$.clientX;if($.currentTarget.contains(ue)&&D){const ee=$.clientX>M.current?"right":"left";V.current=ee,M.current=$.clientX}}))})})})})})})});Mf.displayName=qt;var NS="MenuGroup",$a=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(_e.div,{role:"group",...r,ref:t})});$a.displayName=NS;var AS="MenuLabel",Df=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(_e.div,{...r,ref:t})});Df.displayName=AS;var Rs="MenuItem",Lf="menu.itemSelect",Ps=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=uo(Rs,e.__scopeMenu),a=La(Rs,e.__scopeMenu),l=We(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(Lf,{bubbles:!0,cancelable:!0});f.addEventListener(Lf,p=>r==null?void 0:r(p),{once:!0}),xu(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(Ff,{...o,ref:l,disabled:n,onClick:de(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:de(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:de(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||Oa.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Ps.displayName=Rs;var Ff=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=La(Rs,n),a=_f(n),l=m.useRef(null),u=We(t,l),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const v=l.current;v&&p((v.textContent??"").trim())},[s.children]),c.jsx(co.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(hS,{asChild:!0,...a,focusable:!r,children:c.jsx(_e.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:de(e.onPointerMove,ho(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:de(e.onPointerLeave,ho(v=>i.onItemLeave(v))),onFocus:de(e.onFocus,()=>f(!0)),onBlur:de(e.onBlur,()=>f(!1))})})})}),jS="MenuCheckboxItem",$f=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(Wf,{scope:e.__scopeMenu,checked:n,children:c.jsx(Ps,{role:"menuitemcheckbox","aria-checked":Os(n)?"mixed":n,...o,ref:t,"data-state":Ba(n),onSelect:de(o.onSelect,()=>r==null?void 0:r(Os(n)?!0:!n),{checkForDefaultPrevented:!1})})})});$f.displayName=jS;var zf="MenuRadioGroup",[_S,RS]=rr(zf,{value:void 0,onValueChange:()=>{}}),Bf=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=yt(r);return c.jsx(_S,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx($a,{...o,ref:t})})});Bf.displayName=zf;var Hf="MenuRadioItem",Uf=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=RS(Hf,e.__scopeMenu),s=n===o.value;return c.jsx(Wf,{scope:e.__scopeMenu,checked:s,children:c.jsx(Ps,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Ba(s),onSelect:de(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Uf.displayName=Hf;var za="MenuItemIndicator",[Wf,PS]=rr(za,{checked:!1}),Vf=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=PS(za,n);return c.jsx($t,{present:r||Os(s.checked)||s.checked===!0,children:c.jsx(_e.span,{...o,ref:t,"data-state":Ba(s.checked)})})});Vf.displayName=za;var OS="MenuSeparator",qf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(_e.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});qf.displayName=OS;var MS="MenuArrow",Kf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=_s(n);return c.jsx(Sf,{...o,...r,ref:t})});Kf.displayName=MS;var DS="MenuSub",[vT,Gf]=rr(DS),fo="MenuSubTrigger",Yf=m.forwardRef((e,t)=>{const n=or(fo,e.__scopeMenu),r=uo(fo,e.__scopeMenu),o=Gf(fo,e.__scopeMenu),s=La(fo,e.__scopeMenu),i=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},d=m.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return m.useEffect(()=>d,[d]),m.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),c.jsx(Ma,{asChild:!0,...u,children:c.jsx(Ff,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Zf(n.open),...e,ref:qi(t,o.onTriggerChange),onClick:f=>{var h;(h=e.onClick)==null||h.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:de(e.onPointerMove,ho(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:de(e.onPointerLeave,ho(f=>{var p,v;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const w=(v=n.content)==null?void 0:v.dataset.side,g=w==="right",x=g?-5:5,b=h[g?"left":"right"],S=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+x,y:f.clientY},{x:b,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:b,y:h.bottom}],side:w}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:de(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||gS[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});Yf.displayName=fo;var Xf="MenuSubContent",Jf=m.forwardRef((e,t)=>{const n=Pf(qt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=or(qt,e.__scopeMenu),i=uo(qt,e.__scopeMenu),a=Gf(Xf,e.__scopeMenu),l=m.useRef(null),u=We(t,l);return c.jsx(co.Provider,{scope:e.__scopeMenu,children:c.jsx($t,{present:r||s.open,children:c.jsx(co.Slot,{scope:e.__scopeMenu,children:c.jsx(Fa,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:de(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:de(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:de(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=xS[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});Jf.displayName=Xf;function Zf(e){return e?"open":"closed"}function Os(e){return e==="indeterminate"}function Ba(e){return Os(e)?"indeterminate":e?"checked":"unchecked"}function LS(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function FS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function $S(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=FS(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function zS(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],u=a.x,d=a.y,f=l.x,h=l.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function BS(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return zS(n,t)}function ho(e){return t=>t.pointerType==="mouse"?e(t):void 0}var HS=Rf,US=Ma,WS=Of,VS=Mf,qS=$a,KS=Df,GS=Ps,YS=$f,XS=Bf,JS=Uf,ZS=Vf,QS=qf,e0=Kf,t0=Yf,n0=Jf,Ms="DropdownMenu",[r0,wT]=fn(Ms,[jf]),jt=jf(),[o0,Qf]=r0(Ms),eh=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=jt(t),u=m.useRef(null),[d,f]=Jn({prop:o,defaultProp:s??!1,onChange:i,caller:Ms});return c.jsx(o0,{scope:t,triggerId:hn(),triggerRef:u,contentId:hn(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(HS,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};eh.displayName=Ms;var th="DropdownMenuTrigger",nh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Qf(th,n),i=jt(n);return c.jsx(US,{asChild:!0,...i,children:c.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:qi(t,s.triggerRef),onPointerDown:de(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:de(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});nh.displayName=th;var s0="DropdownMenuPortal",rh=e=>{const{__scopeDropdownMenu:t,...n}=e,r=jt(t);return c.jsx(WS,{...r,...n})};rh.displayName=s0;var oh="DropdownMenuContent",sh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qf(oh,n),s=jt(n),i=m.useRef(!1);return c.jsx(VS,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:de(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:de(e.onInteractOutside,a=>{const l=a.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,d=l.button===2||u;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});sh.displayName=oh;var i0="DropdownMenuGroup",a0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(qS,{...o,...r,ref:t})});a0.displayName=i0;var l0="DropdownMenuLabel",ih=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(KS,{...o,...r,ref:t})});ih.displayName=l0;var c0="DropdownMenuItem",ah=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(GS,{...o,...r,ref:t})});ah.displayName=c0;var u0="DropdownMenuCheckboxItem",lh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(YS,{...o,...r,ref:t})});lh.displayName=u0;var d0="DropdownMenuRadioGroup",f0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(XS,{...o,...r,ref:t})});f0.displayName=d0;var h0="DropdownMenuRadioItem",ch=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(JS,{...o,...r,ref:t})});ch.displayName=h0;var p0="DropdownMenuItemIndicator",uh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(ZS,{...o,...r,ref:t})});uh.displayName=p0;var m0="DropdownMenuSeparator",dh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(QS,{...o,...r,ref:t})});dh.displayName=m0;var g0="DropdownMenuArrow",x0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(e0,{...o,...r,ref:t})});x0.displayName=g0;var v0="DropdownMenuSubTrigger",fh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(t0,{...o,...r,ref:t})});fh.displayName=v0;var w0="DropdownMenuSubContent",hh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(n0,{...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)"}})});hh.displayName=w0;var b0=eh,y0=nh,S0=rh,ph=sh,mh=ih,gh=ah,xh=lh,vh=ch,wh=uh,bh=dh,yh=fh,Sh=hh;const C0=b0,T0=y0,k0=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(yh,{ref:o,className:Q("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,c.jsx(ie.ChevronRight,{className:"ml-auto h-4 w-4"})]}));k0.displayName=yh.displayName;const I0=m.forwardRef(({className:e,...t},n)=>c.jsx(Sh,{ref:n,className:Q("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));I0.displayName=Sh.displayName;const Ch=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(S0,{children:c.jsx(ph,{ref:r,sideOffset:t,className:Q("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Ch.displayName=ph.displayName;const Ha=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(gh,{ref:r,className:Q("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Ha.displayName=gh.displayName;const E0=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(xh,{ref:o,className:Q("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(wh,{children:c.jsx(ie.Check,{className:"h-4 w-4"})})}),t]}));E0.displayName=xh.displayName;const N0=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(vh,{ref:r,className:Q("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(wh,{children:c.jsx(ie.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));N0.displayName=vh.displayName;const A0=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(mh,{ref:r,className:Q("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));A0.displayName=mh.displayName;const j0=m.forwardRef(({className:e,...t},n)=>c.jsx(bh,{ref:n,className:Q("-mx-1 my-1 h-px bg-muted",e),...t}));j0.displayName=bh.displayName;function Ds({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:h,onError:p}){const{api:v}=fi(),{currentThreadId:w}=jo(),{threadId:g,messages:x,hasMore:b,isHistoryLoading:S,isLoading:N,loadOlder:C,listCheckpoints:k,navigateToCheckpoint:E,returnToLatest:A,checkpoint:j,respondToInterrupt:P,metadata:L}=_o(),{isStreaming:F,error:V,submit:M,stop:Y}=gc(),q=g??w??null,W=(j==null?void 0:j.id)??null,z=(j==null?void 0:j.namespace)??null,$=(L==null?void 0:L.assemblingMessageId)??null,[ue,D]=y.useState(null),[ee,fe]=y.useState(""),[ve,be]=y.useState(null),[ye,K]=y.useState([]),[O,J]=y.useState(0),[te,G]=y.useState(0),[se,Ve]=y.useState(!1),[Je,nt]=y.useState(null),[De,Be]=y.useState(null),[Ee,Ze]=y.useState(!1),[wt,ht]=y.useState(null),[Z,re]=y.useState([]),[pe,Ne]=y.useState(null),[we,Ae]=y.useState(null),[Qe,ze]=y.useState(!1),lt=y.useRef(null),St=y.useRef(null),Ht=y.useRef(null),gt=y.useCallback(()=>{lt.current&&(lt.current.value=""),St.current&&(St.current.value=""),J(ae=>ae+1),G(ae=>ae+1)},[]),_r=y.useRef(!1);y.useEffect(()=>{_r.current&&!F&&(K([]),gt()),_r.current=F},[F,gt]);const[lr,bt]=y.useState("desktop");y.useEffect(()=>{const ae=()=>{const Te=window.innerWidth;bt(Te<640?"phone":Te<1024?"tablet":"desktop")};return ae(),window.addEventListener("resize",ae),()=>window.removeEventListener("resize",ae)},[]),y.useEffect(()=>{let ae=!1;if(!q){re([]),Ne(null),Ae(null),Ht.current=null;return}const Te={threadId:q,checkpointId:W??null,checkpointNs:z??null},Oe=Ht.current;if(!(Oe&&Oe.threadId===Te.threadId&&Oe.checkpointId===Te.checkpointId&&Oe.checkpointNs===Te.checkpointNs))return k(q).then(rt=>{var ke;if(ae)return;const _t=((rt==null?void 0:rt.checkpoints)??[]).slice().sort((Fe,qe)=>new Date(qe.createdAt).getTime()-new Date(Fe.createdAt).getTime());re(_t);const I=pe,H=I&&_t.some(Fe=>Fe.checkpointId===I)?I:((ke=_t[0])==null?void 0:ke.checkpointId)??null;let oe=null;if(H){const Fe=_t.find(qe=>qe.checkpointId===H);oe=(Fe==null?void 0:Fe.checkpointNs)??null}Ne(H),Ae(oe),Ht.current=Te}).catch(rt=>{console.error("ChatInterface - listCheckpoints error:",rt),ae||(re([]),Ht.current=null)}),()=>{ae=!0}},[q,W,z,pe,k]),y.useEffect(()=>{W&&(Ne(W),Ae(z??null))},[W,z]);const bn=y.useCallback(async()=>{if(!(!b||S))try{await C()}catch(ae){console.warn("loadOlder failed",ae)}},[b,S,C]);y.useEffect(()=>{(async()=>{if(!v.baseUrl){ht(null);return}try{const Te=await v.getAgent("default");ht(Te.uiDefaultMessage||null)}catch(Te){console.warn("Failed to fetch default message:",Te),ht(null)}})()},[v]),y.useEffect(()=>{V&&!Ee&&(p==null||p(V))},[V,Ee,p]);const on=ae=>{if(ae.length>vs)return`Message too long (${ae.length}/${vs} characters)`;try{return Db(ae),null}catch(Te){return(Te==null?void 0:Te.message)||"Invalid message"}},cr=async ae=>{const Te=ae.trim();if(!(!Te&&ye.length===0)){if(Te){const Oe=on(Te);if(Oe){be(Oe);return}}try{await M({text:Te||"",attachments:ye,payload:ue?{edit:!0,originalMessageId:ue}:void 0},{checkpointId:pe??W??void 0,checkpointNs:we??z??void 0}),f==null||f(Te),be(null),K([]),gt(),D(null),fe("")}catch(Oe){const rt=(Oe==null?void 0:Oe.message)||"Failed to send message";be(rt),p==null||p(rt)}}},Nt=y.useCallback((ae,Te)=>{u&&(D(ae),fe(Te),be(null))},[u]),sn=y.useCallback(()=>{D(null),fe(""),be(null)},[]),Yt=y.useCallback((ae,Te)=>{Nt(ae,Te)},[Nt]),an=y.useCallback(ae=>{const Te=Oe=>{const rt=Oe.content||[],_t=rt.filter(I=>I.type==="text").map(I=>I.text).join("");if(_t)return _t;try{return JSON.stringify(rt,null,2)}catch{return String(rt)}};for(let Oe=ae-1;Oe>=0;Oe--)if(x[Oe].role==="user"){const rt=Te(x[Oe]);rt&&M({text:rt},{checkpointId:pe??W??void 0,checkpointNs:we??z??void 0});break}},[x,M,pe,we,W,z]),ur=ae=>{const Te=Array.from(ae.target.files||[]);K(Oe=>[...Oe,...Te]),ae.target.value=""},Rr=ae=>{K(Te=>{const Oe=Te.filter((rt,_t)=>ae!==_t);return Oe.length===0&>(),Oe})},Pr=async ae=>{const Te=(ae.target.files||[])[0];if(Te){nt(null),Be(null),Ve(!0);try{await M({attachments:[Te]},{checkpointId:pe??W??void 0,checkpointNs:we??z??void 0});const Oe=`Uploaded ${Te.name} - processing through chat stream`;Be(Oe)}catch(Oe){const rt=Oe instanceof Error?Oe.message:"Failed to upload Excel file";console.error("Excel upload failed",Oe),nt(rt),p==null||p(rt)}finally{Ve(!1),ae.target.value="",gt()}}},dr=ae=>{if(!ae)return"Unknown";const Te=Date.parse(ae);return Number.isNaN(Te)?ae:new Date(Te).toLocaleString()},En=async ae=>{if(w){ze(!0);try{if(!ae){await A(),Ne(null),Ae(null);return}const Te=Z.find(rt=>rt.checkpointId===ae),Oe=(Te==null?void 0:Te.checkpointNs)??null;await E(ae,Oe),Ne(ae),Ae(Oe)}finally{ze(!1)}}},Or=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,Nn=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${d.messagesArea||""}`,fr=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return c.jsxs("div",{className:Or,children:[!!V&&!Ee&&c.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[c.jsx("span",{children:V}),c.jsx(Ge,{variant:"ghost",size:"sm",onClick:()=>Ze(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(ie.X,{size:16})})]}),w&&Z.length>0&&c.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[c.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),c.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:pe??"",onChange:ae=>{const Te=ae.target.value||null;En(Te)},children:[c.jsx("option",{value:"",children:"Latest"}),Z.map(ae=>c.jsxs("option",{value:ae.checkpointId,children:[dr(ae.createdAt),ae.preview?` — ${ae.preview.slice(0,40)}`:""]},ae.checkpointId))]})]}),c.jsxs("div",{className:`relative ${Nn}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(xa,{className:"h-full",style:{height:"100%"},messages:x,isStreaming:F,streamingAssistantId:$,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:lr,enableMessageEditing:u,editingMessageId:ue,onStartReached:()=>{bn()},onEdit:Yt,onRegenerate:an,onCancelEdit:sn,emptyMessage:wt??void 0,isNavigatingCheckpoint:Qe}),N&&c.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[c.jsx(ie.Loader2,{className:"h-6 w-6 animate-spin"}),c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]})]}),c.jsxs("div",{className:fr,children:[ue&&c.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ie.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(Ge,{variant:"ghost",size:"sm",onClick:sn,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(ie.X,{size:16})})]})}),(a||l)&&c.jsxs("div",{className:"mb-3 space-y-3",children:[a&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:lt,type:"file",multiple:!0,onChange:ae=>ur(ae),className:"hidden"},O),ye.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:ye.map((ae,Te)=>c.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[c.jsx(ie.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:ae.name}),c.jsx(Ge,{variant:"ghost",size:"sm",onClick:()=>Rr(Te),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 ${ae.name}`,children:c.jsx(ie.X,{size:12})})]},Te))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:St,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Pr,className:"hidden"},te),se&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(ie.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),De&&!se&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:De}),Je&&!se&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Je})]})]}),ve&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:ve}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(C0,{children:[c.jsx(T0,{asChild:!0,children:c.jsx(Ge,{type:"button",size:"icon",variant:"outline",disabled:F,title:"More input actions",className:d.moreButton||"",children:c.jsx(ie.Plus,{size:16})})}),c.jsxs(Ch,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(Ha,{onClick:()=>{var ae;return(ae=lt.current)==null?void 0:ae.click()},className:"cursor-pointer",children:[c.jsx(ie.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(Ha,{onClick:()=>{var ae;se||(ae=St.current)==null||ae.click()},className:`cursor-pointer ${se?"opacity-60 pointer-events-none":""}`,children:[c.jsx(ie.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx(Yg,{initialValue:ee,editingMessageId:ue,placeholder:ue?"Edit your message...":t,isStreaming:F,disabled:!1,maxLength:vs,onSend:cr,onCancelEdit:sn,onStop:Y,allowEmptySend:ye.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${ue?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${ve?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const Ls=m.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:Q("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Ls.displayName="Input";function Ua(e,[t,n]){return Math.min(n,Math.max(t,e))}function _0(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Wa="ScrollArea",[Th,bT]=fn(Wa),[R0,Kt]=Th(Wa),kh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=m.useState(null),[u,d]=m.useState(null),[f,h]=m.useState(null),[p,v]=m.useState(null),[w,g]=m.useState(null),[x,b]=m.useState(0),[S,N]=m.useState(0),[C,k]=m.useState(!1),[E,A]=m.useState(!1),j=We(t,L=>l(L)),P=ws(o);return c.jsx(R0,{scope:n,type:r,dir:P,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:k,scrollbarY:w,onScrollbarYChange:g,scrollbarYEnabled:E,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:N,children:c.jsx(_e.div,{dir:P,...i,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});kh.displayName=Wa;var Ih="ScrollAreaViewport",Eh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Kt(Ih,n),a=m.useRef(null),l=We(t,a,i.onViewportChange);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),c.jsx(_e.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:c.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Eh.displayName=Ih;var wn="ScrollAreaScrollbar",Va=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Kt(wn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return m.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?c.jsx(P0,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(O0,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(Nh,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(qa,{...r,ref:t}):null});Va.displayName=wn;var P0=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Kt(wn,e.__scopeScrollArea),[s,i]=m.useState(!1);return m.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const u=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),c.jsx($t,{present:n||s,children:c.jsx(Nh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),O0=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Kt(wn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Bs(()=>l("SCROLL_END"),100),[a,l]=_0("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return m.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,l]),m.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const p=u[d];f!==p&&(l("SCROLL"),i()),f=p};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),c.jsx($t,{present:n||a!=="hidden",children:c.jsx(qa,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:de(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:de(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Nh=m.forwardRef((e,t)=>{const n=Kt(wn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",l=Bs(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return Nr(n.viewport,l),Nr(n.content,l),c.jsx($t,{present:r||s,children:c.jsx(qa,{"data-state":s?"visible":"hidden",...o,ref:t})})}),qa=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Kt(wn,e.__scopeScrollArea),s=m.useRef(null),i=m.useRef(0),[a,l]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=Ph(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:u>0&&u<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return z0(h,i.current,a,p)}return n==="horizontal"?c.jsx(M0,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=Oh(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?c.jsx(D0,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=Oh(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),M0=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Kt(wn,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=We(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(jh,{"data-orientation":"horizontal",...o,ref:u,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":zs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(h),Dh(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:$s(i.paddingLeft),paddingEnd:$s(i.paddingRight)}})}})}),D0=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Kt(wn,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=We(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(jh,{"data-orientation":"vertical",...o,ref:u,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":zs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(h),Dh(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:$s(i.paddingTop),paddingEnd:$s(i.paddingBottom)}})}})}),[L0,Ah]=Th(wn),jh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,p=Kt(wn,n),[v,w]=m.useState(null),g=We(t,j=>w(j)),x=m.useRef(null),b=m.useRef(""),S=p.viewport,N=r.content-r.viewport,C=yt(d),k=yt(l),E=Bs(f,10);function A(j){if(x.current){const P=j.clientX-x.current.left,L=j.clientY-x.current.top;u({x:P,y:L})}}return m.useEffect(()=>{const j=P=>{const L=P.target;(v==null?void 0:v.contains(L))&&C(P,N)};return document.addEventListener("wheel",j,{passive:!1}),()=>document.removeEventListener("wheel",j,{passive:!1})},[S,v,N,C]),m.useEffect(k,[r,k]),Nr(v,E),Nr(p.content,E),c.jsx(L0,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:yt(s),onThumbPointerUp:yt(i),onThumbPositionChange:k,onThumbPointerDown:yt(a),children:c.jsx(_e.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:de(e.onPointerDown,j=>{j.button===0&&(j.target.setPointerCapture(j.pointerId),x.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(j))}),onPointerMove:de(e.onPointerMove,A),onPointerUp:de(e.onPointerUp,j=>{const P=j.target;P.hasPointerCapture(j.pointerId)&&P.releasePointerCapture(j.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),x.current=null})})})}),Fs="ScrollAreaThumb",_h=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ah(Fs,e.__scopeScrollArea);return c.jsx($t,{present:n||o.hasThumb,children:c.jsx(F0,{ref:t,...r})})}),F0=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Kt(Fs,n),i=Ah(Fs,n),{onThumbPositionChange:a}=i,l=We(t,f=>i.onThumbChange(f)),u=m.useRef(void 0),d=Bs(()=>{u.current&&(u.current(),u.current=void 0)},100);return m.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const p=B0(f,a);u.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),c.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:de(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),v=f.clientX-p.left,w=f.clientY-p.top;i.onThumbPointerDown({x:v,y:w})}),onPointerUp:de(e.onPointerUp,i.onThumbPointerUp)})});_h.displayName=Fs;var Ka="ScrollAreaCorner",Rh=m.forwardRef((e,t)=>{const n=Kt(Ka,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx($0,{...e,ref:t}):null});Rh.displayName=Ka;var $0=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Kt(Ka,n),[s,i]=m.useState(0),[a,l]=m.useState(0),u=!!(s&&a);return Nr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Nr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?c.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 $s(e){return e?parseInt(e,10):0}function Ph(e,t){const n=e/t;return isNaN(n)?0:n}function zs(e){const t=Ph(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function z0(e,t,n,r="ltr"){const o=zs(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return Mh([l,u],f)(e)}function Oh(e,t,n="ltr"){const r=zs(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],u=Ua(e,l);return Mh([0,i],[0,a])(u)}function Mh(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Dh(e,t){return e>0&&e<t}var B0=(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 Bs(e,t){const n=yt(e),r=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),m.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Nr(e,t){const n=yt(t);vt(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var Lh=kh,H0=Eh,U0=Rh;const Fh=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Lh,{ref:r,className:Q("relative overflow-hidden",e),...n,children:[c.jsx(H0,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx($h,{}),c.jsx(U0,{})]}));Fh.displayName=Lh.displayName;const $h=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(Va,{ref:r,orientation:t,className:Q("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:c.jsx(_h,{className:"relative flex-1 rounded-full bg-border"})}));$h.displayName=Va.displayName;function Ga({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:u,onThreadDelete:d}){const{threads:f,currentThreadId:h,isLoading:p,actions:v}=jo(),{loadThread:w}=_o(),{createThread:g,deleteThread:x,renameThread:b}=v,[S,N]=y.useState(Array.isArray(f)?f:[]),C=y.useRef(S.length>0),[k,E]=y.useState(null),[A,j]=y.useState(""),[P,L]=y.useState(!1);y.useEffect(()=>{const D=Array.isArray(f)?f:[];if(D.length>0){C.current=!0,N(D);return}p||(C.current=!1,N(D))},[f,p]);const F=async D=>{try{await w(D),a==null||a(D),l==null||l(D)}catch(ee){console.error("Failed to select thread:",ee)}},V=async()=>{try{L(!0);const D=await g();u==null||u(D),a==null||a(D)}catch(D){console.error("Failed to create thread:",D)}finally{L(!1)}},M=async(D,ee)=>{if(ee.stopPropagation(),!!confirm("Delete this thread?"))try{await x(D),d==null||d(D)}catch(fe){console.error("Failed to delete thread:",fe)}},Y=(D,ee)=>{ee.stopPropagation(),E(D.threadId),j(D.title||`Thread ${D.threadId.slice(0,8)}`)},q=async D=>{if(A.trim())try{await b(D,A.trim()),E(null),j("")}catch(ee){console.error("Failed to update title:",ee)}},W=()=>{E(null),j("")},z=(D,ee)=>{D.key==="Enter"?q(ee):D.key==="Escape"&&W()},$=D=>{if(!D)return"";try{const ee=new Date(D),ve=new Date().getTime()-ee.getTime(),be=Math.floor(ve/(1e3*60*60*24));return be===0?ee.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):be===1?"Yesterday":be<7?`${be} days ago`:ee.toLocaleDateString()}catch{return""}},ue=D=>D.title||`Thread ${D.threadId.slice(0,8)}`;return c.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&c.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:c.jsx(Ge,{onClick:V,disabled:P||p,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:P?"Creating...":"New Chat",children:c.jsx(ie.MessageSquarePlus,{size:20})})}),c.jsx(Fh,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:c.jsx("div",{className:"p-2 space-y-1 pb-4",children:p?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(ie.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):S.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(ie.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),c.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):S.slice().sort((D,ee)=>new Date(ee.updatedAt||ee.createdAt||"").getTime()-new Date(D.updatedAt||D.createdAt||"").getTime()).map(D=>c.jsxs("div",{onClick:()=>F(D.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??h)===D.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"flex-1 min-w-0",children:k===D.threadId?c.jsxs("div",{className:"flex items-center gap-2",onClick:ee=>ee.stopPropagation(),children:[c.jsx(Ls,{value:A,onChange:ee=>j(ee.target.value),onKeyDown:ee=>z(ee,D.threadId),className:"h-6 text-sm",autoFocus:!0}),c.jsx(Ge,{variant:"ghost",size:"sm",onClick:()=>q(D.threadId),className:"h-6 w-6 p-0",children:c.jsx(ie.Check,{size:12})}),c.jsx(Ge,{variant:"ghost",size:"sm",onClick:W,className:"h-6 w-6 p-0",children:c.jsx(ie.X,{size:12})})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:ue(D)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(ie.Calendar,{size:10}),c.jsx("span",{children:$(D.updatedAt||D.createdAt)})]})]})}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&k!==D.threadId&&c.jsx(Ge,{variant:"ghost",size:"sm",onClick:ee=>Y(D,ee),className:"h-6 w-6 p-0",title:"Edit title",children:c.jsx(ie.Edit3,{size:12})}),n&&c.jsx(Ge,{variant:"ghost",size:"sm",onClick:ee=>M(D.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:c.jsx(ie.Trash2,{size:12})})]})]}),i===D.threadId&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},D.threadId))})})]})}function Ar(e){if(!(typeof globalThis>"u"))return globalThis[e]}function W0(e){if(typeof e!="string")return;const t=e.trim();if(t)return Cn(t)}function zh(){const e=[Ar("__API_BASE_URL__"),Ar("__CHAT_API_BASE_URL__"),Ar("__CHAT_API_URL__")];for(const t of e){const n=W0(t);if(n)return n}}function Bh(){const e=[Ar("__API_AUTH_TOKEN__"),Ar("__CHAT_API_KEY__"),Ar("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Hh(...e){for(const t of e)if(typeof t=="string"&&t.trim())return Cn(t);return Cn()}function Uh(){const e={},t=zh(),n=Bh();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Wh(){const e=Uh(),t=jn.getAuthToken(),n=zh();return{apiBaseUrl:Hh(e.baseUrl,jn.baseUrl,n),apiKey:t||e.apiKey||Bh()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const Vh="chat-settings";function V0(){try{const e=localStorage.getItem(Vh);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function q0(e){try{const t={...e,apiBaseUrl:Cn(e.apiBaseUrl)};localStorage.setItem(Vh,JSON.stringify(t)),t.apiKey&&jn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function K0(){const e=Wh(),t=V0(),n=jn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Hh(jn.baseUrl,r,e.apiBaseUrl)}}function G0(e){jn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),q0(e)}var Y0="Label",qh=m.forwardRef((e,t)=>c.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())}}));qh.displayName=Y0;var Kh=qh;const X0=mo.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Gt=m.forwardRef(({className:e,...t},n)=>c.jsx(Kh,{ref:n,className:Q(X0(),e),...t}));Gt.displayName=Kh.displayName;function Gh(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Hs="Switch",[J0,yT]=fn(Hs),[Z0,Q0]=J0(Hs),Yh=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:u,form:d,...f}=e,[h,p]=m.useState(null),v=We(t,S=>p(S)),w=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[x,b]=Jn({prop:o,defaultProp:s??!1,onChange:u,caller:Hs});return c.jsxs(Z0,{scope:n,checked:x,disabled:a,children:[c.jsx(_e.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":Qh(x),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:v,onClick:de(e.onClick,S=>{b(N=>!N),g&&(w.current=S.isPropagationStopped(),w.current||S.stopPropagation())})}),g&&c.jsx(Zh,{control:h,bubbles:!w.current,name:r,value:l,checked:x,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Yh.displayName=Hs;var Xh="SwitchThumb",Jh=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=Q0(Xh,n);return c.jsx(_e.span,{"data-state":Qh(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Jh.displayName=Xh;var eC="SwitchBubbleInput",Zh=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=We(i,s),l=Gh(n),u=cf(t);return m.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const v=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(v)}},[l,n,r]),c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Zh.displayName=eC;function Qh(e){return e?"checked":"unchecked"}var ep=Yh,tC=Jh;const zn=m.forwardRef(({className:e,...t},n)=>c.jsx(ep,{className:Q("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:c.jsx(tC,{className:Q("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));zn.displayName=ep.displayName;var tp=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),nC="VisuallyHidden",rC=m.forwardRef((e,t)=>c.jsx(_e.span,{...e,ref:t,style:{...tp,...e.style}}));rC.displayName=nC;var oC=[" ","Enter","ArrowUp","ArrowDown"],sC=[" ","Enter"],sr="Select",[Us,Ws,iC]=va(sr),[jr,ST]=fn(sr,[iC,js]),Vs=js(),[aC,Bn]=jr(sr),[lC,cC]=jr(sr),np=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:u,name:d,autoComplete:f,disabled:h,required:p,form:v}=e,w=Vs(t),[g,x]=m.useState(null),[b,S]=m.useState(null),[N,C]=m.useState(!1),k=ws(u),[E,A]=Jn({prop:r,defaultProp:o??!1,onChange:s,caller:sr}),[j,P]=Jn({prop:i,defaultProp:a,onChange:l,caller:sr}),L=m.useRef(null),F=g?v||!!g.closest("form"):!0,[V,M]=m.useState(new Set),Y=Array.from(V).map(q=>q.props.value).join(";");return c.jsx(wf,{...w,children:c.jsxs(aC,{required:p,scope:t,trigger:g,onTriggerChange:x,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:N,onValueNodeHasChildrenChange:C,contentId:hn(),value:j,onValueChange:P,open:E,onOpenChange:A,dir:k,triggerPointerDownPosRef:L,disabled:h,children:[c.jsx(Us.Provider,{scope:t,children:c.jsx(lC,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(q=>{M(W=>new Set(W).add(q))},[]),onNativeOptionRemove:m.useCallback(q=>{M(W=>{const z=new Set(W);return z.delete(q),z})},[]),children:n})}),F?c.jsxs(Ip,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:j,onChange:q=>P(q.target.value),disabled:h,form:v,children:[j===void 0?c.jsx("option",{value:""}):null,Array.from(V)]},Y):null]})})};np.displayName=sr;var rp="SelectTrigger",op=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Vs(n),i=Bn(rp,n),a=i.disabled||r,l=We(t,i.onTriggerChange),u=Ws(n),d=m.useRef("touch"),[f,h,p]=Np(w=>{const g=u().filter(S=>!S.disabled),x=g.find(S=>S.value===i.value),b=Ap(g,w,x);b!==void 0&&i.onValueChange(b.value)}),v=w=>{a||(i.onOpenChange(!0),p()),w&&(i.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return c.jsx(bf,{asChild:!0,...s,children:c.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":Ep(i.value)?"":void 0,...o,ref:l,onClick:de(o.onClick,w=>{w.currentTarget.focus(),d.current!=="mouse"&&v(w)}),onPointerDown:de(o.onPointerDown,w=>{d.current=w.pointerType;const g=w.target;g.hasPointerCapture(w.pointerId)&&g.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(v(w),w.preventDefault())}),onKeyDown:de(o.onKeyDown,w=>{const g=f.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&h(w.key),!(g&&w.key===" ")&&oC.includes(w.key)&&(v(),w.preventDefault())})})})});op.displayName=rp;var sp="SelectValue",ip=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Bn(sp,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=We(t,l.onValueNodeChange);return vt(()=>{u(d)},[u,d]),c.jsx(_e.span,{...a,ref:f,style:{pointerEvents:"none"},children:Ep(l.value)?c.jsx(c.Fragment,{children:i}):s})});ip.displayName=sp;var uC="SelectIcon",ap=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(_e.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});ap.displayName=uC;var dC="SelectPortal",lp=e=>c.jsx(rs,{asChild:!0,...e});lp.displayName=dC;var ir="SelectContent",cp=m.forwardRef((e,t)=>{const n=Bn(ir,e.__scopeSelect),[r,o]=m.useState();if(vt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?go.createPortal(c.jsx(up,{scope:e.__scopeSelect,children:c.jsx(Us.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(dp,{...e,ref:t})});cp.displayName=ir;var rn=10,[up,Hn]=jr(ir),fC="SelectContentImpl",hC=Un.createSlot("SelectContent.RemoveScroll"),dp=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:w,avoidCollisions:g,...x}=e,b=Bn(ir,n),[S,N]=m.useState(null),[C,k]=m.useState(null),E=We(t,K=>N(K)),[A,j]=m.useState(null),[P,L]=m.useState(null),F=Ws(n),[V,M]=m.useState(!1),Y=m.useRef(!1);m.useEffect(()=>{if(S)return fa(S)},[S]),ia();const q=m.useCallback(K=>{const[O,...J]=F().map(se=>se.ref.current),[te]=J.slice(-1),G=document.activeElement;for(const se of K)if(se===G||(se==null||se.scrollIntoView({block:"nearest"}),se===O&&C&&(C.scrollTop=0),se===te&&C&&(C.scrollTop=C.scrollHeight),se==null||se.focus(),document.activeElement!==G))return},[F,C]),W=m.useCallback(()=>q([A,S]),[q,A,S]);m.useEffect(()=>{V&&W()},[V,W]);const{onOpenChange:z,triggerPointerDownPosRef:$}=b;m.useEffect(()=>{if(S){let K={x:0,y:0};const O=te=>{var G,se;K={x:Math.abs(Math.round(te.pageX)-(((G=$.current)==null?void 0:G.x)??0)),y:Math.abs(Math.round(te.pageY)-(((se=$.current)==null?void 0:se.y)??0))}},J=te=>{K.x<=10&&K.y<=10?te.preventDefault():S.contains(te.target)||z(!1),document.removeEventListener("pointermove",O),$.current=null};return $.current!==null&&(document.addEventListener("pointermove",O),document.addEventListener("pointerup",J,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",O),document.removeEventListener("pointerup",J,{capture:!0})}}},[S,z,$]),m.useEffect(()=>{const K=()=>z(!1);return window.addEventListener("blur",K),window.addEventListener("resize",K),()=>{window.removeEventListener("blur",K),window.removeEventListener("resize",K)}},[z]);const[ue,D]=Np(K=>{const O=F().filter(G=>!G.disabled),J=O.find(G=>G.ref.current===document.activeElement),te=Ap(O,K,J);te&&setTimeout(()=>te.ref.current.focus())}),ee=m.useCallback((K,O,J)=>{const te=!Y.current&&!J;(b.value!==void 0&&b.value===O||te)&&(j(K),te&&(Y.current=!0))},[b.value]),fe=m.useCallback(()=>S==null?void 0:S.focus(),[S]),ve=m.useCallback((K,O,J)=>{const te=!Y.current&&!J;(b.value!==void 0&&b.value===O||te)&&L(K)},[b.value]),be=r==="popper"?Ya:fp,ye=be===Ya?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:w,avoidCollisions:g}:{};return c.jsx(up,{scope:n,content:S,viewport:C,onViewportChange:k,itemRefCallback:ee,selectedItem:A,onItemLeave:fe,itemTextRefCallback:ve,focusSelectedItem:W,selectedItemText:P,position:r,isPositioned:V,searchRef:ue,children:c.jsx(cs,{as:hC,allowPinchZoom:!0,children:c.jsx(ns,{asChild:!0,trapped:b.open,onMountAutoFocus:K=>{K.preventDefault()},onUnmountAutoFocus:de(o,K=>{var O;(O=b.trigger)==null||O.focus({preventScroll:!0}),K.preventDefault()}),children:c.jsx(ts,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:K=>K.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:c.jsx(be,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:K=>K.preventDefault(),...x,...ye,onPlaced:()=>M(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:de(x.onKeyDown,K=>{const O=K.ctrlKey||K.altKey||K.metaKey;if(K.key==="Tab"&&K.preventDefault(),!O&&K.key.length===1&&D(K.key),["ArrowUp","ArrowDown","Home","End"].includes(K.key)){let te=F().filter(G=>!G.disabled).map(G=>G.ref.current);if(["ArrowUp","End"].includes(K.key)&&(te=te.slice().reverse()),["ArrowUp","ArrowDown"].includes(K.key)){const G=K.target,se=te.indexOf(G);te=te.slice(se+1)}setTimeout(()=>q(te)),K.preventDefault()}})})})})})})});dp.displayName=fC;var pC="SelectItemAlignedPosition",fp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Bn(ir,n),i=Hn(ir,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=We(t,E=>d(E)),h=Ws(n),p=m.useRef(!1),v=m.useRef(!0),{viewport:w,selectedItem:g,selectedItemText:x,focusSelectedItem:b}=i,S=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&w&&g&&x){const E=s.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),j=s.valueNode.getBoundingClientRect(),P=x.getBoundingClientRect();if(s.dir!=="rtl"){const G=P.left-A.left,se=j.left-G,Ve=E.left-se,Je=E.width+Ve,nt=Math.max(Je,A.width),De=window.innerWidth-rn,Be=Ua(se,[rn,Math.max(rn,De-nt)]);a.style.minWidth=Je+"px",a.style.left=Be+"px"}else{const G=A.right-P.right,se=window.innerWidth-j.right-G,Ve=window.innerWidth-E.right-se,Je=E.width+Ve,nt=Math.max(Je,A.width),De=window.innerWidth-rn,Be=Ua(se,[rn,Math.max(rn,De-nt)]);a.style.minWidth=Je+"px",a.style.right=Be+"px"}const L=h(),F=window.innerHeight-rn*2,V=w.scrollHeight,M=window.getComputedStyle(u),Y=parseInt(M.borderTopWidth,10),q=parseInt(M.paddingTop,10),W=parseInt(M.borderBottomWidth,10),z=parseInt(M.paddingBottom,10),$=Y+q+V+z+W,ue=Math.min(g.offsetHeight*5,$),D=window.getComputedStyle(w),ee=parseInt(D.paddingTop,10),fe=parseInt(D.paddingBottom,10),ve=E.top+E.height/2-rn,be=F-ve,ye=g.offsetHeight/2,K=g.offsetTop+ye,O=Y+q+K,J=$-O;if(O<=ve){const G=L.length>0&&g===L[L.length-1].ref.current;a.style.bottom="0px";const se=u.clientHeight-w.offsetTop-w.offsetHeight,Ve=Math.max(be,ye+(G?fe:0)+se+W),Je=O+Ve;a.style.height=Je+"px"}else{const G=L.length>0&&g===L[0].ref.current;a.style.top="0px";const Ve=Math.max(ve,Y+w.offsetTop+(G?ee:0)+ye)+J;a.style.height=Ve+"px",w.scrollTop=O-ve+w.offsetTop}a.style.margin=`${rn}px 0`,a.style.minHeight=ue+"px",a.style.maxHeight=F+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,w,g,x,s.dir,r]);vt(()=>S(),[S]);const[N,C]=m.useState();vt(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const k=m.useCallback(E=>{E&&v.current===!0&&(S(),b==null||b(),v.current=!1)},[S,b]);return c.jsx(gC,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:k,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:N},children:c.jsx(_e.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});fp.displayName=pC;var mC="SelectPopperPosition",Ya=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=rn,...s}=e,i=Vs(n);return c.jsx(yf,{...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)"}})});Ya.displayName=mC;var[gC,Xa]=jr(ir,{}),Ja="SelectViewport",hp=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Hn(Ja,n),i=Xa(Ja,n),a=We(t,s.onViewportChange),l=m.useRef(0);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),c.jsx(Us.Slot,{scope:n,children:c.jsx(_e.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:de(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const v=window.innerHeight-rn*2,w=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),x=Math.max(w,g);if(x<v){const b=x+p,S=Math.min(v,b),N=b-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=N>0?N:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});hp.displayName=Ja;var pp="SelectGroup",[xC,vC]=jr(pp),wC=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=hn();return c.jsx(xC,{scope:n,id:o,children:c.jsx(_e.div,{role:"group","aria-labelledby":o,...r,ref:t})})});wC.displayName=pp;var mp="SelectLabel",gp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=vC(mp,n);return c.jsx(_e.div,{id:o.id,...r,ref:t})});gp.displayName=mp;var qs="SelectItem",[bC,xp]=jr(qs),vp=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Bn(qs,n),l=Hn(qs,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),v=We(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),w=hn(),g=m.useRef("touch"),x=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return c.jsx(bC,{scope:n,value:r,disabled:o,textId:w,isSelected:u,onItemTextChange:m.useCallback(b=>{f(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:c.jsx(Us.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(_e.div,{role:"option","aria-labelledby":w,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:de(i.onFocus,()=>p(!0)),onBlur:de(i.onBlur,()=>p(!1)),onClick:de(i.onClick,()=>{g.current!=="mouse"&&x()}),onPointerUp:de(i.onPointerUp,()=>{g.current==="mouse"&&x()}),onPointerDown:de(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:de(i.onPointerMove,b=>{var S;g.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):g.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:de(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:de(i.onKeyDown,b=>{var N;((N=l.searchRef)==null?void 0:N.current)!==""&&b.key===" "||(sC.includes(b.key)&&x(),b.key===" "&&b.preventDefault())})})})})});vp.displayName=qs;var po="SelectItemText",wp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Bn(po,n),a=Hn(po,n),l=xp(po,n),u=cC(po,n),[d,f]=m.useState(null),h=We(t,x=>f(x),l.onItemTextChange,x=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,x,l.value,l.disabled)}),p=d==null?void 0:d.textContent,v=m.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:w,onNativeOptionRemove:g}=u;return vt(()=>(w(v),()=>g(v)),[w,g,v]),c.jsxs(c.Fragment,{children:[c.jsx(_e.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?go.createPortal(s.children,i.valueNode):null]})});wp.displayName=po;var bp="SelectItemIndicator",yp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return xp(bp,n).isSelected?c.jsx(_e.span,{"aria-hidden":!0,...r,ref:t}):null});yp.displayName=bp;var Za="SelectScrollUpButton",Sp=m.forwardRef((e,t)=>{const n=Hn(Za,e.__scopeSelect),r=Xa(Za,e.__scopeSelect),[o,s]=m.useState(!1),i=We(t,r.onScrollButtonChange);return vt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollTop>0;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(Tp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Sp.displayName=Za;var Qa="SelectScrollDownButton",Cp=m.forwardRef((e,t)=>{const n=Hn(Qa,e.__scopeSelect),r=Xa(Qa,e.__scopeSelect),[o,s]=m.useState(!1),i=We(t,r.onScrollButtonChange);return vt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<u;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(Tp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Cp.displayName=Qa;var Tp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Hn("SelectScrollButton",n),i=m.useRef(null),a=Ws(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),vt(()=>{var d;const u=a().find(f=>f.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),c.jsx(_e.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:de(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:de(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:de(o.onPointerLeave,()=>{l()})})}),yC="SelectSeparator",kp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(_e.div,{"aria-hidden":!0,...r,ref:t})});kp.displayName=yC;var el="SelectArrow",SC=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Vs(n),s=Bn(el,n),i=Hn(el,n);return s.open&&i.position==="popper"?c.jsx(Sf,{...o,...r,ref:t}):null});SC.displayName=el;var CC="SelectBubbleInput",Ip=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=We(r,o),i=Gh(t);return m.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(_e.select,{...n,style:{...tp,...n.style},ref:s,defaultValue:t})});Ip.displayName=CC;function Ep(e){return e===""||e===void 0}function Np(e){const t=yt(e),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(i=>{const a=n.current+i;t(a),function l(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Ap(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=TC(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function TC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var kC=np,jp=op,IC=ip,EC=ap,NC=lp,_p=cp,AC=hp,Rp=gp,Pp=vp,jC=wp,_C=yp,Op=Sp,Mp=Cp,Dp=kp;const Lp=kC,Fp=IC,tl=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(jp,{ref:r,className:Q("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,c.jsx(EC,{asChild:!0,children:c.jsx(ie.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));tl.displayName=jp.displayName;const $p=m.forwardRef(({className:e,...t},n)=>c.jsx(Op,{ref:n,className:Q("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ie.ChevronUp,{className:"h-4 w-4"})}));$p.displayName=Op.displayName;const zp=m.forwardRef(({className:e,...t},n)=>c.jsx(Mp,{ref:n,className:Q("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ie.ChevronDown,{className:"h-4 w-4"})}));zp.displayName=Mp.displayName;const nl=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(NC,{children:c.jsxs(_p,{ref:o,className:Q("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[c.jsx($p,{}),c.jsx(AC,{className:Q("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(zp,{})]})}));nl.displayName=_p.displayName;const RC=m.forwardRef(({className:e,...t},n)=>c.jsx(Rp,{ref:n,className:Q("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));RC.displayName=Rp.displayName;const ar=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Pp,{ref:r,className:Q("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(_C,{children:c.jsx(ie.Check,{className:"h-4 w-4"})})}),c.jsx(jC,{children:t})]}));ar.displayName=Pp.displayName;const PC=m.forwardRef(({className:e,...t},n)=>c.jsx(Dp,{ref:n,className:Q("-mx-1 my-1 h-px bg-muted",e),...t}));PC.displayName=Dp.displayName;var OC="Separator",Bp="horizontal",MC=["horizontal","vertical"],Hp=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=Bp,...o}=e,s=DC(r)?r:Bp,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(_e.div,{"data-orientation":s,...a,...o,ref:t})});Hp.displayName=OC;function DC(e){return MC.includes(e)}var Up=Hp;const Wp=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(Up,{ref:o,decorative:n,orientation:t,className:Q("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Wp.displayName=Up.displayName;const LC=Id,FC=xb,$C=Ed,Vp=m.forwardRef(({className:e,...t},n)=>c.jsx(ps,{className:Q("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));Vp.displayName=ps.displayName;const zC=mo.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"}}),qp=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs($C,{children:[c.jsx(Vp,{}),c.jsxs(ms,{ref:o,className:Q(zC({side:e}),t),...r,children:[n,c.jsxs(Nd,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[c.jsx(ie.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));qp.displayName=ms.displayName;const Kp=({className:e,...t})=>c.jsx("div",{className:Q("flex flex-col space-y-2 text-center sm:text-left",e),...t});Kp.displayName="SheetHeader";const Gp=m.forwardRef(({className:e,...t},n)=>c.jsx(er,{ref:n,className:Q("text-lg font-semibold text-foreground",e),...t}));Gp.displayName=er.displayName;const Yp=m.forwardRef(({className:e,...t},n)=>c.jsx(gs,{ref:n,className:Q("text-sm text-muted-foreground",e),...t}));Yp.displayName=gs.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]=y.useState(!1),[s,i]=y.useState(!1),[a,l]=y.useState(e),[u,d]=y.useState(!1),{toast:f}=ta();y.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),y.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(BC),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},v=()=>{l(e),d(!1),o(!1)},w=async()=>{try{const x=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${x.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return c.jsxs(LC,{open:r,onOpenChange:o,children:[c.jsx(FC,{asChild:!0,children:c.jsxs(Ge,{variant:"outline",size:"sm",className:n,children:[c.jsx(ie.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(Vi,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(qp,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(Kp,{children:[c.jsx(Gp,{children:"Chat Settings"}),c.jsx(Yp,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),c.jsxs("div",{className:"space-y-6 py-6",children:[c.jsxs(Qr,{children:[c.jsx(eo,{className:"pb-3",children:c.jsxs(to,{className:"text-lg flex items-center gap-2",children:[c.jsx(ie.Server,{className:"h-5 w-5"}),"API Configuration"]})}),c.jsxs(Go,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Gt,{htmlFor:"api-url",children:"API Base URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ls,{id:"api-url",value:a.api.baseUrl,onChange:g=>l(x=>({...x,api:{...x.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(Ge,{variant:"outline",onClick:w,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Gt,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(zn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>l(x=>({...x,api:{...x.api,enableAuth:g}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(Gt,{htmlFor:"auth-token",children:"Authentication Token"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ls,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>l(x=>({...x,api:{...x.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(Ge,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(ie.EyeOff,{className:"h-4 w-4"}):c.jsx(ie.Eye,{className:"h-4 w-4"})})]})]})]})]}),c.jsxs(Qr,{children:[c.jsx(eo,{className:"pb-3",children:c.jsxs(to,{className:"text-lg flex items-center gap-2",children:[c.jsx(ie.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),c.jsxs(Go,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Gt,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(Lp,{value:a.ui.layout,onValueChange:g=>l(x=>({...x,ui:{...x.ui,layout:g}})),children:[c.jsx(tl,{children:c.jsx(Fp,{})}),c.jsxs(nl,{children:[c.jsx(ar,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(ar,{value:"fullscreen",children:"Fullscreen"}),c.jsx(ar,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Gt,{htmlFor:"theme",children:"Theme"}),c.jsxs(Lp,{value:a.ui.theme,onValueChange:g=>l(x=>({...x,ui:{...x.ui,theme:g}})),children:[c.jsx(tl,{children:c.jsx(Fp,{})}),c.jsxs(nl,{children:[c.jsx(ar,{value:"light",children:"Light"}),c.jsx(ar,{value:"dark",children:"Dark"}),c.jsx(ar,{value:"system",children:"System"})]})]})]}),c.jsx(Wp,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Gt,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(zn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,showTimestamps:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Gt,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(zn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,showAgentNames:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Gt,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(zn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,compactMessages:g}}))})]})]})]})]}),c.jsxs(Qr,{children:[c.jsx(eo,{className:"pb-3",children:c.jsxs(to,{className:"text-lg flex items-center gap-2",children:[c.jsx(ie.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),c.jsxs(Go,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Gt,{htmlFor:"auto-save",children:"Auto-save Conversations"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),c.jsx(zn,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,autoSave:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Gt,{htmlFor:"enable-streaming",children:"Enable Streaming"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),c.jsx(zn,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,enableStreaming:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Gt,{htmlFor:"typing-indicator",children:"Typing Indicator"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),c.jsx(zn,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,showTypingIndicator:g}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(Ge,{variant:"outline",onClick:p,children:[c.jsx(ie.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ge,{variant:"outline",onClick:v,children:"Cancel"}),c.jsxs(Ge,{onClick:h,disabled:!u,children:[c.jsx(ie.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function UC({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),l=y.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?c.jsx(Ro,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsx(Ds,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?c.jsx(Ro,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&c.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(Ga,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(Ds,{onError:s.onError,enableFileUpload:!0})})]})})}):c.jsx(Ro,{...s,onThreadChange:l,children:c.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&c.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(Ga,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(Ds,{onError:s.onError,enableFileUpload:!0})})]})})}Re.ChatApi=Zl,Re.ChatInterface=Ds,Re.ChatProviders=Ro,Re.ChatSettings=HC,Re.MarkdownContent=Zi,Re.MessageComponent=Ld,Re.MessageList=xa,Re.ThreadManager=Ga,Re.applySettings=G0,Re.chatApiClient=jn,Re.default=UC,Re.del=Jl,Re.get=Mt,Re.getChatToken=Gl,Re.getCurrentSettings=K0,Re.getDefaultApiConfig=Uh,Re.getDefaultChatSettings=Wh,Re.onChatTokenChanged=Yl,Re.post=di,Re.put=Xl,Re.setChatToken=ui,Re.useApi=fi,Re.useChatStream=cc,Re.useMessagesReducer=ec,Re.useStream=gc,Re.useThreadState=_o,Re.useThreads=jo,Object.defineProperties(Re,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
140
|
+
`).trim():n.replace(/</g,"<").replace(/>/g,">").trim()}function Gb(e,t=bs){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 Yb(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),Gb(t),Kb(t)}function ba(e){const t=e+"CollectionProvider",[n,r]=pn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=w=>{const{scope:g,children:v}=w,b=y.useRef(null),S=y.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:S,collectionRef:b,children:v})};i.displayName=t;const a=e+"CollectionSlot",l=Wn.createSlot(a),u=y.forwardRef((w,g)=>{const{scope:v,children:b}=w,S=s(a,v),N=We(g,S.collectionRef);return c.jsx(l,{ref:N,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=Wn.createSlot(d),p=y.forwardRef((w,g)=>{const{scope:v,children:b,...S}=w,N=y.useRef(null),C=We(g,N),k=s(d,v);return y.useEffect(()=>(k.itemMap.set(N,{ref:N,...S}),()=>void k.itemMap.delete(N))),c.jsx(h,{[f]:"",ref:C,children:b})});p.displayName=d;function x(w){const g=s(e+"CollectionConsumer",w);return y.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const S=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((k,E)=>S.indexOf(k.ref.current)-S.indexOf(E.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},x,r]}var Xb=m.createContext(void 0);function ys(e){const t=m.useContext(Xb);return e||t||"ltr"}const Jb=["top","right","bottom","left"],$n=Math.min,Bt=Math.max,Ss=Math.round,Cs=Math.floor,xn=e=>({x:e,y:e}),Zb={left:"right",right:"left",bottom:"top",top:"bottom"},Qb={start:"end",end:"start"};function ya(e,t,n){return Bt(e,$n(t,n))}function In(e,t){return typeof e=="function"?e(t):e}function En(e){return e.split("-")[0]}function kr(e){return e.split("-")[1]}function Sa(e){return e==="x"?"y":"x"}function Ca(e){return e==="y"?"height":"width"}const ey=new Set(["top","bottom"]);function vn(e){return ey.has(En(e))?"y":"x"}function Ta(e){return Sa(vn(e))}function ty(e,t,n){n===void 0&&(n=!1);const r=kr(e),o=Ta(e),s=Ca(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Ts(i)),[i,Ts(i)]}function ny(e){const t=Ts(e);return[ka(e),t,ka(t)]}function ka(e){return e.replace(/start|end/g,t=>Qb[t])}const Wd=["left","right"],Vd=["right","left"],ry=["top","bottom"],oy=["bottom","top"];function sy(e,t,n){switch(e){case"top":case"bottom":return n?t?Vd:Wd:t?Wd:Vd;case"left":case"right":return t?ry:oy;default:return[]}}function iy(e,t,n,r){const o=kr(e);let s=sy(En(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(ka)))),s}function Ts(e){return e.replace(/left|right|bottom|top/g,t=>Zb[t])}function ay(e){return{top:0,right:0,bottom:0,left:0,...e}}function qd(e){return typeof e!="number"?ay(e):{top:e,right:e,bottom:e,left:e}}function ks(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 Kd(e,t,n){let{reference:r,floating:o}=e;const s=vn(t),i=Ta(t),a=Ca(i),l=En(t),u=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(kr(t)){case"start":p[i]-=h*(n&&u?-1:1);break;case"end":p[i]+=h*(n&&u?-1:1);break}return p}const ly=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=Kd(u,r,l),h=r,p={},x=0;for(let w=0;w<a.length;w++){const{name:g,fn:v}=a[w],{x:b,y:S,data:N,reset:C}=await v({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});d=b??d,f=S??f,p={...p,[g]:{...p[g],...N}},C&&x<=50&&(x++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=Kd(u,h,l)),w=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function io(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=In(t,e),x=qd(p),g=a[h?f==="floating"?"reference":"floating":f],v=ks(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:l})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),N=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=ks(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(v.top-C.top+x.top)/N.y,bottom:(C.bottom-v.bottom+x.bottom)/N.y,left:(v.left-C.left+x.left)/N.x,right:(C.right-v.right+x.right)/N.x}}const cy=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:u,padding:d=0}=In(e,t)||{};if(u==null)return{};const f=qd(d),h={x:n,y:r},p=Ta(o),x=Ca(p),w=await i.getDimensions(u),g=p==="y",v=g?"top":"left",b=g?"bottom":"right",S=g?"clientHeight":"clientWidth",N=s.reference[x]+s.reference[p]-h[p]-s.floating[x],C=h[p]-s.reference[p],k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let E=k?k[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(k)))&&(E=a.floating[S]||s.floating[x]);const A=N/2-C/2,j=E/2-w[x]/2-1,P=$n(f[v],j),L=$n(f[b],j),F=P,V=E-w[x]-L,M=E/2-w[x]/2+A,Y=ya(F,M,V),q=!l.arrow&&kr(o)!=null&&M!==Y&&s.reference[x]/2-(M<F?P:L)-w[x]/2<0,W=q?M<F?M-F:M-V:0;return{[p]:h[p]+W,data:{[p]:Y,centerOffset:M-Y-W,...q&&{alignmentOffset:W}},reset:q}}}),uy=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:w=!0,...g}=In(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const v=En(o),b=vn(a),S=En(a)===a,N=await(l.isRTL==null?void 0:l.isRTL(u.floating)),C=h||(S||!w?[Ts(a)]:ny(a)),k=x!=="none";!h&&k&&C.push(...iy(a,w,x,N));const E=[a,...C],A=await io(t,g),j=[];let P=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&j.push(A[v]),f){const M=ty(o,i,N);j.push(A[M[0]],A[M[1]])}if(P=[...P,{placement:o,overflows:j}],!j.every(M=>M<=0)){var L,F;const M=(((L=s.flip)==null?void 0:L.index)||0)+1,Y=E[M];if(Y&&(!(f==="alignment"?b!==vn(Y):!1)||P.every(z=>vn(z.placement)===b?z.overflows[0]>0:!0)))return{data:{index:M,overflows:P},reset:{placement:Y}};let q=(F=P.filter(W=>W.overflows[0]<=0).sort((W,z)=>W.overflows[1]-z.overflows[1])[0])==null?void 0:F.placement;if(!q)switch(p){case"bestFit":{var V;const W=(V=P.filter(z=>{if(k){const $=vn(z.placement);return $===b||$==="y"}return!0}).map(z=>[z.placement,z.overflows.filter($=>$>0).reduce(($,ue)=>$+ue,0)]).sort((z,$)=>z[1]-$[1])[0])==null?void 0:V[0];W&&(q=W);break}case"initialPlacement":q=a;break}if(o!==q)return{reset:{placement:q}}}return{}}}};function Gd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Yd(e){return Jb.some(t=>e[t]>=0)}const dy=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=In(e,t);switch(r){case"referenceHidden":{const s=await io(t,{...o,elementContext:"reference"}),i=Gd(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Yd(i)}}}case"escaped":{const s=await io(t,{...o,altBoundary:!0}),i=Gd(s,n.floating);return{data:{escapedOffsets:i,escaped:Yd(i)}}}default:return{}}}}},Xd=new Set(["left","top"]);async function fy(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=En(n),a=kr(n),l=vn(n)==="y",u=Xd.has(i)?-1:1,d=s&&l?-1:1,f=In(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:x}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof x=="number"&&(p=a==="end"?x*-1:x),l?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const hy=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 fy(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}}}}},py=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x:v,y:b}=g;return{x:v,y:b}}},...l}=In(e,t),u={x:n,y:r},d=await io(t,l),f=vn(En(o)),h=Sa(f);let p=u[h],x=u[f];if(s){const g=h==="y"?"top":"left",v=h==="y"?"bottom":"right",b=p+d[g],S=p-d[v];p=ya(b,p,S)}if(i){const g=f==="y"?"top":"left",v=f==="y"?"bottom":"right",b=x+d[g],S=x-d[v];x=ya(b,x,S)}const w=a.fn({...t,[h]:p,[f]:x});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[h]:s,[f]:i}}}}}},my=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:u=!0}=In(e,t),d={x:n,y:r},f=vn(o),h=Sa(f);let p=d[h],x=d[f];const w=In(a,t),g=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(l){const S=h==="y"?"height":"width",N=s.reference[h]-s.floating[S]+g.mainAxis,C=s.reference[h]+s.reference[S]-g.mainAxis;p<N?p=N:p>C&&(p=C)}if(u){var v,b;const S=h==="y"?"width":"height",N=Xd.has(En(o)),C=s.reference[f]-s.floating[S]+(N&&((v=i.offset)==null?void 0:v[f])||0)+(N?0:g.crossAxis),k=s.reference[f]+s.reference[S]+(N?0:((b=i.offset)==null?void 0:b[f])||0)-(N?g.crossAxis:0);x<C?x=C:x>k&&(x=k)}return{[h]:p,[f]:x}}}},gy=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...u}=In(e,t),d=await io(t,u),f=En(o),h=kr(o),p=vn(o)==="y",{width:x,height:w}=s.floating;let g,v;f==="top"||f==="bottom"?(g=f,v=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(v=f,g=h==="end"?"top":"bottom");const b=w-d.top-d.bottom,S=x-d.left-d.right,N=$n(w-d[g],b),C=$n(x-d[v],S),k=!t.middlewareData.shift;let E=N,A=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),k&&!h){const P=Bt(d.left,0),L=Bt(d.right,0),F=Bt(d.top,0),V=Bt(d.bottom,0);p?A=x-2*(P!==0||L!==0?P+L:Bt(d.left,d.right)):E=w-2*(F!==0||V!==0?F+V:Bt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:E});const j=await i.getDimensions(a.floating);return x!==j.width||w!==j.height?{reset:{rects:!0}}:{}}}};function Is(){return typeof window<"u"}function Ir(e){return Jd(e)?(e.nodeName||"").toLowerCase():"#document"}function Ht(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function wn(e){var t;return(t=(Jd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Jd(e){return Is()?e instanceof Node||e instanceof Ht(e).Node:!1}function rn(e){return Is()?e instanceof Element||e instanceof Ht(e).Element:!1}function bn(e){return Is()?e instanceof HTMLElement||e instanceof Ht(e).HTMLElement:!1}function Zd(e){return!Is()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ht(e).ShadowRoot}const xy=new Set(["inline","contents"]);function ao(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=on(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!xy.has(o)}const vy=new Set(["table","td","th"]);function wy(e){return vy.has(Ir(e))}const by=[":popover-open",":modal"];function Es(e){return by.some(t=>{try{return e.matches(t)}catch{return!1}})}const yy=["transform","translate","scale","rotate","perspective"],Sy=["transform","translate","scale","rotate","perspective","filter"],Cy=["paint","layout","strict","content"];function Ia(e){const t=Ea(),n=rn(e)?on(e):e;return yy.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)||Sy.some(r=>(n.willChange||"").includes(r))||Cy.some(r=>(n.contain||"").includes(r))}function Ty(e){let t=zn(e);for(;bn(t)&&!Er(t);){if(Ia(t))return t;if(Es(t))return null;t=zn(t)}return null}function Ea(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const ky=new Set(["html","body","#document"]);function Er(e){return ky.has(Ir(e))}function on(e){return Ht(e).getComputedStyle(e)}function Ns(e){return rn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function zn(e){if(Ir(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Zd(e)&&e.host||wn(e);return Zd(t)?t.host:t}function Qd(e){const t=zn(e);return Er(t)?e.ownerDocument?e.ownerDocument.body:e.body:bn(t)&&ao(t)?t:Qd(t)}function lo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Qd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Ht(o);if(s){const a=Na(i);return t.concat(i,i.visualViewport||[],ao(o)?o:[],a&&n?lo(a):[])}return t.concat(o,lo(o,[],n))}function Na(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ef(e){const t=on(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=Ss(n)!==s||Ss(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Aa(e){return rn(e)?e:e.contextElement}function Nr(e){const t=Aa(e);if(!bn(t))return xn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=ef(t);let i=(s?Ss(n.width):n.width)/r,a=(s?Ss(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Iy=xn(0);function tf(e){const t=Ht(e);return!Ea()||!t.visualViewport?Iy:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ey(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ht(e)?!1:t}function rr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Aa(e);let i=xn(1);t&&(r?rn(r)&&(i=Nr(r)):i=Nr(e));const a=Ey(s,n,r)?tf(s):xn(0);let l=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=Ht(s),p=r&&rn(r)?Ht(r):r;let x=h,w=Na(x);for(;w&&r&&p!==x;){const g=Nr(w),v=w.getBoundingClientRect(),b=on(w),S=v.left+(w.clientLeft+parseFloat(b.paddingLeft))*g.x,N=v.top+(w.clientTop+parseFloat(b.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=S,u+=N,x=Ht(w),w=Na(x)}}return ks({width:d,height:f,x:l,y:u})}function As(e,t){const n=Ns(e).scrollLeft;return t?t.left+n:rr(wn(e)).left+n}function nf(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-As(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=wn(r),a=t?Es(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=xn(1);const d=xn(0),f=bn(r);if((f||!f&&!s)&&((Ir(r)!=="body"||ao(i))&&(l=Ns(r)),bn(r))){const p=rr(r);u=Nr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?nf(i,l):xn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-l.scrollTop*u.y+d.y+h.y}}function Ay(e){return Array.from(e.getClientRects())}function _y(e){const t=wn(e),n=Ns(e),r=e.ownerDocument.body,o=Bt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Bt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+As(e);const a=-n.scrollTop;return on(r).direction==="rtl"&&(i+=Bt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const rf=25;function jy(e,t){const n=Ht(e),r=wn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=Ea();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const u=As(r);if(u<=0){const d=r.ownerDocument,f=d.body,h=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,x=Math.abs(r.clientWidth-f.clientWidth-p);x<=rf&&(s-=x)}else u<=rf&&(s+=u);return{width:s,height:i,x:a,y:l}}const Ry=new Set(["absolute","fixed"]);function Py(e,t){const n=rr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=bn(e)?Nr(e):xn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,u=r*s.y;return{width:i,height:a,x:l,y:u}}function of(e,t,n){let r;if(t==="viewport")r=jy(e,n);else if(t==="document")r=_y(wn(e));else if(rn(t))r=Py(t,n);else{const o=tf(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ks(r)}function sf(e,t){const n=zn(e);return n===t||!rn(n)||Er(n)?!1:on(n).position==="fixed"||sf(n,t)}function Oy(e,t){const n=t.get(e);if(n)return n;let r=lo(e,[],!1).filter(a=>rn(a)&&Ir(a)!=="body"),o=null;const s=on(e).position==="fixed";let i=s?zn(e):e;for(;rn(i)&&!Er(i);){const a=on(i),l=Ia(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Ry.has(o.position)||ao(i)&&!l&&sf(e,i))?r=r.filter(d=>d!==i):o=a,i=zn(i)}return t.set(e,r),r}function My(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Es(t)?[]:Oy(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=of(t,d,o);return u.top=Bt(f.top,u.top),u.right=$n(f.right,u.right),u.bottom=$n(f.bottom,u.bottom),u.left=Bt(f.left,u.left),u},of(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Dy(e){const{width:t,height:n}=ef(e);return{width:t,height:n}}function Ly(e,t,n){const r=bn(t),o=wn(t),s=n==="fixed",i=rr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=xn(0);function u(){l.x=As(o)}if(r||!r&&!s)if((Ir(t)!=="body"||ao(o))&&(a=Ns(t)),r){const p=rr(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?nf(o,a):xn(0),f=i.left+a.scrollLeft-l.x-d.x,h=i.top+a.scrollTop-l.y-d.y;return{x:f,y:h,width:i.width,height:i.height}}function _a(e){return on(e).position==="static"}function af(e,t){if(!bn(e)||on(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return wn(e)===n&&(n=n.ownerDocument.body),n}function lf(e,t){const n=Ht(e);if(Es(e))return n;if(!bn(e)){let o=zn(e);for(;o&&!Er(o);){if(rn(o)&&!_a(o))return o;o=zn(o)}return n}let r=af(e,t);for(;r&&wy(r)&&_a(r);)r=af(r,t);return r&&Er(r)&&_a(r)&&!Ia(r)?n:r||Ty(e)||n}const Fy=async function(e){const t=this.getOffsetParent||lf,n=this.getDimensions,r=await n(e.floating);return{reference:Ly(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function $y(e){return on(e).direction==="rtl"}const zy={convertOffsetParentRelativeRectToViewportRelativeRect:Ny,getDocumentElement:wn,getClippingRect:My,getOffsetParent:lf,getElementRects:Fy,getClientRects:Ay,getDimensions:Dy,getScale:Nr,isElement:rn,isRTL:$y};function cf(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function By(e,t){let n=null,r;const o=wn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:p}=u;if(a||t(),!h||!p)return;const x=Cs(f),w=Cs(o.clientWidth-(d+h)),g=Cs(o.clientHeight-(f+p)),v=Cs(d),S={rootMargin:-x+"px "+-w+"px "+-g+"px "+-v+"px",threshold:Bt(0,$n(1,l))||1};let N=!0;function C(k){const E=k[0].intersectionRatio;if(E!==l){if(!N)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!cf(u,e.getBoundingClientRect())&&i(),N=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function Hy(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=Aa(e),d=o||s?[...u?lo(u):[],...lo(t)]:[];d.forEach(v=>{o&&v.addEventListener("scroll",n,{passive:!0}),s&&v.addEventListener("resize",n)});const f=u&&a?By(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(v=>{let[b]=v;b&&b.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let x,w=l?rr(e):null;l&&g();function g(){const v=rr(e);w&&!cf(w,v)&&n(),w=v,x=requestAnimationFrame(g)}return n(),()=>{var v;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(v=p)==null||v.disconnect(),p=null,l&&cancelAnimationFrame(x)}}const Uy=hy,Wy=py,Vy=uy,qy=gy,Ky=dy,uf=cy,Gy=my,Yy=(e,t,n)=>{const r=new Map,o={platform:zy,...n},s={...o.platform,_c:r};return ly(e,t,{...o,platform:s})};var Xy=typeof document<"u",Jy=function(){},_s=Xy?y.useLayoutEffect:Jy;function js(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(!js(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)&&!js(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function df(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function ff(e,t){const n=df(e);return Math.round(t*n)/n}function ja(e){const t=m.useRef(e);return _s(()=>{t.current=e}),t}function Zy(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=m.useState(r);js(h,r)||p(r);const[x,w]=m.useState(null),[g,v]=m.useState(null),b=m.useCallback(z=>{z!==k.current&&(k.current=z,w(z))},[]),S=m.useCallback(z=>{z!==E.current&&(E.current=z,v(z))},[]),N=s||x,C=i||g,k=m.useRef(null),E=m.useRef(null),A=m.useRef(d),j=l!=null,P=ja(l),L=ja(o),F=ja(u),V=m.useCallback(()=>{if(!k.current||!E.current)return;const z={placement:t,strategy:n,middleware:h};L.current&&(z.platform=L.current),Yy(k.current,E.current,z).then($=>{const ue={...$,isPositioned:F.current!==!1};M.current&&!js(A.current,ue)&&(A.current=ue,vo.flushSync(()=>{f(ue)}))})},[h,t,n,L,F]);_s(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(z=>({...z,isPositioned:!1})))},[u]);const M=m.useRef(!1);_s(()=>(M.current=!0,()=>{M.current=!1}),[]),_s(()=>{if(N&&(k.current=N),C&&(E.current=C),N&&C){if(P.current)return P.current(N,C,V);V()}},[N,C,V,P,j]);const Y=m.useMemo(()=>({reference:k,floating:E,setReference:b,setFloating:S}),[b,S]),q=m.useMemo(()=>({reference:N,floating:C}),[N,C]),W=m.useMemo(()=>{const z={position:n,left:0,top:0};if(!q.floating)return z;const $=ff(q.floating,d.x),ue=ff(q.floating,d.y);return a?{...z,transform:"translate("+$+"px, "+ue+"px)",...df(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:$,top:ue}},[n,a,q.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:V,refs:Y,elements:q,floatingStyles:W}),[d,V,Y,q,W])}const Qy=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?uf({element:r.current,padding:o}).fn(n):{}:r?uf({element:r,padding:o}).fn(n):{}}}},e0=(e,t)=>({...Uy(e),options:[e,t]}),t0=(e,t)=>({...Wy(e),options:[e,t]}),n0=(e,t)=>({...Gy(e),options:[e,t]}),r0=(e,t)=>({...Vy(e),options:[e,t]}),o0=(e,t)=>({...qy(e),options:[e,t]}),s0=(e,t)=>({...Ky(e),options:[e,t]}),i0=(e,t)=>({...Qy(e),options:[e,t]});var a0="Arrow",hf=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(je.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});hf.displayName=a0;var l0=hf;function pf(e){const[t,n]=m.useState(void 0);return vt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,u=Array.isArray(l)?l[0]:l;i=u.inlineSize,a=u.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Ra="Popper",[mf,Rs]=pn(Ra),[c0,gf]=mf(Ra),xf=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(c0,{scope:t,anchor:r,onAnchorChange:o,children:n})};xf.displayName=Ra;var vf="PopperAnchor",wf=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=gf(vf,n),i=m.useRef(null),a=We(t,i),l=m.useRef(null);return m.useEffect(()=>{const u=l.current;l.current=(r==null?void 0:r.current)||i.current,u!==l.current&&s.onAnchorChange(l.current)}),r?null:c.jsx(je.div,{...o,ref:a})});wf.displayName=vf;var Pa="PopperContent",[u0,d0]=mf(Pa),bf=m.forwardRef((e,t)=>{var K,O,J,te,G,se;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:x,...w}=e,g=gf(Pa,n),[v,b]=m.useState(null),S=We(t,Ve=>b(Ve)),[N,C]=m.useState(null),k=pf(N),E=(k==null?void 0:k.width)??0,A=(k==null?void 0:k.height)??0,j=r+(s!=="center"?"-"+s:""),P=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},L=Array.isArray(u)?u:[u],F=L.length>0,V={padding:P,boundary:L.filter(h0),altBoundary:F},{refs:M,floatingStyles:Y,placement:q,isPositioned:W,middlewareData:z}=Zy({strategy:"fixed",placement:j,whileElementsMounted:(...Ve)=>Hy(...Ve,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[e0({mainAxis:o+A,alignmentAxis:i}),l&&t0({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?n0():void 0,...V}),l&&r0({...V}),o0({...V,apply:({elements:Ve,rects:Je,availableWidth:nt,availableHeight:De})=>{const{width:Be,height:Ee}=Je.reference,Ze=Ve.floating.style;Ze.setProperty("--radix-popper-available-width",`${nt}px`),Ze.setProperty("--radix-popper-available-height",`${De}px`),Ze.setProperty("--radix-popper-anchor-width",`${Be}px`),Ze.setProperty("--radix-popper-anchor-height",`${Ee}px`)}}),N&&i0({element:N,padding:a}),p0({arrowWidth:E,arrowHeight:A}),h&&s0({strategy:"referenceHidden",...V})]}),[$,ue]=Cf(q),D=yt(x);vt(()=>{W&&(D==null||D())},[W,D]);const ee=(K=z.arrow)==null?void 0:K.x,fe=(O=z.arrow)==null?void 0:O.y,ve=((J=z.arrow)==null?void 0:J.centerOffset)!==0,[be,ye]=m.useState();return vt(()=>{v&&ye(window.getComputedStyle(v).zIndex)},[v]),c.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:W?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:be,"--radix-popper-transform-origin":[(te=z.transformOrigin)==null?void 0:te.x,(G=z.transformOrigin)==null?void 0:G.y].join(" "),...((se=z.hide)==null?void 0:se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(u0,{scope:n,placedSide:$,onArrowChange:C,arrowX:ee,arrowY:fe,shouldHideArrow:ve,children:c.jsx(je.div,{"data-side":$,"data-align":ue,...w,ref:S,style:{...w.style,animation:W?void 0:"none"}})})})});bf.displayName=Pa;var yf="PopperArrow",f0={top:"bottom",right:"left",bottom:"top",left:"right"},Sf=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=d0(yf,r),i=f0[s.placedSide];return c.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:c.jsx(l0,{...o,ref:n,style:{...o.style,display:"block"}})})});Sf.displayName=yf;function h0(e){return e!==null}var p0=e=>({name:"transformOrigin",options:e,fn(t){var g,v,b;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[u,d]=Cf(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((v=o.arrow)==null?void 0:v.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let x="",w="";return u==="bottom"?(x=i?f:`${h}px`,w=`${-l}px`):u==="top"?(x=i?f:`${h}px`,w=`${r.floating.height+l}px`):u==="right"?(x=`${-l}px`,w=i?f:`${p}px`):u==="left"&&(x=`${r.floating.width+l}px`,w=i?f:`${p}px`),{data:{x,y:w}}}});function Cf(e){const[t,n="center"]=e.split("-");return[t,n]}var Tf=xf,kf=wf,If=bf,Ef=Sf,Oa="rovingFocusGroup.onEntryFocus",m0={bubbles:!1,cancelable:!0},co="RovingFocusGroup",[Ma,Nf,g0]=ba(co),[x0,Af]=pn(co,[g0]),[v0,w0]=x0(co),_f=m.forwardRef((e,t)=>c.jsx(Ma.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Ma.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(b0,{...e,ref:t})})}));_f.displayName=co;var b0=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=m.useRef(null),p=We(t,h),x=ys(s),[w,g]=Zn({prop:i,defaultProp:a??null,onChange:l,caller:co}),[v,b]=m.useState(!1),S=yt(u),N=Nf(n),C=m.useRef(!1),[k,E]=m.useState(0);return m.useEffect(()=>{const A=h.current;if(A)return A.addEventListener(Oa,S),()=>A.removeEventListener(Oa,S)},[S]),c.jsx(v0,{scope:n,orientation:r,dir:x,loop:o,currentTabStopId:w,onItemFocus:m.useCallback(A=>g(A),[g]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>E(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>E(A=>A-1),[]),children:c.jsx(je.div,{tabIndex:v||k===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:de(e.onMouseDown,()=>{C.current=!0}),onFocus:de(e.onFocus,A=>{const j=!C.current;if(A.target===A.currentTarget&&j&&!v){const P=new CustomEvent(Oa,m0);if(A.currentTarget.dispatchEvent(P),!P.defaultPrevented){const L=N().filter(q=>q.focusable),F=L.find(q=>q.active),V=L.find(q=>q.id===w),Y=[F,V,...L].filter(Boolean).map(q=>q.ref.current);Pf(Y,d)}}C.current=!1}),onBlur:de(e.onBlur,()=>b(!1))})})}),jf="RovingFocusGroupItem",Rf=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=mn(),u=s||l,d=w0(jf,n),f=d.currentTabStopId===u,h=Nf(n),{onFocusableItemAdd:p,onFocusableItemRemove:x,currentTabStopId:w}=d;return m.useEffect(()=>{if(r)return p(),()=>x()},[r,p,x]),c.jsx(Ma.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(je.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:de(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:de(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:de(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const v=C0(g,d.orientation,d.dir);if(v!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let S=h().filter(N=>N.focusable).map(N=>N.ref.current);if(v==="last")S.reverse();else if(v==="prev"||v==="next"){v==="prev"&&S.reverse();const N=S.indexOf(g.currentTarget);S=d.loop?T0(S,N+1):S.slice(N+1)}setTimeout(()=>Pf(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:w!=null}):i})})});Rf.displayName=jf;var y0={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function S0(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function C0(e,t,n){const r=S0(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return y0[r]}function Pf(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function T0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var k0=_f,I0=Rf,Da=["Enter"," "],E0=["ArrowDown","PageUp","Home"],Of=["ArrowUp","PageDown","End"],N0=[...E0,...Of],A0={ltr:[...Da,"ArrowRight"],rtl:[...Da,"ArrowLeft"]},_0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},uo="Menu",[fo,j0,R0]=ba(uo),[or,Mf]=pn(uo,[R0,Rs,Af]),Ps=Rs(),Df=Af(),[P0,sr]=or(uo),[O0,ho]=or(uo),Lf=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=Ps(t),[l,u]=m.useState(null),d=m.useRef(!1),f=yt(s),h=ys(o);return m.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},x=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),c.jsx(Tf,{...a,children:c.jsx(P0,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(O0,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};Lf.displayName=uo;var M0="MenuAnchor",La=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ps(n);return c.jsx(kf,{...o,...r,ref:t})});La.displayName=M0;var Fa="MenuPortal",[D0,Ff]=or(Fa,{forceMount:void 0}),$f=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=sr(Fa,t);return c.jsx(D0,{scope:t,forceMount:n,children:c.jsx(zt,{present:n||s.open,children:c.jsx(ss,{asChild:!0,container:o,children:r})})})};$f.displayName=Fa;var Kt="MenuContent",[L0,$a]=or(Kt),zf=m.forwardRef((e,t)=>{const n=Ff(Kt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=sr(Kt,e.__scopeMenu),i=ho(Kt,e.__scopeMenu);return c.jsx(fo.Provider,{scope:e.__scopeMenu,children:c.jsx(zt,{present:r||s.open,children:c.jsx(fo.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(F0,{...o,ref:t}):c.jsx($0,{...o,ref:t})})})})}),F0=m.forwardRef((e,t)=>{const n=sr(Kt,e.__scopeMenu),r=m.useRef(null),o=We(t,r);return m.useEffect(()=>{const s=r.current;if(s)return pa(s)},[]),c.jsx(za,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:de(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),$0=m.forwardRef((e,t)=>{const n=sr(Kt,e.__scopeMenu);return c.jsx(za,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),z0=Wn.createSlot("MenuContent.ScrollLock"),za=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:x,...w}=e,g=sr(Kt,n),v=ho(Kt,n),b=Ps(n),S=Df(n),N=j0(n),[C,k]=m.useState(null),E=m.useRef(null),A=We(t,E,g.onContentChange),j=m.useRef(0),P=m.useRef(""),L=m.useRef(0),F=m.useRef(null),V=m.useRef("right"),M=m.useRef(0),Y=x?ds:m.Fragment,q=x?{as:z0,allowPinchZoom:!0}:void 0,W=$=>{var K,O;const ue=P.current+$,D=N().filter(J=>!J.disabled),ee=document.activeElement,fe=(K=D.find(J=>J.ref.current===ee))==null?void 0:K.textValue,ve=D.map(J=>J.textValue),be=Z0(ve,ue,fe),ye=(O=D.find(J=>J.textValue===be))==null?void 0:O.ref.current;(function J(te){P.current=te,window.clearTimeout(j.current),te!==""&&(j.current=window.setTimeout(()=>J(""),1e3))})(ue),ye&&setTimeout(()=>ye.focus())};m.useEffect(()=>()=>window.clearTimeout(j.current),[]),la();const z=m.useCallback($=>{var D,ee;return V.current===((D=F.current)==null?void 0:D.side)&&eS($,(ee=F.current)==null?void 0:ee.area)},[]);return c.jsx(L0,{scope:n,searchRef:P,onItemEnter:m.useCallback($=>{z($)&&$.preventDefault()},[z]),onItemLeave:m.useCallback($=>{var ue;z($)||((ue=E.current)==null||ue.focus(),k(null))},[z]),onTriggerLeave:m.useCallback($=>{z($)&&$.preventDefault()},[z]),pointerGraceTimerRef:L,onPointerGraceIntentChange:m.useCallback($=>{F.current=$},[]),children:c.jsx(Y,{...q,children:c.jsx(os,{asChild:!0,trapped:o,onMountAutoFocus:de(s,$=>{var ue;$.preventDefault(),(ue=E.current)==null||ue.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(rs,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:c.jsx(k0,{asChild:!0,...S,dir:v.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:de(l,$=>{v.isUsingKeyboardRef.current||$.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(If,{role:"menu","aria-orientation":"vertical","data-state":rh(g.open),"data-radix-menu-content":"",dir:v.dir,...b,...w,ref:A,style:{outline:"none",...w.style},onKeyDown:de(w.onKeyDown,$=>{const D=$.target.closest("[data-radix-menu-content]")===$.currentTarget,ee=$.ctrlKey||$.altKey||$.metaKey,fe=$.key.length===1;D&&($.key==="Tab"&&$.preventDefault(),!ee&&fe&&W($.key));const ve=E.current;if($.target!==ve||!N0.includes($.key))return;$.preventDefault();const ye=N().filter(K=>!K.disabled).map(K=>K.ref.current);Of.includes($.key)&&ye.reverse(),X0(ye)}),onBlur:de(e.onBlur,$=>{$.currentTarget.contains($.target)||(window.clearTimeout(j.current),P.current="")}),onPointerMove:de(e.onPointerMove,mo($=>{const ue=$.target,D=M.current!==$.clientX;if($.currentTarget.contains(ue)&&D){const ee=$.clientX>M.current?"right":"left";V.current=ee,M.current=$.clientX}}))})})})})})})});zf.displayName=Kt;var B0="MenuGroup",Ba=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(je.div,{role:"group",...r,ref:t})});Ba.displayName=B0;var H0="MenuLabel",Bf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(je.div,{...r,ref:t})});Bf.displayName=H0;var Os="MenuItem",Hf="menu.itemSelect",Ms=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=ho(Os,e.__scopeMenu),a=$a(Os,e.__scopeMenu),l=We(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(Hf,{bubbles:!0,cancelable:!0});f.addEventListener(Hf,p=>r==null?void 0:r(p),{once:!0}),Su(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(Uf,{...o,ref:l,disabled:n,onClick:de(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:de(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:de(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||Da.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Ms.displayName=Os;var Uf=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=$a(Os,n),a=Df(n),l=m.useRef(null),u=We(t,l),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const x=l.current;x&&p((x.textContent??"").trim())},[s.children]),c.jsx(fo.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(I0,{asChild:!0,...a,focusable:!r,children:c.jsx(je.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:de(e.onPointerMove,mo(x=>{r?i.onItemLeave(x):(i.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:de(e.onPointerLeave,mo(x=>i.onItemLeave(x))),onFocus:de(e.onFocus,()=>f(!0)),onBlur:de(e.onBlur,()=>f(!1))})})})}),U0="MenuCheckboxItem",Wf=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(Yf,{scope:e.__scopeMenu,checked:n,children:c.jsx(Ms,{role:"menuitemcheckbox","aria-checked":Ds(n)?"mixed":n,...o,ref:t,"data-state":Ua(n),onSelect:de(o.onSelect,()=>r==null?void 0:r(Ds(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Wf.displayName=U0;var Vf="MenuRadioGroup",[W0,V0]=or(Vf,{value:void 0,onValueChange:()=>{}}),qf=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=yt(r);return c.jsx(W0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(Ba,{...o,ref:t})})});qf.displayName=Vf;var Kf="MenuRadioItem",Gf=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=V0(Kf,e.__scopeMenu),s=n===o.value;return c.jsx(Yf,{scope:e.__scopeMenu,checked:s,children:c.jsx(Ms,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Ua(s),onSelect:de(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Gf.displayName=Kf;var Ha="MenuItemIndicator",[Yf,q0]=or(Ha,{checked:!1}),Xf=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=q0(Ha,n);return c.jsx(zt,{present:r||Ds(s.checked)||s.checked===!0,children:c.jsx(je.span,{...o,ref:t,"data-state":Ua(s.checked)})})});Xf.displayName=Ha;var K0="MenuSeparator",Jf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(je.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Jf.displayName=K0;var G0="MenuArrow",Zf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ps(n);return c.jsx(Ef,{...o,...r,ref:t})});Zf.displayName=G0;var Y0="MenuSub",[jT,Qf]=or(Y0),po="MenuSubTrigger",eh=m.forwardRef((e,t)=>{const n=sr(po,e.__scopeMenu),r=ho(po,e.__scopeMenu),o=Qf(po,e.__scopeMenu),s=$a(po,e.__scopeMenu),i=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},d=m.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return m.useEffect(()=>d,[d]),m.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),c.jsx(La,{asChild:!0,...u,children:c.jsx(Uf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":rh(n.open),...e,ref:Gi(t,o.onTriggerChange),onClick:f=>{var h;(h=e.onClick)==null||h.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:de(e.onPointerMove,mo(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:de(e.onPointerLeave,mo(f=>{var p,x;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const w=(x=n.content)==null?void 0:x.dataset.side,g=w==="right",v=g?-5:5,b=h[g?"left":"right"],S=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+v,y:f.clientY},{x:b,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:b,y:h.bottom}],side:w}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:de(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||A0[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});eh.displayName=po;var th="MenuSubContent",nh=m.forwardRef((e,t)=>{const n=Ff(Kt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=sr(Kt,e.__scopeMenu),i=ho(Kt,e.__scopeMenu),a=Qf(th,e.__scopeMenu),l=m.useRef(null),u=We(t,l);return c.jsx(fo.Provider,{scope:e.__scopeMenu,children:c.jsx(zt,{present:r||s.open,children:c.jsx(fo.Slot,{scope:e.__scopeMenu,children:c.jsx(za,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:de(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:de(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:de(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=_0[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});nh.displayName=th;function rh(e){return e?"open":"closed"}function Ds(e){return e==="indeterminate"}function Ua(e){return Ds(e)?"indeterminate":e?"checked":"unchecked"}function X0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function J0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Z0(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=J0(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function Q0(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],u=a.x,d=a.y,f=l.x,h=l.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function eS(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Q0(n,t)}function mo(e){return t=>t.pointerType==="mouse"?e(t):void 0}var tS=Lf,nS=La,rS=$f,oS=zf,sS=Ba,iS=Bf,aS=Ms,lS=Wf,cS=qf,uS=Gf,dS=Xf,fS=Jf,hS=Zf,pS=eh,mS=nh,Ls="DropdownMenu",[gS,RT]=pn(Ls,[Mf]),jt=Mf(),[xS,oh]=gS(Ls),sh=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=jt(t),u=m.useRef(null),[d,f]=Zn({prop:o,defaultProp:s??!1,onChange:i,caller:Ls});return c.jsx(xS,{scope:t,triggerId:mn(),triggerRef:u,contentId:mn(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(tS,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};sh.displayName=Ls;var ih="DropdownMenuTrigger",ah=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=oh(ih,n),i=jt(n);return c.jsx(nS,{asChild:!0,...i,children:c.jsx(je.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:Gi(t,s.triggerRef),onPointerDown:de(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:de(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});ah.displayName=ih;var vS="DropdownMenuPortal",lh=e=>{const{__scopeDropdownMenu:t,...n}=e,r=jt(t);return c.jsx(rS,{...r,...n})};lh.displayName=vS;var ch="DropdownMenuContent",uh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=oh(ch,n),s=jt(n),i=m.useRef(!1);return c.jsx(oS,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:de(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:de(e.onInteractOutside,a=>{const l=a.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,d=l.button===2||u;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});uh.displayName=ch;var wS="DropdownMenuGroup",bS=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(sS,{...o,...r,ref:t})});bS.displayName=wS;var yS="DropdownMenuLabel",dh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(iS,{...o,...r,ref:t})});dh.displayName=yS;var SS="DropdownMenuItem",fh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(aS,{...o,...r,ref:t})});fh.displayName=SS;var CS="DropdownMenuCheckboxItem",hh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(lS,{...o,...r,ref:t})});hh.displayName=CS;var TS="DropdownMenuRadioGroup",kS=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(cS,{...o,...r,ref:t})});kS.displayName=TS;var IS="DropdownMenuRadioItem",ph=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(uS,{...o,...r,ref:t})});ph.displayName=IS;var ES="DropdownMenuItemIndicator",mh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(dS,{...o,...r,ref:t})});mh.displayName=ES;var NS="DropdownMenuSeparator",gh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(fS,{...o,...r,ref:t})});gh.displayName=NS;var AS="DropdownMenuArrow",_S=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(hS,{...o,...r,ref:t})});_S.displayName=AS;var jS="DropdownMenuSubTrigger",xh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(pS,{...o,...r,ref:t})});xh.displayName=jS;var RS="DropdownMenuSubContent",vh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(mS,{...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)"}})});vh.displayName=RS;var PS=sh,OS=ah,MS=lh,wh=uh,bh=dh,yh=fh,Sh=hh,Ch=ph,Th=mh,kh=gh,Ih=xh,Eh=vh;const DS=PS,LS=OS,FS=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(Ih,{ref:o,className:Q("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,c.jsx(ie.ChevronRight,{className:"ml-auto h-4 w-4"})]}));FS.displayName=Ih.displayName;const $S=m.forwardRef(({className:e,...t},n)=>c.jsx(Eh,{ref:n,className:Q("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));$S.displayName=Eh.displayName;const Nh=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(MS,{children:c.jsx(wh,{ref:r,sideOffset:t,className:Q("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Nh.displayName=wh.displayName;const Wa=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(yh,{ref:r,className:Q("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Wa.displayName=yh.displayName;const zS=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(Sh,{ref:o,className:Q("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Th,{children:c.jsx(ie.Check,{className:"h-4 w-4"})})}),t]}));zS.displayName=Sh.displayName;const BS=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Ch,{ref:r,className:Q("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Th,{children:c.jsx(ie.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));BS.displayName=Ch.displayName;const HS=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(bh,{ref:r,className:Q("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));HS.displayName=bh.displayName;const US=m.forwardRef(({className:e,...t},n)=>c.jsx(kh,{ref:n,className:Q("-mx-1 my-1 h-px bg-muted",e),...t}));US.displayName=kh.displayName;function Fs({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:h,onError:p}){const{api:x}=pi(),{currentThreadId:w}=Ro(),{threadId:g,messages:v,hasMore:b,isHistoryLoading:S,isLoading:N,loadOlder:C,listCheckpoints:k,navigateToCheckpoint:E,returnToLatest:A,checkpoint:j,respondToInterrupt:P,metadata:L}=Po(),{isStreaming:F,error:V,submit:M,stop:Y}=yc(),q=g??w??null,W=(j==null?void 0:j.id)??null,z=(j==null?void 0:j.namespace)??null,$=(L==null?void 0:L.assemblingMessageId)??null,[ue,D]=y.useState(null),[ee,fe]=y.useState(""),[ve,be]=y.useState(null),[ye,K]=y.useState([]),[O,J]=y.useState(0),[te,G]=y.useState(0),[se,Ve]=y.useState(!1),[Je,nt]=y.useState(null),[De,Be]=y.useState(null),[Ee,Ze]=y.useState(!1),[wt,ht]=y.useState(null),[Z,re]=y.useState([]),[pe,Ne]=y.useState(null),[we,Ae]=y.useState(null),[Qe,ze]=y.useState(!1),lt=y.useRef(null),St=y.useRef(null),Ut=y.useRef(null),gt=y.useCallback(()=>{lt.current&&(lt.current.value=""),St.current&&(St.current.value=""),J(ae=>ae+1),G(ae=>ae+1)},[]),Rr=y.useRef(!1);y.useEffect(()=>{Rr.current&&!F&&(K([]),gt()),Rr.current=F},[F,gt]);const[cr,bt]=y.useState("desktop");y.useEffect(()=>{const ae=()=>{const Te=window.innerWidth;bt(Te<640?"phone":Te<1024?"tablet":"desktop")};return ae(),window.addEventListener("resize",ae),()=>window.removeEventListener("resize",ae)},[]),y.useEffect(()=>{let ae=!1;if(!q){re([]),Ne(null),Ae(null),Ut.current=null;return}const Te={threadId:q,checkpointId:W??null,checkpointNs:z??null},Oe=Ut.current;if(!(Oe&&Oe.threadId===Te.threadId&&Oe.checkpointId===Te.checkpointId&&Oe.checkpointNs===Te.checkpointNs))return k(q).then(rt=>{var ke;if(ae)return;const Rt=((rt==null?void 0:rt.checkpoints)??[]).slice().sort((Fe,qe)=>new Date(qe.createdAt).getTime()-new Date(Fe.createdAt).getTime());re(Rt);const I=pe,B=I&&Rt.some(Fe=>Fe.checkpointId===I)?I:((ke=Rt[0])==null?void 0:ke.checkpointId)??null;let oe=null;if(B){const Fe=Rt.find(qe=>qe.checkpointId===B);oe=(Fe==null?void 0:Fe.checkpointNs)??null}Ne(B),Ae(oe),Ut.current=Te}).catch(rt=>{console.error("ChatInterface - listCheckpoints error:",rt),ae||(re([]),Ut.current=null)}),()=>{ae=!0}},[q,W,z,pe,k]),y.useEffect(()=>{W&&(Ne(W),Ae(z??null))},[W,z]);const Sn=y.useCallback(async()=>{if(!(!b||S))try{await C()}catch(ae){console.warn("loadOlder failed",ae)}},[b,S,C]);y.useEffect(()=>{(async()=>{if(!x.baseUrl){ht(null);return}try{const Te=await x.getAgent("default");ht(Te.uiDefaultMessage||null)}catch(Te){console.warn("Failed to fetch default message:",Te),ht(null)}})()},[x]),y.useEffect(()=>{V&&!Ee&&(p==null||p(V))},[V,Ee,p]);const an=ae=>{if(ae.length>bs)return`Message too long (${ae.length}/${bs} characters)`;try{return Yb(ae),null}catch(Te){return(Te==null?void 0:Te.message)||"Invalid message"}},ur=async ae=>{const Te=ae.trim();if(!(!Te&&ye.length===0)){if(Te){const Oe=an(Te);if(Oe){be(Oe);return}}try{await M({text:Te||"",attachments:ye,payload:ue?{edit:!0,originalMessageId:ue}:void 0},{checkpointId:pe??W??void 0,checkpointNs:we??z??void 0}),f==null||f(Te),be(null),K([]),gt(),D(null),fe("")}catch(Oe){const rt=(Oe==null?void 0:Oe.message)||"Failed to send message";be(rt),p==null||p(rt)}}},Nt=y.useCallback((ae,Te)=>{u&&(D(ae),fe(Te),be(null))},[u]),ln=y.useCallback(()=>{D(null),fe(""),be(null)},[]),Xt=y.useCallback((ae,Te)=>{Nt(ae,Te)},[Nt]),cn=y.useCallback(ae=>{const Te=Oe=>{const rt=Oe.content||[],Rt=rt.filter(I=>I.type==="text").map(I=>I.text).join("");if(Rt)return Rt;try{return JSON.stringify(rt,null,2)}catch{return String(rt)}};for(let Oe=ae-1;Oe>=0;Oe--)if(v[Oe].role==="user"){const rt=Te(v[Oe]);rt&&M({text:rt},{checkpointId:pe??W??void 0,checkpointNs:we??z??void 0});break}},[v,M,pe,we,W,z]),dr=ae=>{const Te=Array.from(ae.target.files||[]);K(Oe=>[...Oe,...Te]),ae.target.value=""},Pr=ae=>{K(Te=>{const Oe=Te.filter((rt,Rt)=>ae!==Rt);return Oe.length===0&>(),Oe})},Or=async ae=>{const Te=(ae.target.files||[])[0];if(Te){nt(null),Be(null),Ve(!0);try{await M({attachments:[Te]},{checkpointId:pe??W??void 0,checkpointNs:we??z??void 0});const Oe=`Uploaded ${Te.name} - processing through chat stream`;Be(Oe)}catch(Oe){const rt=Oe instanceof Error?Oe.message:"Failed to upload Excel file";console.error("Excel upload failed",Oe),nt(rt),p==null||p(rt)}finally{Ve(!1),ae.target.value="",gt()}}},fr=ae=>{if(!ae)return"Unknown";const Te=Date.parse(ae);return Number.isNaN(Te)?ae:new Date(Te).toLocaleString()},Nn=async ae=>{if(w){ze(!0);try{if(!ae){await A(),Ne(null),Ae(null);return}const Te=Z.find(rt=>rt.checkpointId===ae),Oe=(Te==null?void 0:Te.checkpointNs)??null;await E(ae,Oe),Ne(ae),Ae(Oe)}finally{ze(!1)}}},Mr=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,An=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${d.messagesArea||""}`,hr=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return c.jsxs("div",{className:Mr,children:[!!V&&!Ee&&c.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[c.jsx("span",{children:V}),c.jsx(Ge,{variant:"ghost",size:"sm",onClick:()=>Ze(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(ie.X,{size:16})})]}),w&&Z.length>0&&c.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[c.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),c.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:pe??"",onChange:ae=>{const Te=ae.target.value||null;Nn(Te)},children:[c.jsx("option",{value:"",children:"Latest"}),Z.map(ae=>c.jsxs("option",{value:ae.checkpointId,children:[fr(ae.createdAt),ae.preview?` — ${ae.preview.slice(0,40)}`:""]},ae.checkpointId))]})]}),c.jsxs("div",{className:`relative ${An}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(wa,{className:"h-full",style:{height:"100%"},messages:v,isStreaming:F,streamingAssistantId:$,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:cr,enableMessageEditing:u,editingMessageId:ue,onStartReached:()=>{Sn()},onEdit:Xt,onRegenerate:cn,onCancelEdit:ln,emptyMessage:wt??void 0,isNavigatingCheckpoint:Qe}),N&&c.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[c.jsx(ie.Loader2,{className:"h-6 w-6 animate-spin"}),c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]})]}),c.jsxs("div",{className:hr,children:[ue&&c.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ie.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(Ge,{variant:"ghost",size:"sm",onClick:ln,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(ie.X,{size:16})})]})}),(a||l)&&c.jsxs("div",{className:"mb-3 space-y-3",children:[a&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:lt,type:"file",multiple:!0,onChange:ae=>dr(ae),className:"hidden"},O),ye.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:ye.map((ae,Te)=>c.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[c.jsx(ie.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:ae.name}),c.jsx(Ge,{variant:"ghost",size:"sm",onClick:()=>Pr(Te),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 ${ae.name}`,children:c.jsx(ie.X,{size:12})})]},Te))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:St,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Or,className:"hidden"},te),se&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(ie.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),De&&!se&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:De}),Je&&!se&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Je})]})]}),ve&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:ve}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(DS,{children:[c.jsx(LS,{asChild:!0,children:c.jsx(Ge,{type:"button",size:"icon",variant:"outline",disabled:F,title:"More input actions",className:d.moreButton||"",children:c.jsx(ie.Plus,{size:16})})}),c.jsxs(Nh,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(Wa,{onClick:()=>{var ae;return(ae=lt.current)==null?void 0:ae.click()},className:"cursor-pointer",children:[c.jsx(ie.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(Wa,{onClick:()=>{var ae;se||(ae=St.current)==null||ae.click()},className:`cursor-pointer ${se?"opacity-60 pointer-events-none":""}`,children:[c.jsx(ie.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx(lx,{initialValue:ee,editingMessageId:ue,placeholder:ue?"Edit your message...":t,isStreaming:F,disabled:!1,maxLength:bs,onSend:ur,onCancelEdit:ln,onStop:Y,allowEmptySend:ye.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${ue?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${ve?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const $s=m.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:Q("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));$s.displayName="Input";function Va(e,[t,n]){return Math.min(n,Math.max(t,e))}function WS(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var qa="ScrollArea",[Ah,PT]=pn(qa),[VS,Gt]=Ah(qa),_h=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=m.useState(null),[u,d]=m.useState(null),[f,h]=m.useState(null),[p,x]=m.useState(null),[w,g]=m.useState(null),[v,b]=m.useState(0),[S,N]=m.useState(0),[C,k]=m.useState(!1),[E,A]=m.useState(!1),j=We(t,L=>l(L)),P=ys(o);return c.jsx(VS,{scope:n,type:r,dir:P,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:x,scrollbarXEnabled:C,onScrollbarXEnabledChange:k,scrollbarY:w,onScrollbarYChange:g,scrollbarYEnabled:E,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:N,children:c.jsx(je.div,{dir:P,...i,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":v+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});_h.displayName=qa;var jh="ScrollAreaViewport",Rh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Gt(jh,n),a=m.useRef(null),l=We(t,a,i.onViewportChange);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),c.jsx(je.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:c.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Rh.displayName=jh;var yn="ScrollAreaScrollbar",Ka=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Gt(yn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return m.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?c.jsx(qS,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(KS,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(Ph,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(Ga,{...r,ref:t}):null});Ka.displayName=yn;var qS=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Gt(yn,e.__scopeScrollArea),[s,i]=m.useState(!1);return m.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const u=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),c.jsx(zt,{present:n||s,children:c.jsx(Ph,{"data-state":s?"visible":"hidden",...r,ref:t})})}),KS=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Gt(yn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Us(()=>l("SCROLL_END"),100),[a,l]=WS("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return m.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,l]),m.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const p=u[d];f!==p&&(l("SCROLL"),i()),f=p};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),c.jsx(zt,{present:n||a!=="hidden",children:c.jsx(Ga,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:de(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:de(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Ph=m.forwardRef((e,t)=>{const n=Gt(yn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",l=Us(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return Ar(n.viewport,l),Ar(n.content,l),c.jsx(zt,{present:r||s,children:c.jsx(Ga,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Ga=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Gt(yn,e.__scopeScrollArea),s=m.useRef(null),i=m.useRef(0),[a,l]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=Fh(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:u>0&&u<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return QS(h,i.current,a,p)}return n==="horizontal"?c.jsx(GS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=$h(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?c.jsx(YS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=$h(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),GS=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Gt(yn,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=We(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Mh,{"data-orientation":"horizontal",...o,ref:u,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Hs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(h),Bh(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Bs(i.paddingLeft),paddingEnd:Bs(i.paddingRight)}})}})}),YS=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Gt(yn,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=We(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Mh,{"data-orientation":"vertical",...o,ref:u,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Hs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(h),Bh(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Bs(i.paddingTop),paddingEnd:Bs(i.paddingBottom)}})}})}),[XS,Oh]=Ah(yn),Mh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,p=Gt(yn,n),[x,w]=m.useState(null),g=We(t,j=>w(j)),v=m.useRef(null),b=m.useRef(""),S=p.viewport,N=r.content-r.viewport,C=yt(d),k=yt(l),E=Us(f,10);function A(j){if(v.current){const P=j.clientX-v.current.left,L=j.clientY-v.current.top;u({x:P,y:L})}}return m.useEffect(()=>{const j=P=>{const L=P.target;(x==null?void 0:x.contains(L))&&C(P,N)};return document.addEventListener("wheel",j,{passive:!1}),()=>document.removeEventListener("wheel",j,{passive:!1})},[S,x,N,C]),m.useEffect(k,[r,k]),Ar(x,E),Ar(p.content,E),c.jsx(XS,{scope:n,scrollbar:x,hasThumb:o,onThumbChange:yt(s),onThumbPointerUp:yt(i),onThumbPositionChange:k,onThumbPointerDown:yt(a),children:c.jsx(je.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:de(e.onPointerDown,j=>{j.button===0&&(j.target.setPointerCapture(j.pointerId),v.current=x.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(j))}),onPointerMove:de(e.onPointerMove,A),onPointerUp:de(e.onPointerUp,j=>{const P=j.target;P.hasPointerCapture(j.pointerId)&&P.releasePointerCapture(j.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),v.current=null})})})}),zs="ScrollAreaThumb",Dh=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Oh(zs,e.__scopeScrollArea);return c.jsx(zt,{present:n||o.hasThumb,children:c.jsx(JS,{ref:t,...r})})}),JS=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Gt(zs,n),i=Oh(zs,n),{onThumbPositionChange:a}=i,l=We(t,f=>i.onThumbChange(f)),u=m.useRef(void 0),d=Us(()=>{u.current&&(u.current(),u.current=void 0)},100);return m.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const p=eC(f,a);u.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),c.jsx(je.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:de(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),x=f.clientX-p.left,w=f.clientY-p.top;i.onThumbPointerDown({x,y:w})}),onPointerUp:de(e.onPointerUp,i.onThumbPointerUp)})});Dh.displayName=zs;var Ya="ScrollAreaCorner",Lh=m.forwardRef((e,t)=>{const n=Gt(Ya,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(ZS,{...e,ref:t}):null});Lh.displayName=Ya;var ZS=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Gt(Ya,n),[s,i]=m.useState(0),[a,l]=m.useState(0),u=!!(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)}),u?c.jsx(je.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 Bs(e){return e?parseInt(e,10):0}function Fh(e,t){const n=e/t;return isNaN(n)?0:n}function Hs(e){const t=Fh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function QS(e,t,n,r="ltr"){const o=Hs(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return zh([l,u],f)(e)}function $h(e,t,n="ltr"){const r=Hs(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],u=Va(e,l);return zh([0,i],[0,a])(u)}function zh(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 Bh(e,t){return e>0&&e<t}var eC=(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 Us(e,t){const n=yt(e),r=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),m.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Ar(e,t){const n=yt(t);vt(()=>{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 Hh=_h,tC=Rh,nC=Lh;const Uh=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Hh,{ref:r,className:Q("relative overflow-hidden",e),...n,children:[c.jsx(tC,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(Wh,{}),c.jsx(nC,{})]}));Uh.displayName=Hh.displayName;const Wh=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(Ka,{ref:r,orientation:t,className:Q("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:c.jsx(Dh,{className:"relative flex-1 rounded-full bg-border"})}));Wh.displayName=Ka.displayName;function Xa({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:u,onThreadDelete:d}){const{threads:f,currentThreadId:h,isLoading:p,actions:x}=Ro(),{loadThread:w}=Po(),{createThread:g,deleteThread:v,renameThread:b}=x,[S,N]=y.useState(Array.isArray(f)?f:[]),C=y.useRef(S.length>0),[k,E]=y.useState(null),[A,j]=y.useState(""),[P,L]=y.useState(!1);y.useEffect(()=>{const D=Array.isArray(f)?f:[];if(D.length>0){C.current=!0,N(D);return}p||(C.current=!1,N(D))},[f,p]);const F=async D=>{try{await w(D),a==null||a(D),l==null||l(D)}catch(ee){console.error("Failed to select thread:",ee)}},V=async()=>{try{L(!0);const D=await g();u==null||u(D),a==null||a(D)}catch(D){console.error("Failed to create thread:",D)}finally{L(!1)}},M=async(D,ee)=>{if(ee.stopPropagation(),!!confirm("Delete this thread?"))try{await v(D),d==null||d(D)}catch(fe){console.error("Failed to delete thread:",fe)}},Y=(D,ee)=>{ee.stopPropagation(),E(D.threadId),j(D.title||`Thread ${D.threadId.slice(0,8)}`)},q=async D=>{if(A.trim())try{await b(D,A.trim()),E(null),j("")}catch(ee){console.error("Failed to update title:",ee)}},W=()=>{E(null),j("")},z=(D,ee)=>{D.key==="Enter"?q(ee):D.key==="Escape"&&W()},$=D=>{if(!D)return"";try{const ee=new Date(D),ve=new Date().getTime()-ee.getTime(),be=Math.floor(ve/(1e3*60*60*24));return be===0?ee.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):be===1?"Yesterday":be<7?`${be} days ago`:ee.toLocaleDateString()}catch{return""}},ue=D=>D.title||`Thread ${D.threadId.slice(0,8)}`;return c.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&c.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:c.jsx(Ge,{onClick:V,disabled:P||p,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:P?"Creating...":"New Chat",children:c.jsx(ie.MessageSquarePlus,{size:20})})}),c.jsx(Uh,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:c.jsx("div",{className:"p-2 space-y-1 pb-4",children:p?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(ie.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):S.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(ie.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),c.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):S.slice().sort((D,ee)=>new Date(ee.updatedAt||ee.createdAt||"").getTime()-new Date(D.updatedAt||D.createdAt||"").getTime()).map(D=>c.jsxs("div",{onClick:()=>F(D.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??h)===D.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"flex-1 min-w-0",children:k===D.threadId?c.jsxs("div",{className:"flex items-center gap-2",onClick:ee=>ee.stopPropagation(),children:[c.jsx($s,{value:A,onChange:ee=>j(ee.target.value),onKeyDown:ee=>z(ee,D.threadId),className:"h-6 text-sm",autoFocus:!0}),c.jsx(Ge,{variant:"ghost",size:"sm",onClick:()=>q(D.threadId),className:"h-6 w-6 p-0",children:c.jsx(ie.Check,{size:12})}),c.jsx(Ge,{variant:"ghost",size:"sm",onClick:W,className:"h-6 w-6 p-0",children:c.jsx(ie.X,{size:12})})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:ue(D)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(ie.Calendar,{size:10}),c.jsx("span",{children:$(D.updatedAt||D.createdAt)})]})]})}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&k!==D.threadId&&c.jsx(Ge,{variant:"ghost",size:"sm",onClick:ee=>Y(D,ee),className:"h-6 w-6 p-0",title:"Edit title",children:c.jsx(ie.Edit3,{size:12})}),n&&c.jsx(Ge,{variant:"ghost",size:"sm",onClick:ee=>M(D.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:c.jsx(ie.Trash2,{size:12})})]})]}),i===D.threadId&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},D.threadId))})})]})}function _r(e){if(!(typeof globalThis>"u"))return globalThis[e]}function rC(e){if(typeof e!="string")return;const t=e.trim();if(t)return Tn(t)}function Vh(){const e=[_r("__API_BASE_URL__"),_r("__CHAT_API_BASE_URL__"),_r("__CHAT_API_URL__")];for(const t of e){const n=rC(t);if(n)return n}}function qh(){const e=[_r("__API_AUTH_TOKEN__"),_r("__CHAT_API_KEY__"),_r("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Kh(...e){for(const t of e)if(typeof t=="string"&&t.trim())return Tn(t);return Tn()}function Gh(){const e={},t=Vh(),n=qh();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Yh(){const e=Gh(),t=jn.getAuthToken(),n=Vh();return{apiBaseUrl:Kh(e.baseUrl,jn.baseUrl,n),apiKey:t||e.apiKey||qh()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const Xh="chat-settings";function oC(){try{const e=localStorage.getItem(Xh);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function sC(e){try{const t={...e,apiBaseUrl:Tn(e.apiBaseUrl)};localStorage.setItem(Xh,JSON.stringify(t)),t.apiKey&&jn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function iC(){const e=Yh(),t=oC(),n=jn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Kh(jn.baseUrl,r,e.apiBaseUrl)}}function aC(e){jn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),sC(e)}var lC="Label",Jh=m.forwardRef((e,t)=>c.jsx(je.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())}}));Jh.displayName=lC;var Zh=Jh;const cC=xo.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Yt=m.forwardRef(({className:e,...t},n)=>c.jsx(Zh,{ref:n,className:Q(cC(),e),...t}));Yt.displayName=Zh.displayName;function Qh(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Ws="Switch",[uC,OT]=pn(Ws),[dC,fC]=uC(Ws),ep=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:u,form:d,...f}=e,[h,p]=m.useState(null),x=We(t,S=>p(S)),w=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[v,b]=Zn({prop:o,defaultProp:s??!1,onChange:u,caller:Ws});return c.jsxs(dC,{scope:n,checked:v,disabled:a,children:[c.jsx(je.button,{type:"button",role:"switch","aria-checked":v,"aria-required":i,"data-state":op(v),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:x,onClick:de(e.onClick,S=>{b(N=>!N),g&&(w.current=S.isPropagationStopped(),w.current||S.stopPropagation())})}),g&&c.jsx(rp,{control:h,bubbles:!w.current,name:r,value:l,checked:v,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});ep.displayName=Ws;var tp="SwitchThumb",np=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=fC(tp,n);return c.jsx(je.span,{"data-state":op(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});np.displayName=tp;var hC="SwitchBubbleInput",rp=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=We(i,s),l=Qh(n),u=pf(t);return m.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const x=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(x)}},[l,n,r]),c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});rp.displayName=hC;function op(e){return e?"checked":"unchecked"}var sp=ep,pC=np;const Bn=m.forwardRef(({className:e,...t},n)=>c.jsx(sp,{className:Q("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:c.jsx(pC,{className:Q("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));Bn.displayName=sp.displayName;var ip=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),mC="VisuallyHidden",gC=m.forwardRef((e,t)=>c.jsx(je.span,{...e,ref:t,style:{...ip,...e.style}}));gC.displayName=mC;var xC=[" ","Enter","ArrowUp","ArrowDown"],vC=[" ","Enter"],ir="Select",[Vs,qs,wC]=ba(ir),[jr,MT]=pn(ir,[wC,Rs]),Ks=Rs(),[bC,Hn]=jr(ir),[yC,SC]=jr(ir),ap=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:u,name:d,autoComplete:f,disabled:h,required:p,form:x}=e,w=Ks(t),[g,v]=m.useState(null),[b,S]=m.useState(null),[N,C]=m.useState(!1),k=ys(u),[E,A]=Zn({prop:r,defaultProp:o??!1,onChange:s,caller:ir}),[j,P]=Zn({prop:i,defaultProp:a,onChange:l,caller:ir}),L=m.useRef(null),F=g?x||!!g.closest("form"):!0,[V,M]=m.useState(new Set),Y=Array.from(V).map(q=>q.props.value).join(";");return c.jsx(Tf,{...w,children:c.jsxs(bC,{required:p,scope:t,trigger:g,onTriggerChange:v,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:N,onValueNodeHasChildrenChange:C,contentId:mn(),value:j,onValueChange:P,open:E,onOpenChange:A,dir:k,triggerPointerDownPosRef:L,disabled:h,children:[c.jsx(Vs.Provider,{scope:t,children:c.jsx(yC,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(q=>{M(W=>new Set(W).add(q))},[]),onNativeOptionRemove:m.useCallback(q=>{M(W=>{const z=new Set(W);return z.delete(q),z})},[]),children:n})}),F?c.jsxs(jp,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:j,onChange:q=>P(q.target.value),disabled:h,form:x,children:[j===void 0?c.jsx("option",{value:""}):null,Array.from(V)]},Y):null]})})};ap.displayName=ir;var lp="SelectTrigger",cp=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Ks(n),i=Hn(lp,n),a=i.disabled||r,l=We(t,i.onTriggerChange),u=qs(n),d=m.useRef("touch"),[f,h,p]=Pp(w=>{const g=u().filter(S=>!S.disabled),v=g.find(S=>S.value===i.value),b=Op(g,w,v);b!==void 0&&i.onValueChange(b.value)}),x=w=>{a||(i.onOpenChange(!0),p()),w&&(i.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return c.jsx(kf,{asChild:!0,...s,children:c.jsx(je.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":Rp(i.value)?"":void 0,...o,ref:l,onClick:de(o.onClick,w=>{w.currentTarget.focus(),d.current!=="mouse"&&x(w)}),onPointerDown:de(o.onPointerDown,w=>{d.current=w.pointerType;const g=w.target;g.hasPointerCapture(w.pointerId)&&g.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(x(w),w.preventDefault())}),onKeyDown:de(o.onKeyDown,w=>{const g=f.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&h(w.key),!(g&&w.key===" ")&&xC.includes(w.key)&&(x(),w.preventDefault())})})})});cp.displayName=lp;var up="SelectValue",dp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Hn(up,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=We(t,l.onValueNodeChange);return vt(()=>{u(d)},[u,d]),c.jsx(je.span,{...a,ref:f,style:{pointerEvents:"none"},children:Rp(l.value)?c.jsx(c.Fragment,{children:i}):s})});dp.displayName=up;var CC="SelectIcon",fp=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(je.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});fp.displayName=CC;var TC="SelectPortal",hp=e=>c.jsx(ss,{asChild:!0,...e});hp.displayName=TC;var ar="SelectContent",pp=m.forwardRef((e,t)=>{const n=Hn(ar,e.__scopeSelect),[r,o]=m.useState();if(vt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?vo.createPortal(c.jsx(mp,{scope:e.__scopeSelect,children:c.jsx(Vs.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(gp,{...e,ref:t})});pp.displayName=ar;var sn=10,[mp,Un]=jr(ar),kC="SelectContentImpl",IC=Wn.createSlot("SelectContent.RemoveScroll"),gp=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:x,hideWhenDetached:w,avoidCollisions:g,...v}=e,b=Hn(ar,n),[S,N]=m.useState(null),[C,k]=m.useState(null),E=We(t,K=>N(K)),[A,j]=m.useState(null),[P,L]=m.useState(null),F=qs(n),[V,M]=m.useState(!1),Y=m.useRef(!1);m.useEffect(()=>{if(S)return pa(S)},[S]),la();const q=m.useCallback(K=>{const[O,...J]=F().map(se=>se.ref.current),[te]=J.slice(-1),G=document.activeElement;for(const se of K)if(se===G||(se==null||se.scrollIntoView({block:"nearest"}),se===O&&C&&(C.scrollTop=0),se===te&&C&&(C.scrollTop=C.scrollHeight),se==null||se.focus(),document.activeElement!==G))return},[F,C]),W=m.useCallback(()=>q([A,S]),[q,A,S]);m.useEffect(()=>{V&&W()},[V,W]);const{onOpenChange:z,triggerPointerDownPosRef:$}=b;m.useEffect(()=>{if(S){let K={x:0,y:0};const O=te=>{var G,se;K={x:Math.abs(Math.round(te.pageX)-(((G=$.current)==null?void 0:G.x)??0)),y:Math.abs(Math.round(te.pageY)-(((se=$.current)==null?void 0:se.y)??0))}},J=te=>{K.x<=10&&K.y<=10?te.preventDefault():S.contains(te.target)||z(!1),document.removeEventListener("pointermove",O),$.current=null};return $.current!==null&&(document.addEventListener("pointermove",O),document.addEventListener("pointerup",J,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",O),document.removeEventListener("pointerup",J,{capture:!0})}}},[S,z,$]),m.useEffect(()=>{const K=()=>z(!1);return window.addEventListener("blur",K),window.addEventListener("resize",K),()=>{window.removeEventListener("blur",K),window.removeEventListener("resize",K)}},[z]);const[ue,D]=Pp(K=>{const O=F().filter(G=>!G.disabled),J=O.find(G=>G.ref.current===document.activeElement),te=Op(O,K,J);te&&setTimeout(()=>te.ref.current.focus())}),ee=m.useCallback((K,O,J)=>{const te=!Y.current&&!J;(b.value!==void 0&&b.value===O||te)&&(j(K),te&&(Y.current=!0))},[b.value]),fe=m.useCallback(()=>S==null?void 0:S.focus(),[S]),ve=m.useCallback((K,O,J)=>{const te=!Y.current&&!J;(b.value!==void 0&&b.value===O||te)&&L(K)},[b.value]),be=r==="popper"?Ja:xp,ye=be===Ja?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:x,hideWhenDetached:w,avoidCollisions:g}:{};return c.jsx(mp,{scope:n,content:S,viewport:C,onViewportChange:k,itemRefCallback:ee,selectedItem:A,onItemLeave:fe,itemTextRefCallback:ve,focusSelectedItem:W,selectedItemText:P,position:r,isPositioned:V,searchRef:ue,children:c.jsx(ds,{as:IC,allowPinchZoom:!0,children:c.jsx(os,{asChild:!0,trapped:b.open,onMountAutoFocus:K=>{K.preventDefault()},onUnmountAutoFocus:de(o,K=>{var O;(O=b.trigger)==null||O.focus({preventScroll:!0}),K.preventDefault()}),children:c.jsx(rs,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:K=>K.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:c.jsx(be,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:K=>K.preventDefault(),...v,...ye,onPlaced:()=>M(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:de(v.onKeyDown,K=>{const O=K.ctrlKey||K.altKey||K.metaKey;if(K.key==="Tab"&&K.preventDefault(),!O&&K.key.length===1&&D(K.key),["ArrowUp","ArrowDown","Home","End"].includes(K.key)){let te=F().filter(G=>!G.disabled).map(G=>G.ref.current);if(["ArrowUp","End"].includes(K.key)&&(te=te.slice().reverse()),["ArrowUp","ArrowDown"].includes(K.key)){const G=K.target,se=te.indexOf(G);te=te.slice(se+1)}setTimeout(()=>q(te)),K.preventDefault()}})})})})})})});gp.displayName=kC;var EC="SelectItemAlignedPosition",xp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Hn(ar,n),i=Un(ar,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=We(t,E=>d(E)),h=qs(n),p=m.useRef(!1),x=m.useRef(!0),{viewport:w,selectedItem:g,selectedItemText:v,focusSelectedItem:b}=i,S=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&w&&g&&v){const E=s.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),j=s.valueNode.getBoundingClientRect(),P=v.getBoundingClientRect();if(s.dir!=="rtl"){const G=P.left-A.left,se=j.left-G,Ve=E.left-se,Je=E.width+Ve,nt=Math.max(Je,A.width),De=window.innerWidth-sn,Be=Va(se,[sn,Math.max(sn,De-nt)]);a.style.minWidth=Je+"px",a.style.left=Be+"px"}else{const G=A.right-P.right,se=window.innerWidth-j.right-G,Ve=window.innerWidth-E.right-se,Je=E.width+Ve,nt=Math.max(Je,A.width),De=window.innerWidth-sn,Be=Va(se,[sn,Math.max(sn,De-nt)]);a.style.minWidth=Je+"px",a.style.right=Be+"px"}const L=h(),F=window.innerHeight-sn*2,V=w.scrollHeight,M=window.getComputedStyle(u),Y=parseInt(M.borderTopWidth,10),q=parseInt(M.paddingTop,10),W=parseInt(M.borderBottomWidth,10),z=parseInt(M.paddingBottom,10),$=Y+q+V+z+W,ue=Math.min(g.offsetHeight*5,$),D=window.getComputedStyle(w),ee=parseInt(D.paddingTop,10),fe=parseInt(D.paddingBottom,10),ve=E.top+E.height/2-sn,be=F-ve,ye=g.offsetHeight/2,K=g.offsetTop+ye,O=Y+q+K,J=$-O;if(O<=ve){const G=L.length>0&&g===L[L.length-1].ref.current;a.style.bottom="0px";const se=u.clientHeight-w.offsetTop-w.offsetHeight,Ve=Math.max(be,ye+(G?fe:0)+se+W),Je=O+Ve;a.style.height=Je+"px"}else{const G=L.length>0&&g===L[0].ref.current;a.style.top="0px";const Ve=Math.max(ve,Y+w.offsetTop+(G?ee:0)+ye)+J;a.style.height=Ve+"px",w.scrollTop=O-ve+w.offsetTop}a.style.margin=`${sn}px 0`,a.style.minHeight=ue+"px",a.style.maxHeight=F+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,w,g,v,s.dir,r]);vt(()=>S(),[S]);const[N,C]=m.useState();vt(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const k=m.useCallback(E=>{E&&x.current===!0&&(S(),b==null||b(),x.current=!1)},[S,b]);return c.jsx(AC,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:k,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:N},children:c.jsx(je.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});xp.displayName=EC;var NC="SelectPopperPosition",Ja=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=sn,...s}=e,i=Ks(n);return c.jsx(If,{...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)"}})});Ja.displayName=NC;var[AC,Za]=jr(ar,{}),Qa="SelectViewport",vp=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Un(Qa,n),i=Za(Qa,n),a=We(t,s.onViewportChange),l=m.useRef(0);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),c.jsx(Vs.Slot,{scope:n,children:c.jsx(je.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:de(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const x=window.innerHeight-sn*2,w=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),v=Math.max(w,g);if(v<x){const b=v+p,S=Math.min(x,b),N=b-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=N>0?N:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});vp.displayName=Qa;var wp="SelectGroup",[_C,jC]=jr(wp),RC=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=mn();return c.jsx(_C,{scope:n,id:o,children:c.jsx(je.div,{role:"group","aria-labelledby":o,...r,ref:t})})});RC.displayName=wp;var bp="SelectLabel",yp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=jC(bp,n);return c.jsx(je.div,{id:o.id,...r,ref:t})});yp.displayName=bp;var Gs="SelectItem",[PC,Sp]=jr(Gs),Cp=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Hn(Gs,n),l=Un(Gs,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),x=We(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),w=mn(),g=m.useRef("touch"),v=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return c.jsx(PC,{scope:n,value:r,disabled:o,textId:w,isSelected:u,onItemTextChange:m.useCallback(b=>{f(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:c.jsx(Vs.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(je.div,{role:"option","aria-labelledby":w,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:x,onFocus:de(i.onFocus,()=>p(!0)),onBlur:de(i.onBlur,()=>p(!1)),onClick:de(i.onClick,()=>{g.current!=="mouse"&&v()}),onPointerUp:de(i.onPointerUp,()=>{g.current==="mouse"&&v()}),onPointerDown:de(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:de(i.onPointerMove,b=>{var S;g.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):g.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:de(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:de(i.onKeyDown,b=>{var N;((N=l.searchRef)==null?void 0:N.current)!==""&&b.key===" "||(vC.includes(b.key)&&v(),b.key===" "&&b.preventDefault())})})})})});Cp.displayName=Gs;var go="SelectItemText",Tp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Hn(go,n),a=Un(go,n),l=Sp(go,n),u=SC(go,n),[d,f]=m.useState(null),h=We(t,v=>f(v),l.onItemTextChange,v=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,v,l.value,l.disabled)}),p=d==null?void 0:d.textContent,x=m.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:w,onNativeOptionRemove:g}=u;return vt(()=>(w(x),()=>g(x)),[w,g,x]),c.jsxs(c.Fragment,{children:[c.jsx(je.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?vo.createPortal(s.children,i.valueNode):null]})});Tp.displayName=go;var kp="SelectItemIndicator",Ip=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Sp(kp,n).isSelected?c.jsx(je.span,{"aria-hidden":!0,...r,ref:t}):null});Ip.displayName=kp;var el="SelectScrollUpButton",Ep=m.forwardRef((e,t)=>{const n=Un(el,e.__scopeSelect),r=Za(el,e.__scopeSelect),[o,s]=m.useState(!1),i=We(t,r.onScrollButtonChange);return vt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollTop>0;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(Ap,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Ep.displayName=el;var tl="SelectScrollDownButton",Np=m.forwardRef((e,t)=>{const n=Un(tl,e.__scopeSelect),r=Za(tl,e.__scopeSelect),[o,s]=m.useState(!1),i=We(t,r.onScrollButtonChange);return vt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<u;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(Ap,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Np.displayName=tl;var Ap=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Un("SelectScrollButton",n),i=m.useRef(null),a=qs(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),vt(()=>{var d;const u=a().find(f=>f.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),c.jsx(je.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:de(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:de(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:de(o.onPointerLeave,()=>{l()})})}),OC="SelectSeparator",_p=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(je.div,{"aria-hidden":!0,...r,ref:t})});_p.displayName=OC;var nl="SelectArrow",MC=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Ks(n),s=Hn(nl,n),i=Un(nl,n);return s.open&&i.position==="popper"?c.jsx(Ef,{...o,...r,ref:t}):null});MC.displayName=nl;var DC="SelectBubbleInput",jp=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=We(r,o),i=Qh(t);return m.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(je.select,{...n,style:{...ip,...n.style},ref:s,defaultValue:t})});jp.displayName=DC;function Rp(e){return e===""||e===void 0}function Pp(e){const t=yt(e),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(i=>{const a=n.current+i;t(a),function l(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Op(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=LC(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function LC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var FC=ap,Mp=cp,$C=dp,zC=fp,BC=hp,Dp=pp,HC=vp,Lp=yp,Fp=Cp,UC=Tp,WC=Ip,$p=Ep,zp=Np,Bp=_p;const Hp=FC,Up=$C,rl=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Mp,{ref:r,className:Q("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,c.jsx(zC,{asChild:!0,children:c.jsx(ie.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));rl.displayName=Mp.displayName;const Wp=m.forwardRef(({className:e,...t},n)=>c.jsx($p,{ref:n,className:Q("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ie.ChevronUp,{className:"h-4 w-4"})}));Wp.displayName=$p.displayName;const Vp=m.forwardRef(({className:e,...t},n)=>c.jsx(zp,{ref:n,className:Q("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ie.ChevronDown,{className:"h-4 w-4"})}));Vp.displayName=zp.displayName;const ol=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(BC,{children:c.jsxs(Dp,{ref:o,className:Q("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[c.jsx(Wp,{}),c.jsx(HC,{className:Q("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(Vp,{})]})}));ol.displayName=Dp.displayName;const VC=m.forwardRef(({className:e,...t},n)=>c.jsx(Lp,{ref:n,className:Q("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));VC.displayName=Lp.displayName;const lr=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Fp,{ref:r,className:Q("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(WC,{children:c.jsx(ie.Check,{className:"h-4 w-4"})})}),c.jsx(UC,{children:t})]}));lr.displayName=Fp.displayName;const qC=m.forwardRef(({className:e,...t},n)=>c.jsx(Bp,{ref:n,className:Q("-mx-1 my-1 h-px bg-muted",e),...t}));qC.displayName=Bp.displayName;var KC="Separator",qp="horizontal",GC=["horizontal","vertical"],Kp=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=qp,...o}=e,s=YC(r)?r:qp,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(je.div,{"data-orientation":s,...a,...o,ref:t})});Kp.displayName=KC;function YC(e){return GC.includes(e)}var Gp=Kp;const Yp=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(Gp,{ref:o,decorative:n,orientation:t,className:Q("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Yp.displayName=Gp.displayName;const XC=jd,JC=_b,ZC=Rd,Xp=m.forwardRef(({className:e,...t},n)=>c.jsx(gs,{className:Q("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));Xp.displayName=gs.displayName;const QC=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"}}),Jp=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(ZC,{children:[c.jsx(Xp,{}),c.jsxs(xs,{ref:o,className:Q(QC({side:e}),t),...r,children:[n,c.jsxs(Pd,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[c.jsx(ie.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Jp.displayName=xs.displayName;const Zp=({className:e,...t})=>c.jsx("div",{className:Q("flex flex-col space-y-2 text-center sm:text-left",e),...t});Zp.displayName="SheetHeader";const Qp=m.forwardRef(({className:e,...t},n)=>c.jsx(tr,{ref:n,className:Q("text-lg font-semibold text-foreground",e),...t}));Qp.displayName=tr.displayName;const em=m.forwardRef(({className:e,...t},n)=>c.jsx(vs,{ref:n,className:Q("text-sm text-muted-foreground",e),...t}));em.displayName=vs.displayName;const eT={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 tT({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=y.useState(!1),[s,i]=y.useState(!1),[a,l]=y.useState(e),[u,d]=y.useState(!1),{toast:f}=ra();y.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),y.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(eT),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},x=()=>{l(e),d(!1),o(!1)},w=async()=>{try{const v=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${v.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return c.jsxs(XC,{open:r,onOpenChange:o,children:[c.jsx(JC,{asChild:!0,children:c.jsxs(Ge,{variant:"outline",size:"sm",className:n,children:[c.jsx(ie.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(Ki,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(Jp,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(Zp,{children:[c.jsx(Qp,{children:"Chat Settings"}),c.jsx(em,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),c.jsxs("div",{className:"space-y-6 py-6",children:[c.jsxs(to,{children:[c.jsx(no,{className:"pb-3",children:c.jsxs(ro,{className:"text-lg flex items-center gap-2",children:[c.jsx(ie.Server,{className:"h-5 w-5"}),"API Configuration"]})}),c.jsxs(Xo,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Yt,{htmlFor:"api-url",children:"API Base URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx($s,{id:"api-url",value:a.api.baseUrl,onChange:g=>l(v=>({...v,api:{...v.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(Ge,{variant:"outline",onClick:w,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Yt,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(Bn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>l(v=>({...v,api:{...v.api,enableAuth:g}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(Yt,{htmlFor:"auth-token",children:"Authentication Token"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx($s,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>l(v=>({...v,api:{...v.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(Ge,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(ie.EyeOff,{className:"h-4 w-4"}):c.jsx(ie.Eye,{className:"h-4 w-4"})})]})]})]})]}),c.jsxs(to,{children:[c.jsx(no,{className:"pb-3",children:c.jsxs(ro,{className:"text-lg flex items-center gap-2",children:[c.jsx(ie.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),c.jsxs(Xo,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Yt,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(Hp,{value:a.ui.layout,onValueChange:g=>l(v=>({...v,ui:{...v.ui,layout:g}})),children:[c.jsx(rl,{children:c.jsx(Up,{})}),c.jsxs(ol,{children:[c.jsx(lr,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(lr,{value:"fullscreen",children:"Fullscreen"}),c.jsx(lr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Yt,{htmlFor:"theme",children:"Theme"}),c.jsxs(Hp,{value:a.ui.theme,onValueChange:g=>l(v=>({...v,ui:{...v.ui,theme:g}})),children:[c.jsx(rl,{children:c.jsx(Up,{})}),c.jsxs(ol,{children:[c.jsx(lr,{value:"light",children:"Light"}),c.jsx(lr,{value:"dark",children:"Dark"}),c.jsx(lr,{value:"system",children:"System"})]})]})]}),c.jsx(Yp,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Yt,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(Bn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>l(v=>({...v,ui:{...v.ui,showTimestamps:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Yt,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(Bn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>l(v=>({...v,ui:{...v.ui,showAgentNames:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Yt,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(Bn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(v=>({...v,ui:{...v.ui,compactMessages:g}}))})]})]})]})]}),c.jsxs(to,{children:[c.jsx(no,{className:"pb-3",children:c.jsxs(ro,{className:"text-lg flex items-center gap-2",children:[c.jsx(ie.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),c.jsxs(Xo,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Yt,{htmlFor:"auto-save",children:"Auto-save Conversations"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),c.jsx(Bn,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>l(v=>({...v,behavior:{...v.behavior,autoSave:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Yt,{htmlFor:"enable-streaming",children:"Enable Streaming"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),c.jsx(Bn,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>l(v=>({...v,behavior:{...v.behavior,enableStreaming:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Yt,{htmlFor:"typing-indicator",children:"Typing Indicator"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),c.jsx(Bn,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>l(v=>({...v,behavior:{...v.behavior,showTypingIndicator:g}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(Ge,{variant:"outline",onClick:p,children:[c.jsx(ie.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ge,{variant:"outline",onClick:x,children:"Cancel"}),c.jsxs(Ge,{onClick:h,disabled:!u,children:[c.jsx(ie.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function nT({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),l=y.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?c.jsx(Oo,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsx(Fs,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?c.jsx(Oo,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&c.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(Xa,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(Fs,{onError:s.onError,enableFileUpload:!0})})]})})}):c.jsx(Oo,{...s,onThreadChange:l,children:c.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&c.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(Xa,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(Fs,{onError:s.onError,enableFileUpload:!0})})]})})}Re.ChatApi=ec,Re.ChatInterface=Fs,Re.ChatProviders=Oo,Re.ChatSettings=tT,Re.MarkdownContent=ea,Re.MessageComponent=Hd,Re.MessageList=wa,Re.ThreadManager=Xa,Re.applySettings=aC,Re.chatApiClient=jn,Re.default=nT,Re.del=Ql,Re.get=Dt,Re.getChatToken=Xl,Re.getCurrentSettings=iC,Re.getDefaultApiConfig=Gh,Re.getDefaultChatSettings=Yh,Re.onChatTokenChanged=Jl,Re.post=hi,Re.put=Zl,Re.setChatToken=fi,Re.useApi=pi,Re.useChatStream=pc,Re.useMessagesReducer=sc,Re.useStream=yc,Re.useThreadState=Po,Re.useThreads=Ro,Object.defineProperties(Re,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|