teodor-new-chat-ui 3.0.166 → 3.0.167
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +1489 -1481
- package/dist/index.umd.js +29 -29
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(Te,C){typeof exports=="object"&&typeof module<"u"?C(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"],C):(Te=typeof globalThis<"u"?globalThis:Te||self,C(Te.NewChatUI={},Te.React,Te.LucideReact,Te.reactSlot,Te.classVarianceAuthority,Te.clsx,Te.tailwindMerge,Te.ReactDOM))})(this,function(Te,C,se,Et,mr,
|
|
1
|
+
(function(Te,C){typeof exports=="object"&&typeof module<"u"?C(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"],C):(Te=typeof globalThis<"u"?globalThis:Te||self,C(Te.NewChatUI={},Te.React,Te.LucideReact,Te.reactSlot,Te.classVarianceAuthority,Te.clsx,Te.tailwindMerge,Te.ReactDOM))})(this,function(Te,C,se,Et,mr,Wp,Vp,Ps){"use strict";var TT=Object.defineProperty;var kT=(Te,C,se)=>C in Te?TT(Te,C,{enumerable:!0,configurable:!0,writable:!0,value:se}):Te[C]=se;var Hp=(Te,C,se)=>kT(Te,typeof C!="symbol"?C+"":C,se);function Ba(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 h=Ba(C),eo=Ba(Ps);var Os={exports:{}},gr={};/**
|
|
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 Ha;function
|
|
9
|
+
*/var Ha;function Kp(){if(Ha)return gr;Ha=1;var e=C,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,c,u){var d,f={},p=null,m=null;u!==void 0&&(p=""+u),c.key!==void 0&&(p=""+c.key),c.ref!==void 0&&(m=c.ref);for(d in c)r.call(c,d)&&!s.hasOwnProperty(d)&&(f[d]=c[d]);if(a&&a.defaultProps)for(d in c=a.defaultProps,c)f[d]===void 0&&(f[d]=c[d]);return{$$typeof:t,type:a,key:p,ref:m,props:f,_owner:o.current}}return gr.Fragment=n,gr.jsx=i,gr.jsxs=i,gr}var xr={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,7 +14,7 @@
|
|
|
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 Ua;function
|
|
17
|
+
*/var Ua;function qp(){return Ua||(Ua=1,process.env.NODE_ENV!=="production"&&function(){var e=C,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"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.for("react.offscreen"),w=Symbol.iterator,b="@@iterator";function g(k){if(k===null||typeof k!="object")return null;var V=w&&k[w]||k[b];return typeof V=="function"?V:null}var x=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function v(k){{for(var V=arguments.length,ie=new Array(V>1?V-1:0),Ce=1;Ce<V;Ce++)ie[Ce-1]=arguments[Ce];y("error",k,ie)}}function y(k,V,ie){{var Ce=x.ReactDebugCurrentFrame,We=Ce.getStackAddendum();We!==""&&(V+="%s",ie=ie.concat([We]));var Ye=ie.map(function(Le){return String(Le)});Ye.unshift("Warning: "+V),Function.prototype.apply.call(console[k],console,Ye)}}var E=!1,S=!1,T=!1,I=!1,N=!1,j;j=Symbol.for("react.module.reference");function O(k){return!!(typeof k=="string"||typeof k=="function"||k===r||k===s||N||k===o||k===u||k===d||I||k===m||E||S||T||typeof k=="object"&&k!==null&&(k.$$typeof===p||k.$$typeof===f||k.$$typeof===i||k.$$typeof===a||k.$$typeof===c||k.$$typeof===j||k.getModuleId!==void 0))}function A(k,V,ie){var Ce=k.displayName;if(Ce)return Ce;var We=V.displayName||V.name||"";return We!==""?ie+"("+We+")":ie}function F(k){return k.displayName||"Context"}function H(k){if(k==null)return null;if(typeof k.tag=="number"&&v("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof k=="function")return k.displayName||k.name||null;if(typeof k=="string")return k;switch(k){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case u:return"Suspense";case d:return"SuspenseList"}if(typeof k=="object")switch(k.$$typeof){case a:var V=k;return F(V)+".Consumer";case i:var ie=k;return F(ie._context)+".Provider";case c:return A(k,k.render,"ForwardRef");case f:var Ce=k.displayName||null;return Ce!==null?Ce:H(k.type)||"Memo";case p:{var We=k,Ye=We._payload,Le=We._init;try{return H(Le(Ye))}catch{return null}}}return null}var D=Object.assign,J=0,K,oe,W,M,X,Z,he;function $(){}$.__reactDisabledLog=!0;function G(){{if(J===0){K=console.log,oe=console.info,W=console.warn,M=console.error,X=console.group,Z=console.groupCollapsed,he=console.groupEnd;var k={configurable:!0,enumerable:!0,value:$,writable:!0};Object.defineProperties(console,{info:k,log:k,warn:k,error:k,group:k,groupCollapsed:k,groupEnd:k})}J++}}function ee(){{if(J--,J===0){var k={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:D({},k,{value:K}),info:D({},k,{value:oe}),warn:D({},k,{value:W}),error:D({},k,{value:M}),group:D({},k,{value:X}),groupCollapsed:D({},k,{value:Z}),groupEnd:D({},k,{value:he})})}J<0&&v("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var pe=x.ReactCurrentDispatcher,z;function _(k,V,ie){{if(z===void 0)try{throw Error()}catch(We){var Ce=We.stack.trim().match(/\n( *(at )?)/);z=Ce&&Ce[1]||""}return`
|
|
18
18
|
`+z+k}}var Y=!1,Q;{var de=typeof WeakMap=="function"?WeakMap:Map;Q=new de}function ne(k,V){if(!k||Y)return"";{var ie=Q.get(k);if(ie!==void 0)return ie}var Ce;Y=!0;var We=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Ye;Ye=pe.current,pe.current=null,G();try{if(V){var Le=function(){throw Error()};if(Object.defineProperty(Le.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Le,[])}catch(kt){Ce=kt}Reflect.construct(k,[],Le)}else{try{Le.call()}catch(kt){Ce=kt}k.call(Le.prototype)}}else{try{throw Error()}catch(kt){Ce=kt}k()}}catch(kt){if(kt&&Ce&&typeof kt.stack=="string"){for(var Oe=kt.stack.split(`
|
|
19
19
|
`),wt=Ce.stack.split(`
|
|
20
20
|
`),rt=Oe.length-1,st=wt.length-1;rt>=1&&st>=0&&Oe[rt]!==wt[st];)st--;for(;rt>=1&&st>=0;rt--,st--)if(Oe[rt]!==wt[st]){if(rt!==1||st!==1)do if(rt--,st--,st<0||Oe[rt]!==wt[st]){var Bt=`
|
|
@@ -22,33 +22,33 @@
|
|
|
22
22
|
|
|
23
23
|
Check the render method of \``+k+"`."}return""}}function ln(k){return""}var cn={};function Xr(k){{var V=Xe();if(!V){var ie=typeof k=="string"?k:k.displayName||k.name;ie&&(V=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+ie+">.")}return V}}function Jr(k,V){{if(!k._store||k._store.validated||k.key!=null)return;k._store.validated=!0;var ie=Xr(V);if(cn[ie])return;cn[ie]=!0;var Ce="";k&&k._owner&&k._owner!==Kn.current&&(Ce=" It was passed a child from "+H(k._owner.type)+"."),re(k),v('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',ie,Ce),re(null)}}function Zr(k,V){{if(typeof k!="object")return;if(ve(k))for(var ie=0;ie<k.length;ie++){var Ce=k[ie];De(Ce)&&Jr(Ce,V)}else if(De(k))k._store&&(k._store.validated=!0);else if(k){var We=g(k);if(typeof We=="function"&&We!==k.entries)for(var Ye=We.call(k),Le;!(Le=Ye.next()).done;)De(Le.value)&&Jr(Le.value,V)}}}function pn(k){{var V=k.type;if(V==null||typeof V=="string")return;var ie;if(typeof V=="function")ie=V.propTypes;else if(typeof V=="object"&&(V.$$typeof===c||V.$$typeof===f))ie=V.propTypes;else return;if(ie){var Ce=H(V);ct(ie,k.props,"prop",Ce,k)}else if(V.PropTypes!==void 0&&!me){me=!0;var We=H(V);v("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",We||"Unknown")}typeof V.getDefaultProps=="function"&&!V.getDefaultProps.isReactClassApproved&&v("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Qr(k){{for(var V=Object.keys(k.props),ie=0;ie<V.length;ie++){var Ce=V[ie];if(Ce!=="children"&&Ce!=="key"){re(k),v("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ce),re(null);break}}k.ref!==null&&(re(k),v("Invalid attribute `ref` supplied to `React.Fragment`."),re(null))}}var
|
|
25
|
+
Check the top-level render call using <`+ie+">.")}return V}}function Jr(k,V){{if(!k._store||k._store.validated||k.key!=null)return;k._store.validated=!0;var ie=Xr(V);if(cn[ie])return;cn[ie]=!0;var Ce="";k&&k._owner&&k._owner!==Kn.current&&(Ce=" It was passed a child from "+H(k._owner.type)+"."),re(k),v('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',ie,Ce),re(null)}}function Zr(k,V){{if(typeof k!="object")return;if(ve(k))for(var ie=0;ie<k.length;ie++){var Ce=k[ie];De(Ce)&&Jr(Ce,V)}else if(De(k))k._store&&(k._store.validated=!0);else if(k){var We=g(k);if(typeof We=="function"&&We!==k.entries)for(var Ye=We.call(k),Le;!(Le=Ye.next()).done;)De(Le.value)&&Jr(Le.value,V)}}}function pn(k){{var V=k.type;if(V==null||typeof V=="string")return;var ie;if(typeof V=="function")ie=V.propTypes;else if(typeof V=="object"&&(V.$$typeof===c||V.$$typeof===f))ie=V.propTypes;else return;if(ie){var Ce=H(V);ct(ie,k.props,"prop",Ce,k)}else if(V.PropTypes!==void 0&&!me){me=!0;var We=H(V);v("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",We||"Unknown")}typeof V.getDefaultProps=="function"&&!V.getDefaultProps.isReactClassApproved&&v("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Qr(k){{for(var V=Object.keys(k.props),ie=0;ie<V.length;ie++){var Ce=V[ie];if(Ce!=="children"&&Ce!=="key"){re(k),v("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ce),re(null);break}}k.ref!==null&&(re(k),v("Invalid attribute `ref` supplied to `React.Fragment`."),re(null))}}var zp={};function Bp(k,V,ie,Ce,We,Ye){{var Le=O(k);if(!Le){var Oe="";(k===void 0||typeof k=="object"&&k!==null&&Object.keys(k).length===0)&&(Oe+=" 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 wt=ln();wt?Oe+=wt:Oe+=Xe();var rt;k===null?rt="null":ve(k)?rt="array":k!==void 0&&k.$$typeof===t?(rt="<"+(H(k.type)||"Unknown")+" />",Oe=" Did you accidentally export a JSX literal instead of a component?"):rt=typeof k,v("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",rt,Oe)}var st=jn(k,V,ie,We,Ye);if(st==null)return st;if(Le){var Bt=V.children;if(Bt!==void 0)if(Ce)if(ve(Bt)){for(var pr=0;pr<Bt.length;pr++)Zr(Bt[pr],k);Object.freeze&&Object.freeze(Bt)}else v("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 Zr(Bt,k)}if(Ee.call(V,"key")){var Gn=H(k),kt=Object.keys(V).filter(function(CT){return CT!=="key"}),za=kt.length>0?"{key: someKey, "+kt.join(": ..., ")+": ...}":"{key: someKey}";if(!zp[Gn+za]){var ST=kt.length>0?"{"+kt.join(": ..., ")+": ...}":"{}";v(`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} />`,za,Gn,yT,Gn),Fp[Gn+za]=!0}}return k===r?Qr(st):pn(st),st}}function xT(k,V,ie){return zp(k,V,ie,!0)}function bT(k,V,ie){return zp(k,V,ie,!1)}var vT=bT,wT=xT;xr.Fragment=r,xr.jsx=vT,xr.jsxs=wT}()),xr}process.env.NODE_ENV==="production"?Os.exports=Vp():Os.exports=Kp();var l=Os.exports;function Wa(e,t){return function(){return e.apply(t,arguments)}}const{toString:qp}=Object.prototype,{getPrototypeOf:Ms}=Object,{iterator:to,toStringTag:Va}=Symbol,no=(e=>t=>{const n=qp.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ht=e=>(e=e.toLowerCase(),t=>no(t)===e),ro=e=>t=>typeof t===e,{isArray:Yn}=Array,Xn=ro("undefined");function br(e){return e!==null&&!Xn(e)&&e.constructor!==null&&!Xn(e.constructor)&&yt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ka=Ht("ArrayBuffer");function Gp(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ka(e.buffer),t}const Yp=ro("string"),yt=ro("function"),qa=ro("number"),vr=e=>e!==null&&typeof e=="object",Xp=e=>e===!0||e===!1,oo=e=>{if(no(e)!=="object")return!1;const t=Ms(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Va in e)&&!(to in e)},Jp=e=>{if(!vr(e)||br(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Zp=Ht("Date"),Qp=Ht("File"),em=Ht("Blob"),tm=Ht("FileList"),nm=e=>vr(e)&&yt(e.pipe),rm=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||yt(e.append)&&((t=no(e))==="formdata"||t==="object"&&yt(e.toString)&&e.toString()==="[object FormData]"))},om=Ht("URLSearchParams"),[sm,im,am,lm]=["ReadableStream","Request","Response","Headers"].map(Ht),cm=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function wr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Yn(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(br(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 Ga(e,t){if(br(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 An=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ya=e=>!Xn(e)&&e!==An;function Ds(){const{caseless:e,skipUndefined:t}=Ya(this)&&this||{},n={},r=(o,s)=>{const i=e&&Ga(n,s)||s;oo(n[i])&&oo(o)?n[i]=Ds(n[i],o):oo(o)?n[i]=Ds({},o):Yn(o)?n[i]=o.slice():(!t||!Xn(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&wr(arguments[o],r);return n}const um=(e,t,n,{allOwnKeys:r}={})=>(wr(t,(o,s)=>{n&&yt(o)?e[s]=Wa(o,n):e[s]=o},{allOwnKeys:r}),e),dm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),fm=(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)},hm=(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&&Ms(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},pm=(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},mm=e=>{if(!e)return null;if(Yn(e))return e;let t=e.length;if(!qa(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},gm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Ms(Uint8Array)),xm=(e,t)=>{const r=(e&&e[to]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},bm=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},vm=Ht("HTMLFormElement"),wm=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Xa=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),ym=Ht("RegExp"),Ja=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};wr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Sm=e=>{Ja(e,(t,n)=>{if(yt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(yt(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+"'")})}})},Cm=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return Yn(e)?r(e):r(String(e).split(t)),n},Tm=()=>{},km=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Em(e){return!!(e&&yt(e.append)&&e[Va]==="FormData"&&e[to])}const Im=e=>{const t=new Array(10),n=(r,o)=>{if(vr(r)){if(t.indexOf(r)>=0)return;if(br(r))return r;if(!("toJSON"in r)){t[o]=r;const s=Yn(r)?[]:{};return wr(r,(i,a)=>{const c=n(i,o+1);!Xn(c)&&(s[a]=c)}),t[o]=void 0,s}}return r};return n(e,0)},Nm=Ht("AsyncFunction"),jm=e=>e&&(vr(e)||yt(e))&&yt(e.then)&&yt(e.catch),Za=((e,t)=>e?setImmediate:t?((n,r)=>(An.addEventListener("message",({source:o,data:s})=>{o===An&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),An.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",yt(An.postMessage)),Am=typeof queueMicrotask<"u"?queueMicrotask.bind(An):typeof process<"u"&&process.nextTick||Za,R={isArray:Yn,isArrayBuffer:Ka,isBuffer:br,isFormData:rm,isArrayBufferView:Gp,isString:Yp,isNumber:qa,isBoolean:Xp,isObject:vr,isPlainObject:oo,isEmptyObject:Jp,isReadableStream:sm,isRequest:im,isResponse:am,isHeaders:lm,isUndefined:Xn,isDate:Zp,isFile:Qp,isBlob:em,isRegExp:ym,isFunction:yt,isStream:nm,isURLSearchParams:om,isTypedArray:gm,isFileList:tm,forEach:wr,merge:Ds,extend:um,trim:cm,stripBOM:dm,inherits:fm,toFlatObject:hm,kindOf:no,kindOfTest:Ht,endsWith:pm,toArray:mm,forEachEntry:xm,matchAll:bm,isHTMLForm:vm,hasOwnProperty:Xa,hasOwnProp:Xa,reduceDescriptors:Ja,freezeMethods:Sm,toObjectSet:Cm,toCamelCase:wm,noop:Tm,toFiniteNumber:km,findKey:Ga,global:An,isContextDefined:Ya,isSpecCompliantForm:Em,toJSONObject:Im,isAsyncFn:Nm,isThenable:jm,setImmediate:Za,asap:Am,isIterable:e=>e!=null&&yt(e[to])};function Ie(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(Ie,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:R.toJSONObject(this.config),code:this.code,status:this.status}}});const Qa=Ie.prototype,el={};["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=>{el[e]={value:e}}),Object.defineProperties(Ie,el),Object.defineProperty(Qa,"isAxiosError",{value:!0}),Ie.from=(e,t,n,r,o,s)=>{const i=Object.create(Qa);R.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const a=e&&e.message?e.message:"Error",c=t==null&&e?e.code:t;return Ie.call(i,a,c,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 Rm=null;function Ls(e){return R.isPlainObject(e)||R.isArray(e)}function tl(e){return R.endsWith(e,"[]")?e.slice(0,-2):e}function nl(e,t,n){return e?e.concat(t).map(function(o,s){return o=tl(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function _m(e){return R.isArray(e)&&!e.some(Ls)}const Pm=R.toFlatObject(R,{},null,function(t){return/^is[A-Z]/.test(t)});function so(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(b,g){return!R.isUndefined(g[b])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&R.isSpecCompliantForm(t);if(!R.isFunction(o))throw new TypeError("visitor must be a function");function u(w){if(w===null)return"";if(R.isDate(w))return w.toISOString();if(R.isBoolean(w))return w.toString();if(!c&&R.isBlob(w))throw new Ie("Blob is not supported. Use a Buffer instead.");return R.isArrayBuffer(w)||R.isTypedArray(w)?c&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function d(w,b,g){let x=w;if(w&&!g&&typeof w=="object"){if(R.endsWith(b,"{}"))b=r?b:b.slice(0,-2),w=JSON.stringify(w);else if(R.isArray(w)&&_m(w)||(R.isFileList(w)||R.endsWith(b,"[]"))&&(x=R.toArray(w)))return b=tl(b),x.forEach(function(y,E){!(R.isUndefined(y)||y===null)&&t.append(i===!0?nl([b],E,s):i===null?b:b+"[]",u(y))}),!1}return Ls(w)?!0:(t.append(nl(g,b,s),u(w)),!1)}const f=[],p=Object.assign(Pm,{defaultVisitor:d,convertValue:u,isVisitable:Ls});function m(w,b){if(!R.isUndefined(w)){if(f.indexOf(w)!==-1)throw Error("Circular reference detected in "+b.join("."));f.push(w),R.forEach(w,function(x,v){(!(R.isUndefined(x)||x===null)&&o.call(t,x,R.isString(v)?v.trim():v,b,p))===!0&&m(x,b?b.concat(v):[v])}),f.pop()}}if(!R.isObject(e))throw new TypeError("data must be an object");return m(e),t}function rl(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function $s(e,t){this._pairs=[],e&&so(e,this,t)}const ol=$s.prototype;ol.append=function(t,n){this._pairs.push([t,n])},ol.toString=function(t){const n=t?function(r){return t.call(this,r,rl)}:rl;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function Om(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||Om;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 $s(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class il{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 al={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Mm={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:$s,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Fs=typeof window<"u"&&typeof document<"u",zs=typeof navigator=="object"&&navigator||void 0,Dm=Fs&&(!zs||["ReactNative","NativeScript","NS"].indexOf(zs.product)<0),Lm=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",$m=Fs&&window.location.href||"http://localhost",ht={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Fs,hasStandardBrowserEnv:Dm,hasStandardBrowserWebWorkerEnv:Lm,navigator:zs,origin:$m},Symbol.toStringTag,{value:"Module"})),...Mm};function Fm(e,t){return so(e,new ht.classes.URLSearchParams,{visitor:function(n,r,o,s){return ht.isNode&&R.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function zm(e){return R.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Bm(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 ll(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),c=s>=n.length;return i=!i&&R.isArray(o)?o.length:i,c?(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]=Bm(o[i])),!a)}if(R.isFormData(e)&&R.isFunction(e.entries)){const n={};return R.forEachEntry(e,(r,o)=>{t(zm(r),o,n,0)}),n}return null}function Hm(e,t,n){if(R.isString(e))try{return(t||JSON.parse)(e),R.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const yr={transitional:al,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(ll(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 Fm(t,this.formSerializer).toString();if((a=R.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return so(a?{"files[]":t}:t,c&&new c,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Hm(t)):t}],transformResponse:[function(t){const n=this.transitional||yr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(R.isResponse(t)||R.isReadableStream(t))return t;if(t&&R.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Ie.from(a,Ie.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:ht.classes.FormData,Blob:ht.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};R.forEach(["delete","get","head","post","put","patch"],e=>{yr.headers[e]={}});const Um=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"]),Wm=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[cl]=this[cl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Sr(i);r[a]||(Gm(o,i),r[a]=!0)}return R.isArray(t)?t.forEach(s):s(t),this}};St.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),R.reduceDescriptors(St.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),R.freezeMethods(St);function Hs(e,t){const n=this||yr,r=t||n,o=St.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 ul(e){return!!(e&&e.__CANCEL__)}function Jn(e,t,n){Ie.call(this,e??"canceled",Ie.ERR_CANCELED,t,n),this.name="CanceledError"}R.inherits(Jn,Ie,{__CANCEL__:!0});function dl(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Ie("Request failed with status code "+n.status,[Ie.ERR_BAD_REQUEST,Ie.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Ym(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Xm(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(c){const u=Date.now(),d=r[s];i||(i=u),n[o]=c,r[o]=u;let f=s,p=0;for(;f!==o;)p+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const m=d&&u-d;return m?Math.round(p*1e3/m):void 0}}function Jm(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 ao=(e,t,n=3)=>{let r=0;const o=Xm(50,250);return Jm(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,c=i-r,u=o(c),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:c,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)},fl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},hl=e=>(...t)=>R.asap(()=>e(...t)),Zm=ht.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,ht.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(ht.origin),ht.navigator&&/(msie|trident)/i.test(ht.navigator.userAgent)):()=>!0,Qm=ht.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 eg(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function tg(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function pl(e,t,n){let r=!eg(t);return e&&(r||n==!1)?tg(e,t):t}const ml=e=>e instanceof St?{...e}:e;function Rn(e,t){t=t||{};const n={};function r(u,d,f,p){return R.isPlainObject(u)&&R.isPlainObject(d)?R.merge.call({caseless:p},u,d):R.isPlainObject(d)?R.merge({},d):R.isArray(d)?d.slice():d}function o(u,d,f,p){if(R.isUndefined(d)){if(!R.isUndefined(u))return r(void 0,u,f,p)}else return r(u,d,f,p)}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 c={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(ml(u),ml(d),f,!0)};return R.forEach(Object.keys({...e,...t}),function(d){const f=c[d]||o,p=f(e[d],t[d],d);R.isUndefined(p)&&f!==a||(n[d]=p)}),n}const gl=e=>{const t=Rn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=St.from(i),t.url=sl(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(ht.hasStandardBrowserEnv||ht.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(R.isFunction(n.getHeaders)){const c=n.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([d,f])=>{u.includes(d.toLowerCase())&&i.set(d,f)})}}if(ht.hasStandardBrowserEnv&&(r&&R.isFunction(r)&&(r=r(t)),r||r!==!1&&Zm(t.url))){const c=o&&s&&Qm.read(s);c&&i.set(o,c)}return t},ng=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=gl(e);let s=o.data;const i=St.from(o.headers).normalize();let{responseType:a,onUploadProgress:c,onDownloadProgress:u}=o,d,f,p,m,w;function b(){m&&m(),w&&w(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function x(){if(!g)return;const y=St.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),S={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:y,config:e,request:g};dl(function(I){n(I),b()},function(I){r(I),b()},S),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 Ie("Request aborted",Ie.ECONNABORTED,e,g)),g=null)},g.onerror=function(E){const S=E&&E.message?E.message:"Network Error",T=new Ie(S,Ie.ERR_NETWORK,e,g);T.event=E||null,r(T),g=null},g.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const S=o.transitional||al;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),r(new Ie(E,S.clarifyTimeoutError?Ie.ETIMEDOUT:Ie.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&R.forEach(i.toJSON(),function(E,S){g.setRequestHeader(S,E)}),R.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([p,w]=ao(u,!0),g.addEventListener("progress",p)),c&&g.upload&&([f,m]=ao(c),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",m)),(o.cancelToken||o.signal)&&(d=y=>{g&&(r(!y||y.type?new Jn(null,e,g):y),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const v=Ym(o.url);if(v&&ht.protocols.indexOf(v)===-1){r(new Ie("Unsupported protocol "+v+":",Ie.ERR_BAD_REQUEST,e));return}g.send(s||null)})},rg=(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 Ie?d:new Jn(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Ie(`timeout ${t} of ms exceeded`,Ie.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:c}=r;return c.unsubscribe=()=>R.asap(a),c}},og=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},sg=async function*(e,t){for await(const n of ig(e))yield*og(n,t)},ig=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()}},xl=(e,t,n,r)=>{const o=sg(e,t);let s=0,i,a=c=>{i||(i=!0,r&&r(c))};return new ReadableStream({async pull(c){try{const{done:u,value:d}=await o.next();if(u){a(),c.close();return}let f=d.byteLength;if(n){let p=s+=f;n(p)}c.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(c){return a(c),o.return()}},{highWaterMark:2})},bl=64*1024,{isFunction:lo}=R,ag=(({Request:e,Response:t})=>({Request:e,Response:t}))(R.global),{ReadableStream:vl,TextEncoder:wl}=R.global,yl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},lg=e=>{e=R.merge.call({skipUndefined:!0},ag,e);const{fetch:t,Request:n,Response:r}=e,o=t?lo(t):typeof fetch=="function",s=lo(n),i=lo(r);if(!o)return!1;const a=o&&lo(vl),c=o&&(typeof wl=="function"?(w=>b=>w.encode(b))(new wl):async w=>new Uint8Array(await new n(w).arrayBuffer())),u=s&&a&&yl(()=>{let w=!1;const b=new n(ht.origin,{body:new vl,method:"POST",get duplex(){return w=!0,"half"}}).headers.has("Content-Type");return w&&!b}),d=i&&a&&yl(()=>R.isReadableStream(new r("").body)),f={stream:d&&(w=>w.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(w=>{!f[w]&&(f[w]=(b,g)=>{let x=b&&b[w];if(x)return x.call(b);throw new Ie(`Response type '${w}' is not supported`,Ie.ERR_NOT_SUPPORT,g)})});const p=async w=>{if(w==null)return 0;if(R.isBlob(w))return w.size;if(R.isSpecCompliantForm(w))return(await new n(ht.origin,{method:"POST",body:w}).arrayBuffer()).byteLength;if(R.isArrayBufferView(w)||R.isArrayBuffer(w))return w.byteLength;if(R.isURLSearchParams(w)&&(w=w+""),R.isString(w))return(await c(w)).byteLength},m=async(w,b)=>{const g=R.toFiniteNumber(w.getContentLength());return g??p(b)};return async w=>{let{url:b,method:g,data:x,signal:v,cancelToken:y,timeout:E,onDownloadProgress:S,onUploadProgress:T,responseType:I,headers:N,withCredentials:j="same-origin",fetchOptions:O}=gl(w),A=t||fetch;I=I?(I+"").toLowerCase():"text";let F=rg([v,y&&y.toAbortSignal()],E),H=null;const D=F&&F.unsubscribe&&(()=>{F.unsubscribe()});let J;try{if(T&&u&&g!=="get"&&g!=="head"&&(J=await m(N,x))!==0){let Z=new n(b,{method:"POST",body:x,duplex:"half"}),he;if(R.isFormData(x)&&(he=Z.headers.get("content-type"))&&N.setContentType(he),Z.body){const[$,G]=fl(J,ao(hl(T)));x=xl(Z.body,bl,$,G)}}R.isString(j)||(j=j?"include":"omit");const K=s&&"credentials"in n.prototype,oe={...O,signal:F,method:g.toUpperCase(),headers:N.normalize().toJSON(),body:x,duplex:"half",credentials:K?j:void 0};H=s&&new n(b,oe);let W=await(s?A(H,O):A(b,oe));const M=d&&(I==="stream"||I==="response");if(d&&(S||M&&D)){const Z={};["status","statusText","headers"].forEach(ee=>{Z[ee]=W[ee]});const he=R.toFiniteNumber(W.headers.get("content-length")),[$,G]=S&&fl(he,ao(hl(S),!0))||[];W=new r(xl(W.body,bl,$,()=>{G&&G(),D&&D()}),Z)}I=I||"text";let X=await f[R.findKey(f,I)||"text"](W,w);return!M&&D&&D(),await new Promise((Z,he)=>{dl(Z,he,{data:X,headers:St.from(W.headers),status:W.status,statusText:W.statusText,config:w,request:H})})}catch(K){throw D&&D(),K&&K.name==="TypeError"&&/Load failed|fetch/i.test(K.message)?Object.assign(new Ie("Network Error",Ie.ERR_NETWORK,w,H),{cause:K.cause||K}):Ie.from(K,K&&K.code,w,H)}}},cg=new Map,Sl=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,c,u,d=cg;for(;a--;)c=s[a],u=d.get(c),u===void 0&&d.set(c,u=a?new Map:lg(t)),d=u;return u};Sl();const Us={http:Rm,xhr:ng,fetch:{get:Sl}};R.forEach(Us,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Cl=e=>`- ${e}`,ug=e=>R.isFunction(e)||e===null||e===!1,Tl={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,!ug(r)&&(o=Us[(a=String(r)).toLowerCase()],o===void 0))throw new Ie(`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(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
30
|
+
<%s key={someKey} {...props} />`,za,Gn,ST,Gn),zp[Gn+za]=!0}}return k===r?Qr(st):pn(st),st}}function bT(k,V,ie){return Bp(k,V,ie,!0)}function vT(k,V,ie){return Bp(k,V,ie,!1)}var wT=vT,yT=bT;xr.Fragment=r,xr.jsx=wT,xr.jsxs=yT}()),xr}process.env.NODE_ENV==="production"?Os.exports=Kp():Os.exports=qp();var l=Os.exports;function Wa(e,t){return function(){return e.apply(t,arguments)}}const{toString:Gp}=Object.prototype,{getPrototypeOf:Ms}=Object,{iterator:to,toStringTag:Va}=Symbol,no=(e=>t=>{const n=Gp.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ht=e=>(e=e.toLowerCase(),t=>no(t)===e),ro=e=>t=>typeof t===e,{isArray:Yn}=Array,Xn=ro("undefined");function br(e){return e!==null&&!Xn(e)&&e.constructor!==null&&!Xn(e.constructor)&&yt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ka=Ht("ArrayBuffer");function Yp(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ka(e.buffer),t}const Xp=ro("string"),yt=ro("function"),qa=ro("number"),vr=e=>e!==null&&typeof e=="object",Jp=e=>e===!0||e===!1,oo=e=>{if(no(e)!=="object")return!1;const t=Ms(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Va in e)&&!(to in e)},Zp=e=>{if(!vr(e)||br(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Qp=Ht("Date"),em=Ht("File"),tm=Ht("Blob"),nm=Ht("FileList"),rm=e=>vr(e)&&yt(e.pipe),om=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||yt(e.append)&&((t=no(e))==="formdata"||t==="object"&&yt(e.toString)&&e.toString()==="[object FormData]"))},sm=Ht("URLSearchParams"),[im,am,lm,cm]=["ReadableStream","Request","Response","Headers"].map(Ht),um=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function wr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Yn(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(br(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 Ga(e,t){if(br(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 An=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ya=e=>!Xn(e)&&e!==An;function Ds(){const{caseless:e,skipUndefined:t}=Ya(this)&&this||{},n={},r=(o,s)=>{const i=e&&Ga(n,s)||s;oo(n[i])&&oo(o)?n[i]=Ds(n[i],o):oo(o)?n[i]=Ds({},o):Yn(o)?n[i]=o.slice():(!t||!Xn(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&wr(arguments[o],r);return n}const dm=(e,t,n,{allOwnKeys:r}={})=>(wr(t,(o,s)=>{n&&yt(o)?e[s]=Wa(o,n):e[s]=o},{allOwnKeys:r}),e),fm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),hm=(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)},pm=(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&&Ms(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},mm=(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},gm=e=>{if(!e)return null;if(Yn(e))return e;let t=e.length;if(!qa(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},xm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Ms(Uint8Array)),bm=(e,t)=>{const r=(e&&e[to]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},vm=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},wm=Ht("HTMLFormElement"),ym=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Xa=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Sm=Ht("RegExp"),Ja=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};wr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Cm=e=>{Ja(e,(t,n)=>{if(yt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(yt(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+"'")})}})},Tm=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return Yn(e)?r(e):r(String(e).split(t)),n},km=()=>{},Em=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Im(e){return!!(e&&yt(e.append)&&e[Va]==="FormData"&&e[to])}const Nm=e=>{const t=new Array(10),n=(r,o)=>{if(vr(r)){if(t.indexOf(r)>=0)return;if(br(r))return r;if(!("toJSON"in r)){t[o]=r;const s=Yn(r)?[]:{};return wr(r,(i,a)=>{const c=n(i,o+1);!Xn(c)&&(s[a]=c)}),t[o]=void 0,s}}return r};return n(e,0)},jm=Ht("AsyncFunction"),Am=e=>e&&(vr(e)||yt(e))&&yt(e.then)&&yt(e.catch),Za=((e,t)=>e?setImmediate:t?((n,r)=>(An.addEventListener("message",({source:o,data:s})=>{o===An&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),An.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",yt(An.postMessage)),Rm=typeof queueMicrotask<"u"?queueMicrotask.bind(An):typeof process<"u"&&process.nextTick||Za,R={isArray:Yn,isArrayBuffer:Ka,isBuffer:br,isFormData:om,isArrayBufferView:Yp,isString:Xp,isNumber:qa,isBoolean:Jp,isObject:vr,isPlainObject:oo,isEmptyObject:Zp,isReadableStream:im,isRequest:am,isResponse:lm,isHeaders:cm,isUndefined:Xn,isDate:Qp,isFile:em,isBlob:tm,isRegExp:Sm,isFunction:yt,isStream:rm,isURLSearchParams:sm,isTypedArray:xm,isFileList:nm,forEach:wr,merge:Ds,extend:dm,trim:um,stripBOM:fm,inherits:hm,toFlatObject:pm,kindOf:no,kindOfTest:Ht,endsWith:mm,toArray:gm,forEachEntry:bm,matchAll:vm,isHTMLForm:wm,hasOwnProperty:Xa,hasOwnProp:Xa,reduceDescriptors:Ja,freezeMethods:Cm,toObjectSet:Tm,toCamelCase:ym,noop:km,toFiniteNumber:Em,findKey:Ga,global:An,isContextDefined:Ya,isSpecCompliantForm:Im,toJSONObject:Nm,isAsyncFn:jm,isThenable:Am,setImmediate:Za,asap:Rm,isIterable:e=>e!=null&&yt(e[to])};function Ie(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(Ie,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:R.toJSONObject(this.config),code:this.code,status:this.status}}});const Qa=Ie.prototype,el={};["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=>{el[e]={value:e}}),Object.defineProperties(Ie,el),Object.defineProperty(Qa,"isAxiosError",{value:!0}),Ie.from=(e,t,n,r,o,s)=>{const i=Object.create(Qa);R.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const a=e&&e.message?e.message:"Error",c=t==null&&e?e.code:t;return Ie.call(i,a,c,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 _m=null;function Ls(e){return R.isPlainObject(e)||R.isArray(e)}function tl(e){return R.endsWith(e,"[]")?e.slice(0,-2):e}function nl(e,t,n){return e?e.concat(t).map(function(o,s){return o=tl(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function Pm(e){return R.isArray(e)&&!e.some(Ls)}const Om=R.toFlatObject(R,{},null,function(t){return/^is[A-Z]/.test(t)});function so(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(b,g){return!R.isUndefined(g[b])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&R.isSpecCompliantForm(t);if(!R.isFunction(o))throw new TypeError("visitor must be a function");function u(w){if(w===null)return"";if(R.isDate(w))return w.toISOString();if(R.isBoolean(w))return w.toString();if(!c&&R.isBlob(w))throw new Ie("Blob is not supported. Use a Buffer instead.");return R.isArrayBuffer(w)||R.isTypedArray(w)?c&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function d(w,b,g){let x=w;if(w&&!g&&typeof w=="object"){if(R.endsWith(b,"{}"))b=r?b:b.slice(0,-2),w=JSON.stringify(w);else if(R.isArray(w)&&Pm(w)||(R.isFileList(w)||R.endsWith(b,"[]"))&&(x=R.toArray(w)))return b=tl(b),x.forEach(function(y,E){!(R.isUndefined(y)||y===null)&&t.append(i===!0?nl([b],E,s):i===null?b:b+"[]",u(y))}),!1}return Ls(w)?!0:(t.append(nl(g,b,s),u(w)),!1)}const f=[],p=Object.assign(Om,{defaultVisitor:d,convertValue:u,isVisitable:Ls});function m(w,b){if(!R.isUndefined(w)){if(f.indexOf(w)!==-1)throw Error("Circular reference detected in "+b.join("."));f.push(w),R.forEach(w,function(x,v){(!(R.isUndefined(x)||x===null)&&o.call(t,x,R.isString(v)?v.trim():v,b,p))===!0&&m(x,b?b.concat(v):[v])}),f.pop()}}if(!R.isObject(e))throw new TypeError("data must be an object");return m(e),t}function rl(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function $s(e,t){this._pairs=[],e&&so(e,this,t)}const ol=$s.prototype;ol.append=function(t,n){this._pairs.push([t,n])},ol.toString=function(t){const n=t?function(r){return t.call(this,r,rl)}:rl;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function Mm(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function sl(e,t,n){if(!t)return e;const r=n&&n.encode||Mm;R.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=R.isURLSearchParams(t)?t.toString():new $s(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class il{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 al={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Dm={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:$s,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Fs=typeof window<"u"&&typeof document<"u",zs=typeof navigator=="object"&&navigator||void 0,Lm=Fs&&(!zs||["ReactNative","NativeScript","NS"].indexOf(zs.product)<0),$m=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Fm=Fs&&window.location.href||"http://localhost",ht={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Fs,hasStandardBrowserEnv:Lm,hasStandardBrowserWebWorkerEnv:$m,navigator:zs,origin:Fm},Symbol.toStringTag,{value:"Module"})),...Dm};function zm(e,t){return so(e,new ht.classes.URLSearchParams,{visitor:function(n,r,o,s){return ht.isNode&&R.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Bm(e){return R.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Hm(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 ll(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),c=s>=n.length;return i=!i&&R.isArray(o)?o.length:i,c?(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]=Hm(o[i])),!a)}if(R.isFormData(e)&&R.isFunction(e.entries)){const n={};return R.forEachEntry(e,(r,o)=>{t(Bm(r),o,n,0)}),n}return null}function Um(e,t,n){if(R.isString(e))try{return(t||JSON.parse)(e),R.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const yr={transitional:al,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(ll(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 zm(t,this.formSerializer).toString();if((a=R.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return so(a?{"files[]":t}:t,c&&new c,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Um(t)):t}],transformResponse:[function(t){const n=this.transitional||yr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(R.isResponse(t)||R.isReadableStream(t))return t;if(t&&R.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Ie.from(a,Ie.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:ht.classes.FormData,Blob:ht.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};R.forEach(["delete","get","head","post","put","patch"],e=>{yr.headers[e]={}});const Wm=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"]),Vm=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]&&Wm[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},cl=Symbol("internals");function Sr(e){return e&&String(e).trim().toLowerCase()}function io(e){return e===!1||e==null?e:R.isArray(e)?e.map(io):String(e)}function Km(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 qm=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Bs(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 Gm(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Ym(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 St=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,c,u){const d=Sr(c);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||c]=io(a))}const i=(a,c)=>R.forEach(a,(u,d)=>s(u,d,c));if(R.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(R.isString(t)&&(t=t.trim())&&!qm(t))i(Vm(t),n);else if(R.isObject(t)&&R.isIterable(t)){let a={},c,u;for(const d of t){if(!R.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(c=a[u])?R.isArray(c)?[...c,d[1]]:[c,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=Sr(t),t){const r=R.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Km(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=Sr(t),t){const r=R.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Bs(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Sr(i),i){const a=R.findKey(r,i);a&&(!n||Bs(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||Bs(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]=io(o),delete n[s];return}const a=t?Gm(s):String(s).trim();a!==s&&delete n[s],n[a]=io(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[cl]=this[cl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Sr(i);r[a]||(Ym(o,i),r[a]=!0)}return R.isArray(t)?t.forEach(s):s(t),this}};St.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),R.reduceDescriptors(St.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),R.freezeMethods(St);function Hs(e,t){const n=this||yr,r=t||n,o=St.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 ul(e){return!!(e&&e.__CANCEL__)}function Jn(e,t,n){Ie.call(this,e??"canceled",Ie.ERR_CANCELED,t,n),this.name="CanceledError"}R.inherits(Jn,Ie,{__CANCEL__:!0});function dl(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Ie("Request failed with status code "+n.status,[Ie.ERR_BAD_REQUEST,Ie.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Xm(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Jm(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(c){const u=Date.now(),d=r[s];i||(i=u),n[o]=c,r[o]=u;let f=s,p=0;for(;f!==o;)p+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const m=d&&u-d;return m?Math.round(p*1e3/m):void 0}}function Zm(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 ao=(e,t,n=3)=>{let r=0;const o=Jm(50,250);return Zm(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,c=i-r,u=o(c),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:c,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)},fl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},hl=e=>(...t)=>R.asap(()=>e(...t)),Qm=ht.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,ht.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(ht.origin),ht.navigator&&/(msie|trident)/i.test(ht.navigator.userAgent)):()=>!0,eg=ht.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 tg(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function ng(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function pl(e,t,n){let r=!tg(t);return e&&(r||n==!1)?ng(e,t):t}const ml=e=>e instanceof St?{...e}:e;function Rn(e,t){t=t||{};const n={};function r(u,d,f,p){return R.isPlainObject(u)&&R.isPlainObject(d)?R.merge.call({caseless:p},u,d):R.isPlainObject(d)?R.merge({},d):R.isArray(d)?d.slice():d}function o(u,d,f,p){if(R.isUndefined(d)){if(!R.isUndefined(u))return r(void 0,u,f,p)}else return r(u,d,f,p)}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 c={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(ml(u),ml(d),f,!0)};return R.forEach(Object.keys({...e,...t}),function(d){const f=c[d]||o,p=f(e[d],t[d],d);R.isUndefined(p)&&f!==a||(n[d]=p)}),n}const gl=e=>{const t=Rn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=St.from(i),t.url=sl(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(ht.hasStandardBrowserEnv||ht.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(R.isFunction(n.getHeaders)){const c=n.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([d,f])=>{u.includes(d.toLowerCase())&&i.set(d,f)})}}if(ht.hasStandardBrowserEnv&&(r&&R.isFunction(r)&&(r=r(t)),r||r!==!1&&Qm(t.url))){const c=o&&s&&eg.read(s);c&&i.set(o,c)}return t},rg=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=gl(e);let s=o.data;const i=St.from(o.headers).normalize();let{responseType:a,onUploadProgress:c,onDownloadProgress:u}=o,d,f,p,m,w;function b(){m&&m(),w&&w(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function x(){if(!g)return;const y=St.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),S={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:y,config:e,request:g};dl(function(I){n(I),b()},function(I){r(I),b()},S),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 Ie("Request aborted",Ie.ECONNABORTED,e,g)),g=null)},g.onerror=function(E){const S=E&&E.message?E.message:"Network Error",T=new Ie(S,Ie.ERR_NETWORK,e,g);T.event=E||null,r(T),g=null},g.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const S=o.transitional||al;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),r(new Ie(E,S.clarifyTimeoutError?Ie.ETIMEDOUT:Ie.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&R.forEach(i.toJSON(),function(E,S){g.setRequestHeader(S,E)}),R.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([p,w]=ao(u,!0),g.addEventListener("progress",p)),c&&g.upload&&([f,m]=ao(c),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",m)),(o.cancelToken||o.signal)&&(d=y=>{g&&(r(!y||y.type?new Jn(null,e,g):y),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const v=Xm(o.url);if(v&&ht.protocols.indexOf(v)===-1){r(new Ie("Unsupported protocol "+v+":",Ie.ERR_BAD_REQUEST,e));return}g.send(s||null)})},og=(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 Ie?d:new Jn(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Ie(`timeout ${t} of ms exceeded`,Ie.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:c}=r;return c.unsubscribe=()=>R.asap(a),c}},sg=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},ig=async function*(e,t){for await(const n of ag(e))yield*sg(n,t)},ag=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()}},xl=(e,t,n,r)=>{const o=ig(e,t);let s=0,i,a=c=>{i||(i=!0,r&&r(c))};return new ReadableStream({async pull(c){try{const{done:u,value:d}=await o.next();if(u){a(),c.close();return}let f=d.byteLength;if(n){let p=s+=f;n(p)}c.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(c){return a(c),o.return()}},{highWaterMark:2})},bl=64*1024,{isFunction:lo}=R,lg=(({Request:e,Response:t})=>({Request:e,Response:t}))(R.global),{ReadableStream:vl,TextEncoder:wl}=R.global,yl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},cg=e=>{e=R.merge.call({skipUndefined:!0},lg,e);const{fetch:t,Request:n,Response:r}=e,o=t?lo(t):typeof fetch=="function",s=lo(n),i=lo(r);if(!o)return!1;const a=o&&lo(vl),c=o&&(typeof wl=="function"?(w=>b=>w.encode(b))(new wl):async w=>new Uint8Array(await new n(w).arrayBuffer())),u=s&&a&&yl(()=>{let w=!1;const b=new n(ht.origin,{body:new vl,method:"POST",get duplex(){return w=!0,"half"}}).headers.has("Content-Type");return w&&!b}),d=i&&a&&yl(()=>R.isReadableStream(new r("").body)),f={stream:d&&(w=>w.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(w=>{!f[w]&&(f[w]=(b,g)=>{let x=b&&b[w];if(x)return x.call(b);throw new Ie(`Response type '${w}' is not supported`,Ie.ERR_NOT_SUPPORT,g)})});const p=async w=>{if(w==null)return 0;if(R.isBlob(w))return w.size;if(R.isSpecCompliantForm(w))return(await new n(ht.origin,{method:"POST",body:w}).arrayBuffer()).byteLength;if(R.isArrayBufferView(w)||R.isArrayBuffer(w))return w.byteLength;if(R.isURLSearchParams(w)&&(w=w+""),R.isString(w))return(await c(w)).byteLength},m=async(w,b)=>{const g=R.toFiniteNumber(w.getContentLength());return g??p(b)};return async w=>{let{url:b,method:g,data:x,signal:v,cancelToken:y,timeout:E,onDownloadProgress:S,onUploadProgress:T,responseType:I,headers:N,withCredentials:j="same-origin",fetchOptions:O}=gl(w),A=t||fetch;I=I?(I+"").toLowerCase():"text";let F=og([v,y&&y.toAbortSignal()],E),H=null;const D=F&&F.unsubscribe&&(()=>{F.unsubscribe()});let J;try{if(T&&u&&g!=="get"&&g!=="head"&&(J=await m(N,x))!==0){let Z=new n(b,{method:"POST",body:x,duplex:"half"}),he;if(R.isFormData(x)&&(he=Z.headers.get("content-type"))&&N.setContentType(he),Z.body){const[$,G]=fl(J,ao(hl(T)));x=xl(Z.body,bl,$,G)}}R.isString(j)||(j=j?"include":"omit");const K=s&&"credentials"in n.prototype,oe={...O,signal:F,method:g.toUpperCase(),headers:N.normalize().toJSON(),body:x,duplex:"half",credentials:K?j:void 0};H=s&&new n(b,oe);let W=await(s?A(H,O):A(b,oe));const M=d&&(I==="stream"||I==="response");if(d&&(S||M&&D)){const Z={};["status","statusText","headers"].forEach(ee=>{Z[ee]=W[ee]});const he=R.toFiniteNumber(W.headers.get("content-length")),[$,G]=S&&fl(he,ao(hl(S),!0))||[];W=new r(xl(W.body,bl,$,()=>{G&&G(),D&&D()}),Z)}I=I||"text";let X=await f[R.findKey(f,I)||"text"](W,w);return!M&&D&&D(),await new Promise((Z,he)=>{dl(Z,he,{data:X,headers:St.from(W.headers),status:W.status,statusText:W.statusText,config:w,request:H})})}catch(K){throw D&&D(),K&&K.name==="TypeError"&&/Load failed|fetch/i.test(K.message)?Object.assign(new Ie("Network Error",Ie.ERR_NETWORK,w,H),{cause:K.cause||K}):Ie.from(K,K&&K.code,w,H)}}},ug=new Map,Sl=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,c,u,d=ug;for(;a--;)c=s[a],u=d.get(c),u===void 0&&d.set(c,u=a?new Map:cg(t)),d=u;return u};Sl();const Us={http:_m,xhr:rg,fetch:{get:Sl}};R.forEach(Us,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Cl=e=>`- ${e}`,dg=e=>R.isFunction(e)||e===null||e===!1,Tl={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,!dg(r)&&(o=Us[(a=String(r)).toLowerCase()],o===void 0))throw new Ie(`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(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
33
33
|
`+i.map(Cl).join(`
|
|
34
|
-
`):" "+Cl(i[0]):"as no adapter specified";throw new Ie("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:Us};function Ws(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Jn(null,e)}function kl(e){return Ws(e),e.headers=St.from(e.headers),e.data=Hs.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Tl.getAdapter(e.adapter||yr.adapter,e)(e).then(function(r){return Ws(e),r.data=Hs.call(e,e.transformResponse,r),r.headers=St.from(r.headers),r},function(r){return ul(r)||(Ws(e),r&&r.response&&(r.response.data=Hs.call(e,e.transformResponse,r.response),r.response.headers=St.from(r.response.headers))),Promise.reject(r)})}const El="1.12.2",co={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{co[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Il={};co.transitional=function(t,n,r){function o(s,i){return"[Axios v"+El+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Ie(o(i," has been removed"+(n?" in "+n:"")),Ie.ERR_DEPRECATED);return n&&!Il[i]&&(Il[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}},co.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function
|
|
35
|
-
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Rn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&uo.assertOptions(r,{silentJSONParsing:Jt.transitional(Jt.boolean),forcedJSONParsing:Jt.transitional(Jt.boolean),clarifyTimeoutError:Jt.transitional(Jt.boolean)},!1),o!=null&&(R.isFunction(o)?n.paramsSerializer={serialize:o}:uo.assertOptions(o,{encode:Jt.function,serialize:Jt.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),uo.assertOptions(n,{baseUrl:Jt.spelling("baseURL"),withXsrfToken:Jt.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&R.merge(s.common,s[n.method]);s&&R.forEach(["delete","get","head","post","put","patch","common"],w=>{delete s[w]}),n.headers=St.concat(i,s);const a=[];let c=!0;this.interceptors.request.forEach(function(b){typeof b.runWhen=="function"&&b.runWhen(n)===!1||(c=c&&b.synchronous,a.unshift(b.fulfilled,b.rejected))});const u=[];this.interceptors.response.forEach(function(b){u.push(b.fulfilled,b.rejected)});let d,f=0,p;if(!c){const w=[kl.bind(this),void 0];for(w.unshift(...a),w.push(...u),p=w.length,d=Promise.resolve(n);f<p;)d=d.then(w[f++],w[f++]);return d}p=a.length;let m=n;for(;f<p;){const w=a[f++],b=a[f++];try{m=w(m)}catch(g){b.call(this,g);break}}try{d=kl.call(this,m)}catch(w){return Promise.reject(w)}for(f=0,p=u.length;f<p;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=Rn(this.defaults,t);const n=pl(t.baseURL,t.url,t.allowAbsoluteUrls);return sl(n,t.params,t.paramsSerializer)}};R.forEach(["delete","get","head","options"],function(t){_n.prototype[t]=function(n,r){return this.request(Rn(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(Rn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}_n.prototype[t]=n(),_n.prototype[t+"Form"]=n(!0)});let fg=class Hp{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 Jn(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 Hp(function(o){t=o}),cancel:t}}};function hg(e){return function(n){return e.apply(null,n)}}function pg(e){return R.isObject(e)&&e.isAxiosError===!0}const Vs={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(Vs).forEach(([e,t])=>{Vs[t]=e});function Nl(e){const t=new _n(e),n=Wa(_n.prototype.request,t);return R.extend(n,_n.prototype,t,{allOwnKeys:!0}),R.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Nl(Rn(e,o))},n}const tt=Nl(yr);tt.Axios=_n,tt.CanceledError=Jn,tt.CancelToken=fg,tt.isCancel=ul,tt.VERSION=El,tt.toFormData=so,tt.AxiosError=Ie,tt.Cancel=tt.CanceledError,tt.all=function(t){return Promise.all(t)},tt.spread=hg,tt.isAxiosError=pg,tt.mergeConfig=Rn,tt.AxiosHeaders=St,tt.formToJSON=e=>ll(R.isHTMLForm(e)?new FormData(e):e),tt.getAdapter=Tl.getAdapter,tt.HttpStatusCode=Vs,tt.default=tt;const{Axios:RT,AxiosError:_T,CanceledError:PT,isCancel:OT,CancelToken:MT,VERSION:DT,all:LT,Cancel:$T,isAxiosError:FT,spread:zT,toFormData:BT,AxiosHeaders:HT,HttpStatusCode:UT,formToJSON:WT,getAdapter:VT,mergeConfig:KT}=tt,jl=typeof window<"u"?window.__API_BASE_URL__:void 0,Ks=jl?jl.replace(/\/+$/,""):void 0;!Ks&&typeof window<"u"&&console.warn("API base URL is not configured. The API client will need to be configured via apiConfig prop or window.__API_BASE_URL__.");let fo=null;const qs=new Set;function Al(){return fo}function Gs(e){fo=e,qs.forEach(t=>t(e))}function Rl(e){return qs.add(e),()=>qs.delete(e)}const Ot=tt.create({...Ks?{baseURL:Ks}:{},timeout:3e4,withCredentials:!0});Ot.interceptors.request.use(e=>(fo&&(e.headers.Authorization=`Bearer ${fo}`),e)),Ot.interceptors.response.use(e=>e,e=>Promise.reject(e));async function It(e,t){return Ot.defaults.baseURL?(await Ot.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function _l(e,t,n){return Ot.defaults.baseURL?(await Ot.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Pl(e,t,n){return Ot.defaults.baseURL?(await Ot.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ol(e,t){return Ot.defaults.baseURL?(await Ot.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Mt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Ml{get baseUrl(){const t=Ot.defaults.baseURL||"";return String(t).replace(/\/+$|^\s+|\s+$/g,"")}updateConfig(t){t.baseUrl&&(Ot.defaults.baseURL=String(t.baseUrl).replace(/\/+$/g,"")),t.authToken!==void 0&&Gs(t.authToken)}getAuthToken(){return Al()}setAuthToken(t){Gs(t)}onTokenChange(t){return Rl(t)}async listThreads(){const t=await It("/chat/threads"),n=Mt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await _l("/chat/threads",t?{title:t}:void 0);return Mt(r)}async updateThread(t,n){const r=await Pl(`/chat/threads/${t}`,{title:n});return Mt(r)}async deleteThread(t){const n=await Ol(`/chat/threads/${t}`);return Mt(n)}async threadInfo(t){const n=await It(`/chat/threads/${t}/info`);return Mt(n)}async listAgents(){const t=await It("/chat/agents"),n=Mt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await It(`/chat/agents/${t}`);return Mt(n)}async getAgentSchema(t){const n=await It(`/chat/agents/${t}/schema`);return Mt(n)}async getMessages(t){const n=await It(`/chat/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 Mt(n)}async getState(t){const n=await It(`/chat/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Mt(n)}async getStateHistory(t){const n=await It(`/chat/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Mt(n)}async listCheckpoints(t){const n=await It(`/chat/threads/${t}/checkpoints`,{params:{thread_id:t}});return Mt(n)}}const mn=new Ml;function Dl(e={}){const t=e.baseUrl??"/api/chat",n=e.streamPath??"/runs/stream",[r,o]=C.useState(e.token??null),s=C.useRef(e.headers??{}),[i,a]=C.useState(!1),[c,u]=C.useState(null),[d,f]=C.useState(""),[p,m]=C.useState(null),[w,b]=C.useState(0),[g,x]=C.useState(!1),v=C.useRef(null),y=C.useRef(!0),E=C.useRef(0),S=C.useCallback(j=>{o(j)},[]),T=C.useCallback(()=>{var j;(j=v.current)==null||j.abort(),v.current=null,a(!1),x(!1)},[]),I=C.useCallback(()=>{f(""),m(null),u(null)},[]),N=C.useCallback((j,O,A)=>{v.current&&(v.current.abort(),v.current=null),a(!0),u(null),e.autoAppendAssistant!==!1&&f("");const F=new AbortController;return v.current=F,(async()=>{var J,K,oe,W,M,X,Z,he;const H=(()=>{var $;try{return typeof window<"u"&&(($=window.localStorage)==null?void 0:$.getItem("chat-debug"))==="1"}catch{return!1}})(),D=$=>{var G;try{const ee=JSON.parse(JSON.stringify($));return(G=ee==null?void 0:ee.payload)!=null&&G.files_info&&Array.isArray(ee.payload.files_info)&&(ee.payload.files_info=ee.payload.files_info.map(pe=>({...pe,data:pe!=null&&pe.data?`<base64 ${String(pe.data).length} chars>`:pe==null?void 0:pe.data}))),ee}catch{return $}};try{let $={};try{if(r)$={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ae=window.__AUTH_TOKEN__,et=((J=window.localStorage)==null?void 0:J.getItem("authToken"))||null;let qe=null;try{const ut=(K=window.localStorage)==null?void 0:K.getItem("chat-settings");ut&&(qe=((oe=JSON.parse(ut))==null?void 0:oe.apiKey)||null)}catch{}const ct=Ae||et||qe||null;ct&&($={Authorization:`Bearer ${ct}`})}}catch{}H&&console.debug("[use-chat] POST",t+n,D(j));const G=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...$,...s.current},body:JSON.stringify(j),signal:F.signal});if(!G.ok||!G.body){const Ee=await G.text().catch(()=>"");throw H&&console.debug("[use-chat] non-OK response",G.status,Ee==null?void 0:Ee.slice(0,500)),new Error(`stream ${G.status}${Ee?": "+Ee:""}`)}x(!0);const ee=G.body.getReader(),pe=new TextDecoder;let z="",_=[],Y=E.current,Q=null;const de=()=>{if(_.length){const Ee=_.join("");_=[],y.current&&f(Ae=>Ae+Ee)}Q=null},ne=()=>{typeof window<"u"&&Q==null&&(Q=requestAnimationFrame(de))};let _e=Date.now();const Pe=setInterval(()=>{var Ee;if(Date.now()-_e>2e4){const Ae="Stream idle timeout";u(Ae),F.abort(),(Ee=A==null?void 0:A.onError)==null||Ee.call(A,Ae)}},5e3),Ue=1024*1024;try{const Ee=G.headers.get("X-Thread-Id")||G.headers.get("x-thread-id"),Ae=G.headers.get("X-Thread-Created")||G.headers.get("x-thread-created"),et=Ee??null,qe=String(Ae??"").toLowerCase()==="true";for((W=A==null?void 0:A.onOpen)==null||W.call(A,{threadId:et,created:qe});;){const{value:ct,done:ut}=await ee.read();if(ut)break;z+=pe.decode(ct,{stream:!0}),z.length>Ue&&(z="",console.warn("Stream buffer reset: exceeded 1MB"));let ve;for(;(ve=z.indexOf(`
|
|
34
|
+
`):" "+Cl(i[0]):"as no adapter specified";throw new Ie("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:Us};function Ws(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Jn(null,e)}function kl(e){return Ws(e),e.headers=St.from(e.headers),e.data=Hs.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Tl.getAdapter(e.adapter||yr.adapter,e)(e).then(function(r){return Ws(e),r.data=Hs.call(e,e.transformResponse,r),r.headers=St.from(r.headers),r},function(r){return ul(r)||(Ws(e),r&&r.response&&(r.response.data=Hs.call(e,e.transformResponse,r.response),r.response.headers=St.from(r.response.headers))),Promise.reject(r)})}const El="1.12.2",co={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{co[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Il={};co.transitional=function(t,n,r){function o(s,i){return"[Axios v"+El+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Ie(o(i," has been removed"+(n?" in "+n:"")),Ie.ERR_DEPRECATED);return n&&!Il[i]&&(Il[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}},co.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function fg(e,t,n){if(typeof e!="object")throw new Ie("options must be an object",Ie.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],c=a===void 0||i(a,s,e);if(c!==!0)throw new Ie("option "+s+" must be "+c,Ie.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Ie("Unknown option "+s,Ie.ERR_BAD_OPTION)}}const uo={assertOptions:fg,validators:co},Jt=uo.validators;let _n=class{constructor(t){this.defaults=t||{},this.interceptors={request:new il,response:new il}}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=Rn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&uo.assertOptions(r,{silentJSONParsing:Jt.transitional(Jt.boolean),forcedJSONParsing:Jt.transitional(Jt.boolean),clarifyTimeoutError:Jt.transitional(Jt.boolean)},!1),o!=null&&(R.isFunction(o)?n.paramsSerializer={serialize:o}:uo.assertOptions(o,{encode:Jt.function,serialize:Jt.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),uo.assertOptions(n,{baseUrl:Jt.spelling("baseURL"),withXsrfToken:Jt.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&R.merge(s.common,s[n.method]);s&&R.forEach(["delete","get","head","post","put","patch","common"],w=>{delete s[w]}),n.headers=St.concat(i,s);const a=[];let c=!0;this.interceptors.request.forEach(function(b){typeof b.runWhen=="function"&&b.runWhen(n)===!1||(c=c&&b.synchronous,a.unshift(b.fulfilled,b.rejected))});const u=[];this.interceptors.response.forEach(function(b){u.push(b.fulfilled,b.rejected)});let d,f=0,p;if(!c){const w=[kl.bind(this),void 0];for(w.unshift(...a),w.push(...u),p=w.length,d=Promise.resolve(n);f<p;)d=d.then(w[f++],w[f++]);return d}p=a.length;let m=n;for(;f<p;){const w=a[f++],b=a[f++];try{m=w(m)}catch(g){b.call(this,g);break}}try{d=kl.call(this,m)}catch(w){return Promise.reject(w)}for(f=0,p=u.length;f<p;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=Rn(this.defaults,t);const n=pl(t.baseURL,t.url,t.allowAbsoluteUrls);return sl(n,t.params,t.paramsSerializer)}};R.forEach(["delete","get","head","options"],function(t){_n.prototype[t]=function(n,r){return this.request(Rn(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(Rn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}_n.prototype[t]=n(),_n.prototype[t+"Form"]=n(!0)});let hg=class Up{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 Jn(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 Up(function(o){t=o}),cancel:t}}};function pg(e){return function(n){return e.apply(null,n)}}function mg(e){return R.isObject(e)&&e.isAxiosError===!0}const Vs={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(Vs).forEach(([e,t])=>{Vs[t]=e});function Nl(e){const t=new _n(e),n=Wa(_n.prototype.request,t);return R.extend(n,_n.prototype,t,{allOwnKeys:!0}),R.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Nl(Rn(e,o))},n}const tt=Nl(yr);tt.Axios=_n,tt.CanceledError=Jn,tt.CancelToken=hg,tt.isCancel=ul,tt.VERSION=El,tt.toFormData=so,tt.AxiosError=Ie,tt.Cancel=tt.CanceledError,tt.all=function(t){return Promise.all(t)},tt.spread=pg,tt.isAxiosError=mg,tt.mergeConfig=Rn,tt.AxiosHeaders=St,tt.formToJSON=e=>ll(R.isHTMLForm(e)?new FormData(e):e),tt.getAdapter=Tl.getAdapter,tt.HttpStatusCode=Vs,tt.default=tt;const{Axios:_T,AxiosError:PT,CanceledError:OT,isCancel:MT,CancelToken:DT,VERSION:LT,all:$T,Cancel:FT,isAxiosError:zT,spread:BT,toFormData:HT,AxiosHeaders:UT,HttpStatusCode:WT,formToJSON:VT,getAdapter:KT,mergeConfig:qT}=tt,jl=typeof window<"u"?window.__API_BASE_URL__:void 0,Ks=jl?jl.replace(/\/+$/,""):void 0;!Ks&&typeof window<"u"&&console.warn("API base URL is not configured. The API client will need to be configured via apiConfig prop or window.__API_BASE_URL__.");let fo=null;const qs=new Set;function Al(){return fo}function Gs(e){fo=e,qs.forEach(t=>t(e))}function Rl(e){return qs.add(e),()=>qs.delete(e)}const Ot=tt.create({...Ks?{baseURL:Ks}:{},timeout:3e4,withCredentials:!0});Ot.interceptors.request.use(e=>(fo&&(e.headers.Authorization=`Bearer ${fo}`),e)),Ot.interceptors.response.use(e=>e,e=>Promise.reject(e));async function It(e,t){return Ot.defaults.baseURL?(await Ot.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function _l(e,t,n){return Ot.defaults.baseURL?(await Ot.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Pl(e,t,n){return Ot.defaults.baseURL?(await Ot.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ol(e,t){return Ot.defaults.baseURL?(await Ot.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Mt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Ml{get baseUrl(){const t=Ot.defaults.baseURL||"";return String(t).replace(/\/+$|^\s+|\s+$/g,"")}updateConfig(t){t.baseUrl&&(Ot.defaults.baseURL=String(t.baseUrl).replace(/\/+$/g,"")),t.authToken!==void 0&&Gs(t.authToken)}getAuthToken(){return Al()}setAuthToken(t){Gs(t)}onTokenChange(t){return Rl(t)}async listThreads(){const t=await It("/chat/threads"),n=Mt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await _l("/chat/threads",t?{title:t}:void 0);return Mt(r)}async updateThread(t,n){const r=await Pl(`/chat/threads/${t}`,{title:n});return Mt(r)}async deleteThread(t){const n=await Ol(`/chat/threads/${t}`);return Mt(n)}async threadInfo(t){const n=await It(`/chat/threads/${t}/info`);return Mt(n)}async listAgents(){const t=await It("/chat/agents"),n=Mt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await It(`/chat/agents/${t}`);return Mt(n)}async getAgentSchema(t){const n=await It(`/chat/agents/${t}/schema`);return Mt(n)}async getMessages(t){const n=await It(`/chat/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 Mt(n)}async getState(t){const n=await It(`/chat/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Mt(n)}async getStateHistory(t){const n=await It(`/chat/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Mt(n)}async listCheckpoints(t){const n=await It(`/chat/threads/${t}/checkpoints`,{params:{thread_id:t}});return Mt(n)}}const mn=new Ml;function Dl(e={}){const t=e.baseUrl??"/api/chat",n=e.streamPath??"/runs/stream",[r,o]=C.useState(e.token??null),s=C.useRef(e.headers??{}),[i,a]=C.useState(!1),[c,u]=C.useState(null),[d,f]=C.useState(""),[p,m]=C.useState(null),[w,b]=C.useState(0),[g,x]=C.useState(!1),v=C.useRef(null),y=C.useRef(!0),E=C.useRef(0),S=C.useCallback(j=>{o(j)},[]),T=C.useCallback(()=>{var j;(j=v.current)==null||j.abort(),v.current=null,a(!1),x(!1)},[]),I=C.useCallback(()=>{f(""),m(null),u(null)},[]),N=C.useCallback((j,O,A)=>{v.current&&(v.current.abort(),v.current=null),a(!0),u(null),e.autoAppendAssistant!==!1&&f("");const F=new AbortController;return v.current=F,(async()=>{var J,K,oe,W,M,X,Z,he;const H=(()=>{var $;try{return typeof window<"u"&&(($=window.localStorage)==null?void 0:$.getItem("chat-debug"))==="1"}catch{return!1}})(),D=$=>{var G;try{const ee=JSON.parse(JSON.stringify($));return(G=ee==null?void 0:ee.payload)!=null&&G.files_info&&Array.isArray(ee.payload.files_info)&&(ee.payload.files_info=ee.payload.files_info.map(pe=>({...pe,data:pe!=null&&pe.data?`<base64 ${String(pe.data).length} chars>`:pe==null?void 0:pe.data}))),ee}catch{return $}};try{let $={};try{if(r)$={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ae=window.__AUTH_TOKEN__,et=((J=window.localStorage)==null?void 0:J.getItem("authToken"))||null;let qe=null;try{const ut=(K=window.localStorage)==null?void 0:K.getItem("chat-settings");ut&&(qe=((oe=JSON.parse(ut))==null?void 0:oe.apiKey)||null)}catch{}const ct=Ae||et||qe||null;ct&&($={Authorization:`Bearer ${ct}`})}}catch{}H&&console.debug("[use-chat] POST",t+n,D(j));const G=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...$,...s.current},body:JSON.stringify(j),signal:F.signal});if(!G.ok||!G.body){const Ee=await G.text().catch(()=>"");throw H&&console.debug("[use-chat] non-OK response",G.status,Ee==null?void 0:Ee.slice(0,500)),new Error(`stream ${G.status}${Ee?": "+Ee:""}`)}x(!0);const ee=G.body.getReader(),pe=new TextDecoder;let z="",_=[],Y=E.current,Q=null;const de=()=>{if(_.length){const Ee=_.join("");_=[],y.current&&f(Ae=>Ae+Ee)}Q=null},ne=()=>{typeof window<"u"&&Q==null&&(Q=requestAnimationFrame(de))};let _e=Date.now();const Pe=setInterval(()=>{var Ee;if(Date.now()-_e>2e4){const Ae="Stream idle timeout";u(Ae),F.abort(),(Ee=A==null?void 0:A.onError)==null||Ee.call(A,Ae)}},5e3),Ue=1024*1024;try{const Ee=G.headers.get("X-Thread-Id")||G.headers.get("x-thread-id"),Ae=G.headers.get("X-Thread-Created")||G.headers.get("x-thread-created"),et=Ee??null,qe=String(Ae??"").toLowerCase()==="true";for((W=A==null?void 0:A.onOpen)==null||W.call(A,{threadId:et,created:qe});;){const{value:ct,done:ut}=await ee.read();if(ut)break;z+=pe.decode(ct,{stream:!0}),z.length>Ue&&(z="",console.warn("Stream buffer reset: exceeded 1MB"));let ve;for(;(ve=z.indexOf(`
|
|
36
36
|
|
|
37
|
-
`))>=0;){const Fe=z.slice(0,ve);z=z.slice(ve+2);const Ge=
|
|
38
|
-
`)}const xg={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};function bg(e,t){var n;switch(t.type){case"reset":return{messages:Ys(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};case"seed":{const r=Ys(t.payload.messages),o={...e,messages:r,assemblingId:null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),console.log("[MessageReducer] seed action (REPLACE mode):",{incomingCount:t.payload.messages.length,sanitizedCount:r.length,previousCount:e.messages.length,checkpointId:o.lastCheckpointId}),o}case"prepend":{const r=Ys(t.payload.messages);if(!r.length)return console.log("[MessageReducer] No incoming messages after sanitize - skipping"),e;const o=new Set(e.messages.map(i=>i.id)),s=r.filter(i=>!o.has(i.id));return console.log("[MessageReducer] After dedup:",{uniqueCount:s.length,duplicates:r.length-s.length,finalTotal:s.length+e.messages.length}),s.length?{...e,messages:[...s,...e.messages]}:(console.log("[MessageReducer] All messages were duplicates - skipping"),e)}case"user_message":{const r=t.payload.message;if(e.assemblingId){const o=e.messages.findIndex(s=>s.id===e.assemblingId);if(o!==-1)return{...e,messages:[...e.messages.slice(0,o),r,...e.messages.slice(o)]}}return{...e,messages:[...e.messages,r]}}case"event":return $l(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>$l(o,s),e):e}default:return e}}function Ll(e=[]){const[t,n]=C.useReducer(bg,{...xg,messages:e}),r=C.useRef([]),o=C.useRef(null),s=C.useRef(null),i=C.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=C.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]),c=C.useCallback(d=>{r.current.push(d),a()},[a]);C.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const u=C.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:c}),[c]);return{state:t,dispatch:n,...u}}function $l(e,t){var n;if(t.type==="message_start"&&t.role==="assistant"){const r=t.id,o=Cg(t.model),s={id:r,role:"assistant",name:o||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:r,messages:[...e.messages,s]}}if(t.type==="token"){const r=e.assemblingId??Xs(e.messages);return r?{...e,messages:wg(e.messages,r,t.content)}:e}if(t.type==="message_delta"){const r=e.assemblingId??Xs(e.messages);return r?{...e,messages:Fl(e.messages,r,t.delta)}:e}if(t.type==="message_end"){const r=e.assemblingId??Xs(e.messages);if(!r)return{...e,assemblingId:null};const o=e.messages,s=o.findIndex(i=>i.id===r&&i.role==="assistant");if(s>=0&&!((n=o[s].content)==null?void 0:n.some(c=>{var u;return(c==null?void 0:c.type)==="text"&&((u=c.text)==null?void 0:u.trim())}))){const c=[...o.slice(0,s),...o.slice(s+1)];return{...e,assemblingId:null,messages:c}}return e}if(t.type==="tool_start"){const r=`tool-${t.id}`,o={type:"tool_call",id:t.id,name:t.name,args:t.args},s={id:r,role:"tool",name:t.name,createdAt:new Date().toISOString(),content:[o]};return{...e,messages:[...e.messages,s],toolIndex:{...e.toolIndex,[t.id]:r}}}if(t.type==="tool_result"){const r=e.toolIndex[t.id]??`tool-${t.id}`,o={type:"tool_result",toolCallId:t.id,output:t.output,error:t.error},s=e.messages.find(c=>c.id===r),i={id:r,role:"tool",content:[o],createdAt:new Date().toISOString()},a=s?Fl(e.messages,r,[o]):[...e.messages,i];return{...e,messages:a}}if(t.type==="checkpoint"){const r=t.checkpointNs??e.lastCheckpointNs??null,o=Sg(e.messages,t.checkpointId,r);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:r,messages:o}}if(t.type==="branch"){const r=t.checkpointId??e.lastCheckpointId,o=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:r??null,lastCheckpointNs:o??null}}if(t.type==="error"){const r={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,r]}}return e}function Ys(e){return e.filter(t=>{if(t.role!=="assistant")return!0;const n=(t.content||[]).some(o=>{var s;return o&&o.type==="text"&&((s=o.text)==null?void 0:s.trim())}),r=(t.content||[]).some(o=>o&&o.type==="image_url");return!!(n||r)})}function vg(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Xs(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function wg(e,t,n){return e.map(r=>{if(r.id!==t)return r;const o=r.content.slice(),s=o[o.length-1];return s&&s.type==="text"?s.text+=n:o.push({type:"text",text:n}),{...r,content:o}})}function Fl(e,t,n){return e.map(r=>r.id===t?{...r,content:yg(r.content,n)}:r)}function yg(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1];(o==null?void 0:o.type)==="text"?o.text+=r.text:n.push({type:"text",text:r.text})}else n.push(r);return n}function Sg(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 vg(e,r,s)}return e}function Cg(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Tg(e,t){const n=e==null?void 0:e.checkpoints,r=Array.isArray(n)?n.slice():n?Object.values(n):[],o=i=>i&&typeof i=="object"&&i!==null&&"checkpointId"in i&&"createdAt"in i&&typeof i.checkpointId=="string"&&typeof i.createdAt=="string",s=r.filter(o).map(i=>{const a=i;return{checkpointId:a.checkpointId,checkpointNs:a.checkpointNs??"",createdAt:a.createdAt,messagesLen:a.messagesLen??0,preview:a.preview??"",role:a.role??null,parentId:a.parentId??null,editedMessageId:a.editedMessageId??null,branchLabel:a.branchLabel??null,lastMessageId:a.lastMessageId??null,hasMessages:typeof a.hasMessages=="boolean"?a.hasMessages:void 0}});return{threadId:(e==null?void 0:e.threadId)??t??null,checkpoints:s}}async function kg(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 c=0;c<a;c++)i+=String.fromCharCode(s[c]);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 c of t)try{const u=await kg(c);a.push({filename:c.name,data:u,mime_type:c.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const zl=C.createContext(null);function Cr({children:e,apiConfig:t,onError:n,onThreadChange:r,initialThreadId:o=null,autoLoadInitial:s=!0,enableFileAgentRouting:i=!1,fileAgentId:a="invoice_reader"}){const c=mn;C.useEffect(()=>{t&&c.updateConfig({baseUrl:t.baseUrl,authToken:t.apiKey})},[c,t]);const{isStreaming:u,error:d,stream:f,stop:p,setToken:m}=Dl({baseUrl:c.baseUrl,token:null,headers:t==null?void 0:t.headers,streamPath:"/chat/runs/stream"}),[w,b]=C.useState(()=>typeof c.getAuthToken=="function"?c.getAuthToken():null);C.useEffect(()=>{m(typeof c.getAuthToken=="function"?c.getAuthToken():null);const P=c.onTokenChange(U=>{b(U),m(U)});return()=>{P()}},[c,m]);const g=C.useCallback(P=>{c.setAuthToken(P)},[c]),{state:x,seed:v,prepend:y,pushUser:E,onEvent:S,reset:T}=Ll(),I=20,[N,j]=C.useState(!1),[O,A]=C.useState(!1),[F,H]=C.useState(null),[D,J]=C.useState(void 0),[K,oe]=C.useState(void 0),W=C.useRef(!1),M=C.useRef([]),X=C.useCallback(P=>{P.cursor!==void 0&&H(P.cursor),P.hasMore!==void 0&&j(P.hasMore),P.checkpointId!==void 0&&J(P.checkpointId),P.checkpointNs!==void 0&&oe(P.checkpointNs)},[]),Z=C.useCallback((P,U)=>new Promise((ue,be)=>{const le=async()=>{if(W.current){console.warn(`[ChatProvider] Operation "${U}" queued - another operation in progress`),M.current.push(le);return}W.current=!0;try{console.log(`[ChatProvider] Executing operation: ${U}`),await P(),ue()}catch(Be){console.error(`[ChatProvider] Operation "${U}" failed:`,Be),be(Be)}finally{W.current=!1;const Be=M.current.shift();Be&&Be().catch(()=>{})}};W.current?(M.current.push(le),console.log(`[ChatProvider] Queued operation: ${U}`)):le().catch(Be=>{be(Be)})}),[]),he=C.useCallback((P,U)=>{const ue=Array.isArray(P==null?void 0:P.messages)?P.messages:[];U==="replace"?(console.log("[ChatProvider] Replacing messages, count:",ue.length),v(ue,{checkpointId:(P==null?void 0:P.checkpointId)??null,checkpointNs:(P==null?void 0:P.checkpointNs)??null})):U==="prepend"&&ue.length?(console.log("[ChatProvider] Calling prepend with",ue.length,"messages"),y(ue)):console.log("[ChatProvider] Skipping prepend - empty list or wrong mode"),H((P==null?void 0:P.nextCursor)??null),j(!!(P!=null&&P.hasMore)),J(be=>(P==null?void 0:P.checkpointId)??be??void 0),oe(be=>(P==null?void 0:P.checkpointNs)??be??void 0)},[v,y]),[$,G]=C.useState([]),[ee,pe]=C.useState(null),z=C.useCallback(async()=>{const P=await c.listThreads();G(P)},[c]),[_,Y]=C.useState(!1),Q=C.useCallback(async P=>{const U=(P==null?void 0:P.maxAttempts)??5,ue=(P==null?void 0:P.baseDelayMs)??500,be=(P==null?void 0:P.timeoutMs)??2e3;if(!c.baseUrl)return!1;const le=c.baseUrl.replace(/\/+$/,""),Be=["/health","/api/health","/","/api/v2/health","/api/v2/chat/health"],at=async xt=>{try{const _t=new AbortController,ft=setTimeout(()=>_t.abort(),be),Pt=await fetch(xt,{method:"GET",signal:_t.signal});return clearTimeout(ft),Pt.ok}catch{return!1}},hn=async xt=>{try{const _t=new AbortController,ft=setTimeout(()=>_t.abort(),be),Pt=await fetch(xt,{method:"HEAD",signal:_t.signal});return clearTimeout(ft),Pt.ok}catch{return!1}};for(let xt=0;xt<U;xt++){console.debug(`[ChatProvider] health-check attempt ${xt+1}/${U}`);for(const ft of Be){let Pt=ft;le.endsWith("/api")&&ft.startsWith("/api")&&(Pt=ft.replace(/^\/api/,"")||"/");const jn=Pt==="/"?le+"/":le+Pt;if(console.debug(`[ChatProvider] checking ${jn}`),await at(jn)||ft==="/"&&await hn(le+"/"))return Y(!0),!0}const _t=ue*Math.pow(2,xt);await new Promise(ft=>setTimeout(ft,_t))}return Y(!1),!1},[c.baseUrl]);C.useEffect(()=>{let P=!0;if(!c.baseUrl){console.debug("[ChatProvider] skipping initial refreshThreads: api.baseUrl not configured");return}return(async()=>{try{const U=await Q();if(!P)return;U?z().catch(()=>{}):console.warn("[ChatProvider] backend health-check failed — skipping initial loads")}catch{}})(),()=>{P=!1}},[z,c.baseUrl,Q]),C.useEffect(()=>{r==null||r(ee)},[ee,r]);const de=C.useRef(null);C.useEffect(()=>{if(o&&s){if(!c.baseUrl){console.debug("[ChatProvider] skipping initial load: api.baseUrl not configured");return}if(!_){console.debug("[ChatProvider] deferring initial load until backend health-check passes");return}de.current!==o&&(de.current=o,Pe(o).catch(()=>{}))}},[o,s,c.baseUrl,_]);const ne=C.useRef(null),_e=C.useRef(null),Pe=C.useCallback(async(P,U,ue)=>{await Z(async()=>{if(!c.baseUrl){console.debug("[ChatProvider] skipping loadThread: api.baseUrl not configured");return}if(ne.current){console.warn(`[ChatProvider] Thread load cancelled - another thread (${ne.current}) is loading`);return}_e.current!==null&&_e.current!==P&&(console.log(`[ChatProvider] Thread switch detected: ${_e.current} -> ${P}`),T([])),ne.current=P,_e.current=P;try{X({cursor:null,hasMore:!1,checkpointId:void 0,checkpointNs:void 0}),pe(P);const le=await c.getMessages({threadId:P,checkpointId:U,checkpointNs:ue,limit:I}),Be=Array.isArray(le==null?void 0:le.messages)?le.messages:[];console.log("[ChatProvider] Loading thread with",Be.length,"messages"),v(Be,{checkpointId:(le==null?void 0:le.checkpointId)??null,checkpointNs:(le==null?void 0:le.checkpointNs)??null}),H((le==null?void 0:le.nextCursor)??null),j(!!(le!=null&&le.hasMore)),J(at=>(le==null?void 0:le.checkpointId)??at??void 0),oe(at=>(le==null?void 0:le.checkpointNs)??at??void 0)}finally{ne.current=null}},`loadThread-${P}`)},[c,Z,X,v]),Ue=C.useCallback(async P=>{const U=await c.listCheckpoints(P);return Tg(U,P)},[c]),Ee=C.useCallback(async(P,U)=>{await Z(async()=>{if(!ee)throw new Error("No active thread");X({cursor:null,hasMore:!1,checkpointId:void 0,checkpointNs:void 0});const ue=await c.getMessages({threadId:ee,checkpointId:P,checkpointNs:U??void 0,limit:I});he(ue,"replace")},`navigateToCheckpoint-${P}`)},[c,ee,he,Z,X]),Ae=C.useCallback(async()=>{if(!ee)throw new Error("No active thread");await Pe(ee)},[ee,Pe]),et=C.useRef(!1);C.useEffect(()=>{const P=et.current;et.current=u,P&&!u&&ee&&Z(async()=>{try{await z()}catch(U){console.warn("[ChatProvider] Post-streaming thread refresh failed:",U)}},"postStreamingRefresh")},[u,ee,c,he,z,Z]);const qe=C.useCallback(async P=>{const U=await c.createThread(P);return await z(),await Pe(U.threadId),U.threadId},[c,z,Pe]),ct=C.useCallback(async P=>{await c.deleteThread(P),await z(),ee===P&&(pe(null),T([]),j(!1),H(null),J(void 0),oe(void 0))},[c,z,ee,T]),ut=C.useCallback(async(P,U)=>{await c.updateThread(P,U),await z()},[c,z]),ve=C.useCallback(async(P,U)=>{await Z(async()=>{var qn;const ue=(U==null?void 0:U.attachments)||[],{contentParts:be,filesInfo:le}=await Eg(c,ue,t==null?void 0:t.uploadPath),Be=[];P&&P.trim()&&Be.push({type:"text",text:P.trim()});const at={id:((qn=crypto.randomUUID)==null?void 0:qn.call(crypto))||`user-${Date.now()}`,role:"user",content:Be,createdAt:new Date().toISOString(),checkpointId:(U==null?void 0:U.checkpointId)??x.lastCheckpointId??void 0,checkpointNs:(U==null?void 0:U.checkpointNs)??x.lastCheckpointNs??void 0};E(at);const hn={...at,content:Be},xt={...(U==null?void 0:U.payloadExtras)??{}},_t=!!xt.edit,ft=xt.originalMessageId,Pt=typeof ft=="string"?ft:void 0,jn=ue&&ue.length>0,Kn={...ee?{threadId:ee}:{},payload:{messages:[hn],files_info:le,...i&&jn&&a?{active_agent:a}:{},...xt},checkpointId:(U==null?void 0:U.checkpointId)??x.lastCheckpointId??void 0,checkpointNs:(U==null?void 0:U.checkpointNs)??x.lastCheckpointNs??void 0,nodeFilter:U==null?void 0:U.nodeFilter,config:U==null?void 0:U.config,edit:_t,originalMessageId:Pt};f(Kn,re=>S(re),{onError:re=>console.warn("stream error",re),onOpen:({threadId:re,created:me})=>{!ee&&re&&(pe(re),me&&z().catch(()=>{}))}})},"send")},[ee,E,f,S,x.lastCheckpointId,x.lastCheckpointNs,c,t==null?void 0:t.uploadPath,z,pe,i,a,Z]),Fe=C.useCallback(async P=>{if(!ee)throw new Error("No active thread");if(O||!N)return;const U=F;if(U){A(!0);try{const ue=await c.getMessages({threadId:ee,checkpointId:D,checkpointNs:K,limit:(P==null?void 0:P.limit)??I,beforeId:U});he(ue,"prepend")}finally{A(!1)}}},[c,ee,D,K,F,N,O,he,I]),Ge={baseUrl:c.baseUrl,token:w,setToken:g,api:c,threads:$,currentThreadId:ee,setCurrentThreadId:pe,messages:x.messages,isStreaming:u,error:d,lastCheckpointId:x.lastCheckpointId,lastCheckpointNs:x.lastCheckpointNs,streamingAssistantId:x.assemblingId,hasMoreHistory:N,isLoadingHistory:O,loadOlderMessages:Fe,historyPageSize:I,listCheckpoints:Ue,navigateToCheckpoint:Ee,returnToLatest:Ae,refreshThreads:z,createThread:qe,deleteThread:ct,renameThread:ut,loadThread:Pe,send:ve,stop:p};return l.jsx(zl.Provider,{value:Ge,children:e})}function ho(){const e=C.useContext(zl);if(!e)throw new Error("useChat must be used within ChatProvider");return e}function L(...e){return Wp.twMerge(Up.clsx(e))}const Ig=mr.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"}}),ze=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Et.Slot:"button";return l.jsx(i,{className:L(Ig({variant:t,size:n,className:e})),ref:s,...o})});ze.displayName="Button";const Bl=h.forwardRef(({className:e,...t},n)=>l.jsx("textarea",{className:L("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}));Bl.displayName="Textarea";function Ng({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,onSend:i,onCancelEdit:a,onStop:c,className:u="",textareaClassName:d="",allowEmptySend:f=!1}){const[p,m]=C.useState(e),[w,b]=C.useTransition(),g=C.useRef(null);C.useEffect(()=>{m(e??""),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const x=C.useCallback(()=>{const N=g.current;N&&(N.style.height="auto",N.style.height=`${N.scrollHeight}px`)},[]);C.useEffect(()=>{x()},[x]);const v=C.useCallback(async N=>{N&&N.preventDefault();const j=(p??"").trim();!j&&!f||b(()=>{try{const O=i(j);O&&typeof O.then=="function"?O.then(()=>{m(""),g.current&&(g.current.style.height="auto")}).catch(()=>{}):(m(""),g.current&&(g.current.style.height="auto"))}catch{}})},[p,i,f]),y=C.useCallback(N=>{m(N.target.value),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),E=C.useCallback(N=>{N.key==="Enter"&&!N.shiftKey?(N.preventDefault(),v()):N.key==="Escape"&&t&&(N.preventDefault(),a==null||a())},[v,t,a]),I=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${d}`;return l.jsx("form",{onSubmit:N=>void v(N),className:`w-full ${u}`,children:l.jsxs("div",{className:"flex items-end gap-2",children:[l.jsx("div",{className:"flex-1",children:l.jsx(Bl,{ref:g,value:p,onChange:y,onKeyDown:E,placeholder:t?"Edit your message...":n,className:I,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),l.jsx("div",{children:r?l.jsx(ze,{type:"button",onClick:()=>{c==null||c()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!c,children:l.jsx(se.Square,{size:16})}):l.jsx(ze,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!p.trim()&&!f||w,children:l.jsx(se.Send,{size:16})})})]})})}const jg=C.memo(Ng),po=0,gn=1,Zn=2,Hl=4;function Ul(e){return()=>e}function Ag(e){e()}function Wl(e,t){return n=>e(t(n))}function Vl(e,t){return()=>e(t)}function Rg(e,t){return n=>e(t,n)}function Js(e){return e!==void 0}function _g(...e){return()=>{e.map(Ag)}}function Qn(){}function mo(e,t){return t(e),e}function Pg(e,t){return t(e)}function Je(...e){return e}function He(e,t){return e(gn,t)}function Ne(e,t){e(po,t)}function Zs(e){e(Zn)}function nt(e){return e(Hl)}function fe(e,t){return He(e,Rg(t,po))}function Ut(e,t){const n=e(gn,r=>{n(),t(r)});return n}function Kl(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function ql(e,t){return e===t}function Ze(e=ql){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function ye(e){return t=>n=>{e(n)&&t(n)}}function ae(e){return t=>Wl(t,e)}function Zt(e){return t=>()=>{t(e)}}function B(e,...t){const n=Og(...t);return(r,o)=>{switch(r){case Zn:Zs(e);return;case gn:return He(e,n(o))}}}function Qt(e,t){return n=>r=>{n(t=e(t,r))}}function Pn(e){return t=>n=>{e>0?e--:t(n)}}function un(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function je(...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);He(s,c=>{const u=n;n=n|a,t[i]=c,u!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function Og(...e){return t=>e.reduceRight(Pg,t)}function Mg(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case gn:return s?n===s?void 0:(r(),n=s,t=He(e,s),t):(r(),Qn);case Zn:r(),n=null;return}}}function q(e){let t=e;const n=Me();return(r,o)=>{switch(r){case po:t=o;break;case gn:{o(t);break}case Hl:return t}return n(r,o)}}function pt(e,t){return mo(q(t),n=>fe(e,n))}function Me(){const e=[];return(t,n)=>{switch(t){case po:e.slice().forEach(r=>{r(n)});return;case Zn:e.splice(0,e.length);return;case gn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Nt(e){return mo(Me(),t=>fe(e,t))}function $e(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Dg(),singleton:n}}const Dg=()=>Symbol();function Lg(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(c=>n(c)));return i&&t.set(s,a),a};return n(e)}function ot(...e){const t=Me(),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);He(s,c=>{n[i]=c,r=r|a,r===o&&Ne(t,n)})}),function(s,i){switch(s){case Zn:{Zs(t);return}case gn:return r===o&&i(n),He(t,i)}}}function we(e,t=ql){return B(e,Ze(t))}function Qs(...e){return function(t,n){switch(t){case Zn:return;case gn:return _g(...e.map(r=>He(r,n)))}}}var Ct=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ct||{});const $g={0:"debug",3:"error",1:"log",2:"warn"},Fg=()=>typeof globalThis>"u"?window:globalThis,xn=$e(()=>{const e=q(3);return{log:q((t,n,r=1)=>{var o;const s=(o=Fg().VIRTUOSO_LOG_LEVEL)!=null?o:nt(e);r>=s&&console[$g[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function On(e,t,n){return ei(e,t,n).callbackRef}function ei(e,t,n){const r=C.useRef(null);let o=i=>{};const s=C.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const c=i[0].target;c.offsetParent!==null&&e(c)};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 zg(e,t,n,r,o,s,i,a,c){const u=C.useCallback(d=>{const f=Bg(d.children,t,a?"offsetWidth":"offsetHeight",o);let p=d.parentElement;for(;!p.dataset.virtuosoScroller;)p=p.parentElement;const m=p.lastElementChild.dataset.viewportType==="window";let w;m&&(w=p.ownerDocument.defaultView);const b=i?a?i.scrollLeft:i.scrollTop:m?a?w.scrollX||w.document.documentElement.scrollLeft:w.scrollY||w.document.documentElement.scrollTop:a?p.scrollLeft:p.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:m?a?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight:a?p.scrollWidth:p.scrollHeight,x=i?a?i.offsetWidth:i.offsetHeight:m?a?w.innerWidth:w.innerHeight:a?p.offsetWidth:p.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(b,0),viewportHeight:x}),s==null||s(a?Gl("column-gap",getComputedStyle(d).columnGap,o):Gl("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return ei(u,n,c)}function Bg(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const c=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},Ct.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==c-1?s.push({endIndex:c,size:d,startIndex:c}):s[s.length-1].endIndex++}return s}function Gl(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ct.WARN),t==="normal"?0:parseInt(t??"0",10)}function Yl(e,t,n){const r=C.useRef(null),o=C.useCallback(c=>{if(!(c!=null&&c.offsetParent))return;const u=c.getBoundingClientRect(),d=u.width;let f,p;if(t){const m=t.getBoundingClientRect(),w=u.top-m.top;p=m.height-Math.max(0,w),f=w+t.scrollTop}else{const m=i.current.ownerDocument.defaultView;p=m.innerHeight-Math.max(0,u.top),f=u.top+m.scrollY}r.current={offsetTop:f,visibleHeight:p,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=ei(o,!0,n),a=C.useCallback(()=>{o(i.current)},[o,i]);return C.useEffect(()=>{var c;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=(c=i.current)==null?void 0:c.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 bt=$e(()=>{const e=Me(),t=Me(),n=q(0),r=Me(),o=q(0),s=Me(),i=Me(),a=q(0),c=q(0),u=q(0),d=q(0),f=Me(),p=Me(),m=q(!1),w=q(!1),b=q(!1);return fe(B(e,ae(({scrollTop:g})=>g)),t),fe(B(e,ae(({scrollHeight:g})=>g)),i),fe(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:c,footerHeight:d,headerHeight:a,horizontalDirection:w,scrollBy:p,scrollContainerState:e,scrollHeight:i,scrollingInProgress:m,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:b,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Tr={lvl:0};function Xl(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:c}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=c}return s.push({end:1/0,start:r,value:o}),s}function Ve(e){return e===Tr}function kr(e,t){if(!Ve(e))return t===e.k?e.v:t<e.k?kr(e.l,t):kr(e.r,t)}function Wt(e,t,n="k"){if(Ve(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=Wt(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return Wt(e.l,t,n)}function jt(e,t,n){return Ve(e)?Ql(t,n,1):t===e.k?it(e,{k:t,v:n}):t<e.k?ec(it(e,{l:jt(e.l,t,n)})):ec(it(e,{r:jt(e.r,t,n)}))}function er(){return Tr}function go(e,t,n){if(Ve(e))return[];const r=Wt(e,t)[0];return Hg(ni(e,r,n))}function ti(e,t){if(Ve(e))return Tr;const{k:n,l:r,r:o}=e;if(t===n){if(Ve(r))return o;if(Ve(o))return r;{const[s,i]=Zl(r);return xo(it(e,{k:s,l:Jl(r),v:i}))}}else return t<n?xo(it(e,{l:ti(r,t)})):xo(it(e,{r:ti(o,t)}))}function Mn(e){return Ve(e)?[]:[...Mn(e.l),{k:e.k,v:e.v},...Mn(e.r)]}function ni(e,t,n){if(Ve(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(ni(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(ni(s,t,n))),a}function xo(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(ri(t))return tc(it(e,{lvl:n-1}));if(!Ve(t)&&!Ve(t.r))return it(t.r,{l:it(t,{r:t.r.l}),lvl:n,r:it(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(ri(e))return oi(it(e,{lvl:n-1}));if(!Ve(r)&&!Ve(r.l)){const o=r.l,s=ri(o)?r.lvl-1:r.lvl;return it(o,{l:it(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:oi(it(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function it(e,t){return Ql(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 Jl(e){return Ve(e.r)?e.l:xo(it(e,{r:Jl(e.r)}))}function ri(e){return Ve(e)||e.lvl>e.r.lvl}function Zl(e){return Ve(e.r)?[e.k,e.v]:Zl(e.r)}function Ql(e,t,n,r=Tr,o=Tr){return{k:e,l:r,lvl:n,r:o,v:t}}function ec(e){return oi(tc(e))}function tc(e){const{l:t}=e;return!Ve(t)&&t.lvl===e.lvl?it(t,{r:it(e,{l:t.r})}):e}function oi(e){const{lvl:t,r:n}=e;return!Ve(n)&&!Ve(n.r)&&n.lvl===t&&n.r.lvl===t?it(n,{l:it(e,{r:n.l}),lvl:t+1}):e}function Hg(e){return Xl(e,({k:t,v:n})=>({index:t,value:n}))}function nc(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Er(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const si=$e(()=>({recalcInProgress:q(!1)}),[],{singleton:!0});function rc(e,t,n){return e[bo(e,t,n)]}function bo(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 Ug(e,t,n,r){const o=bo(e,t,r),s=bo(e,n,r,o);return e.slice(o,s+1)}function bn(e,t){return Math.round(e.getBoundingClientRect()[t])}function vo(e){return!Ve(e.groupOffsetTree)}function ii({index:e},t){return t===e?0:t<e?-1:1}function Wg(){return{groupIndices:[],groupOffsetTree:er(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:er()}}function Vg(e,t){let n=Ve(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Ve(e)){e=jt(e,0,s);continue}const a=go(e,i-1,o+1);if(a.some(Zg(r)))continue;let c=!1,u=!1;for(const{end:d,start:f,value:p}of a)c?(o>=f||s===p)&&(e=ti(e,f)):(u=p!==s,c=!0),d>o&&o>=f&&p!==s&&(e=jt(e,o+1,p));u&&(e=jt(e,i,s))}return[e,n]}function Kg(e){return typeof e.groupIndex<"u"}function qg({offset:e},t){return t===e?0:t<e?-1:1}function Ir(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=rc(t,e,ii),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function oc(e,t){if(!vo(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function sc(e,t,n){if(Kg(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 Gg(e,t,n,r=0){return r>0&&(t=Math.max(t,rc(e,r,ii).offset)),Xl(Ug(e,t,n,qg),Jg)}function Yg(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ct.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&Ve(s)&&t.length===2){const p=t[0].size,m=t[1].size;i=n.reduce((w,b)=>jt(jt(w,b,p),b+1,m),i)}else[i,a]=Vg(i,t);if(i===s)return e;const{lastIndex:c,lastOffset:u,lastSize:d,offsetTree:f}=ai(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((p,m)=>jt(p,m,Ir(m,f,o)),er()),lastIndex:c,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function Xg(e){return Mn(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 ic(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 ai(e,t,n,r){let o=e,s=0,i=0,a=0,c=0;if(t!==0){c=bo(o,t-1,ii),a=o[c].offset;const u=Wt(n,t-1);s=u[0],i=u[1],o.length&&o[c].size===Wt(n,t)[1]&&(c-=1),o=o.slice(0,c+1)}else o=[];for(const{start:u,value:d}of go(n,t,1/0)){const f=u-s,p=f*i+a+f*r;o.push({index:u,offset:p,size:d}),s=u,a=p,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function Jg(e){return{index:e.index,value:e}}function Zg(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 Qg={offsetHeight:"height",offsetWidth:"width"},en=$e(([{log:e},{recalcInProgress:t}])=>{const n=Me(),r=Me(),o=pt(r,0),s=Me(),i=Me(),a=q(0),c=q([]),u=q(void 0),d=q(void 0),f=q((S,T)=>bn(S,Qg[T])),p=q(void 0),m=q(0),w=Wg(),b=pt(B(n,je(c,e,m),Qt(Yg,w),Ze()),w),g=pt(B(c,Ze(),Qt((S,T)=>({current:T,prev:S.current}),{current:[],prev:[]}),ae(({prev:S})=>S)),[]);fe(B(c,ye(S=>S.length>0),je(b,m),ae(([S,T,I])=>{const N=S.reduce((j,O,A)=>jt(j,O,Ir(O,T.offsetTree,I)||A),er());return{...T,groupIndices:S,groupOffsetTree:N}})),b),fe(B(r,je(b),ye(([S,{lastIndex:T}])=>S<T),ae(([S,{lastIndex:T,lastSize:I}])=>[{endIndex:T,size:I,startIndex:S}])),n),fe(u,d);const x=pt(B(u,ae(S=>S===void 0)),!0);fe(B(d,ye(S=>S!==void 0&&Ve(nt(b).sizeTree)),ae(S=>[{endIndex:0,size:S,startIndex:0}])),n);const v=Nt(B(n,je(b),Qt(({sizes:S},[T,I])=>({changed:I!==S,sizes:I}),{changed:!1,sizes:w}),ae(S=>S.changed)));He(B(a,Qt((S,T)=>({diff:S.prev-T,prev:T}),{diff:0,prev:0}),ae(S=>S.diff)),S=>{const{groupIndices:T}=nt(b);if(S>0)Ne(t,!0),Ne(s,S+ic(S,T));else if(S<0){const I=nt(g);I.length>0&&(S-=ic(-S,I)),Ne(i,S)}}),He(B(a,je(e)),([S,T])=>{S<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Ct.ERROR)});const y=Nt(s);fe(B(s,je(b),ae(([S,T])=>{const I=T.groupIndices.length>0,N=[],j=T.lastSize;if(I){const O=kr(T.sizeTree,0);let A=0,F=0;for(;A<S;){const D=T.groupIndices[F],J=T.groupIndices.length===F+1?1/0:T.groupIndices[F+1]-D-1;N.push({endIndex:D,size:O,startIndex:D}),N.push({endIndex:D+1+J-1,size:j,startIndex:D+1}),F++,A+=J+1}const H=Mn(T.sizeTree);return A!==S&&H.shift(),H.reduce((D,{k:J,v:K})=>{let oe=D.ranges;return D.prevSize!==0&&(oe=[...D.ranges,{endIndex:J+S-1,size:D.prevSize,startIndex:D.prevIndex}]),{prevIndex:J+S,prevSize:K,ranges:oe}},{prevIndex:S,prevSize:0,ranges:N}).ranges}return Mn(T.sizeTree).reduce((O,{k:A,v:F})=>({prevIndex:A+S,prevSize:F,ranges:[...O.ranges,{endIndex:A+S-1,size:O.prevSize,startIndex:O.prevIndex}]}),{prevIndex:0,prevSize:j,ranges:[]}).ranges})),n);const E=Nt(B(i,je(b,m),ae(([S,{offsetTree:T},I])=>{const N=-S;return Ir(N,T,I)})));return fe(B(i,je(b,m),ae(([S,T,I])=>{if(T.groupIndices.length>0){if(Ve(T.sizeTree))return T;let N=er();const j=nt(g);let O=0,A=0,F=0;for(;O<-S;){F=j[A];const H=j[A+1]-F-1;A++,O+=H+1}if(N=Mn(T.sizeTree).reduce((H,{k:D,v:J})=>jt(H,Math.max(0,D+S),J),N),O!==-S){const H=kr(T.sizeTree,F);N=jt(N,0,H);const D=Wt(T.sizeTree,-S+1)[1];N=jt(N,1,D)}return{...T,sizeTree:N,...ai(T.offsetTree,0,N,I)}}else{const N=Mn(T.sizeTree).reduce((j,{k:O,v:A})=>jt(j,Math.max(0,O+S),A),er());return{...T,sizeTree:N,...ai(T.offsetTree,0,N,I)}}})),b),{beforeUnshiftWith:y,data:p,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:m,groupIndices:c,itemSize:f,listRefresh:v,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:b,statefulTotalCount:o,totalCount:r,trackItemSizes:x,unshiftWith:s}},Je(xn,si),{singleton:!0});function ex(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const ac=$e(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Me(),i=Me(),a=Nt(B(s,ae(ex)));return fe(B(a,ae(c=>c.totalCount)),n),fe(B(a,ae(c=>c.groupIndices)),e),fe(B(ot(o,t,r),ye(([c,u])=>vo(u)),ae(([c,u,d])=>Wt(u.groupOffsetTree,Math.max(c-d,0),"v")[0]),Ze(),ae(c=>[c])),i),{groupCounts:s,topItemsIndexes:i}},Je(en,bt)),vn=$e(([{log:e}])=>{const t=q(!1),n=Nt(B(t,ye(r=>r),Ze()));return He(t,r=>{r&&nt(e)("props updated",{},Ct.DEBUG)}),{didMount:n,propsReady:t}},Je(xn),{singleton:!0}),tx=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function lc(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!tx)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Nr=$e(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:c,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:p}])=>{const m=Me(),w=Me(),b=q(0);let g=null,x=null,v=null;function y(){g&&(g(),g=null),v&&(v(),v=null),x&&(clearTimeout(x),x=null),Ne(c,!1)}return fe(B(m,je(n,f,r,b,a,i,p),je(e,s,o),ae(([[E,S,T,I,N,j,O,A],F,H,D])=>{const J=lc(E),{align:K,behavior:oe,offset:W}=J,M=I-1,X=sc(J,S,M);let Z=Ir(X,S.offsetTree,F)+j;K==="end"?(Z+=H+Wt(S.sizeTree,X)[1]-T+D,X===M&&(Z+=O)):K==="center"?Z+=(H+Wt(S.sizeTree,X)[1]-T+D)/2:Z-=N,W&&(Z+=W);const he=$=>{y(),$?(A("retrying to scroll to",{location:E},Ct.DEBUG),Ne(m,E)):(Ne(w,!0),A("list did not change, scroll successful",{},Ct.DEBUG))};if(y(),oe==="smooth"){let $=!1;v=He(t,G=>{$=$||G}),g=Ut(d,()=>{he($)})}else g=Ut(B(t,nx(150)),he);return x=setTimeout(()=>{y()},1200),Ne(c,!0),A("scrolling from index to",{behavior:oe,index:X,top:Z},Ct.DEBUG),{behavior:oe,top:Z}})),u),{scrollTargetReached:w,scrollToIndex:m,topListHeight:b}},Je(en,bt,xn),{singleton:!0});function nx(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function li(e,t){e==0?t():requestAnimationFrame(()=>{li(e-1,t)})}function ci(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const jr=$e(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=q(!0),c=q(0),u=q(!0);return fe(B(i,je(c),ye(([d,f])=>!!f),Zt(!1)),a),fe(B(i,je(c),ye(([d,f])=>!!f),Zt(!1)),u),He(B(ot(t,i),je(a,n,e,u),ye(([[,d],f,{sizeTree:p},m,w])=>d&&(!Ve(p)||Js(m))&&!f&&!w),je(c)),([,d])=>{Ut(o,()=>{Ne(u,!0)}),li(4,()=>{Ut(r,()=>{Ne(a,!0)}),Ne(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:c,scrolledToInitialItem:a}},Je(en,bt,Nr,vn),{singleton:!0});function cc(e,t){return Math.abs(e-t)<1.01}const Ar="up",Rr="down",rx="none",ox={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},sx=0,_r=$e(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=q(!1),a=q(!0),c=Me(),u=Me(),d=q(4),f=q(sx),p=pt(B(Qs(B(we(o),Pn(1),Zt(!0)),B(we(o),Pn(1),Zt(!1),Kl(100))),Ze()),!1),m=pt(B(Qs(B(n,Zt(!0)),B(n,Zt(!1),Kl(200))),Ze()),!1);fe(B(ot(we(o),we(f)),ae(([v,y])=>v<=y),Ze()),a),fe(B(a,un(50)),u);const w=Nt(B(ot(r,we(s),we(t),we(e),we(d)),Qt((v,[{scrollHeight:y,scrollTop:E},S,T,I,N])=>{const j=E+S-y>-N,O={scrollHeight:y,scrollTop:E,viewportHeight:S};if(j){let F,H;return E>v.state.scrollTop?(F="SCROLLED_DOWN",H=v.state.scrollTop-E):(F="SIZE_DECREASED",H=v.state.scrollTop-E||v.scrollTopDelta),{atBottom:!0,atBottomBecause:F,scrollTopDelta:H,state:O}}let A;return O.scrollHeight>v.state.scrollHeight?A="SIZE_INCREASED":S<v.state.viewportHeight?A="VIEWPORT_HEIGHT_DECREASING":E<v.state.scrollTop?A="SCROLLING_UPWARDS":A="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:A,state:O}},ox),Ze((v,y)=>v&&v.atBottom===y.atBottom))),b=pt(B(r,Qt((v,{scrollHeight:y,scrollTop:E,viewportHeight:S})=>{if(cc(v.scrollHeight,y))return{changed:!1,jump:0,scrollHeight:y,scrollTop:E};{const T=y-(E+S)<1;return v.scrollTop!==E&&T?{changed:!0,jump:v.scrollTop-E,scrollHeight:y,scrollTop:E}:{changed:!0,jump:0,scrollHeight:y,scrollTop:E}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ye(v=>v.changed),ae(v=>v.jump)),0);fe(B(w,ae(v=>v.atBottom)),i),fe(B(i,un(50)),c);const g=q(Rr);fe(B(r,ae(({scrollTop:v})=>v),Ze(),Qt((v,y)=>nt(m)?{direction:v.direction,prevScrollTop:y}:{direction:y<v.prevScrollTop?Ar:Rr,prevScrollTop:y},{direction:Rr,prevScrollTop:0}),ae(v=>v.direction)),g),fe(B(r,un(50),Zt(rx)),g);const x=q(0);return fe(B(p,ye(v=>!v),Zt(0)),x),fe(B(o,un(100),je(p),ye(([v,y])=>!!y),Qt(([v,y],[E])=>[y,E],[0,0]),ae(([v,y])=>y-v)),x),{atBottomState:w,atBottomStateChange:c,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:p,lastJumpDueToItemResize:b,scrollDirection:g,scrollVelocity:x}},Je(bt)),wo="top",yo="bottom",uc="none";function dc(e,t,n){return typeof e=="number"?n===Ar&&t===wo||n===Rr&&t===yo?e:0:n===Ar?t===wo?e.main:e.reverse:t===yo?e.main:e.reverse}function fc(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const ui=$e(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Me(),i=q(0),a=q(0),c=q(0),u=pt(B(ot(we(r),we(o),we(n),we(s,Er),we(c),we(i),we(t),we(e),we(a)),ae(([d,f,p,[m,w],b,g,x,v,y])=>{const E=d-v,S=g+x,T=Math.max(p-E,0);let I=uc;const N=fc(y,wo),j=fc(y,yo);return m-=v,m+=p+x,w+=p+x,w-=v,m>d+S-N&&(I=Ar),w<d-T+f+j&&(I=Rr),I!==uc?[Math.max(E-p-dc(b,wo,I)-N,0),E-T-x+f+dc(b,yo,I)+j]:null}),ye(d=>d!=null),Ze(Er)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:c,topListHeight:i,visibleRange:u}},Je(bt),{singleton:!0});function ix(e,t,n){if(vo(t)){const r=oc(e,t);return[{index:Wt(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const di={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function So(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:c}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const b=e[e.length-1];d=b.offset+b.size}const f=n-i,p=a+f*c+(f-1)*r,m=u,w=p-d;return{bottom:d,firstItemIndex:s,items:pc(e,o,s),offsetBottom:w,offsetTop:u,top:m,topItems:pc(t,o,s),topListHeight:t.reduce((b,g)=>g.size+b,0),totalCount:n}}function hc(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,c=ci(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+c],index:f+c,offset:0,size:0}));return So(u,[],a,o,n,r)}function pc(e,t,n){if(e.length===0)return[];if(!vo(t))return e.map(u=>({...u,index:u.index+n,originalIndex:u.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=go(t.groupOffsetTree,r,o);let a,c=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),c=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:c,type:"group"}:d={groupIndex:c,index:u.index-(c+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const Dn=$e(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:c},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},p,{didMount:m},{recalcInProgress:w}])=>{const b=q([]),g=q(0),x=Me();fe(s.topItemsIndexes,b);const v=pt(B(ot(m,w,we(c,Er),we(o),we(r),we(u),d,we(b),we(t),we(n),e),ye(([T,I,,N,,,,,,,j])=>{const O=j&&j.length!==N;return T&&!I&&!O}),ae(([,,[T,I],N,j,O,A,F,H,D,J])=>{const K=j,{offsetTree:oe,sizeTree:W}=K,M=nt(g);if(N===0)return{...di,totalCount:N};if(T===0&&I===0)return M===0?{...di,totalCount:N}:hc(M,O,j,H,D,J||[]);if(Ve(W))return M>0?null:So(ix(ci(O,N),K,J),[],N,D,K,H);const X=[];if(F.length>0){const ee=F[0],pe=F[F.length-1];let z=0;for(const _ of go(W,ee,pe)){const Y=_.value,Q=Math.max(_.start,ee),de=Math.min(_.end,pe);for(let ne=Q;ne<=de;ne++)X.push({data:J==null?void 0:J[ne],index:ne,offset:z,size:Y}),z+=Y}}if(!A)return So([],X,N,D,K,H);const Z=F.length>0?F[F.length-1]+1:0,he=Gg(oe,T,I,Z);if(he.length===0)return null;const $=N-1,G=mo([],ee=>{for(const pe of he){const z=pe.value;let _=z.offset,Y=pe.start;const Q=z.size;if(z.offset<T){Y+=Math.floor((T-z.offset+D)/(Q+D));const ne=Y-pe.start;_+=ne*Q+ne*D}Y<Z&&(_+=(Z-Y)*Q,Y=Z);const de=Math.min(pe.end,$);for(let ne=Y;ne<=de&&!(_>=I);ne++)ee.push({data:J==null?void 0:J[ne],index:ne,offset:_,size:Q}),_+=Q+D}});return So(G,X,N,D,K,H)}),ye(T=>T!==null),Ze()),di);fe(B(e,ye(Js),ae(T=>T==null?void 0:T.length)),o),fe(B(v,ae(T=>T.topListHeight)),f),fe(f,a),fe(B(v,ae(T=>[T.top,T.bottom])),i),fe(B(v,ae(T=>T.items)),x);const y=Nt(B(v,ye(({items:T})=>T.length>0),je(o,e),ye(([{items:T},I])=>T[T.length-1].originalIndex===I-1),ae(([,T,I])=>[T-1,I]),Ze(Er),ae(([T])=>T))),E=Nt(B(v,un(200),ye(({items:T,topItems:I})=>T.length>0&&T[0].originalIndex===I.length),ae(({items:T})=>T[0].index),Ze())),S=Nt(B(v,ye(({items:T})=>T.length>0),ae(({items:T})=>{let I=0,N=T.length-1;for(;T[I].type==="group"&&I<N;)I++;for(;T[N].type==="group"&&N>I;)N--;return{endIndex:T[N].index,startIndex:T[I].index}}),Ze(nc)));return{endReached:y,initialItemCount:g,itemsRendered:x,listState:v,rangeChanged:S,startReached:E,topItemsIndexes:b,...p}},Je(en,ac,ui,jr,Nr,_r,vn,si),{singleton:!0}),mc=$e(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Me(),i=pt(B(ot(n,e,r,t,o),ae(([a,c,u,d,f])=>a+c+u+d+f.offsetBottom+f.bottom)),0);return fe(we(i),s),{totalListHeight:i,totalListHeightChanged:s}},Je(bt,Dn),{singleton:!0}),ax=$e(([{viewportHeight:e},{totalListHeight:t}])=>{const n=q(!1),r=pt(B(ot(n,e,t),ye(([o])=>o),ae(([,o,s])=>Math.max(0,o-s)),un(0),Ze()),0);return{alignToBottom:n,paddingTopAddition:r}},Je(bt,mc),{singleton:!0}),gc=$e(()=>({context:q(null)})),lx=({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,xc=$e(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:c},{scrollToIndex:u}])=>{const d=Me();return fe(B(d,je(t,c,n,s,o,r,a),je(e),ae(([[f,p,m,w,b,g,x,v],y])=>{const{align:E,behavior:S,calculateViewLocation:T=lx,done:I,...N}=f,j=sc(f,p,w-1),O=Ir(j,p.offsetTree,y)+b+g,A=O+Wt(p.sizeTree,j)[1],F=v+g,H=v+m-x,D=T({itemBottom:A,itemTop:O,locationParams:{align:E,behavior:S,...N},viewportBottom:H,viewportTop:F});return D?I&&Ut(B(i,ye(J=>!J),Pn(nt(i)?1:2)),I):I&&I(),D}),ye(f=>f!==null)),u),{scrollIntoView:d}},Je(en,bt,Nr,Dn,xn),{singleton:!0});function bc(e){return e?e==="smooth"?"smooth":"auto":!1}const cx=(e,t)=>typeof e=="function"?bc(e(t)):t&&bc(e),ux=$e(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:c,propsReady:u},{log:d},{scrollingInProgress:f},{context:p},{scrollIntoView:m}])=>{const w=q(!1),b=Me();let g=null;function x(S){Ne(i,{align:"end",behavior:S,index:"LAST"})}He(B(ot(B(we(t),Pn(1)),c),je(we(w),s,a,f),ae(([[S,T],I,N,j,O])=>{let A=T&&j,F="auto";return A&&(F=cx(I,N||O),A=A&&!!F),{followOutputBehavior:F,shouldFollow:A,totalCount:S}}),ye(({shouldFollow:S})=>S)),({followOutputBehavior:S,totalCount:T})=>{g&&(g(),g=null),nt(n)?requestAnimationFrame(()=>{nt(d)("following output to ",{totalCount:T},Ct.DEBUG),x(S)}):g=Ut(e,()=>{nt(d)("following output to ",{totalCount:T},Ct.DEBUG),x(S),g=null})});function v(S){const T=Ut(o,I=>{S&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(nt(d)("scrolling to bottom due to increased size",{},Ct.DEBUG),x("auto"))});setTimeout(T,100)}He(B(ot(we(w),t,u),ye(([S,,T])=>S&&T),Qt(({value:S},[,T])=>({refreshed:S===T,value:T}),{refreshed:!1,value:0}),ye(({refreshed:S})=>S),je(w,t)),([,S])=>{nt(a)&&v(S!==!1)}),He(b,()=>{v(nt(w)!==!1)}),He(ot(we(w),o),([S,T])=>{S&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&x("auto")});const y=q(null),E=Me();return fe(Qs(B(we(r),ae(S=>{var T;return(T=S==null?void 0:S.length)!=null?T:0})),B(we(t))),E),He(B(ot(B(E,Pn(1)),c),je(we(y),a,f,p),ae(([[S,T],I,N,j,O])=>T&&N&&(I==null?void 0:I({context:O,totalCount:S,scrollingInProgress:j}))),ye(S=>!!S),un(0)),S=>{g&&(g(),g=null),nt(n)?requestAnimationFrame(()=>{nt(d)("scrolling into view",{}),Ne(m,S)}):g=Ut(e,()=>{nt(d)("scrolling into view",{}),Ne(m,S),g=null})}),{autoscrollToBottom:b,followOutput:w,scrollIntoViewOnChange:y}},Je(en,_r,Nr,jr,vn,xn,bt,gc,xc)),dx=$e(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(fe(B(a,je(s),ye(([,c])=>c!==0),je(o,r,t,n,e),ae(([[,c],u,d,f,p,m=[]])=>hc(c,u,d,f,p,m))),i),{}),Je(en,jr,Dn,vn),{singleton:!0}),fx=$e(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=q(0);return He(B(e,je(r),ye(([,o])=>o!==0),ae(([,o])=>({top:o}))),o=>{Ut(B(n,Pn(1),ye(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Ne(t,o)})})}),{initialScrollTop:r}},Je(vn,bt,Dn),{singleton:!0}),vc=$e(([{scrollVelocity:e}])=>{const t=q(!1),n=Me(),r=q(!1);return fe(B(e,je(r,t,n),ye(([o,s])=>!!s),ae(([o,s,i,a])=>{const{enter:c,exit:u}=s;if(i){if(u(o,a))return!1}else if(c(o,a))return!0;return i}),Ze()),t),He(B(ot(t,e,n),je(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},Je(_r),{singleton:!0}),fi=$e(([{scrollContainerState:e,scrollTo:t}])=>{const n=Me(),r=Me(),o=Me(),s=q(!1),i=q(void 0);return fe(B(ot(n,r),ae(([{scrollHeight:a,scrollTop:c,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,c-d),viewportHeight:u}))),e),fe(B(t,je(r),ae(([a,{offsetTop:c}])=>({...a,top:a.top+c}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},Je(bt)),hx=$e(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:c}])=>{const u=Me(),d=q(void 0),f=q(null),p=q(null);return fe(a,f),fe(c,p),He(B(u,je(t,r,i,f,p,n)),([m,w,b,g,x,v,y])=>{const E=Xg(w.sizeTree);g&&x!==null&&v!==null&&(b=x.scrollTop-v.offsetTop),b-=y,m({ranges:E,scrollTop:b})}),fe(B(d,ye(Js),ae(px)),o),fe(B(s,je(d),ye(([,m])=>m!==void 0),Ze(),ae(([,m])=>m.ranges)),e),{getState:u,restoreStateFrom:d}},Je(en,bt,jr,vn,fi));function px(e){return{align:"start",index:0,offset:e.scrollTop}}const mx=$e(([{topItemsIndexes:e}])=>{const t=q(0);return fe(B(t,ye(n=>n>=0),ae(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},Je(Dn));function wc(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const gx=wc(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),xx=$e(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:c},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:p},{log:m},{recalcInProgress:w}])=>{const b=Nt(B(c,je(i),Qt(([,x,v,y],[{bottom:E,items:S,offsetBottom:T,totalCount:I},N])=>{const j=E+T;let O=0;return v===I&&x.length>0&&S.length>0&&(S[0].originalIndex===0&&x[0].originalIndex===0||(O=j-y,O!==0&&(O+=N))),[O,S,I,j]},[0,[],0,0]),ye(([x])=>x!==0),je(r,a,n,o,m,w),ye(([,x,v,y,,,E])=>!E&&!y&&x!==0&&v===Ar),ae(([[x],,,,,v])=>(v("Upward scrolling compensation",{amount:x},Ct.DEBUG),x))));function g(x){x>0?(Ne(t,{behavior:"auto",top:-x}),Ne(e,0)):(Ne(e,0),Ne(t,{behavior:"auto",top:-x}))}return He(B(b,je(e,s)),([x,v,y])=>{y&&gx()?Ne(e,v-x):g(-x)}),He(B(ot(pt(s,!1),e,w),ye(([x,v,y])=>!x&&!y&&v!==0),ae(([x,v])=>v),un(1)),g),fe(B(f,ae(x=>({top:-x}))),t),He(B(u,je(p,d),ae(([x,{groupIndices:v,lastSize:y,sizeTree:E},S])=>{function T(I){return I*(y+S)}if(v.length===0)return T(x);{let I=0;const N=kr(E,0);let j=0,O=0;for(;j<x;){j++,I+=N;let A=v.length===O+1?1/0:v[O+1]-v[O]-1;j+A>x&&(I-=N,A=x-j+1),j+=A,I+=T(A),O++}return I}})),x=>{Ne(e,x),requestAnimationFrame(()=>{Ne(t,{top:x}),requestAnimationFrame(()=>{Ne(e,0),Ne(w,!1)})})}),{deviation:e}},Je(bt,_r,Dn,en,xn,si)),bx=$e(([e,t,n,r,o,s,i,a,c,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...c,...u,...d}),Je(ui,dx,vn,vc,mc,fx,ax,fi,xc,xn,gc)),yc=$e(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:c,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:p,initialTopMostItemIndex:m,scrolledToInitialItem:w},b,g,x,{listState:v,topItemsIndexes:y,...E},{scrollToIndex:S},T,{topItemCount:I},{groupCounts:N},j])=>(fe(E.rangeChanged,j.scrollSeekRangeChanged),fe(B(j.windowViewportRect,ae(O=>O.visibleHeight)),b.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:N,initialItemFinalLocationReached:p,initialTopMostItemIndex:m,scrolledToInitialItem:w,sizeRanges:a,topItemCount:I,topItemsIndexes:y,totalCount:d,...x,groupIndices:s,itemSize:i,listState:v,scrollToIndex:S,statefulTotalCount:u,trackItemSizes:f,...E,...j,...b,sizes:c,...g}),Je(en,jr,bt,hx,ux,Dn,Nr,xx,mx,ac,bx));function vx(e,t){const n={},r={};let o=0;const s=e.length;for(;o<s;)r[e[o]]=1,o+=1;for(const i in t)Object.hasOwn(r,i)||(n[i]=t[i]);return n}const Co=typeof document<"u"?C.useLayoutEffect:C.useEffect;function Sc(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=C.createContext({});function c(g,x){g.propsReady&&Ne(g.propsReady,!1);for(const v of r){const y=g[t.required[v]];Ne(y,x[v])}for(const v of o)if(v in x){const y=g[t.optional[v]];Ne(y,x[v])}g.propsReady&&Ne(g.propsReady,!0)}function u(g){return s.reduce((x,v)=>(x[v]=y=>{const E=g[t.methods[v]];Ne(E,y)},x),{})}function d(g){return i.reduce((x,v)=>(x[v]=Mg(g[t.events[v]]),x),{})}const f=C.forwardRef((g,x)=>{const{children:v,...y}=g,[E]=C.useState(()=>mo(Lg(e),I=>{c(I,y)})),[S]=C.useState(Vl(d,E));Co(()=>{for(const I of i)I in y&&He(S[I],y[I]);return()=>{Object.values(S).map(Zs)}},[y,S,E]),Co(()=>{c(E,y)}),C.useImperativeHandle(x,Ul(u(E)));const T=n;return l.jsx(a.Provider,{value:E,children:n?l.jsx(T,{...vx([...r,...o,...i],y),children:v}):v})}),p=g=>{const x=C.useContext(a);return C.useCallback(v=>{Ne(x[g],v)},[x,g])},m=g=>{const x=C.useContext(a)[g],v=C.useCallback(y=>He(x,y),[x]);return C.useSyncExternalStore(v,()=>nt(x),()=>nt(x))},w=g=>{const x=C.useContext(a)[g],[v,y]=C.useState(Vl(nt,x));return Co(()=>He(x,E=>{E!==v&&y(Ul(E))}),[x,v]),v},b=C.version.startsWith("18")?m:w;return{Component:f,useEmitter:(g,x)=>{const v=C.useContext(a)[g];Co(()=>He(v,x),[x,v])},useEmitterValue:b,usePublisher:p}}const Cc=C.createContext(void 0),Tc=C.createContext(void 0),kc=typeof document<"u"?C.useLayoutEffect:C.useEffect;function hi(e){return"self"in e}function wx(e){return"body"in e}function Ec(e,t,n,r=Qn,o,s){const i=C.useRef(null),a=C.useRef(null),c=C.useRef(null),u=C.useCallback(p=>{let m,w,b;const g=p.target;if(wx(g)||hi(g)){const v=hi(g)?g:g.defaultView;b=s?v.scrollX:v.scrollY,m=s?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight,w=s?v.innerWidth:v.innerHeight}else b=s?g.scrollLeft:g.scrollTop,m=s?g.scrollWidth:g.scrollHeight,w=s?g.offsetWidth:g.offsetHeight;const x=()=>{e({scrollHeight:m,scrollTop:Math.max(b,0),viewportHeight:w})};p.suppressFlushSync?x():Ps.flushSync(x),a.current!==null&&(b===a.current||b<=0||b===m-w)&&(a.current=null,t(!0),c.current&&(clearTimeout(c.current),c.current=null))},[e,t,s]);C.useEffect(()=>{const p=o||i.current;return r(o||i.current),u({suppressFlushSync:!0,target:p}),p.addEventListener("scroll",u,{passive:!0}),()=>{r(null),p.removeEventListener("scroll",u)}},[i,u,n,r,o]);function d(p){const m=i.current;if(!m||(s?"offsetWidth"in m&&m.offsetWidth===0:"offsetHeight"in m&&m.offsetHeight===0))return;const w=p.behavior==="smooth";let b,g,x;hi(m)?(g=Math.max(bn(m.document.documentElement,s?"width":"height"),s?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight),b=s?m.innerWidth:m.innerHeight,x=s?window.scrollX:window.scrollY):(g=m[s?"scrollWidth":"scrollHeight"],b=bn(m,s?"width":"height"),x=m[s?"scrollLeft":"scrollTop"]);const v=g-b;if(p.top=Math.ceil(Math.max(Math.min(v,p.top),0)),cc(b,g)||p.top===x){e({scrollHeight:g,scrollTop:x,viewportHeight:b}),w&&t(!0);return}w?(a.current=p.top,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(p={behavior:p.behavior,left:p.top}),m.scrollTo(p)}function f(p){s&&(p={behavior:p.behavior,left:p.top}),i.current.scrollBy(p)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const pi="-webkit-sticky",Ic="sticky",mi=wc(()=>{if(typeof document>"u")return Ic;const e=document.createElement("div");return e.style.position=pi,e.style.position===pi?pi:Ic});function gi(e){return e}const yx=$e(()=>{const e=q(a=>`Item ${a}`),t=q(a=>`Group ${a}`),n=q({}),r=q(gi),o=q("div"),s=q(Qn),i=(a,c=null)=>pt(B(n,ae(u=>u[a]),Ze()),c);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")}}),Sx=$e(([e,t])=>({...e,...t}),Je(yc,yx)),Cx=({height:e})=>l.jsx("div",{style:{height:e}}),Tx={overflowAnchor:"none",position:mi(),zIndex:1},Nc={overflowAnchor:"none"},kx={...Nc,display:"inline-block",height:"100%"},jc=C.memo(function({showTopList:e=!1}){const t=ke("listState"),n=Dt("sizeRanges"),r=ke("useWindowScroll"),o=ke("customScrollParent"),s=Dt("windowScrollContainerState"),i=Dt("scrollContainerState"),a=o||r?s:i,c=ke("itemContent"),u=ke("context"),d=ke("groupContent"),f=ke("trackItemSizes"),p=ke("itemSize"),m=ke("log"),w=Dt("gap"),b=ke("horizontalDirection"),{callbackRef:g}=zg(n,p,f,e?Qn:a,m,w,o,b,ke("skipAnimationFrameInResizeObserver")),[x,v]=C.useState(0);xi("deviation",D=>{x!==D&&v(D)});const y=ke("EmptyPlaceholder"),E=ke("ScrollSeekPlaceholder")||Cx,S=ke("ListComponent"),T=ke("ItemComponent"),I=ke("GroupComponent"),N=ke("computeItemKey"),j=ke("isSeeking"),O=ke("groupIndices").length>0,A=ke("alignToBottom"),F=ke("initialItemFinalLocationReached"),H=e?{}:{boxSizing:"border-box",...b?{display:"inline-block",height:"100%",marginLeft:x!==0?x:A?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:x!==0?x:A?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...F?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&y?l.jsx(y,{...mt(y,u)}):l.jsx(S,{...mt(S,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:H,children:(e?t.topItems:t.items).map(D=>{const J=D.originalIndex,K=N(J+t.firstItemIndex,D.data,u);return j?C.createElement(E,{...mt(E,u),height:D.size,index:D.index,key:K,type:D.type||"item",...D.type==="group"?{}:{groupIndex:D.groupIndex}}):D.type==="group"?C.createElement(I,{...mt(I,u),"data-index":J,"data-item-index":D.index,"data-known-size":D.size,key:K,style:Tx},d(D.index,u)):C.createElement(T,{...mt(T,u),...jx(T,D.data),"data-index":J,"data-item-group-index":D.groupIndex,"data-item-index":D.index,"data-known-size":D.size,key:K,style:b?kx:Nc},O?c(D.index,D.groupIndex,D.data,u):c(D.index,D.data,u))})})}),Ex={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Ix={outline:"none",overflowX:"auto",position:"relative"},To=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Nx={position:mi(),top:0,width:"100%",zIndex:1};function mt(e,t){if(typeof e!="string")return{context:t}}function jx(e,t){return{item:typeof e=="string"?void 0:t}}const Ax=C.memo(function(){const e=ke("HeaderComponent"),t=Dt("headerHeight"),n=ke("HeaderFooterTag"),r=On(C.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,ke("skipAnimationFrameInResizeObserver")),o=ke("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...mt(e,o)})}):null}),Rx=C.memo(function(){const e=ke("FooterComponent"),t=Dt("footerHeight"),n=ke("HeaderFooterTag"),r=On(C.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,ke("skipAnimationFrameInResizeObserver")),o=ke("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...mt(e,o)})}):null});function Ac({useEmitter:e,useEmitterValue:t,usePublisher:n}){return C.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),c=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:p,scrollerRef:m,scrollToCallback:w}=Ec(a,u,c,d,void 0,f);return e("scrollTo",w),e("scrollBy",p),l.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:m,style:{...f?Ix:Ex,...o},tabIndex:0,...i,...mt(c,s),children:r})})}function Rc({useEmitter:e,useEmitterValue:t,usePublisher:n}){return C.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),c=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),p=t("customScrollParent"),m=C.useRef(null),w=t("scrollerRef"),{scrollByCallback:b,scrollerRef:g,scrollToCallback:x}=Ec(a,u,c,w,p);return kc(()=>{var v;return g.current=p||((v=m.current)==null?void 0:v.ownerDocument.defaultView),()=>{g.current=null}},[g,p]),e("windowScrollTo",x),e("scrollBy",b),l.jsx(c,{ref:m,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...mt(c,s),children:r})})}const _x=({children:e})=>{const t=C.useContext(Cc),n=Dt("viewportHeight"),r=Dt("fixedItemHeight"),o=ke("alignToBottom"),s=ke("horizontalDirection"),i=C.useMemo(()=>Wl(n,c=>bn(c,s?"width":"height")),[n,s]),a=On(i,!0,ke("skipAnimationFrameInResizeObserver"));return C.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),l.jsx("div",{"data-viewport-type":"element",ref:a,style:To(o),children:e})},Px=({children:e})=>{const t=C.useContext(Cc),n=Dt("windowViewportRect"),r=Dt("fixedItemHeight"),o=ke("customScrollParent"),s=Yl(n,o,ke("skipAnimationFrameInResizeObserver")),i=ke("alignToBottom");return C.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),l.jsx("div",{"data-viewport-type":"window",ref:s,style:To(i),children:e})},Ox=({children:e})=>{const t=ke("TopItemListComponent")||"div",n=ke("headerHeight"),r={...Nx,marginTop:`${n}px`},o=ke("context");return l.jsx(t,{style:r,...mt(t,o),children:e})},Mx=C.memo(function(e){const t=ke("useWindowScroll"),n=ke("topItemsIndexes").length>0,r=ke("customScrollParent"),o=ke("context");return l.jsxs(r||t?$x:Lx,{...e,context:o,children:[n&&l.jsx(Ox,{children:l.jsx(jc,{showTopList:!0})}),l.jsxs(r||t?Px:_x,{children:[l.jsx(Ax,{}),l.jsx(jc,{}),l.jsx(Rx,{})]})]})}),{Component:Dx,useEmitter:xi,useEmitterValue:ke,usePublisher:Dt}=Sc(Sx,{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"}},Mx),Lx=Ac({useEmitter:xi,useEmitterValue:ke,usePublisher:Dt}),$x=Rc({useEmitter:xi,useEmitterValue:ke,usePublisher:Dt}),Fx=Dx;Je(yc,$e(()=>{const e=q(u=>l.jsxs("td",{children:["Item $",u]})),t=q(null),n=q(u=>l.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=q(null),o=q(null),s=q({}),i=q(gi),a=q(Qn),c=(u,d=null)=>pt(B(s,ae(f=>f[u]),Ze()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:c("EmptyPlaceholder"),FillerRow:c("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder"),TableBodyComponent:c("TableBody","tbody"),TableComponent:c("Table","table"),TableFooterComponent:c("TableFoot","tfoot"),TableHeadComponent:c("TableHead","thead"),TableRowComponent:c("TableRow","tr"),GroupComponent:c("Group","tr")}})),mi();const _c={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},zx={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Pc,floor:ko,max:Pr,min:bi,round:Oc}=Math;function Mc(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function Bx(e){return{...zx,items:e}}function Eo(e,t){return e&&e.width===t.width&&e.height===t.height}function Hx(e,t){return e&&e.column===t.column&&e.row===t.row}const Ux=$e(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:c,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},p,m,{didMount:w,propsReady:b},{customScrollParent:g,useWindowScroll:x,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:E},S])=>{const T=q(0),I=q(0),N=q(_c),j=q({height:0,width:0}),O=q({height:0,width:0}),A=Me(),F=Me(),H=q(0),D=q(null),J=q({column:0,row:0}),K=Me(),oe=Me(),W=q(!1),M=q(0),X=q(!0),Z=q(!1),he=q(!1);He(B(w,je(M),ye(([_,Y])=>!!Y)),()=>{Ne(X,!1)}),He(B(ot(w,X,O,j,M,Z),ye(([_,Y,Q,de,,ne])=>_&&!Y&&Q.height!==0&&de.height!==0&&!ne)),([,,,,_])=>{Ne(Z,!0),li(1,()=>{Ne(A,_)}),Ut(B(u),()=>{Ne(t,[0,0]),Ne(X,!0)})}),fe(B(oe,ye(_=>_!=null&&_.scrollTop>0),Zt(0)),I),He(B(w,je(oe),ye(([,_])=>_!=null)),([,_])=>{_&&(Ne(j,_.viewport),Ne(O,_.item),Ne(J,_.gap),_.scrollTop>0&&(Ne(W,!0),Ut(B(u,Pn(1)),Y=>{Ne(W,!1)}),Ne(c,{top:_.scrollTop})))}),fe(B(j,ae(({height:_})=>_)),f),fe(B(ot(we(j,Eo),we(O,Eo),we(J,(_,Y)=>_&&_.column===Y.column&&_.row===Y.row),we(u)),ae(([_,Y,Q,de])=>({gap:Q,item:Y,scrollTop:de,viewport:_}))),K),fe(B(ot(we(T),r,we(J,Hx),we(O,Eo),we(j,Eo),we(D),we(I),we(W),we(X),we(M)),ye(([,,,,,,,_])=>!_),ae(([_,[Y,Q],de,ne,_e,Pe,Ue,,Ee,Ae])=>{const{column:et,row:qe}=de,{height:ct,width:ut}=ne,{width:ve}=_e;if(Ue===0&&(_===0||ve===0))return _c;if(ut===0){const at=ci(Ae,_),hn=at+Math.max(Ue-1,0);return Bx(Mc(at,hn,Pe))}const Fe=Dc(ve,ut,et);let Ge,P;Ee?Y===0&&Q===0&&Ue>0?(Ge=0,P=Ue-1):(Ge=Fe*ko((Y+qe)/(ct+qe)),P=Fe*Pc((Q+qe)/(ct+qe))-1,P=bi(_-1,Pr(P,Fe-1)),Ge=bi(P,Pr(0,Ge))):(Ge=0,P=-1);const U=Mc(Ge,P,Pe),{bottom:ue,top:be}=Lc(_e,de,ne,U),le=Pc(_/Fe),Be=le*ct+(le-1)*qe-ue;return{bottom:ue,itemHeight:ct,items:U,itemWidth:ut,offsetBottom:Be,offsetTop:be,top:be}})),N),fe(B(D,ye(_=>_!==null),ae(_=>_.length)),T),fe(B(ot(j,O,N,J),ye(([_,Y,{items:Q}])=>Q.length>0&&Y.height!==0&&_.height!==0),ae(([_,Y,{items:Q},de])=>{const{bottom:ne,top:_e}=Lc(_,de,Y,Q);return[_e,ne]}),Ze(Er)),t);const $=q(!1);fe(B(u,je($),ae(([_,Y])=>Y||_!==0)),$);const G=Nt(B(ot(N,T),ye(([{items:_}])=>_.length>0),je($),ye(([[_,Y],Q])=>{const de=_.items[_.items.length-1].index===Y-1;return(Q||_.bottom>0&&_.itemHeight>0&&_.offsetBottom===0&&_.items.length===Y)&&de}),ae(([[,_]])=>_-1),Ze())),ee=Nt(B(we(N),ye(({items:_})=>_.length>0&&_[0].index===0),Zt(0),Ze())),pe=Nt(B(we(N),je(W),ye(([{items:_},Y])=>_.length>0&&!Y),ae(([{items:_}])=>({endIndex:_[_.length-1].index,startIndex:_[0].index})),Ze(nc),un(0)));fe(pe,m.scrollSeekRangeChanged),fe(B(A,je(j,O,T,J),ae(([_,Y,Q,de,ne])=>{const _e=lc(_),{align:Pe,behavior:Ue,offset:Ee}=_e;let Ae=_e.index;Ae==="LAST"&&(Ae=de-1),Ae=Pr(0,Ae,bi(de-1,Ae));let et=vi(Y,ne,Q,Ae);return Pe==="end"?et=Oc(et-Y.height+Q.height):Pe==="center"&&(et=Oc(et-Y.height/2+Q.height/2)),Ee&&(et+=Ee),{behavior:Ue,top:et}})),c);const z=pt(B(N,ae(_=>_.offsetBottom+_.bottom)),0);return fe(B(E,ae(_=>({height:_.visibleHeight,width:_.visibleWidth}))),j),{customScrollParent:g,data:D,deviation:H,footerHeight:o,gap:J,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:O,overscan:n,restoreStateFrom:oe,scrollBy:i,scrollContainerState:a,scrollHeight:F,scrollTo:c,scrollToIndex:A,scrollTop:u,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:x,viewportDimensions:j,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:E,...m,gridState:N,horizontalDirection:he,initialTopMostItemIndex:M,totalListHeight:z,...p,endReached:G,propsReady:b,rangeChanged:pe,startReached:ee,stateChanged:K,stateRestoreInProgress:W,...S}},Je(ui,bt,_r,vc,vn,fi,xn));function Dc(e,t,n){return Pr(1,ko((e+n)/(ko(t)+n)))}function Lc(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=vi(e,t,n,r[0].index);return{bottom:vi(e,t,n,r[r.length-1].index)+o,top:s}}function vi(e,t,n,r){const o=Dc(e.width,n.width,t.column),s=ko(r/o),i=s*n.height+Pr(0,s-1)*t.row;return i>0?i+t.row:i}const Wx=$e(()=>{const e=q(f=>`Item ${f}`),t=q({}),n=q(null),r=q("virtuoso-grid-item"),o=q("virtuoso-grid-list"),s=q(gi),i=q("div"),a=q(Qn),c=(f,p=null)=>pt(B(t,ae(m=>m[f]),Ze()),p),u=q(!1),d=q(!1);return fe(we(d),u),{components:t,computeItemKey:s,context:n,FooterComponent:c("Footer"),HeaderComponent:c("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:c("Item","div"),itemContent:e,listClassName:o,ListComponent:c("List","div"),readyStateChanged:u,reportReadyState:d,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}),Vx=$e(([e,t])=>({...e,...t}),Je(Ux,Wx)),Kx=C.memo(function(){const e=Qe("gridState"),t=Qe("listClassName"),n=Qe("itemClassName"),r=Qe("itemContent"),o=Qe("computeItemKey"),s=Qe("isSeeking"),i=Lt("scrollHeight"),a=Qe("ItemComponent"),c=Qe("ListComponent"),u=Qe("ScrollSeekPlaceholder"),d=Qe("context"),f=Lt("itemDimensions"),p=Lt("gap"),m=Qe("log"),w=Qe("stateRestoreInProgress"),b=Lt("reportReadyState"),g=On(C.useMemo(()=>x=>{const v=x.parentElement.parentElement.scrollHeight;i(v);const y=x.firstChild;if(y){const{height:E,width:S}=y.getBoundingClientRect();f({height:E,width:S})}p({column:Fc("column-gap",getComputedStyle(x).columnGap,m),row:Fc("row-gap",getComputedStyle(x).rowGap,m)})},[i,f,p,m]),!0,!1);return kc(()=>{e.itemHeight>0&&e.itemWidth>0&&b(!0)},[e]),w?null:l.jsx(c,{className:t,ref:g,...mt(c,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(x=>{const v=o(x.index,x.data,d);return s?l.jsx(u,{...mt(u,d),height:e.itemHeight,index:x.index,width:e.itemWidth},v):C.createElement(a,{...mt(a,d),className:n,"data-index":x.index,key:v},r(x.index,x.data,d))})})}),qx=C.memo(function(){const e=Qe("HeaderComponent"),t=Lt("headerHeight"),n=Qe("headerFooterTag"),r=On(C.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,!1),o=Qe("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...mt(e,o)})}):null}),Gx=C.memo(function(){const e=Qe("FooterComponent"),t=Lt("footerHeight"),n=Qe("headerFooterTag"),r=On(C.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,!1),o=Qe("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...mt(e,o)})}):null}),Yx=({children:e})=>{const t=C.useContext(Tc),n=Lt("itemDimensions"),r=Lt("viewportDimensions"),o=On(C.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return C.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),l.jsx("div",{ref:o,style:To(!1),children:e})},Xx=({children:e})=>{const t=C.useContext(Tc),n=Lt("windowViewportRect"),r=Lt("itemDimensions"),o=Qe("customScrollParent"),s=Yl(n,o,!1);return C.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),l.jsx("div",{ref:s,style:To(!1),children:e})},Jx=C.memo(function({...e}){const t=Qe("useWindowScroll"),n=Qe("customScrollParent"),r=n||t?Qx:Zx,o=n||t?Xx:Yx,s=Qe("context");return l.jsx(r,{...e,...mt(r,s),children:l.jsxs(o,{children:[l.jsx(qx,{}),l.jsx(Kx,{}),l.jsx(Gx,{})]})})}),{useEmitter:$c,useEmitterValue:Qe,usePublisher:Lt}=Sc(Vx,{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"}},Jx),Zx=Ac({useEmitter:$c,useEmitterValue:Qe,usePublisher:Lt}),Qx=Rc({useEmitter:$c,useEmitterValue:Qe,usePublisher:Lt});function Fc(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ct.WARN),t==="normal"?0:parseInt(t??"0",10)}const eb=mr.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 zc({className:e,variant:t,...n}){return l.jsx("div",{className:L(eb({variant:t}),e),...n})}function te(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 tb(e,t){const n=h.createContext(t),r=s=>{const{children:i,...a}=s,c=h.useMemo(()=>a,Object.values(a));return l.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function o(s){const i=h.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 Vt(e,t=[]){let n=[];function r(s,i){const a=h.createContext(i),c=n.length;n=[...n,i];const u=f=>{var x;const{scope:p,children:m,...w}=f,b=((x=p==null?void 0:p[e])==null?void 0:x[c])||a,g=h.useMemo(()=>w,Object.values(w));return l.jsx(b.Provider,{value:g,children:m})};u.displayName=s+"Provider";function d(f,p){var b;const m=((b=p==null?void 0:p[e])==null?void 0:b[c])||a,w=h.useContext(m);if(w)return w;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>h.createContext(i));return function(a){const c=(a==null?void 0:a[e])||s;return h.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,nb(o,...t)]}function nb(...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:c,scopeName:u})=>{const f=c(s)[`__scope${u}`];return{...a,...f}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var lt=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},rb=h[" useInsertionEffect ".trim().toString()]||lt;function wn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=ob({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:o;{const d=h.useRef(e!==void 0);h.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=h.useCallback(d=>{var f;if(a){const p=sb(d)?d(e):d;p!==e&&((f=i.current)==null||f.call(i,p))}else s(d)},[a,e,s,i]);return[c,u]}function ob({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return rb(()=>{s.current=t},[t]),h.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function sb(e){return typeof e=="function"}function Bc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function wi(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Bc(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():Bc(e[o],null)}}}}function Re(...e){return h.useCallback(wi(...e),e)}var ib=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Se=ib.reduce((e,t)=>{const n=Et.createSlot(`Primitive.${t}`),r=h.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(c,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Hc(e,t){e&&eo.flushSync(()=>e.dispatchEvent(t))}function ab(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Tt=e=>{const{present:t,children:n}=e,r=lb(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=Re(r.ref,cb(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};Tt.displayName="Presence";function lb(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,c]=ab(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const u=Io(r.current);s.current=a==="mounted"?u:"none"},[a]),lt(()=>{const u=r.current,d=o.current;if(d!==e){const p=s.current,m=Io(u);e?c("MOUNT"):m==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(d&&p!==m?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),lt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=m=>{const b=Io(r.current).includes(CSS.escape(m.animationName));if(m.target===t&&b&&(c("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},p=m=>{m.target===t&&(s.current=Io(r.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:h.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function Io(e){return(e==null?void 0:e.animationName)||"none"}function cb(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 ub=h[" useId ".trim().toString()]||(()=>{}),db=0;function Kt(e){const[t,n]=h.useState(ub());return lt(()=>{n(r=>r??String(db++))},[e]),e||(t?`radix-${t}`:"")}var No="Collapsible",[fb,GT]=Vt(No),[hb,yi]=fb(No),Uc=h.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[c,u]=wn({prop:r,defaultProp:o??!1,onChange:i,caller:No});return l.jsx(hb,{scope:n,disabled:s,contentId:Kt(),open:c,onOpenToggle:h.useCallback(()=>u(d=>!d),[u]),children:l.jsx(Se.div,{"data-state":Ci(c),"data-disabled":s?"":void 0,...a,ref:t})})});Uc.displayName=No;var Wc="CollapsibleTrigger",Vc=h.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=yi(Wc,n);return l.jsx(Se.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Ci(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:te(e.onClick,o.onOpenToggle)})});Vc.displayName=Wc;var Si="CollapsibleContent",pb=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=yi(Si,e.__scopeCollapsible);return l.jsx(Tt,{present:n||o.open,children:({present:s})=>l.jsx(mb,{...r,ref:t,present:s})})});pb.displayName=Si;var mb=h.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=yi(Si,n),[a,c]=h.useState(r),u=h.useRef(null),d=Re(t,u),f=h.useRef(0),p=f.current,m=h.useRef(0),w=m.current,b=i.open||a,g=h.useRef(b),x=h.useRef(void 0);return h.useEffect(()=>{const v=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(v)},[]),lt(()=>{const v=u.current;if(v){x.current=x.current||{transitionDuration:v.style.transitionDuration,animationName:v.style.animationName},v.style.transitionDuration="0s",v.style.animationName="none";const y=v.getBoundingClientRect();f.current=y.height,m.current=y.width,g.current||(v.style.transitionDuration=x.current.transitionDuration,v.style.animationName=x.current.animationName),c(r)}},[i.open,r]),l.jsx(Se.div,{"data-state":Ci(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!b,...s,ref:d,style:{"--radix-collapsible-content-height":p?`${p}px`:void 0,"--radix-collapsible-content-width":w?`${w}px`:void 0,...e.style},children:b&&o})});function Ci(e){return e?"open":"closed"}var gb=Uc;const Kc=gb,qc=Vc;function Gc(){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 Ln=Gc();function xb(e){Ln=e}const Yc=/[&<>"']/,bb=new RegExp(Yc.source,"g"),Xc=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,vb=new RegExp(Xc.source,"g"),wb={"&":"&","<":"<",">":">",'"':""","'":"'"},Jc=e=>wb[e];function gt(e,t){if(t){if(Yc.test(e))return e.replace(bb,Jc)}else if(Xc.test(e))return e.replace(vb,Jc);return e}const yb=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Zc(e){return e.replace(yb,(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 Sb=/(^|[^\[])\^/g;function Ke(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(Sb,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const Cb=/[^\w:]/g,Tb=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Qc(e,t,n){if(e){let r;try{r=decodeURIComponent(Zc(n)).replace(Cb,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!Tb.test(n)&&(n=Nb(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const jo={},kb=/^[^:]+:\/*[^/]*$/,Eb=/^([^:]+:)[\s\S]*$/,Ib=/^([^:]+:\/*[^/]*)[\s\S]*$/;function Nb(e,t){jo[" "+e]||(kb.test(e)?jo[" "+e]=e+"/":jo[" "+e]=Ro(e,"/",!0)),e=jo[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(Eb,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(Ib,"$1")+t:e+t}const Ao={exec:function(){}};function eu(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let c=!1,u=i;for(;--u>=0&&a[u]==="\\";)c=!c;return c?"|":" |"}),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 Ro(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 jb(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 Ab(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 tu(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function nu(e,t,n,r){const o=t.href,s=t.title?gt(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:gt(i)}}function Rb(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
37
|
+
`))>=0;){const Fe=z.slice(0,ve);z=z.slice(ve+2);const Ge=xg(Fe);if(!Ge)continue;let P;try{P=JSON.parse(Ge)}catch{H&&console.debug("[use-chat] malformed SSE:",Ge.slice(0,200));continue}const U=gg(P)?P.data:P;_e=Date.now(),O==null||O(U);const ue=U.seq;if(ue!==void 0){if(ue<=Y)continue;Y>0&&ue>Y+1&&((M=A==null?void 0:A.onGap)==null||M.call(A,{from:Y,to:ue})),Y=ue,E.current=ue,b(ue)}if(U.type==="token"&&e.autoAppendAssistant!==!1)_.push(U.content),ne();else if(U.type==="message_delta"){const be=U.delta.filter(le=>le.type==="text").map(le=>le.text).join("");be&&e.autoAppendAssistant!==!1&&(_.push(be),ne())}else Q!==null&&cancelAnimationFrame(Q),de(),U.type==="checkpoint"?m(U.checkpointId):U.type==="error"&&u(U.message)}}de()}catch(Ee){if(Ee.name!=="AbortError"){const Ae=Ee.message||String(Ee);u(Ae),(X=A==null?void 0:A.onError)==null||X.call(A,Ae)}}finally{try{await ee.cancel()}catch{}finally{(Z=ee.releaseLock)==null||Z.call(ee)}Q!==null&&typeof window<"u"&&window.cancelAnimationFrame(Q),clearInterval(Pe),a(!1),x(!1),v.current=null}}catch($){if($.name!=="AbortError"){const G=$.message||String($);u(G),(he=A==null?void 0:A.onError)==null||he.call(A,G)}}finally{a(!1),x(!1),v.current=null}})(),{close:()=>F.abort()}},[t,n,r,e.autoAppendAssistant]);return C.useEffect(()=>()=>{var j;y.current=!1,(j=v.current)==null||j.abort()},[]),{isStreaming:i,error:c,assistantText:d,lastCheckpointId:p,lastSeq:w,connected:g,stream:N,stop:T,clear:I,setToken:S}}function gg(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function xg(e){const t=e.split(/\r?\n/),n=[];for(const r of t)if(r&&!r.startsWith(":")&&r.startsWith("data:")){const o=r.slice(5);n.push(o.startsWith(" ")?o.slice(1):o)}return n.length===0?null:n.join(`
|
|
38
|
+
`)}const bg={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};function vg(e,t){var n;switch(t.type){case"reset":return{messages:Ys(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};case"seed":{const r=Ys(t.payload.messages),o={...e,messages:r,assemblingId:null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),console.log("[MessageReducer] seed action (REPLACE mode):",{incomingCount:t.payload.messages.length,sanitizedCount:r.length,previousCount:e.messages.length,checkpointId:o.lastCheckpointId}),o}case"prepend":{const r=Ys(t.payload.messages);if(!r.length)return console.log("[MessageReducer] No incoming messages after sanitize - skipping"),e;const o=new Set(e.messages.map(i=>i.id)),s=r.filter(i=>!o.has(i.id));return console.log("[MessageReducer] After dedup:",{uniqueCount:s.length,duplicates:r.length-s.length,finalTotal:s.length+e.messages.length}),s.length?{...e,messages:[...s,...e.messages]}:(console.log("[MessageReducer] All messages were duplicates - skipping"),e)}case"user_message":{const r=t.payload.message;if(e.assemblingId){const o=e.messages.findIndex(s=>s.id===e.assemblingId);if(o!==-1)return{...e,messages:[...e.messages.slice(0,o),r,...e.messages.slice(o)]}}return{...e,messages:[...e.messages,r]}}case"event":return $l(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>$l(o,s),e):e}default:return e}}function Ll(e=[]){const[t,n]=C.useReducer(vg,{...bg,messages:e}),r=C.useRef([]),o=C.useRef(null),s=C.useRef(null),i=C.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=C.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]),c=C.useCallback(d=>{r.current.push(d),a()},[a]);C.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const u=C.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:c}),[c]);return{state:t,dispatch:n,...u}}function $l(e,t){var n;if(t.type==="message_start"&&t.role==="assistant"){const r=t.id,o=Tg(t.model),s={id:r,role:"assistant",name:o||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:r,messages:[...e.messages,s]}}if(t.type==="token"){const r=e.assemblingId??Xs(e.messages);return r?{...e,messages:yg(e.messages,r,t.content)}:e}if(t.type==="message_delta"){const r=e.assemblingId??Xs(e.messages);return r?{...e,messages:zl(e.messages,r,t.delta)}:e}if(t.type==="message_end"){const r=e.assemblingId??Xs(e.messages);if(!r)return{...e,assemblingId:null};const o=e.messages,s=o.findIndex(i=>i.id===r&&i.role==="assistant");if(s>=0&&!((n=o[s].content)==null?void 0:n.some(c=>{var u;return(c==null?void 0:c.type)==="text"&&((u=c.text)==null?void 0:u.trim())}))){const c=[...o.slice(0,s),...o.slice(s+1)];return{...e,assemblingId:null,messages:c}}return e}if(t.type==="tool_start"){const r=`tool-${t.id}`,o={type:"tool_call",id:t.id,name:t.name,args:t.args},s={id:r,role:"tool",name:t.name,createdAt:new Date().toISOString(),content:[o]};return{...e,messages:[...e.messages,s],toolIndex:{...e.toolIndex,[t.id]:r}}}if(t.type==="tool_result"){const r=e.toolIndex[t.id]??`tool-${t.id}`,o={type:"tool_result",toolCallId:t.id,output:t.output,error:t.error},s=e.messages.find(c=>c.id===r),i={id:r,role:"tool",content:[o],createdAt:new Date().toISOString()},a=s?zl(e.messages,r,[o]):[...e.messages,i];return{...e,messages:a}}if(t.type==="checkpoint"){const r=t.checkpointNs??e.lastCheckpointNs??null,o=Cg(e.messages,t.checkpointId,r);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:r,messages:o}}if(t.type==="branch"){const r=t.checkpointId??e.lastCheckpointId,o=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:r??null,lastCheckpointNs:o??null}}if(t.type==="error"){const r={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,r]}}return e}function Ys(e){return e.filter(t=>{if(t.role!=="assistant")return!0;const n=(t.content||[]).some(o=>{var s;return o&&o.type==="text"&&((s=o.text)==null?void 0:s.trim())}),r=(t.content||[]).some(o=>o&&o.type==="image_url");return!!(n||r)})}function wg(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Xs(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function Fl(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 yg(e,t,n){return Fl(e,t,r=>{const o=r.content.slice(),s=o[o.length-1];return s&&s.type==="text"?s.text+=n:o.push({type:"text",text:n}),{...r,content:o}})}function zl(e,t,n){return Fl(e,t,r=>({...r,content:Sg(r.content,n)}))}function Sg(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1];(o==null?void 0:o.type)==="text"?o.text+=r.text:n.push({type:"text",text:r.text})}else n.push(r);return n}function Cg(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 wg(e,r,s)}return e}function Tg(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}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 Eg(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 c=0;c<a;c++)i+=String.fromCharCode(s[c]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function Ig(e,t=[],n,r,o,s){const i=[],a=[];for(const c of t)try{const u=await Eg(c);a.push({filename:c.name,data:u,mime_type:c.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const Bl=C.createContext(null);function Cr({children:e,apiConfig:t,onError:n,onThreadChange:r,initialThreadId:o=null,autoLoadInitial:s=!0,enableFileAgentRouting:i=!1,fileAgentId:a="invoice_reader"}){const c=mn;C.useEffect(()=>{t&&c.updateConfig({baseUrl:t.baseUrl,authToken:t.apiKey})},[c,t]);const{isStreaming:u,error:d,stream:f,stop:p,setToken:m}=Dl({baseUrl:c.baseUrl,token:null,headers:t==null?void 0:t.headers,streamPath:"/chat/runs/stream"}),[w,b]=C.useState(()=>typeof c.getAuthToken=="function"?c.getAuthToken():null);C.useEffect(()=>{m(typeof c.getAuthToken=="function"?c.getAuthToken():null);const P=c.onTokenChange(U=>{b(U),m(U)});return()=>{P()}},[c,m]);const g=C.useCallback(P=>{c.setAuthToken(P)},[c]),{state:x,seed:v,prepend:y,pushUser:E,onEvent:S,reset:T}=Ll(),I=20,[N,j]=C.useState(!1),[O,A]=C.useState(!1),[F,H]=C.useState(null),[D,J]=C.useState(void 0),[K,oe]=C.useState(void 0),W=C.useRef(!1),M=C.useRef([]),X=C.useCallback(P=>{P.cursor!==void 0&&H(P.cursor),P.hasMore!==void 0&&j(P.hasMore),P.checkpointId!==void 0&&J(P.checkpointId),P.checkpointNs!==void 0&&oe(P.checkpointNs)},[]),Z=C.useCallback((P,U)=>new Promise((ue,be)=>{const le=async()=>{if(W.current){console.warn(`[ChatProvider] Operation "${U}" queued - another operation in progress`),M.current.push(le);return}W.current=!0;try{console.log(`[ChatProvider] Executing operation: ${U}`),await P(),ue()}catch(Be){console.error(`[ChatProvider] Operation "${U}" failed:`,Be),be(Be)}finally{W.current=!1;const Be=M.current.shift();Be&&Be().catch(()=>{})}};W.current?(M.current.push(le),console.log(`[ChatProvider] Queued operation: ${U}`)):le().catch(Be=>{be(Be)})}),[]),he=C.useCallback((P,U)=>{const ue=Array.isArray(P==null?void 0:P.messages)?P.messages:[];U==="replace"?(console.log("[ChatProvider] Replacing messages, count:",ue.length),v(ue,{checkpointId:(P==null?void 0:P.checkpointId)??null,checkpointNs:(P==null?void 0:P.checkpointNs)??null})):U==="prepend"&&ue.length?(console.log("[ChatProvider] Calling prepend with",ue.length,"messages"),y(ue)):console.log("[ChatProvider] Skipping prepend - empty list or wrong mode"),H((P==null?void 0:P.nextCursor)??null),j(!!(P!=null&&P.hasMore)),J(be=>(P==null?void 0:P.checkpointId)??be??void 0),oe(be=>(P==null?void 0:P.checkpointNs)??be??void 0)},[v,y]),[$,G]=C.useState([]),[ee,pe]=C.useState(null),z=C.useCallback(async()=>{const P=await c.listThreads();G(P)},[c]),[_,Y]=C.useState(!1),Q=C.useCallback(async P=>{const U=(P==null?void 0:P.maxAttempts)??5,ue=(P==null?void 0:P.baseDelayMs)??500,be=(P==null?void 0:P.timeoutMs)??2e3;if(!c.baseUrl)return!1;const le=c.baseUrl.replace(/\/+$/,""),Be=["/health","/api/health","/","/api/v2/health","/api/v2/chat/health"],at=async xt=>{try{const _t=new AbortController,ft=setTimeout(()=>_t.abort(),be),Pt=await fetch(xt,{method:"GET",signal:_t.signal});return clearTimeout(ft),Pt.ok}catch{return!1}},hn=async xt=>{try{const _t=new AbortController,ft=setTimeout(()=>_t.abort(),be),Pt=await fetch(xt,{method:"HEAD",signal:_t.signal});return clearTimeout(ft),Pt.ok}catch{return!1}};for(let xt=0;xt<U;xt++){console.debug(`[ChatProvider] health-check attempt ${xt+1}/${U}`);for(const ft of Be){let Pt=ft;le.endsWith("/api")&&ft.startsWith("/api")&&(Pt=ft.replace(/^\/api/,"")||"/");const jn=Pt==="/"?le+"/":le+Pt;if(console.debug(`[ChatProvider] checking ${jn}`),await at(jn)||ft==="/"&&await hn(le+"/"))return Y(!0),!0}const _t=ue*Math.pow(2,xt);await new Promise(ft=>setTimeout(ft,_t))}return Y(!1),!1},[c.baseUrl]);C.useEffect(()=>{let P=!0;if(!c.baseUrl){console.debug("[ChatProvider] skipping initial refreshThreads: api.baseUrl not configured");return}return(async()=>{try{const U=await Q();if(!P)return;U?z().catch(()=>{}):console.warn("[ChatProvider] backend health-check failed — skipping initial loads")}catch{}})(),()=>{P=!1}},[z,c.baseUrl,Q]),C.useEffect(()=>{r==null||r(ee)},[ee,r]);const de=C.useRef(null);C.useEffect(()=>{if(o&&s){if(!c.baseUrl){console.debug("[ChatProvider] skipping initial load: api.baseUrl not configured");return}if(!_){console.debug("[ChatProvider] deferring initial load until backend health-check passes");return}de.current!==o&&(de.current=o,Pe(o).catch(()=>{}))}},[o,s,c.baseUrl,_]);const ne=C.useRef(null),_e=C.useRef(null),Pe=C.useCallback(async(P,U,ue)=>{await Z(async()=>{if(!c.baseUrl){console.debug("[ChatProvider] skipping loadThread: api.baseUrl not configured");return}if(ne.current){console.warn(`[ChatProvider] Thread load cancelled - another thread (${ne.current}) is loading`);return}_e.current!==null&&_e.current!==P&&(console.log(`[ChatProvider] Thread switch detected: ${_e.current} -> ${P}`),T([])),ne.current=P,_e.current=P;try{X({cursor:null,hasMore:!1,checkpointId:void 0,checkpointNs:void 0}),pe(P);const le=await c.getMessages({threadId:P,checkpointId:U,checkpointNs:ue,limit:I}),Be=Array.isArray(le==null?void 0:le.messages)?le.messages:[];console.log("[ChatProvider] Loading thread with",Be.length,"messages"),v(Be,{checkpointId:(le==null?void 0:le.checkpointId)??null,checkpointNs:(le==null?void 0:le.checkpointNs)??null}),H((le==null?void 0:le.nextCursor)??null),j(!!(le!=null&&le.hasMore)),J(at=>(le==null?void 0:le.checkpointId)??at??void 0),oe(at=>(le==null?void 0:le.checkpointNs)??at??void 0)}finally{ne.current=null}},`loadThread-${P}`)},[c,Z,X,v]),Ue=C.useCallback(async P=>{const U=await c.listCheckpoints(P);return kg(U,P)},[c]),Ee=C.useCallback(async(P,U)=>{await Z(async()=>{if(!ee)throw new Error("No active thread");X({cursor:null,hasMore:!1,checkpointId:void 0,checkpointNs:void 0});const ue=await c.getMessages({threadId:ee,checkpointId:P,checkpointNs:U??void 0,limit:I});he(ue,"replace")},`navigateToCheckpoint-${P}`)},[c,ee,he,Z,X]),Ae=C.useCallback(async()=>{if(!ee)throw new Error("No active thread");await Pe(ee)},[ee,Pe]),et=C.useRef(!1);C.useEffect(()=>{const P=et.current;et.current=u,P&&!u&&ee&&Z(async()=>{try{await z()}catch(U){console.warn("[ChatProvider] Post-streaming thread refresh failed:",U)}},"postStreamingRefresh")},[u,ee,c,he,z,Z]);const qe=C.useCallback(async P=>{const U=await c.createThread(P);return await z(),await Pe(U.threadId),U.threadId},[c,z,Pe]),ct=C.useCallback(async P=>{await c.deleteThread(P),await z(),ee===P&&(pe(null),T([]),j(!1),H(null),J(void 0),oe(void 0))},[c,z,ee,T]),ut=C.useCallback(async(P,U)=>{await c.updateThread(P,U),await z()},[c,z]),ve=C.useCallback(async(P,U)=>{await Z(async()=>{var qn;const ue=(U==null?void 0:U.attachments)||[],{contentParts:be,filesInfo:le}=await Ig(c,ue,t==null?void 0:t.uploadPath),Be=[];P&&P.trim()&&Be.push({type:"text",text:P.trim()});const at={id:((qn=crypto.randomUUID)==null?void 0:qn.call(crypto))||`user-${Date.now()}`,role:"user",content:Be,createdAt:new Date().toISOString(),checkpointId:(U==null?void 0:U.checkpointId)??x.lastCheckpointId??void 0,checkpointNs:(U==null?void 0:U.checkpointNs)??x.lastCheckpointNs??void 0};E(at);const hn={...at,content:Be},xt={...(U==null?void 0:U.payloadExtras)??{}},_t=!!xt.edit,ft=xt.originalMessageId,Pt=typeof ft=="string"?ft:void 0,jn=ue&&ue.length>0,Kn={...ee?{threadId:ee}:{},payload:{messages:[hn],files_info:le,...i&&jn&&a?{active_agent:a}:{},...xt},checkpointId:(U==null?void 0:U.checkpointId)??x.lastCheckpointId??void 0,checkpointNs:(U==null?void 0:U.checkpointNs)??x.lastCheckpointNs??void 0,nodeFilter:U==null?void 0:U.nodeFilter,config:U==null?void 0:U.config,edit:_t,originalMessageId:Pt};f(Kn,re=>S(re),{onError:re=>console.warn("stream error",re),onOpen:({threadId:re,created:me})=>{!ee&&re&&(pe(re),me&&z().catch(()=>{}))}})},"send")},[ee,E,f,S,x.lastCheckpointId,x.lastCheckpointNs,c,t==null?void 0:t.uploadPath,z,pe,i,a,Z]),Fe=C.useCallback(async P=>{if(!ee)throw new Error("No active thread");if(O||!N)return;const U=F;if(U){A(!0);try{const ue=await c.getMessages({threadId:ee,checkpointId:D,checkpointNs:K,limit:(P==null?void 0:P.limit)??I,beforeId:U});he(ue,"prepend")}finally{A(!1)}}},[c,ee,D,K,F,N,O,he,I]),Ge={baseUrl:c.baseUrl,token:w,setToken:g,api:c,threads:$,currentThreadId:ee,setCurrentThreadId:pe,messages:x.messages,isStreaming:u,error:d,lastCheckpointId:x.lastCheckpointId,lastCheckpointNs:x.lastCheckpointNs,streamingAssistantId:x.assemblingId,hasMoreHistory:N,isLoadingHistory:O,loadOlderMessages:Fe,historyPageSize:I,listCheckpoints:Ue,navigateToCheckpoint:Ee,returnToLatest:Ae,refreshThreads:z,createThread:qe,deleteThread:ct,renameThread:ut,loadThread:Pe,send:ve,stop:p};return l.jsx(Bl.Provider,{value:Ge,children:e})}function ho(){const e=C.useContext(Bl);if(!e)throw new Error("useChat must be used within ChatProvider");return e}function L(...e){return Vp.twMerge(Wp.clsx(e))}const Ng=mr.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"}}),ze=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Et.Slot:"button";return l.jsx(i,{className:L(Ng({variant:t,size:n,className:e})),ref:s,...o})});ze.displayName="Button";const Hl=h.forwardRef(({className:e,...t},n)=>l.jsx("textarea",{className:L("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Hl.displayName="Textarea";function jg({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,onSend:i,onCancelEdit:a,onStop:c,className:u="",textareaClassName:d="",allowEmptySend:f=!1}){const[p,m]=C.useState(e),[w,b]=C.useTransition(),g=C.useRef(null);C.useEffect(()=>{m(e??""),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const x=C.useCallback(()=>{const N=g.current;N&&(N.style.height="auto",N.style.height=`${N.scrollHeight}px`)},[]);C.useEffect(()=>{x()},[x]);const v=C.useCallback(async N=>{N&&N.preventDefault();const j=(p??"").trim();!j&&!f||b(()=>{try{const O=i(j);O&&typeof O.then=="function"?O.then(()=>{m(""),g.current&&(g.current.style.height="auto")}).catch(()=>{}):(m(""),g.current&&(g.current.style.height="auto"))}catch{}})},[p,i,f]),y=C.useCallback(N=>{m(N.target.value),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),E=C.useCallback(N=>{N.key==="Enter"&&!N.shiftKey?(N.preventDefault(),v()):N.key==="Escape"&&t&&(N.preventDefault(),a==null||a())},[v,t,a]),I=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${d}`;return l.jsx("form",{onSubmit:N=>void v(N),className:`w-full ${u}`,children:l.jsxs("div",{className:"flex items-end gap-2",children:[l.jsx("div",{className:"flex-1",children:l.jsx(Hl,{ref:g,value:p,onChange:y,onKeyDown:E,placeholder:t?"Edit your message...":n,className:I,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),l.jsx("div",{children:r?l.jsx(ze,{type:"button",onClick:()=>{c==null||c()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!c,children:l.jsx(se.Square,{size:16})}):l.jsx(ze,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!p.trim()&&!f||w,children:l.jsx(se.Send,{size:16})})})]})})}const Ag=C.memo(jg),po=0,gn=1,Zn=2,Ul=4;function Wl(e){return()=>e}function Rg(e){e()}function Vl(e,t){return n=>e(t(n))}function Kl(e,t){return()=>e(t)}function _g(e,t){return n=>e(t,n)}function Js(e){return e!==void 0}function Pg(...e){return()=>{e.map(Rg)}}function Qn(){}function mo(e,t){return t(e),e}function Og(e,t){return t(e)}function Je(...e){return e}function He(e,t){return e(gn,t)}function Ne(e,t){e(po,t)}function Zs(e){e(Zn)}function nt(e){return e(Ul)}function fe(e,t){return He(e,_g(t,po))}function Ut(e,t){const n=e(gn,r=>{n(),t(r)});return n}function ql(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Gl(e,t){return e===t}function Ze(e=Gl){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function ye(e){return t=>n=>{e(n)&&t(n)}}function ae(e){return t=>Vl(t,e)}function Zt(e){return t=>()=>{t(e)}}function B(e,...t){const n=Mg(...t);return(r,o)=>{switch(r){case Zn:Zs(e);return;case gn:return He(e,n(o))}}}function Qt(e,t){return n=>r=>{n(t=e(t,r))}}function Pn(e){return t=>n=>{e>0?e--:t(n)}}function un(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function je(...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);He(s,c=>{const u=n;n=n|a,t[i]=c,u!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function Mg(...e){return t=>e.reduceRight(Og,t)}function Dg(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case gn:return s?n===s?void 0:(r(),n=s,t=He(e,s),t):(r(),Qn);case Zn:r(),n=null;return}}}function q(e){let t=e;const n=Me();return(r,o)=>{switch(r){case po:t=o;break;case gn:{o(t);break}case Ul:return t}return n(r,o)}}function pt(e,t){return mo(q(t),n=>fe(e,n))}function Me(){const e=[];return(t,n)=>{switch(t){case po:e.slice().forEach(r=>{r(n)});return;case Zn:e.splice(0,e.length);return;case gn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Nt(e){return mo(Me(),t=>fe(e,t))}function $e(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Lg(),singleton:n}}const Lg=()=>Symbol();function $g(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(c=>n(c)));return i&&t.set(s,a),a};return n(e)}function ot(...e){const t=Me(),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);He(s,c=>{n[i]=c,r=r|a,r===o&&Ne(t,n)})}),function(s,i){switch(s){case Zn:{Zs(t);return}case gn:return r===o&&i(n),He(t,i)}}}function we(e,t=Gl){return B(e,Ze(t))}function Qs(...e){return function(t,n){switch(t){case Zn:return;case gn:return Pg(...e.map(r=>He(r,n)))}}}var Ct=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ct||{});const Fg={0:"debug",3:"error",1:"log",2:"warn"},zg=()=>typeof globalThis>"u"?window:globalThis,xn=$e(()=>{const e=q(3);return{log:q((t,n,r=1)=>{var o;const s=(o=zg().VIRTUOSO_LOG_LEVEL)!=null?o:nt(e);r>=s&&console[Fg[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function On(e,t,n){return ei(e,t,n).callbackRef}function ei(e,t,n){const r=C.useRef(null);let o=i=>{};const s=C.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const c=i[0].target;c.offsetParent!==null&&e(c)};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 Bg(e,t,n,r,o,s,i,a,c){const u=C.useCallback(d=>{const f=Hg(d.children,t,a?"offsetWidth":"offsetHeight",o);let p=d.parentElement;for(;!p.dataset.virtuosoScroller;)p=p.parentElement;const m=p.lastElementChild.dataset.viewportType==="window";let w;m&&(w=p.ownerDocument.defaultView);const b=i?a?i.scrollLeft:i.scrollTop:m?a?w.scrollX||w.document.documentElement.scrollLeft:w.scrollY||w.document.documentElement.scrollTop:a?p.scrollLeft:p.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:m?a?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight:a?p.scrollWidth:p.scrollHeight,x=i?a?i.offsetWidth:i.offsetHeight:m?a?w.innerWidth:w.innerHeight:a?p.offsetWidth:p.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(b,0),viewportHeight:x}),s==null||s(a?Yl("column-gap",getComputedStyle(d).columnGap,o):Yl("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return ei(u,n,c)}function Hg(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 c=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},Ct.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==c-1?s.push({endIndex:c,size:d,startIndex:c}):s[s.length-1].endIndex++}return s}function Yl(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ct.WARN),t==="normal"?0:parseInt(t??"0",10)}function Xl(e,t,n){const r=C.useRef(null),o=C.useCallback(c=>{if(!(c!=null&&c.offsetParent))return;const u=c.getBoundingClientRect(),d=u.width;let f,p;if(t){const m=t.getBoundingClientRect(),w=u.top-m.top;p=m.height-Math.max(0,w),f=w+t.scrollTop}else{const m=i.current.ownerDocument.defaultView;p=m.innerHeight-Math.max(0,u.top),f=u.top+m.scrollY}r.current={offsetTop:f,visibleHeight:p,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=ei(o,!0,n),a=C.useCallback(()=>{o(i.current)},[o,i]);return C.useEffect(()=>{var c;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=(c=i.current)==null?void 0:c.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 bt=$e(()=>{const e=Me(),t=Me(),n=q(0),r=Me(),o=q(0),s=Me(),i=Me(),a=q(0),c=q(0),u=q(0),d=q(0),f=Me(),p=Me(),m=q(!1),w=q(!1),b=q(!1);return fe(B(e,ae(({scrollTop:g})=>g)),t),fe(B(e,ae(({scrollHeight:g})=>g)),i),fe(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:c,footerHeight:d,headerHeight:a,horizontalDirection:w,scrollBy:p,scrollContainerState:e,scrollHeight:i,scrollingInProgress:m,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:b,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Tr={lvl:0};function Jl(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:c}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=c}return s.push({end:1/0,start:r,value:o}),s}function Ve(e){return e===Tr}function kr(e,t){if(!Ve(e))return t===e.k?e.v:t<e.k?kr(e.l,t):kr(e.r,t)}function Wt(e,t,n="k"){if(Ve(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=Wt(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return Wt(e.l,t,n)}function jt(e,t,n){return Ve(e)?ec(t,n,1):t===e.k?it(e,{k:t,v:n}):t<e.k?tc(it(e,{l:jt(e.l,t,n)})):tc(it(e,{r:jt(e.r,t,n)}))}function er(){return Tr}function go(e,t,n){if(Ve(e))return[];const r=Wt(e,t)[0];return Ug(ni(e,r,n))}function ti(e,t){if(Ve(e))return Tr;const{k:n,l:r,r:o}=e;if(t===n){if(Ve(r))return o;if(Ve(o))return r;{const[s,i]=Ql(r);return xo(it(e,{k:s,l:Zl(r),v:i}))}}else return t<n?xo(it(e,{l:ti(r,t)})):xo(it(e,{r:ti(o,t)}))}function Mn(e){return Ve(e)?[]:[...Mn(e.l),{k:e.k,v:e.v},...Mn(e.r)]}function ni(e,t,n){if(Ve(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(ni(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(ni(s,t,n))),a}function xo(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(ri(t))return nc(it(e,{lvl:n-1}));if(!Ve(t)&&!Ve(t.r))return it(t.r,{l:it(t,{r:t.r.l}),lvl:n,r:it(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(ri(e))return oi(it(e,{lvl:n-1}));if(!Ve(r)&&!Ve(r.l)){const o=r.l,s=ri(o)?r.lvl-1:r.lvl;return it(o,{l:it(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:oi(it(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function it(e,t){return ec(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function Zl(e){return Ve(e.r)?e.l:xo(it(e,{r:Zl(e.r)}))}function ri(e){return Ve(e)||e.lvl>e.r.lvl}function Ql(e){return Ve(e.r)?[e.k,e.v]:Ql(e.r)}function ec(e,t,n,r=Tr,o=Tr){return{k:e,l:r,lvl:n,r:o,v:t}}function tc(e){return oi(nc(e))}function nc(e){const{l:t}=e;return!Ve(t)&&t.lvl===e.lvl?it(t,{r:it(e,{l:t.r})}):e}function oi(e){const{lvl:t,r:n}=e;return!Ve(n)&&!Ve(n.r)&&n.lvl===t&&n.r.lvl===t?it(n,{l:it(e,{r:n.l}),lvl:t+1}):e}function Ug(e){return Jl(e,({k:t,v:n})=>({index:t,value:n}))}function rc(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Er(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const si=$e(()=>({recalcInProgress:q(!1)}),[],{singleton:!0});function oc(e,t,n){return e[bo(e,t,n)]}function bo(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 Wg(e,t,n,r){const o=bo(e,t,r),s=bo(e,n,r,o);return e.slice(o,s+1)}function bn(e,t){return Math.round(e.getBoundingClientRect()[t])}function vo(e){return!Ve(e.groupOffsetTree)}function ii({index:e},t){return t===e?0:t<e?-1:1}function Vg(){return{groupIndices:[],groupOffsetTree:er(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:er()}}function Kg(e,t){let n=Ve(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Ve(e)){e=jt(e,0,s);continue}const a=go(e,i-1,o+1);if(a.some(Qg(r)))continue;let c=!1,u=!1;for(const{end:d,start:f,value:p}of a)c?(o>=f||s===p)&&(e=ti(e,f)):(u=p!==s,c=!0),d>o&&o>=f&&p!==s&&(e=jt(e,o+1,p));u&&(e=jt(e,i,s))}return[e,n]}function qg(e){return typeof e.groupIndex<"u"}function Gg({offset:e},t){return t===e?0:t<e?-1:1}function Ir(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=oc(t,e,ii),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function sc(e,t){if(!vo(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function ic(e,t,n){if(qg(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=sc(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function Yg(e,t,n,r=0){return r>0&&(t=Math.max(t,oc(e,r,ii).offset)),Jl(Wg(e,t,n,Gg),Zg)}function Xg(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ct.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&Ve(s)&&t.length===2){const p=t[0].size,m=t[1].size;i=n.reduce((w,b)=>jt(jt(w,b,p),b+1,m),i)}else[i,a]=Kg(i,t);if(i===s)return e;const{lastIndex:c,lastOffset:u,lastSize:d,offsetTree:f}=ai(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((p,m)=>jt(p,m,Ir(m,f,o)),er()),lastIndex:c,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function Jg(e){return Mn(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function ac(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function ai(e,t,n,r){let o=e,s=0,i=0,a=0,c=0;if(t!==0){c=bo(o,t-1,ii),a=o[c].offset;const u=Wt(n,t-1);s=u[0],i=u[1],o.length&&o[c].size===Wt(n,t)[1]&&(c-=1),o=o.slice(0,c+1)}else o=[];for(const{start:u,value:d}of go(n,t,1/0)){const f=u-s,p=f*i+a+f*r;o.push({index:u,offset:p,size:d}),s=u,a=p,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function Zg(e){return{index:e.index,value:e}}function Qg(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 ex={offsetHeight:"height",offsetWidth:"width"},en=$e(([{log:e},{recalcInProgress:t}])=>{const n=Me(),r=Me(),o=pt(r,0),s=Me(),i=Me(),a=q(0),c=q([]),u=q(void 0),d=q(void 0),f=q((S,T)=>bn(S,ex[T])),p=q(void 0),m=q(0),w=Vg(),b=pt(B(n,je(c,e,m),Qt(Xg,w),Ze()),w),g=pt(B(c,Ze(),Qt((S,T)=>({current:T,prev:S.current}),{current:[],prev:[]}),ae(({prev:S})=>S)),[]);fe(B(c,ye(S=>S.length>0),je(b,m),ae(([S,T,I])=>{const N=S.reduce((j,O,A)=>jt(j,O,Ir(O,T.offsetTree,I)||A),er());return{...T,groupIndices:S,groupOffsetTree:N}})),b),fe(B(r,je(b),ye(([S,{lastIndex:T}])=>S<T),ae(([S,{lastIndex:T,lastSize:I}])=>[{endIndex:T,size:I,startIndex:S}])),n),fe(u,d);const x=pt(B(u,ae(S=>S===void 0)),!0);fe(B(d,ye(S=>S!==void 0&&Ve(nt(b).sizeTree)),ae(S=>[{endIndex:0,size:S,startIndex:0}])),n);const v=Nt(B(n,je(b),Qt(({sizes:S},[T,I])=>({changed:I!==S,sizes:I}),{changed:!1,sizes:w}),ae(S=>S.changed)));He(B(a,Qt((S,T)=>({diff:S.prev-T,prev:T}),{diff:0,prev:0}),ae(S=>S.diff)),S=>{const{groupIndices:T}=nt(b);if(S>0)Ne(t,!0),Ne(s,S+ac(S,T));else if(S<0){const I=nt(g);I.length>0&&(S-=ac(-S,I)),Ne(i,S)}}),He(B(a,je(e)),([S,T])=>{S<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Ct.ERROR)});const y=Nt(s);fe(B(s,je(b),ae(([S,T])=>{const I=T.groupIndices.length>0,N=[],j=T.lastSize;if(I){const O=kr(T.sizeTree,0);let A=0,F=0;for(;A<S;){const D=T.groupIndices[F],J=T.groupIndices.length===F+1?1/0:T.groupIndices[F+1]-D-1;N.push({endIndex:D,size:O,startIndex:D}),N.push({endIndex:D+1+J-1,size:j,startIndex:D+1}),F++,A+=J+1}const H=Mn(T.sizeTree);return A!==S&&H.shift(),H.reduce((D,{k:J,v:K})=>{let oe=D.ranges;return D.prevSize!==0&&(oe=[...D.ranges,{endIndex:J+S-1,size:D.prevSize,startIndex:D.prevIndex}]),{prevIndex:J+S,prevSize:K,ranges:oe}},{prevIndex:S,prevSize:0,ranges:N}).ranges}return Mn(T.sizeTree).reduce((O,{k:A,v:F})=>({prevIndex:A+S,prevSize:F,ranges:[...O.ranges,{endIndex:A+S-1,size:O.prevSize,startIndex:O.prevIndex}]}),{prevIndex:0,prevSize:j,ranges:[]}).ranges})),n);const E=Nt(B(i,je(b,m),ae(([S,{offsetTree:T},I])=>{const N=-S;return Ir(N,T,I)})));return fe(B(i,je(b,m),ae(([S,T,I])=>{if(T.groupIndices.length>0){if(Ve(T.sizeTree))return T;let N=er();const j=nt(g);let O=0,A=0,F=0;for(;O<-S;){F=j[A];const H=j[A+1]-F-1;A++,O+=H+1}if(N=Mn(T.sizeTree).reduce((H,{k:D,v:J})=>jt(H,Math.max(0,D+S),J),N),O!==-S){const H=kr(T.sizeTree,F);N=jt(N,0,H);const D=Wt(T.sizeTree,-S+1)[1];N=jt(N,1,D)}return{...T,sizeTree:N,...ai(T.offsetTree,0,N,I)}}else{const N=Mn(T.sizeTree).reduce((j,{k:O,v:A})=>jt(j,Math.max(0,O+S),A),er());return{...T,sizeTree:N,...ai(T.offsetTree,0,N,I)}}})),b),{beforeUnshiftWith:y,data:p,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:m,groupIndices:c,itemSize:f,listRefresh:v,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:b,statefulTotalCount:o,totalCount:r,trackItemSizes:x,unshiftWith:s}},Je(xn,si),{singleton:!0});function tx(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const lc=$e(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Me(),i=Me(),a=Nt(B(s,ae(tx)));return fe(B(a,ae(c=>c.totalCount)),n),fe(B(a,ae(c=>c.groupIndices)),e),fe(B(ot(o,t,r),ye(([c,u])=>vo(u)),ae(([c,u,d])=>Wt(u.groupOffsetTree,Math.max(c-d,0),"v")[0]),Ze(),ae(c=>[c])),i),{groupCounts:s,topItemsIndexes:i}},Je(en,bt)),vn=$e(([{log:e}])=>{const t=q(!1),n=Nt(B(t,ye(r=>r),Ze()));return He(t,r=>{r&&nt(e)("props updated",{},Ct.DEBUG)}),{didMount:n,propsReady:t}},Je(xn),{singleton:!0}),nx=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function cc(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!nx)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Nr=$e(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:c,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:p}])=>{const m=Me(),w=Me(),b=q(0);let g=null,x=null,v=null;function y(){g&&(g(),g=null),v&&(v(),v=null),x&&(clearTimeout(x),x=null),Ne(c,!1)}return fe(B(m,je(n,f,r,b,a,i,p),je(e,s,o),ae(([[E,S,T,I,N,j,O,A],F,H,D])=>{const J=cc(E),{align:K,behavior:oe,offset:W}=J,M=I-1,X=ic(J,S,M);let Z=Ir(X,S.offsetTree,F)+j;K==="end"?(Z+=H+Wt(S.sizeTree,X)[1]-T+D,X===M&&(Z+=O)):K==="center"?Z+=(H+Wt(S.sizeTree,X)[1]-T+D)/2:Z-=N,W&&(Z+=W);const he=$=>{y(),$?(A("retrying to scroll to",{location:E},Ct.DEBUG),Ne(m,E)):(Ne(w,!0),A("list did not change, scroll successful",{},Ct.DEBUG))};if(y(),oe==="smooth"){let $=!1;v=He(t,G=>{$=$||G}),g=Ut(d,()=>{he($)})}else g=Ut(B(t,rx(150)),he);return x=setTimeout(()=>{y()},1200),Ne(c,!0),A("scrolling from index to",{behavior:oe,index:X,top:Z},Ct.DEBUG),{behavior:oe,top:Z}})),u),{scrollTargetReached:w,scrollToIndex:m,topListHeight:b}},Je(en,bt,xn),{singleton:!0});function rx(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function li(e,t){e==0?t():requestAnimationFrame(()=>{li(e-1,t)})}function ci(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const jr=$e(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=q(!0),c=q(0),u=q(!0);return fe(B(i,je(c),ye(([d,f])=>!!f),Zt(!1)),a),fe(B(i,je(c),ye(([d,f])=>!!f),Zt(!1)),u),He(B(ot(t,i),je(a,n,e,u),ye(([[,d],f,{sizeTree:p},m,w])=>d&&(!Ve(p)||Js(m))&&!f&&!w),je(c)),([,d])=>{Ut(o,()=>{Ne(u,!0)}),li(4,()=>{Ut(r,()=>{Ne(a,!0)}),Ne(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:c,scrolledToInitialItem:a}},Je(en,bt,Nr,vn),{singleton:!0});function uc(e,t){return Math.abs(e-t)<1.01}const Ar="up",Rr="down",ox="none",sx={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},ix=0,_r=$e(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=q(!1),a=q(!0),c=Me(),u=Me(),d=q(4),f=q(ix),p=pt(B(Qs(B(we(o),Pn(1),Zt(!0)),B(we(o),Pn(1),Zt(!1),ql(100))),Ze()),!1),m=pt(B(Qs(B(n,Zt(!0)),B(n,Zt(!1),ql(200))),Ze()),!1);fe(B(ot(we(o),we(f)),ae(([v,y])=>v<=y),Ze()),a),fe(B(a,un(50)),u);const w=Nt(B(ot(r,we(s),we(t),we(e),we(d)),Qt((v,[{scrollHeight:y,scrollTop:E},S,T,I,N])=>{const j=E+S-y>-N,O={scrollHeight:y,scrollTop:E,viewportHeight:S};if(j){let F,H;return E>v.state.scrollTop?(F="SCROLLED_DOWN",H=v.state.scrollTop-E):(F="SIZE_DECREASED",H=v.state.scrollTop-E||v.scrollTopDelta),{atBottom:!0,atBottomBecause:F,scrollTopDelta:H,state:O}}let A;return O.scrollHeight>v.state.scrollHeight?A="SIZE_INCREASED":S<v.state.viewportHeight?A="VIEWPORT_HEIGHT_DECREASING":E<v.state.scrollTop?A="SCROLLING_UPWARDS":A="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:A,state:O}},sx),Ze((v,y)=>v&&v.atBottom===y.atBottom))),b=pt(B(r,Qt((v,{scrollHeight:y,scrollTop:E,viewportHeight:S})=>{if(uc(v.scrollHeight,y))return{changed:!1,jump:0,scrollHeight:y,scrollTop:E};{const T=y-(E+S)<1;return v.scrollTop!==E&&T?{changed:!0,jump:v.scrollTop-E,scrollHeight:y,scrollTop:E}:{changed:!0,jump:0,scrollHeight:y,scrollTop:E}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ye(v=>v.changed),ae(v=>v.jump)),0);fe(B(w,ae(v=>v.atBottom)),i),fe(B(i,un(50)),c);const g=q(Rr);fe(B(r,ae(({scrollTop:v})=>v),Ze(),Qt((v,y)=>nt(m)?{direction:v.direction,prevScrollTop:y}:{direction:y<v.prevScrollTop?Ar:Rr,prevScrollTop:y},{direction:Rr,prevScrollTop:0}),ae(v=>v.direction)),g),fe(B(r,un(50),Zt(ox)),g);const x=q(0);return fe(B(p,ye(v=>!v),Zt(0)),x),fe(B(o,un(100),je(p),ye(([v,y])=>!!y),Qt(([v,y],[E])=>[y,E],[0,0]),ae(([v,y])=>y-v)),x),{atBottomState:w,atBottomStateChange:c,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:p,lastJumpDueToItemResize:b,scrollDirection:g,scrollVelocity:x}},Je(bt)),wo="top",yo="bottom",dc="none";function fc(e,t,n){return typeof e=="number"?n===Ar&&t===wo||n===Rr&&t===yo?e:0:n===Ar?t===wo?e.main:e.reverse:t===yo?e.main:e.reverse}function hc(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const ui=$e(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Me(),i=q(0),a=q(0),c=q(0),u=pt(B(ot(we(r),we(o),we(n),we(s,Er),we(c),we(i),we(t),we(e),we(a)),ae(([d,f,p,[m,w],b,g,x,v,y])=>{const E=d-v,S=g+x,T=Math.max(p-E,0);let I=dc;const N=hc(y,wo),j=hc(y,yo);return m-=v,m+=p+x,w+=p+x,w-=v,m>d+S-N&&(I=Ar),w<d-T+f+j&&(I=Rr),I!==dc?[Math.max(E-p-fc(b,wo,I)-N,0),E-T-x+f+fc(b,yo,I)+j]:null}),ye(d=>d!=null),Ze(Er)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:c,topListHeight:i,visibleRange:u}},Je(bt),{singleton:!0});function ax(e,t,n){if(vo(t)){const r=sc(e,t);return[{index:Wt(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const di={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function So(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:c}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const b=e[e.length-1];d=b.offset+b.size}const f=n-i,p=a+f*c+(f-1)*r,m=u,w=p-d;return{bottom:d,firstItemIndex:s,items:mc(e,o,s),offsetBottom:w,offsetTop:u,top:m,topItems:mc(t,o,s),topListHeight:t.reduce((b,g)=>g.size+b,0),totalCount:n}}function pc(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,c=ci(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+c],index:f+c,offset:0,size:0}));return So(u,[],a,o,n,r)}function mc(e,t,n){if(e.length===0)return[];if(!vo(t))return e.map(u=>({...u,index:u.index+n,originalIndex:u.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=go(t.groupOffsetTree,r,o);let a,c=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),c=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:c,type:"group"}:d={groupIndex:c,index:u.index-(c+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const Dn=$e(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:c},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},p,{didMount:m},{recalcInProgress:w}])=>{const b=q([]),g=q(0),x=Me();fe(s.topItemsIndexes,b);const v=pt(B(ot(m,w,we(c,Er),we(o),we(r),we(u),d,we(b),we(t),we(n),e),ye(([T,I,,N,,,,,,,j])=>{const O=j&&j.length!==N;return T&&!I&&!O}),ae(([,,[T,I],N,j,O,A,F,H,D,J])=>{const K=j,{offsetTree:oe,sizeTree:W}=K,M=nt(g);if(N===0)return{...di,totalCount:N};if(T===0&&I===0)return M===0?{...di,totalCount:N}:pc(M,O,j,H,D,J||[]);if(Ve(W))return M>0?null:So(ax(ci(O,N),K,J),[],N,D,K,H);const X=[];if(F.length>0){const ee=F[0],pe=F[F.length-1];let z=0;for(const _ of go(W,ee,pe)){const Y=_.value,Q=Math.max(_.start,ee),de=Math.min(_.end,pe);for(let ne=Q;ne<=de;ne++)X.push({data:J==null?void 0:J[ne],index:ne,offset:z,size:Y}),z+=Y}}if(!A)return So([],X,N,D,K,H);const Z=F.length>0?F[F.length-1]+1:0,he=Yg(oe,T,I,Z);if(he.length===0)return null;const $=N-1,G=mo([],ee=>{for(const pe of he){const z=pe.value;let _=z.offset,Y=pe.start;const Q=z.size;if(z.offset<T){Y+=Math.floor((T-z.offset+D)/(Q+D));const ne=Y-pe.start;_+=ne*Q+ne*D}Y<Z&&(_+=(Z-Y)*Q,Y=Z);const de=Math.min(pe.end,$);for(let ne=Y;ne<=de&&!(_>=I);ne++)ee.push({data:J==null?void 0:J[ne],index:ne,offset:_,size:Q}),_+=Q+D}});return So(G,X,N,D,K,H)}),ye(T=>T!==null),Ze()),di);fe(B(e,ye(Js),ae(T=>T==null?void 0:T.length)),o),fe(B(v,ae(T=>T.topListHeight)),f),fe(f,a),fe(B(v,ae(T=>[T.top,T.bottom])),i),fe(B(v,ae(T=>T.items)),x);const y=Nt(B(v,ye(({items:T})=>T.length>0),je(o,e),ye(([{items:T},I])=>T[T.length-1].originalIndex===I-1),ae(([,T,I])=>[T-1,I]),Ze(Er),ae(([T])=>T))),E=Nt(B(v,un(200),ye(({items:T,topItems:I})=>T.length>0&&T[0].originalIndex===I.length),ae(({items:T})=>T[0].index),Ze())),S=Nt(B(v,ye(({items:T})=>T.length>0),ae(({items:T})=>{let I=0,N=T.length-1;for(;T[I].type==="group"&&I<N;)I++;for(;T[N].type==="group"&&N>I;)N--;return{endIndex:T[N].index,startIndex:T[I].index}}),Ze(rc)));return{endReached:y,initialItemCount:g,itemsRendered:x,listState:v,rangeChanged:S,startReached:E,topItemsIndexes:b,...p}},Je(en,lc,ui,jr,Nr,_r,vn,si),{singleton:!0}),gc=$e(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Me(),i=pt(B(ot(n,e,r,t,o),ae(([a,c,u,d,f])=>a+c+u+d+f.offsetBottom+f.bottom)),0);return fe(we(i),s),{totalListHeight:i,totalListHeightChanged:s}},Je(bt,Dn),{singleton:!0}),lx=$e(([{viewportHeight:e},{totalListHeight:t}])=>{const n=q(!1),r=pt(B(ot(n,e,t),ye(([o])=>o),ae(([,o,s])=>Math.max(0,o-s)),un(0),Ze()),0);return{alignToBottom:n,paddingTopAddition:r}},Je(bt,gc),{singleton:!0}),xc=$e(()=>({context:q(null)})),cx=({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,bc=$e(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:c},{scrollToIndex:u}])=>{const d=Me();return fe(B(d,je(t,c,n,s,o,r,a),je(e),ae(([[f,p,m,w,b,g,x,v],y])=>{const{align:E,behavior:S,calculateViewLocation:T=cx,done:I,...N}=f,j=ic(f,p,w-1),O=Ir(j,p.offsetTree,y)+b+g,A=O+Wt(p.sizeTree,j)[1],F=v+g,H=v+m-x,D=T({itemBottom:A,itemTop:O,locationParams:{align:E,behavior:S,...N},viewportBottom:H,viewportTop:F});return D?I&&Ut(B(i,ye(J=>!J),Pn(nt(i)?1:2)),I):I&&I(),D}),ye(f=>f!==null)),u),{scrollIntoView:d}},Je(en,bt,Nr,Dn,xn),{singleton:!0});function vc(e){return e?e==="smooth"?"smooth":"auto":!1}const ux=(e,t)=>typeof e=="function"?vc(e(t)):t&&vc(e),dx=$e(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:c,propsReady:u},{log:d},{scrollingInProgress:f},{context:p},{scrollIntoView:m}])=>{const w=q(!1),b=Me();let g=null;function x(S){Ne(i,{align:"end",behavior:S,index:"LAST"})}He(B(ot(B(we(t),Pn(1)),c),je(we(w),s,a,f),ae(([[S,T],I,N,j,O])=>{let A=T&&j,F="auto";return A&&(F=ux(I,N||O),A=A&&!!F),{followOutputBehavior:F,shouldFollow:A,totalCount:S}}),ye(({shouldFollow:S})=>S)),({followOutputBehavior:S,totalCount:T})=>{g&&(g(),g=null),nt(n)?requestAnimationFrame(()=>{nt(d)("following output to ",{totalCount:T},Ct.DEBUG),x(S)}):g=Ut(e,()=>{nt(d)("following output to ",{totalCount:T},Ct.DEBUG),x(S),g=null})});function v(S){const T=Ut(o,I=>{S&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(nt(d)("scrolling to bottom due to increased size",{},Ct.DEBUG),x("auto"))});setTimeout(T,100)}He(B(ot(we(w),t,u),ye(([S,,T])=>S&&T),Qt(({value:S},[,T])=>({refreshed:S===T,value:T}),{refreshed:!1,value:0}),ye(({refreshed:S})=>S),je(w,t)),([,S])=>{nt(a)&&v(S!==!1)}),He(b,()=>{v(nt(w)!==!1)}),He(ot(we(w),o),([S,T])=>{S&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&x("auto")});const y=q(null),E=Me();return fe(Qs(B(we(r),ae(S=>{var T;return(T=S==null?void 0:S.length)!=null?T:0})),B(we(t))),E),He(B(ot(B(E,Pn(1)),c),je(we(y),a,f,p),ae(([[S,T],I,N,j,O])=>T&&N&&(I==null?void 0:I({context:O,totalCount:S,scrollingInProgress:j}))),ye(S=>!!S),un(0)),S=>{g&&(g(),g=null),nt(n)?requestAnimationFrame(()=>{nt(d)("scrolling into view",{}),Ne(m,S)}):g=Ut(e,()=>{nt(d)("scrolling into view",{}),Ne(m,S),g=null})}),{autoscrollToBottom:b,followOutput:w,scrollIntoViewOnChange:y}},Je(en,_r,Nr,jr,vn,xn,bt,xc,bc)),fx=$e(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(fe(B(a,je(s),ye(([,c])=>c!==0),je(o,r,t,n,e),ae(([[,c],u,d,f,p,m=[]])=>pc(c,u,d,f,p,m))),i),{}),Je(en,jr,Dn,vn),{singleton:!0}),hx=$e(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=q(0);return He(B(e,je(r),ye(([,o])=>o!==0),ae(([,o])=>({top:o}))),o=>{Ut(B(n,Pn(1),ye(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Ne(t,o)})})}),{initialScrollTop:r}},Je(vn,bt,Dn),{singleton:!0}),wc=$e(([{scrollVelocity:e}])=>{const t=q(!1),n=Me(),r=q(!1);return fe(B(e,je(r,t,n),ye(([o,s])=>!!s),ae(([o,s,i,a])=>{const{enter:c,exit:u}=s;if(i){if(u(o,a))return!1}else if(c(o,a))return!0;return i}),Ze()),t),He(B(ot(t,e,n),je(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},Je(_r),{singleton:!0}),fi=$e(([{scrollContainerState:e,scrollTo:t}])=>{const n=Me(),r=Me(),o=Me(),s=q(!1),i=q(void 0);return fe(B(ot(n,r),ae(([{scrollHeight:a,scrollTop:c,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,c-d),viewportHeight:u}))),e),fe(B(t,je(r),ae(([a,{offsetTop:c}])=>({...a,top:a.top+c}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},Je(bt)),px=$e(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:c}])=>{const u=Me(),d=q(void 0),f=q(null),p=q(null);return fe(a,f),fe(c,p),He(B(u,je(t,r,i,f,p,n)),([m,w,b,g,x,v,y])=>{const E=Jg(w.sizeTree);g&&x!==null&&v!==null&&(b=x.scrollTop-v.offsetTop),b-=y,m({ranges:E,scrollTop:b})}),fe(B(d,ye(Js),ae(mx)),o),fe(B(s,je(d),ye(([,m])=>m!==void 0),Ze(),ae(([,m])=>m.ranges)),e),{getState:u,restoreStateFrom:d}},Je(en,bt,jr,vn,fi));function mx(e){return{align:"start",index:0,offset:e.scrollTop}}const gx=$e(([{topItemsIndexes:e}])=>{const t=q(0);return fe(B(t,ye(n=>n>=0),ae(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},Je(Dn));function yc(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const xx=yc(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),bx=$e(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:c},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:p},{log:m},{recalcInProgress:w}])=>{const b=Nt(B(c,je(i),Qt(([,x,v,y],[{bottom:E,items:S,offsetBottom:T,totalCount:I},N])=>{const j=E+T;let O=0;return v===I&&x.length>0&&S.length>0&&(S[0].originalIndex===0&&x[0].originalIndex===0||(O=j-y,O!==0&&(O+=N))),[O,S,I,j]},[0,[],0,0]),ye(([x])=>x!==0),je(r,a,n,o,m,w),ye(([,x,v,y,,,E])=>!E&&!y&&x!==0&&v===Ar),ae(([[x],,,,,v])=>(v("Upward scrolling compensation",{amount:x},Ct.DEBUG),x))));function g(x){x>0?(Ne(t,{behavior:"auto",top:-x}),Ne(e,0)):(Ne(e,0),Ne(t,{behavior:"auto",top:-x}))}return He(B(b,je(e,s)),([x,v,y])=>{y&&xx()?Ne(e,v-x):g(-x)}),He(B(ot(pt(s,!1),e,w),ye(([x,v,y])=>!x&&!y&&v!==0),ae(([x,v])=>v),un(1)),g),fe(B(f,ae(x=>({top:-x}))),t),He(B(u,je(p,d),ae(([x,{groupIndices:v,lastSize:y,sizeTree:E},S])=>{function T(I){return I*(y+S)}if(v.length===0)return T(x);{let I=0;const N=kr(E,0);let j=0,O=0;for(;j<x;){j++,I+=N;let A=v.length===O+1?1/0:v[O+1]-v[O]-1;j+A>x&&(I-=N,A=x-j+1),j+=A,I+=T(A),O++}return I}})),x=>{Ne(e,x),requestAnimationFrame(()=>{Ne(t,{top:x}),requestAnimationFrame(()=>{Ne(e,0),Ne(w,!1)})})}),{deviation:e}},Je(bt,_r,Dn,en,xn,si)),vx=$e(([e,t,n,r,o,s,i,a,c,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...c,...u,...d}),Je(ui,fx,vn,wc,gc,hx,lx,fi,bc,xn,xc)),Sc=$e(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:c,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:p,initialTopMostItemIndex:m,scrolledToInitialItem:w},b,g,x,{listState:v,topItemsIndexes:y,...E},{scrollToIndex:S},T,{topItemCount:I},{groupCounts:N},j])=>(fe(E.rangeChanged,j.scrollSeekRangeChanged),fe(B(j.windowViewportRect,ae(O=>O.visibleHeight)),b.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:N,initialItemFinalLocationReached:p,initialTopMostItemIndex:m,scrolledToInitialItem:w,sizeRanges:a,topItemCount:I,topItemsIndexes:y,totalCount:d,...x,groupIndices:s,itemSize:i,listState:v,scrollToIndex:S,statefulTotalCount:u,trackItemSizes:f,...E,...j,...b,sizes:c,...g}),Je(en,jr,bt,px,dx,Dn,Nr,bx,gx,lc,vx));function wx(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 Co=typeof document<"u"?C.useLayoutEffect:C.useEffect;function Cc(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=C.createContext({});function c(g,x){g.propsReady&&Ne(g.propsReady,!1);for(const v of r){const y=g[t.required[v]];Ne(y,x[v])}for(const v of o)if(v in x){const y=g[t.optional[v]];Ne(y,x[v])}g.propsReady&&Ne(g.propsReady,!0)}function u(g){return s.reduce((x,v)=>(x[v]=y=>{const E=g[t.methods[v]];Ne(E,y)},x),{})}function d(g){return i.reduce((x,v)=>(x[v]=Dg(g[t.events[v]]),x),{})}const f=C.forwardRef((g,x)=>{const{children:v,...y}=g,[E]=C.useState(()=>mo($g(e),I=>{c(I,y)})),[S]=C.useState(Kl(d,E));Co(()=>{for(const I of i)I in y&&He(S[I],y[I]);return()=>{Object.values(S).map(Zs)}},[y,S,E]),Co(()=>{c(E,y)}),C.useImperativeHandle(x,Wl(u(E)));const T=n;return l.jsx(a.Provider,{value:E,children:n?l.jsx(T,{...wx([...r,...o,...i],y),children:v}):v})}),p=g=>{const x=C.useContext(a);return C.useCallback(v=>{Ne(x[g],v)},[x,g])},m=g=>{const x=C.useContext(a)[g],v=C.useCallback(y=>He(x,y),[x]);return C.useSyncExternalStore(v,()=>nt(x),()=>nt(x))},w=g=>{const x=C.useContext(a)[g],[v,y]=C.useState(Kl(nt,x));return Co(()=>He(x,E=>{E!==v&&y(Wl(E))}),[x,v]),v},b=C.version.startsWith("18")?m:w;return{Component:f,useEmitter:(g,x)=>{const v=C.useContext(a)[g];Co(()=>He(v,x),[x,v])},useEmitterValue:b,usePublisher:p}}const Tc=C.createContext(void 0),kc=C.createContext(void 0),Ec=typeof document<"u"?C.useLayoutEffect:C.useEffect;function hi(e){return"self"in e}function yx(e){return"body"in e}function Ic(e,t,n,r=Qn,o,s){const i=C.useRef(null),a=C.useRef(null),c=C.useRef(null),u=C.useCallback(p=>{let m,w,b;const g=p.target;if(yx(g)||hi(g)){const v=hi(g)?g:g.defaultView;b=s?v.scrollX:v.scrollY,m=s?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight,w=s?v.innerWidth:v.innerHeight}else b=s?g.scrollLeft:g.scrollTop,m=s?g.scrollWidth:g.scrollHeight,w=s?g.offsetWidth:g.offsetHeight;const x=()=>{e({scrollHeight:m,scrollTop:Math.max(b,0),viewportHeight:w})};p.suppressFlushSync?x():Ps.flushSync(x),a.current!==null&&(b===a.current||b<=0||b===m-w)&&(a.current=null,t(!0),c.current&&(clearTimeout(c.current),c.current=null))},[e,t,s]);C.useEffect(()=>{const p=o||i.current;return r(o||i.current),u({suppressFlushSync:!0,target:p}),p.addEventListener("scroll",u,{passive:!0}),()=>{r(null),p.removeEventListener("scroll",u)}},[i,u,n,r,o]);function d(p){const m=i.current;if(!m||(s?"offsetWidth"in m&&m.offsetWidth===0:"offsetHeight"in m&&m.offsetHeight===0))return;const w=p.behavior==="smooth";let b,g,x;hi(m)?(g=Math.max(bn(m.document.documentElement,s?"width":"height"),s?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight),b=s?m.innerWidth:m.innerHeight,x=s?window.scrollX:window.scrollY):(g=m[s?"scrollWidth":"scrollHeight"],b=bn(m,s?"width":"height"),x=m[s?"scrollLeft":"scrollTop"]);const v=g-b;if(p.top=Math.ceil(Math.max(Math.min(v,p.top),0)),uc(b,g)||p.top===x){e({scrollHeight:g,scrollTop:x,viewportHeight:b}),w&&t(!0);return}w?(a.current=p.top,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(p={behavior:p.behavior,left:p.top}),m.scrollTo(p)}function f(p){s&&(p={behavior:p.behavior,left:p.top}),i.current.scrollBy(p)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const pi="-webkit-sticky",Nc="sticky",mi=yc(()=>{if(typeof document>"u")return Nc;const e=document.createElement("div");return e.style.position=pi,e.style.position===pi?pi:Nc});function gi(e){return e}const Sx=$e(()=>{const e=q(a=>`Item ${a}`),t=q(a=>`Group ${a}`),n=q({}),r=q(gi),o=q("div"),s=q(Qn),i=(a,c=null)=>pt(B(n,ae(u=>u[a]),Ze()),c);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")}}),Cx=$e(([e,t])=>({...e,...t}),Je(Sc,Sx)),Tx=({height:e})=>l.jsx("div",{style:{height:e}}),kx={overflowAnchor:"none",position:mi(),zIndex:1},jc={overflowAnchor:"none"},Ex={...jc,display:"inline-block",height:"100%"},Ac=C.memo(function({showTopList:e=!1}){const t=ke("listState"),n=Dt("sizeRanges"),r=ke("useWindowScroll"),o=ke("customScrollParent"),s=Dt("windowScrollContainerState"),i=Dt("scrollContainerState"),a=o||r?s:i,c=ke("itemContent"),u=ke("context"),d=ke("groupContent"),f=ke("trackItemSizes"),p=ke("itemSize"),m=ke("log"),w=Dt("gap"),b=ke("horizontalDirection"),{callbackRef:g}=Bg(n,p,f,e?Qn:a,m,w,o,b,ke("skipAnimationFrameInResizeObserver")),[x,v]=C.useState(0);xi("deviation",D=>{x!==D&&v(D)});const y=ke("EmptyPlaceholder"),E=ke("ScrollSeekPlaceholder")||Tx,S=ke("ListComponent"),T=ke("ItemComponent"),I=ke("GroupComponent"),N=ke("computeItemKey"),j=ke("isSeeking"),O=ke("groupIndices").length>0,A=ke("alignToBottom"),F=ke("initialItemFinalLocationReached"),H=e?{}:{boxSizing:"border-box",...b?{display:"inline-block",height:"100%",marginLeft:x!==0?x:A?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:x!==0?x:A?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...F?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&y?l.jsx(y,{...mt(y,u)}):l.jsx(S,{...mt(S,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:H,children:(e?t.topItems:t.items).map(D=>{const J=D.originalIndex,K=N(J+t.firstItemIndex,D.data,u);return j?C.createElement(E,{...mt(E,u),height:D.size,index:D.index,key:K,type:D.type||"item",...D.type==="group"?{}:{groupIndex:D.groupIndex}}):D.type==="group"?C.createElement(I,{...mt(I,u),"data-index":J,"data-item-index":D.index,"data-known-size":D.size,key:K,style:kx},d(D.index,u)):C.createElement(T,{...mt(T,u),...Ax(T,D.data),"data-index":J,"data-item-group-index":D.groupIndex,"data-item-index":D.index,"data-known-size":D.size,key:K,style:b?Ex:jc},O?c(D.index,D.groupIndex,D.data,u):c(D.index,D.data,u))})})}),Ix={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Nx={outline:"none",overflowX:"auto",position:"relative"},To=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),jx={position:mi(),top:0,width:"100%",zIndex:1};function mt(e,t){if(typeof e!="string")return{context:t}}function Ax(e,t){return{item:typeof e=="string"?void 0:t}}const Rx=C.memo(function(){const e=ke("HeaderComponent"),t=Dt("headerHeight"),n=ke("HeaderFooterTag"),r=On(C.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,ke("skipAnimationFrameInResizeObserver")),o=ke("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...mt(e,o)})}):null}),_x=C.memo(function(){const e=ke("FooterComponent"),t=Dt("footerHeight"),n=ke("HeaderFooterTag"),r=On(C.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,ke("skipAnimationFrameInResizeObserver")),o=ke("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...mt(e,o)})}):null});function Rc({useEmitter:e,useEmitterValue:t,usePublisher:n}){return C.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),c=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:p,scrollerRef:m,scrollToCallback:w}=Ic(a,u,c,d,void 0,f);return e("scrollTo",w),e("scrollBy",p),l.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:m,style:{...f?Nx:Ix,...o},tabIndex:0,...i,...mt(c,s),children:r})})}function _c({useEmitter:e,useEmitterValue:t,usePublisher:n}){return C.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),c=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),p=t("customScrollParent"),m=C.useRef(null),w=t("scrollerRef"),{scrollByCallback:b,scrollerRef:g,scrollToCallback:x}=Ic(a,u,c,w,p);return Ec(()=>{var v;return g.current=p||((v=m.current)==null?void 0:v.ownerDocument.defaultView),()=>{g.current=null}},[g,p]),e("windowScrollTo",x),e("scrollBy",b),l.jsx(c,{ref:m,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...mt(c,s),children:r})})}const Px=({children:e})=>{const t=C.useContext(Tc),n=Dt("viewportHeight"),r=Dt("fixedItemHeight"),o=ke("alignToBottom"),s=ke("horizontalDirection"),i=C.useMemo(()=>Vl(n,c=>bn(c,s?"width":"height")),[n,s]),a=On(i,!0,ke("skipAnimationFrameInResizeObserver"));return C.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),l.jsx("div",{"data-viewport-type":"element",ref:a,style:To(o),children:e})},Ox=({children:e})=>{const t=C.useContext(Tc),n=Dt("windowViewportRect"),r=Dt("fixedItemHeight"),o=ke("customScrollParent"),s=Xl(n,o,ke("skipAnimationFrameInResizeObserver")),i=ke("alignToBottom");return C.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),l.jsx("div",{"data-viewport-type":"window",ref:s,style:To(i),children:e})},Mx=({children:e})=>{const t=ke("TopItemListComponent")||"div",n=ke("headerHeight"),r={...jx,marginTop:`${n}px`},o=ke("context");return l.jsx(t,{style:r,...mt(t,o),children:e})},Dx=C.memo(function(e){const t=ke("useWindowScroll"),n=ke("topItemsIndexes").length>0,r=ke("customScrollParent"),o=ke("context");return l.jsxs(r||t?Fx:$x,{...e,context:o,children:[n&&l.jsx(Mx,{children:l.jsx(Ac,{showTopList:!0})}),l.jsxs(r||t?Ox:Px,{children:[l.jsx(Rx,{}),l.jsx(Ac,{}),l.jsx(_x,{})]})]})}),{Component:Lx,useEmitter:xi,useEmitterValue:ke,usePublisher:Dt}=Cc(Cx,{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"}},Dx),$x=Rc({useEmitter:xi,useEmitterValue:ke,usePublisher:Dt}),Fx=_c({useEmitter:xi,useEmitterValue:ke,usePublisher:Dt}),zx=Lx;Je(Sc,$e(()=>{const e=q(u=>l.jsxs("td",{children:["Item $",u]})),t=q(null),n=q(u=>l.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=q(null),o=q(null),s=q({}),i=q(gi),a=q(Qn),c=(u,d=null)=>pt(B(s,ae(f=>f[u]),Ze()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:c("EmptyPlaceholder"),FillerRow:c("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder"),TableBodyComponent:c("TableBody","tbody"),TableComponent:c("Table","table"),TableFooterComponent:c("TableFoot","tfoot"),TableHeadComponent:c("TableHead","thead"),TableRowComponent:c("TableRow","tr"),GroupComponent:c("Group","tr")}})),mi();const Pc={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Bx={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Oc,floor:ko,max:Pr,min:bi,round:Mc}=Math;function Dc(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function Hx(e){return{...Bx,items:e}}function Eo(e,t){return e&&e.width===t.width&&e.height===t.height}function Ux(e,t){return e&&e.column===t.column&&e.row===t.row}const Wx=$e(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:c,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},p,m,{didMount:w,propsReady:b},{customScrollParent:g,useWindowScroll:x,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:E},S])=>{const T=q(0),I=q(0),N=q(Pc),j=q({height:0,width:0}),O=q({height:0,width:0}),A=Me(),F=Me(),H=q(0),D=q(null),J=q({column:0,row:0}),K=Me(),oe=Me(),W=q(!1),M=q(0),X=q(!0),Z=q(!1),he=q(!1);He(B(w,je(M),ye(([_,Y])=>!!Y)),()=>{Ne(X,!1)}),He(B(ot(w,X,O,j,M,Z),ye(([_,Y,Q,de,,ne])=>_&&!Y&&Q.height!==0&&de.height!==0&&!ne)),([,,,,_])=>{Ne(Z,!0),li(1,()=>{Ne(A,_)}),Ut(B(u),()=>{Ne(t,[0,0]),Ne(X,!0)})}),fe(B(oe,ye(_=>_!=null&&_.scrollTop>0),Zt(0)),I),He(B(w,je(oe),ye(([,_])=>_!=null)),([,_])=>{_&&(Ne(j,_.viewport),Ne(O,_.item),Ne(J,_.gap),_.scrollTop>0&&(Ne(W,!0),Ut(B(u,Pn(1)),Y=>{Ne(W,!1)}),Ne(c,{top:_.scrollTop})))}),fe(B(j,ae(({height:_})=>_)),f),fe(B(ot(we(j,Eo),we(O,Eo),we(J,(_,Y)=>_&&_.column===Y.column&&_.row===Y.row),we(u)),ae(([_,Y,Q,de])=>({gap:Q,item:Y,scrollTop:de,viewport:_}))),K),fe(B(ot(we(T),r,we(J,Ux),we(O,Eo),we(j,Eo),we(D),we(I),we(W),we(X),we(M)),ye(([,,,,,,,_])=>!_),ae(([_,[Y,Q],de,ne,_e,Pe,Ue,,Ee,Ae])=>{const{column:et,row:qe}=de,{height:ct,width:ut}=ne,{width:ve}=_e;if(Ue===0&&(_===0||ve===0))return Pc;if(ut===0){const at=ci(Ae,_),hn=at+Math.max(Ue-1,0);return Hx(Dc(at,hn,Pe))}const Fe=Lc(ve,ut,et);let Ge,P;Ee?Y===0&&Q===0&&Ue>0?(Ge=0,P=Ue-1):(Ge=Fe*ko((Y+qe)/(ct+qe)),P=Fe*Oc((Q+qe)/(ct+qe))-1,P=bi(_-1,Pr(P,Fe-1)),Ge=bi(P,Pr(0,Ge))):(Ge=0,P=-1);const U=Dc(Ge,P,Pe),{bottom:ue,top:be}=$c(_e,de,ne,U),le=Oc(_/Fe),Be=le*ct+(le-1)*qe-ue;return{bottom:ue,itemHeight:ct,items:U,itemWidth:ut,offsetBottom:Be,offsetTop:be,top:be}})),N),fe(B(D,ye(_=>_!==null),ae(_=>_.length)),T),fe(B(ot(j,O,N,J),ye(([_,Y,{items:Q}])=>Q.length>0&&Y.height!==0&&_.height!==0),ae(([_,Y,{items:Q},de])=>{const{bottom:ne,top:_e}=$c(_,de,Y,Q);return[_e,ne]}),Ze(Er)),t);const $=q(!1);fe(B(u,je($),ae(([_,Y])=>Y||_!==0)),$);const G=Nt(B(ot(N,T),ye(([{items:_}])=>_.length>0),je($),ye(([[_,Y],Q])=>{const de=_.items[_.items.length-1].index===Y-1;return(Q||_.bottom>0&&_.itemHeight>0&&_.offsetBottom===0&&_.items.length===Y)&&de}),ae(([[,_]])=>_-1),Ze())),ee=Nt(B(we(N),ye(({items:_})=>_.length>0&&_[0].index===0),Zt(0),Ze())),pe=Nt(B(we(N),je(W),ye(([{items:_},Y])=>_.length>0&&!Y),ae(([{items:_}])=>({endIndex:_[_.length-1].index,startIndex:_[0].index})),Ze(rc),un(0)));fe(pe,m.scrollSeekRangeChanged),fe(B(A,je(j,O,T,J),ae(([_,Y,Q,de,ne])=>{const _e=cc(_),{align:Pe,behavior:Ue,offset:Ee}=_e;let Ae=_e.index;Ae==="LAST"&&(Ae=de-1),Ae=Pr(0,Ae,bi(de-1,Ae));let et=vi(Y,ne,Q,Ae);return Pe==="end"?et=Mc(et-Y.height+Q.height):Pe==="center"&&(et=Mc(et-Y.height/2+Q.height/2)),Ee&&(et+=Ee),{behavior:Ue,top:et}})),c);const z=pt(B(N,ae(_=>_.offsetBottom+_.bottom)),0);return fe(B(E,ae(_=>({height:_.visibleHeight,width:_.visibleWidth}))),j),{customScrollParent:g,data:D,deviation:H,footerHeight:o,gap:J,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:O,overscan:n,restoreStateFrom:oe,scrollBy:i,scrollContainerState:a,scrollHeight:F,scrollTo:c,scrollToIndex:A,scrollTop:u,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:x,viewportDimensions:j,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:E,...m,gridState:N,horizontalDirection:he,initialTopMostItemIndex:M,totalListHeight:z,...p,endReached:G,propsReady:b,rangeChanged:pe,startReached:ee,stateChanged:K,stateRestoreInProgress:W,...S}},Je(ui,bt,_r,wc,vn,fi,xn));function Lc(e,t,n){return Pr(1,ko((e+n)/(ko(t)+n)))}function $c(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=vi(e,t,n,r[0].index);return{bottom:vi(e,t,n,r[r.length-1].index)+o,top:s}}function vi(e,t,n,r){const o=Lc(e.width,n.width,t.column),s=ko(r/o),i=s*n.height+Pr(0,s-1)*t.row;return i>0?i+t.row:i}const Vx=$e(()=>{const e=q(f=>`Item ${f}`),t=q({}),n=q(null),r=q("virtuoso-grid-item"),o=q("virtuoso-grid-list"),s=q(gi),i=q("div"),a=q(Qn),c=(f,p=null)=>pt(B(t,ae(m=>m[f]),Ze()),p),u=q(!1),d=q(!1);return fe(we(d),u),{components:t,computeItemKey:s,context:n,FooterComponent:c("Footer"),HeaderComponent:c("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:c("Item","div"),itemContent:e,listClassName:o,ListComponent:c("List","div"),readyStateChanged:u,reportReadyState:d,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}),Kx=$e(([e,t])=>({...e,...t}),Je(Wx,Vx)),qx=C.memo(function(){const e=Qe("gridState"),t=Qe("listClassName"),n=Qe("itemClassName"),r=Qe("itemContent"),o=Qe("computeItemKey"),s=Qe("isSeeking"),i=Lt("scrollHeight"),a=Qe("ItemComponent"),c=Qe("ListComponent"),u=Qe("ScrollSeekPlaceholder"),d=Qe("context"),f=Lt("itemDimensions"),p=Lt("gap"),m=Qe("log"),w=Qe("stateRestoreInProgress"),b=Lt("reportReadyState"),g=On(C.useMemo(()=>x=>{const v=x.parentElement.parentElement.scrollHeight;i(v);const y=x.firstChild;if(y){const{height:E,width:S}=y.getBoundingClientRect();f({height:E,width:S})}p({column:zc("column-gap",getComputedStyle(x).columnGap,m),row:zc("row-gap",getComputedStyle(x).rowGap,m)})},[i,f,p,m]),!0,!1);return Ec(()=>{e.itemHeight>0&&e.itemWidth>0&&b(!0)},[e]),w?null:l.jsx(c,{className:t,ref:g,...mt(c,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(x=>{const v=o(x.index,x.data,d);return s?l.jsx(u,{...mt(u,d),height:e.itemHeight,index:x.index,width:e.itemWidth},v):C.createElement(a,{...mt(a,d),className:n,"data-index":x.index,key:v},r(x.index,x.data,d))})})}),Gx=C.memo(function(){const e=Qe("HeaderComponent"),t=Lt("headerHeight"),n=Qe("headerFooterTag"),r=On(C.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,!1),o=Qe("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...mt(e,o)})}):null}),Yx=C.memo(function(){const e=Qe("FooterComponent"),t=Lt("footerHeight"),n=Qe("headerFooterTag"),r=On(C.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,!1),o=Qe("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...mt(e,o)})}):null}),Xx=({children:e})=>{const t=C.useContext(kc),n=Lt("itemDimensions"),r=Lt("viewportDimensions"),o=On(C.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return C.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),l.jsx("div",{ref:o,style:To(!1),children:e})},Jx=({children:e})=>{const t=C.useContext(kc),n=Lt("windowViewportRect"),r=Lt("itemDimensions"),o=Qe("customScrollParent"),s=Xl(n,o,!1);return C.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),l.jsx("div",{ref:s,style:To(!1),children:e})},Zx=C.memo(function({...e}){const t=Qe("useWindowScroll"),n=Qe("customScrollParent"),r=n||t?eb:Qx,o=n||t?Jx:Xx,s=Qe("context");return l.jsx(r,{...e,...mt(r,s),children:l.jsxs(o,{children:[l.jsx(Gx,{}),l.jsx(qx,{}),l.jsx(Yx,{})]})})}),{useEmitter:Fc,useEmitterValue:Qe,usePublisher:Lt}=Cc(Kx,{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"}},Zx),Qx=Rc({useEmitter:Fc,useEmitterValue:Qe,usePublisher:Lt}),eb=_c({useEmitter:Fc,useEmitterValue:Qe,usePublisher:Lt});function zc(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ct.WARN),t==="normal"?0:parseInt(t??"0",10)}const tb=mr.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 Bc({className:e,variant:t,...n}){return l.jsx("div",{className:L(tb({variant:t}),e),...n})}function te(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 nb(e,t){const n=h.createContext(t),r=s=>{const{children:i,...a}=s,c=h.useMemo(()=>a,Object.values(a));return l.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function o(s){const i=h.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 Vt(e,t=[]){let n=[];function r(s,i){const a=h.createContext(i),c=n.length;n=[...n,i];const u=f=>{var x;const{scope:p,children:m,...w}=f,b=((x=p==null?void 0:p[e])==null?void 0:x[c])||a,g=h.useMemo(()=>w,Object.values(w));return l.jsx(b.Provider,{value:g,children:m})};u.displayName=s+"Provider";function d(f,p){var b;const m=((b=p==null?void 0:p[e])==null?void 0:b[c])||a,w=h.useContext(m);if(w)return w;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>h.createContext(i));return function(a){const c=(a==null?void 0:a[e])||s;return h.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,rb(o,...t)]}function rb(...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:c,scopeName:u})=>{const f=c(s)[`__scope${u}`];return{...a,...f}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var lt=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},ob=h[" useInsertionEffect ".trim().toString()]||lt;function wn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=sb({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:o;{const d=h.useRef(e!==void 0);h.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=h.useCallback(d=>{var f;if(a){const p=ib(d)?d(e):d;p!==e&&((f=i.current)==null||f.call(i,p))}else s(d)},[a,e,s,i]);return[c,u]}function sb({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return ob(()=>{s.current=t},[t]),h.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function ib(e){return typeof e=="function"}function Hc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function wi(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Hc(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():Hc(e[o],null)}}}}function Re(...e){return h.useCallback(wi(...e),e)}var ab=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Se=ab.reduce((e,t)=>{const n=Et.createSlot(`Primitive.${t}`),r=h.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(c,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Uc(e,t){e&&eo.flushSync(()=>e.dispatchEvent(t))}function lb(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Tt=e=>{const{present:t,children:n}=e,r=cb(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=Re(r.ref,ub(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};Tt.displayName="Presence";function cb(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,c]=lb(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const u=Io(r.current);s.current=a==="mounted"?u:"none"},[a]),lt(()=>{const u=r.current,d=o.current;if(d!==e){const p=s.current,m=Io(u);e?c("MOUNT"):m==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(d&&p!==m?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),lt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=m=>{const b=Io(r.current).includes(CSS.escape(m.animationName));if(m.target===t&&b&&(c("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},p=m=>{m.target===t&&(s.current=Io(r.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:h.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function Io(e){return(e==null?void 0:e.animationName)||"none"}function ub(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 db=h[" useId ".trim().toString()]||(()=>{}),fb=0;function Kt(e){const[t,n]=h.useState(db());return lt(()=>{n(r=>r??String(fb++))},[e]),e||(t?`radix-${t}`:"")}var No="Collapsible",[hb,YT]=Vt(No),[pb,yi]=hb(No),Wc=h.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[c,u]=wn({prop:r,defaultProp:o??!1,onChange:i,caller:No});return l.jsx(pb,{scope:n,disabled:s,contentId:Kt(),open:c,onOpenToggle:h.useCallback(()=>u(d=>!d),[u]),children:l.jsx(Se.div,{"data-state":Ci(c),"data-disabled":s?"":void 0,...a,ref:t})})});Wc.displayName=No;var Vc="CollapsibleTrigger",Kc=h.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=yi(Vc,n);return l.jsx(Se.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Ci(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:te(e.onClick,o.onOpenToggle)})});Kc.displayName=Vc;var Si="CollapsibleContent",mb=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=yi(Si,e.__scopeCollapsible);return l.jsx(Tt,{present:n||o.open,children:({present:s})=>l.jsx(gb,{...r,ref:t,present:s})})});mb.displayName=Si;var gb=h.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=yi(Si,n),[a,c]=h.useState(r),u=h.useRef(null),d=Re(t,u),f=h.useRef(0),p=f.current,m=h.useRef(0),w=m.current,b=i.open||a,g=h.useRef(b),x=h.useRef(void 0);return h.useEffect(()=>{const v=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(v)},[]),lt(()=>{const v=u.current;if(v){x.current=x.current||{transitionDuration:v.style.transitionDuration,animationName:v.style.animationName},v.style.transitionDuration="0s",v.style.animationName="none";const y=v.getBoundingClientRect();f.current=y.height,m.current=y.width,g.current||(v.style.transitionDuration=x.current.transitionDuration,v.style.animationName=x.current.animationName),c(r)}},[i.open,r]),l.jsx(Se.div,{"data-state":Ci(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!b,...s,ref:d,style:{"--radix-collapsible-content-height":p?`${p}px`:void 0,"--radix-collapsible-content-width":w?`${w}px`:void 0,...e.style},children:b&&o})});function Ci(e){return e?"open":"closed"}var xb=Wc;const qc=xb,Gc=Kc;function Yc(){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 Ln=Yc();function bb(e){Ln=e}const Xc=/[&<>"']/,vb=new RegExp(Xc.source,"g"),Jc=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,wb=new RegExp(Jc.source,"g"),yb={"&":"&","<":"<",">":">",'"':""","'":"'"},Zc=e=>yb[e];function gt(e,t){if(t){if(Xc.test(e))return e.replace(vb,Zc)}else if(Jc.test(e))return e.replace(wb,Zc);return e}const Sb=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Qc(e){return e.replace(Sb,(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 Cb=/(^|[^\[])\^/g;function Ke(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(Cb,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const Tb=/[^\w:]/g,kb=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function eu(e,t,n){if(e){let r;try{r=decodeURIComponent(Qc(n)).replace(Tb,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!kb.test(n)&&(n=jb(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const jo={},Eb=/^[^:]+:\/*[^/]*$/,Ib=/^([^:]+:)[\s\S]*$/,Nb=/^([^:]+:\/*[^/]*)[\s\S]*$/;function jb(e,t){jo[" "+e]||(Eb.test(e)?jo[" "+e]=e+"/":jo[" "+e]=Ro(e,"/",!0)),e=jo[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(Ib,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(Nb,"$1")+t:e+t}const Ao={exec:function(){}};function tu(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let c=!1,u=i;for(;--u>=0&&a[u]==="\\";)c=!c;return c?"|":" |"}),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 Ro(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 Ab(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 Rb(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 nu(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function ru(e,t,n,r){const o=t.href,s=t.title?gt(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:gt(i)}}function _b(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
39
39
|
`).map(o=>{const s=o.match(/^\s+/);if(s===null)return o;const[i]=s;return i.length>=r.length?o.slice(r.length):o}).join(`
|
|
40
40
|
`)}class Ti{constructor(t){this.options=t||Ln}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:Ro(r,`
|
|
41
|
-
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=
|
|
41
|
+
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=_b(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=Ro(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,c,u,d,f,p,m,w,b=n[1].trim();const g=b.length>1,x={type:"list",raw:"",ordered:g,start:g?+b.slice(0,-1):"",loose:!1,items:[]};b=g?`\\d{1,9}\\${b.slice(-1)}`:`\\${b}`,this.options.pedantic&&(b=g?b:"[*+-]");const v=new RegExp(`^( {0,3}${b})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(w=!1,!(!(n=v.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
|
|
42
42
|
`,1)[0].replace(/^\t+/,E=>" ".repeat(3*E.length)),f=t.split(`
|
|
43
43
|
`,1)[0],this.options.pedantic?(i=2,m=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,m=d.slice(i),i+=n[1].length),c=!1,!d&&/^ *$/.test(f)&&(r+=f+`
|
|
44
44
|
`,t=t.substring(f.length+1),w=!0),!w){const E=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),S=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),I=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(p=t.split(`
|
|
45
45
|
`,1)[0],f=p,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(T.test(f)||I.test(f)||E.test(f)||S.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())m+=`
|
|
46
46
|
`+f.slice(i);else{if(c||d.search(/[^ ]/)>=4||T.test(d)||I.test(d)||S.test(d))break;m+=`
|
|
47
47
|
`+f}!c&&!f.trim()&&(c=!0),r+=p+`
|
|
48
|
-
`,t=t.substring(p.length+1),d=f.slice(i)}}x.loose||(u?x.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(m),o&&(s=o[0]!=="[ ] ",m=m.replace(/^\[[ xX]\] +/,""))),x.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:m}),x.raw+=r}x.items[x.items.length-1].raw=r.trimRight(),x.items[x.items.length-1].text=m.trimRight(),x.raw=x.raw.trimRight();const y=x.items.length;for(a=0;a<y;a++)if(this.lexer.state.top=!1,x.items[a].tokens=this.lexer.blockTokens(x.items[a].text,[]),!x.loose){const E=x.items[a].tokens.filter(T=>T.type==="space"),S=E.length>0&&E.some(T=>/\n.*\n/.test(T.raw));x.loose=S}if(x.loose)for(a=0;a<y;a++)x.items[a].loose=!0;return x}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):gt(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:
|
|
49
|
-
`):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,c;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]=
|
|
50
|
-
`?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:r,tokens:this.lexer.inline(r)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:gt(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]):gt(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=Ro(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=
|
|
51
|
-
]`).replace("lheading",ge.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ce={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ao,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:Ao,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};ce._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",ce.punctuation=Ke(ce.punctuation).replace(/punctuation/g,ce._punctuation).getRegex(),ce.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,ce.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,ce._comment=Ke(ge._comment).replace("(?:-->|$)","-->").getRegex(),ce.emStrong.lDelim=Ke(ce.emStrong.lDelim).replace(/punct/g,ce._punctuation).getRegex(),ce.emStrong.rDelimAst=Ke(ce.emStrong.rDelimAst,"g").replace(/punct/g,ce._punctuation).getRegex(),ce.emStrong.rDelimUnd=Ke(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=Ke(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=Ke(ce.tag).replace("comment",ce._comment).replace("attribute",ce._attribute).getRegex(),ce._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ce._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,ce._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ce.link=Ke(ce.link).replace("label",ce._label).replace("href",ce._href).replace("title",ce._title).getRegex(),ce.reflink=Ke(ce.reflink).replace("label",ce._label).replace("ref",ge._label).getRegex(),ce.nolink=Ke(ce.nolink).replace("ref",ge._label).getRegex(),ce.reflinkSearch=Ke(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:Ke(/^!?\[(label)\]\((.*?)\)/).replace("label",ce._label).getRegex(),reflink:Ke(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ce._label).getRegex()},ce.gfm={...ce.normal,escape:Ke(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=Ke(ce.gfm.url,"i").replace("email",ce.gfm._extended_email).getRegex(),ce.breaks={...ce.gfm,br:Ke(ce.br).replace("{2,}","*").getRegex(),text:Ke(ce.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function
|
|
48
|
+
`,t=t.substring(p.length+1),d=f.slice(i)}}x.loose||(u?x.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(m),o&&(s=o[0]!=="[ ] ",m=m.replace(/^\[[ xX]\] +/,""))),x.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:m}),x.raw+=r}x.items[x.items.length-1].raw=r.trimRight(),x.items[x.items.length-1].text=m.trimRight(),x.raw=x.raw.trimRight();const y=x.items.length;for(a=0;a<y;a++)if(this.lexer.state.top=!1,x.items[a].tokens=this.lexer.blockTokens(x.items[a].text,[]),!x.loose){const E=x.items[a].tokens.filter(T=>T.type==="space"),S=E.length>0&&E.some(T=>/\n.*\n/.test(T.raw));x.loose=S}if(x.loose)for(a=0;a<y;a++)x.items[a].loose=!0;return x}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):gt(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:tu(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
|
|
49
|
+
`):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,c;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]=tu(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(c=r.rows[i],a=0;a<c.length;a++)c[a].tokens=this.lexer.inline(c[a].text);return r}}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const r=n[1].charAt(n[1].length-1)===`
|
|
50
|
+
`?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:r,tokens:this.lexer.inline(r)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:gt(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]):gt(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=Ro(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=Ab(n[2],"()");if(i>-1){const c=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,c).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)),ru(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 ru(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,c,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(c=a.length,o[3]||o[4]){u+=c;continue}else if((o[5]||o[6])&&i%3&&!((i+c)%3)){d+=c;continue}if(u-=c,u>0)continue;c=Math.min(c,c+u+d);const p=t.slice(0,i+o.index+(o[0].length-a.length)+c);if(Math.min(i,c)%2){const w=p.slice(1,-1);return{type:"em",raw:p,text:w,tokens:this.lexer.inlineTokens(w)}}const m=p.slice(2,-2);return{type:"strong",raw:p,text:m,tokens:this.lexer.inlineTokens(m)}}}}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=gt(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=gt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=gt(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=gt(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=gt(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]):gt(r[0]):r[0]:o=gt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const ge={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:Ao,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};ge._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,ge._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,ge.def=Ke(ge.def).replace("label",ge._label).replace("title",ge._title).getRegex(),ge.bullet=/(?:[*+-]|\d{1,9}[.)])/,ge.listItemStart=Ke(/^( *)(bull) */).replace("bull",ge.bullet).getRegex(),ge.list=Ke(ge.list).replace(/bull/g,ge.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ge.def.source+")").getRegex(),ge._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",ge._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,ge.html=Ke(ge.html,"i").replace("comment",ge._comment).replace("tag",ge._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ge.paragraph=Ke(ge._paragraph).replace("hr",ge.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",ge._tag).getRegex(),ge.blockquote=Ke(ge.blockquote).replace("paragraph",ge.paragraph).getRegex(),ge.normal={...ge},ge.gfm={...ge.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},ge.gfm.table=Ke(ge.gfm.table).replace("hr",ge.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",ge._tag).getRegex(),ge.gfm.paragraph=Ke(ge._paragraph).replace("hr",ge.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",ge.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",ge._tag).getRegex(),ge.pedantic={...ge.normal,html:Ke(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ge._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:Ao,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ke(ge.normal._paragraph).replace("hr",ge.hr).replace("heading",` *#{1,6} *[^
|
|
51
|
+
]`).replace("lheading",ge.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ce={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ao,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:Ao,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};ce._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",ce.punctuation=Ke(ce.punctuation).replace(/punctuation/g,ce._punctuation).getRegex(),ce.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,ce.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,ce._comment=Ke(ge._comment).replace("(?:-->|$)","-->").getRegex(),ce.emStrong.lDelim=Ke(ce.emStrong.lDelim).replace(/punct/g,ce._punctuation).getRegex(),ce.emStrong.rDelimAst=Ke(ce.emStrong.rDelimAst,"g").replace(/punct/g,ce._punctuation).getRegex(),ce.emStrong.rDelimUnd=Ke(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=Ke(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=Ke(ce.tag).replace("comment",ce._comment).replace("attribute",ce._attribute).getRegex(),ce._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ce._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,ce._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ce.link=Ke(ce.link).replace("label",ce._label).replace("href",ce._href).replace("title",ce._title).getRegex(),ce.reflink=Ke(ce.reflink).replace("label",ce._label).replace("ref",ge._label).getRegex(),ce.nolink=Ke(ce.nolink).replace("ref",ge._label).getRegex(),ce.reflinkSearch=Ke(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:Ke(/^!?\[(label)\]\((.*?)\)/).replace("label",ce._label).getRegex(),reflink:Ke(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ce._label).getRegex()},ce.gfm={...ce.normal,escape:Ke(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=Ke(ce.gfm.url,"i").replace("email",ce.gfm._extended_email).getRegex(),ce.breaks={...ce.gfm,br:Ke(ce.br).replace("{2,}","*").getRegex(),text:Ke(ce.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function Pb(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 ou(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 yn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Ln,this.options.tokenizer=this.options.tokenizer||new Ti,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:ge.normal,inline:ce.normal};this.options.pedantic?(n.block=ge.pedantic,n.inline=ce.pedantic):this.options.gfm&&(n.block=ge.gfm,this.options.breaks?n.inline=ce.breaks:n.inline=ce.gfm),this.tokenizer.rules=n}static get rules(){return{block:ge,inline:ce}}static lex(t,n){return new yn(n).lex(t)}static lexInline(t,n){return new yn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
|
|
52
52
|
`),this.blockTokens(t,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(t,n=[]){this.options.pedantic?t=t.replace(/\t/g," ").replace(/^ +$/gm,""):t=t.replace(/^( *)(\t+)/gm,(a,c,u)=>c+" ".repeat(u.length));let r,o,s,i;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(r=a.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=`
|
|
53
53
|
`:n.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&(o.type==="paragraph"||o.type==="text")?(o.raw+=`
|
|
54
54
|
`+r.raw,o.text+=`
|
|
@@ -58,7 +58,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
58
58
|
`+r.raw,o.text+=`
|
|
59
59
|
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r),i=s.length!==t.length,t=t.substring(r.raw.length);continue}if(r=this.tokenizer.text(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&o.type==="text"?(o.raw+=`
|
|
60
60
|
`+r.raw,o.text+=`
|
|
61
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,c,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)+"["+
|
|
61
|
+
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,c,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)+"["+nu("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)+"["+nu("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(c||(u=""),c=!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,ou)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,ou))){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 p;this.options.extensions.startInline.forEach(function(m){p=m.call({lexer:this},f),typeof p=="number"&&p>=0&&(d=Math.min(d,p))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,Pb)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(u=r.raw.slice(-1)),c=!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 ki{constructor(t){this.options=t||Ln}code(t,n,r){const o=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(t,o);s!=null&&s!==t&&(r=!0,t=s)}return t=t.replace(/\n$/,"")+`
|
|
62
62
|
`,o?'<pre><code class="'+this.options.langPrefix+gt(o)+'">'+(r?t:gt(t,!0))+`</code></pre>
|
|
63
63
|
`:"<pre><code>"+(r?t:gt(t,!0))+`</code></pre>
|
|
64
64
|
`}blockquote(t){return`<blockquote>
|
|
@@ -78,10 +78,10 @@ ${t}</blockquote>
|
|
|
78
78
|
`}tablerow(t){return`<tr>
|
|
79
79
|
${t}</tr>
|
|
80
80
|
`}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
|
|
81
|
-
`}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=
|
|
82
|
-
`+(m.tokens?this.parseInline(m.tokens):m.text);r+=n?this.renderer.paragraph(p):p;continue}default:{const N='Token with "'+m.type+'" type was not found.';if(this.options.silent){console.error(N);return}else throw new Error(N)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const c='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(c);return}else throw new Error(c)}}}return r}}class _o{constructor(t){this.options=t||Ln}preprocess(t){return t}postprocess(t){return t}}
|
|
83
|
-
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+gt(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 iu(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...xe.defaults,...s};const i=Pb(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(Ab(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let c;try{r.hooks&&(n=r.hooks.preprocess(n)),c=e(n,r)}catch(f){return i(f)}const u=function(f){let p;if(!f)try{r.walkTokens&&xe.walkTokens(c,r.walkTokens),p=t(c,r),r.hooks&&(p=r.hooks.postprocess(p))}catch(m){f=m}return r.highlight=a,f?i(f):o(null,p)};if(!a||a.length<3||(delete r.highlight,!c.length))return u();let d=0;xe.walkTokens(c,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(p,m){if(p)return u(p);m!=null&&m!==f.text&&(f.text=m,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(xe.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&xe.walkTokens(a,r.walkTokens);let c=t(a,r);return r.hooks&&(c=r.hooks.postprocess(c)),c}catch(a){return i(a)}}}function xe(e,t,n){return iu(yn.lex,Sn.parse)(e,t,n)}xe.options=xe.setOptions=function(e){return xe.defaults={...xe.defaults,...e},xb(xe.defaults),xe},xe.getDefaults=Gc,xe.defaults=Ln,xe.use=function(...e){const t=xe.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=xe.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=xe.defaults.renderer||new ki;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let c=n.renderer[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.renderer=o}if(n.tokenizer){const o=xe.defaults.tokenizer||new Ti;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let c=n.tokenizer[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.tokenizer=o}if(n.hooks){const o=xe.defaults.hooks||new _o;for(const s in n.hooks){const i=o[s];_o.passThroughHooks.has(s)?o[s]=a=>{if(xe.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(u=>i.call(o,u));const c=n.hooks[s].call(o,a);return i.call(o,c)}:o[s]=(...a)=>{let c=n.hooks[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.hooks=o}if(n.walkTokens){const o=xe.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}xe.setOptions(r)})},xe.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(xe,r)),r.type){case"table":{for(const o of r.header)n=n.concat(xe.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(xe.walkTokens(s.tokens,t));break}case"list":{n=n.concat(xe.walkTokens(r.items,t));break}default:xe.defaults.extensions&&xe.defaults.extensions.childTokens&&xe.defaults.extensions.childTokens[r.type]?xe.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(xe.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(xe.walkTokens(r.tokens,t)))}return n},xe.parseInline=iu(yn.lexInline,Sn.parseInline),xe.Parser=Sn,xe.parser=Sn.parse,xe.Renderer=ki,xe.TextRenderer=ou,xe.Lexer=yn,xe.lexer=yn.lex,xe.Tokenizer=Ti,xe.Slugger=su,xe.Hooks=_o,xe.parse=xe,xe.options,xe.setOptions,xe.use,xe.walkTokens,xe.parseInline,Sn.parse,yn.lex;function Po({content:e,className:t="",allowHtml:n=!1}){const r=C.useMemo(()=>{try{if(!n){const o=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return xe.parse(o)}return xe.parse(e)}catch(o){return console.error("[MarkdownContent] parse error",o),`<pre>Error rendering markdown: ${String(o)}</pre>`}},[e,n]);return l.jsx("div",{className:L("markdown prose max-w-none break-words dark:prose-invert",t),dangerouslySetInnerHTML:{__html:r}})}async function au(e,t){return await It(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function lu(e,t){return await(await au(`/chat/files/${e}/view`,t)).text()}async function Ob(e,t){const n=await au(`/chat/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await It(`/chat/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 Mb(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await It("/chat/files",{params:r})}const Db=1,Lb=1e6;let Ei=0;function $b(){return Ei=(Ei+1)%Number.MAX_SAFE_INTEGER,Ei.toString()}const Ii=new Map,cu=e=>{if(Ii.has(e))return;const t=setTimeout(()=>{Ii.delete(e),Or({type:"REMOVE_TOAST",toastId:e})},Lb);Ii.set(e,t)},Fb=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Db)};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?cu(n):e.toasts.forEach(r=>{cu(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)}}},Oo=[];let Mo={toasts:[]};function Or(e){Mo=Fb(Mo,e),Oo.forEach(t=>{t(Mo)})}function zb({...e}){const t=$b(),n=o=>Or({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Or({type:"DISMISS_TOAST",toastId:t});return Or({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Ni(){const[e,t]=h.useState(Mo);return h.useEffect(()=>(Oo.push(t),()=>{const n=Oo.indexOf(t);n>-1&&Oo.splice(n,1)}),[e]),{...e,toast:zb,dismiss:n=>Or({type:"DISMISS_TOAST",toastId:n})}}function dt(e){const t=h.useRef(e);return h.useEffect(()=>{t.current=e}),h.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Bb(e,t=globalThis==null?void 0:globalThis.document){const n=dt(e);h.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 Hb="DismissableLayer",ji="dismissableLayer.update",Ub="dismissableLayer.pointerDownOutside",Wb="dismissableLayer.focusOutside",uu,du=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Mr=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...c}=e,u=h.useContext(du),[d,f]=h.useState(null),p=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=h.useState({}),w=Re(t,I=>f(I)),b=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=b.indexOf(g),v=d?b.indexOf(d):-1,y=u.layersWithOutsidePointerEventsDisabled.size>0,E=v>=x,S=qb(I=>{const N=I.target,j=[...u.branches].some(O=>O.contains(N));!E||j||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},p),T=Gb(I=>{const N=I.target;[...u.branches].some(O=>O.contains(N))||(s==null||s(I),i==null||i(I),I.defaultPrevented||a==null||a())},p);return Bb(I=>{v===u.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},p),h.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(uu=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),fu(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=uu)}},[d,p,n,u]),h.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),fu())},[d,u]),h.useEffect(()=>{const I=()=>m({});return document.addEventListener(ji,I),()=>document.removeEventListener(ji,I)},[]),l.jsx(Se.div,{...c,ref:w,style:{pointerEvents:y?E?"auto":"none":void 0,...e.style},onFocusCapture:te(e.onFocusCapture,T.onFocusCapture),onBlurCapture:te(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:te(e.onPointerDownCapture,S.onPointerDownCapture)})});Mr.displayName=Hb;var Vb="DismissableLayerBranch",Kb=h.forwardRef((e,t)=>{const n=h.useContext(du),r=h.useRef(null),o=Re(t,r);return h.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),l.jsx(Se.div,{...e,ref:o})});Kb.displayName=Vb;function qb(e,t=globalThis==null?void 0:globalThis.document){const n=dt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let c=function(){hu(Ub,n,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}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 Gb(e,t=globalThis==null?void 0:globalThis.document){const n=dt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&hu(Wb,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 fu(){const e=new CustomEvent(ji);document.dispatchEvent(e)}function hu(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Hc(o,s):o.dispatchEvent(s)}var Ai="focusScope.autoFocusOnMount",Ri="focusScope.autoFocusOnUnmount",pu={bubbles:!1,cancelable:!0},Yb="FocusScope",Do=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,c]=h.useState(null),u=dt(o),d=dt(s),f=h.useRef(null),p=Re(t,b=>c(b)),m=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let b=function(y){if(m.paused||!a)return;const E=y.target;a.contains(E)?f.current=E:Cn(f.current,{select:!0})},g=function(y){if(m.paused||!a)return;const E=y.relatedTarget;E!==null&&(a.contains(E)||Cn(f.current,{select:!0}))},x=function(y){if(document.activeElement===document.body)for(const S of y)S.removedNodes.length>0&&Cn(a)};document.addEventListener("focusin",b),document.addEventListener("focusout",g);const v=new MutationObserver(x);return a&&v.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",g),v.disconnect()}}},[r,a,m.paused]),h.useEffect(()=>{if(a){xu.add(m);const b=document.activeElement;if(!a.contains(b)){const x=new CustomEvent(Ai,pu);a.addEventListener(Ai,u),a.dispatchEvent(x),x.defaultPrevented||(Xb(tv(mu(a)),{select:!0}),document.activeElement===b&&Cn(a))}return()=>{a.removeEventListener(Ai,u),setTimeout(()=>{const x=new CustomEvent(Ri,pu);a.addEventListener(Ri,d),a.dispatchEvent(x),x.defaultPrevented||Cn(b??document.body,{select:!0}),a.removeEventListener(Ri,d),xu.remove(m)},0)}}},[a,u,d,m]);const w=h.useCallback(b=>{if(!n&&!r||m.paused)return;const g=b.key==="Tab"&&!b.altKey&&!b.ctrlKey&&!b.metaKey,x=document.activeElement;if(g&&x){const v=b.currentTarget,[y,E]=Jb(v);y&&E?!b.shiftKey&&x===E?(b.preventDefault(),n&&Cn(y,{select:!0})):b.shiftKey&&x===y&&(b.preventDefault(),n&&Cn(E,{select:!0})):x===v&&b.preventDefault()}},[n,r,m.paused]);return l.jsx(Se.div,{tabIndex:-1,...i,ref:p,onKeyDown:w})});Do.displayName=Yb;function Xb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Cn(r,{select:t}),document.activeElement!==n)return}function Jb(e){const t=mu(e),n=gu(t,e),r=gu(t.reverse(),e);return[n,r]}function mu(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 gu(e,t){for(const n of e)if(!Zb(n,{upTo:t}))return n}function Zb(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 Qb(e){return e instanceof HTMLInputElement&&"select"in e}function Cn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Qb(e)&&t&&e.select()}}var xu=ev();function ev(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=bu(e,t),e.unshift(t)},remove(t){var n;e=bu(e,t),(n=e[0])==null||n.resume()}}}function bu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function tv(e){return e.filter(t=>t.tagName!=="A")}var nv="Portal",Lo=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);lt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Ps.createPortal(l.jsx(Se.div,{...r,ref:t}),i):null});Lo.displayName=nv;var _i=0;function Pi(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??vu()),document.body.insertAdjacentElement("beforeend",e[1]??vu()),_i++,()=>{_i===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),_i--}},[])}function vu(){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 tn=function(){return tn=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},tn.apply(this,arguments)};function wu(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 rv(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 $o="right-scroll-bar-position",Fo="width-before-scroll-bar",ov="with-scroll-bars-hidden",sv="--removed-body-scroll-bar-size";function Oi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function iv(e,t){var n=C.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 av=typeof window<"u"?h.useLayoutEffect:h.useEffect,yu=new WeakMap;function lv(e,t){var n=iv(null,function(r){return e.forEach(function(o){return Oi(o,r)})});return av(function(){var r=yu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Oi(a,null)}),s.forEach(function(a){o.has(a)||Oi(a,i)})}yu.set(n,e)},[e]),n}function cv(e){return e}function uv(e,t){t===void 0&&(t=cv);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 c=function(){var d=i;i=[],d.forEach(s)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return o}function dv(e){e===void 0&&(e={});var t=uv(null);return t.options=tn({async:!0,ssr:!1},e),t}var Su=function(e){var t=e.sideCar,n=wu(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 h.createElement(r,tn({},n))};Su.isSideCarExport=!0;function fv(e,t){return e.useMedium(t),Su}var Cu=dv(),Mi=function(){},zo=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:Mi,onWheelCapture:Mi,onTouchMoveCapture:Mi}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,c=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,w=e.noIsolation,b=e.inert,g=e.allowPinchZoom,x=e.as,v=x===void 0?"div":x,y=e.gapMode,E=wu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=p,T=lv([n,t]),I=tn(tn({},E),o);return h.createElement(h.Fragment,null,d&&h.createElement(S,{sideCar:Cu,removeScrollBar:u,shards:f,noRelative:m,noIsolation:w,inert:b,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:y}),i?h.cloneElement(h.Children.only(a),tn(tn({},I),{ref:T})):h.createElement(v,tn({},I,{className:c,ref:T}),a))});zo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},zo.classNames={fullWidth:Fo,zeroRight:$o};var hv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function pv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=hv();return t&&e.setAttribute("nonce",t),e}function mv(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function gv(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var xv=function(){var e=0,t=null;return{add:function(n){e==0&&(t=pv())&&(mv(t,n),gv(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},bv=function(){var e=xv();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Tu=function(){var e=bv(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},vv={left:0,top:0,right:0,gap:0},Di=function(e){return parseInt(e||"",10)||0},wv=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[Di(n),Di(r),Di(o)]},yv=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return vv;var t=wv(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])}},Sv=Tu(),tr="data-scroll-locked",Cv=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
84
|
-
.`.concat(
|
|
81
|
+
`}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=eu(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=eu(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 su{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 iu{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 Sn{constructor(t){this.options=t||Ln,this.options.renderer=this.options.renderer||new ki,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new su,this.slugger=new iu}static parse(t,n){return new Sn(n).parse(t)}static parseInline(t,n){return new Sn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,c,u,d,f,p,m,w,b,g,x,v,y,E,S,T;const I=t.length;for(o=0;o<I;o++){if(m=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[m.type]&&(T=this.options.extensions.renderers[m.type].call({parser:this},m),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(m.type))){r+=T||"";continue}switch(m.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(m.tokens),m.depth,Qc(this.parseInline(m.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(m.text,m.lang,m.escaped);continue}case"table":{for(f="",d="",a=m.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(m.header[s].tokens),{header:!0,align:m.align[s]});for(f+=this.renderer.tablerow(d),p="",a=m.rows.length,s=0;s<a;s++){for(u=m.rows[s],d="",c=u.length,i=0;i<c;i++)d+=this.renderer.tablecell(this.parseInline(u[i].tokens),{header:!1,align:m.align[i]});p+=this.renderer.tablerow(d)}r+=this.renderer.table(f,p);continue}case"blockquote":{p=this.parse(m.tokens),r+=this.renderer.blockquote(p);continue}case"list":{for(w=m.ordered,b=m.start,g=m.loose,a=m.items.length,p="",s=0;s<a;s++)v=m.items[s],y=v.checked,E=v.task,x="",v.task&&(S=this.renderer.checkbox(y),g?v.tokens.length>0&&v.tokens[0].type==="paragraph"?(v.tokens[0].text=S+" "+v.tokens[0].text,v.tokens[0].tokens&&v.tokens[0].tokens.length>0&&v.tokens[0].tokens[0].type==="text"&&(v.tokens[0].tokens[0].text=S+" "+v.tokens[0].tokens[0].text)):v.tokens.unshift({type:"text",text:S}):x+=S),x+=this.parse(v.tokens,g),p+=this.renderer.listitem(x,E,y);r+=this.renderer.list(p,w,b);continue}case"html":{r+=this.renderer.html(m.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(m.tokens));continue}case"text":{for(p=m.tokens?this.parseInline(m.tokens):m.text;o+1<I&&t[o+1].type==="text";)m=t[++o],p+=`
|
|
82
|
+
`+(m.tokens?this.parseInline(m.tokens):m.text);r+=n?this.renderer.paragraph(p):p;continue}default:{const N='Token with "'+m.type+'" type was not found.';if(this.options.silent){console.error(N);return}else throw new Error(N)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const c='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(c);return}else throw new Error(c)}}}return r}}class _o{constructor(t){this.options=t||Ln}preprocess(t){return t}postprocess(t){return t}}Hp(_o,"passThroughHooks",new Set(["preprocess","postprocess"]));function Ob(e,t,n){return r=>{if(r.message+=`
|
|
83
|
+
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+gt(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 au(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...xe.defaults,...s};const i=Ob(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(Rb(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let c;try{r.hooks&&(n=r.hooks.preprocess(n)),c=e(n,r)}catch(f){return i(f)}const u=function(f){let p;if(!f)try{r.walkTokens&&xe.walkTokens(c,r.walkTokens),p=t(c,r),r.hooks&&(p=r.hooks.postprocess(p))}catch(m){f=m}return r.highlight=a,f?i(f):o(null,p)};if(!a||a.length<3||(delete r.highlight,!c.length))return u();let d=0;xe.walkTokens(c,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(p,m){if(p)return u(p);m!=null&&m!==f.text&&(f.text=m,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(xe.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&xe.walkTokens(a,r.walkTokens);let c=t(a,r);return r.hooks&&(c=r.hooks.postprocess(c)),c}catch(a){return i(a)}}}function xe(e,t,n){return au(yn.lex,Sn.parse)(e,t,n)}xe.options=xe.setOptions=function(e){return xe.defaults={...xe.defaults,...e},bb(xe.defaults),xe},xe.getDefaults=Yc,xe.defaults=Ln,xe.use=function(...e){const t=xe.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=xe.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=xe.defaults.renderer||new ki;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let c=n.renderer[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.renderer=o}if(n.tokenizer){const o=xe.defaults.tokenizer||new Ti;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let c=n.tokenizer[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.tokenizer=o}if(n.hooks){const o=xe.defaults.hooks||new _o;for(const s in n.hooks){const i=o[s];_o.passThroughHooks.has(s)?o[s]=a=>{if(xe.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(u=>i.call(o,u));const c=n.hooks[s].call(o,a);return i.call(o,c)}:o[s]=(...a)=>{let c=n.hooks[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.hooks=o}if(n.walkTokens){const o=xe.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}xe.setOptions(r)})},xe.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(xe,r)),r.type){case"table":{for(const o of r.header)n=n.concat(xe.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(xe.walkTokens(s.tokens,t));break}case"list":{n=n.concat(xe.walkTokens(r.items,t));break}default:xe.defaults.extensions&&xe.defaults.extensions.childTokens&&xe.defaults.extensions.childTokens[r.type]?xe.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(xe.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(xe.walkTokens(r.tokens,t)))}return n},xe.parseInline=au(yn.lexInline,Sn.parseInline),xe.Parser=Sn,xe.parser=Sn.parse,xe.Renderer=ki,xe.TextRenderer=su,xe.Lexer=yn,xe.lexer=yn.lex,xe.Tokenizer=Ti,xe.Slugger=iu,xe.Hooks=_o,xe.parse=xe,xe.options,xe.setOptions,xe.use,xe.walkTokens,xe.parseInline,Sn.parse,yn.lex;function Po({content:e,className:t="",allowHtml:n=!1}){const r=C.useMemo(()=>{try{if(!n){const o=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return xe.parse(o)}return xe.parse(e)}catch(o){return console.error("[MarkdownContent] parse error",o),`<pre>Error rendering markdown: ${String(o)}</pre>`}},[e,n]);return l.jsx("div",{className:L("markdown prose max-w-none break-words dark:prose-invert",t),dangerouslySetInnerHTML:{__html:r}})}async function lu(e,t){return await It(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function cu(e,t){return await(await lu(`/chat/files/${e}/view`,t)).text()}async function Mb(e,t){const n=await lu(`/chat/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await It(`/chat/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 Db(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await It("/chat/files",{params:r})}const Lb=1,$b=1e6;let Ei=0;function Fb(){return Ei=(Ei+1)%Number.MAX_SAFE_INTEGER,Ei.toString()}const Ii=new Map,uu=e=>{if(Ii.has(e))return;const t=setTimeout(()=>{Ii.delete(e),Or({type:"REMOVE_TOAST",toastId:e})},$b);Ii.set(e,t)},zb=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Lb)};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?uu(n):e.toasts.forEach(r=>{uu(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)}}},Oo=[];let Mo={toasts:[]};function Or(e){Mo=zb(Mo,e),Oo.forEach(t=>{t(Mo)})}function Bb({...e}){const t=Fb(),n=o=>Or({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Or({type:"DISMISS_TOAST",toastId:t});return Or({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Ni(){const[e,t]=h.useState(Mo);return h.useEffect(()=>(Oo.push(t),()=>{const n=Oo.indexOf(t);n>-1&&Oo.splice(n,1)}),[e]),{...e,toast:Bb,dismiss:n=>Or({type:"DISMISS_TOAST",toastId:n})}}function dt(e){const t=h.useRef(e);return h.useEffect(()=>{t.current=e}),h.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Hb(e,t=globalThis==null?void 0:globalThis.document){const n=dt(e);h.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 Ub="DismissableLayer",ji="dismissableLayer.update",Wb="dismissableLayer.pointerDownOutside",Vb="dismissableLayer.focusOutside",du,fu=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Mr=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...c}=e,u=h.useContext(fu),[d,f]=h.useState(null),p=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=h.useState({}),w=Re(t,I=>f(I)),b=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=b.indexOf(g),v=d?b.indexOf(d):-1,y=u.layersWithOutsidePointerEventsDisabled.size>0,E=v>=x,S=Gb(I=>{const N=I.target,j=[...u.branches].some(O=>O.contains(N));!E||j||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},p),T=Yb(I=>{const N=I.target;[...u.branches].some(O=>O.contains(N))||(s==null||s(I),i==null||i(I),I.defaultPrevented||a==null||a())},p);return Hb(I=>{v===u.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},p),h.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(du=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),hu(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=du)}},[d,p,n,u]),h.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),hu())},[d,u]),h.useEffect(()=>{const I=()=>m({});return document.addEventListener(ji,I),()=>document.removeEventListener(ji,I)},[]),l.jsx(Se.div,{...c,ref:w,style:{pointerEvents:y?E?"auto":"none":void 0,...e.style},onFocusCapture:te(e.onFocusCapture,T.onFocusCapture),onBlurCapture:te(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:te(e.onPointerDownCapture,S.onPointerDownCapture)})});Mr.displayName=Ub;var Kb="DismissableLayerBranch",qb=h.forwardRef((e,t)=>{const n=h.useContext(fu),r=h.useRef(null),o=Re(t,r);return h.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),l.jsx(Se.div,{...e,ref:o})});qb.displayName=Kb;function Gb(e,t=globalThis==null?void 0:globalThis.document){const n=dt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let c=function(){pu(Wb,n,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}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 Yb(e,t=globalThis==null?void 0:globalThis.document){const n=dt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&pu(Vb,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 hu(){const e=new CustomEvent(ji);document.dispatchEvent(e)}function pu(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?Uc(o,s):o.dispatchEvent(s)}var Ai="focusScope.autoFocusOnMount",Ri="focusScope.autoFocusOnUnmount",mu={bubbles:!1,cancelable:!0},Xb="FocusScope",Do=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,c]=h.useState(null),u=dt(o),d=dt(s),f=h.useRef(null),p=Re(t,b=>c(b)),m=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let b=function(y){if(m.paused||!a)return;const E=y.target;a.contains(E)?f.current=E:Cn(f.current,{select:!0})},g=function(y){if(m.paused||!a)return;const E=y.relatedTarget;E!==null&&(a.contains(E)||Cn(f.current,{select:!0}))},x=function(y){if(document.activeElement===document.body)for(const S of y)S.removedNodes.length>0&&Cn(a)};document.addEventListener("focusin",b),document.addEventListener("focusout",g);const v=new MutationObserver(x);return a&&v.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",g),v.disconnect()}}},[r,a,m.paused]),h.useEffect(()=>{if(a){bu.add(m);const b=document.activeElement;if(!a.contains(b)){const x=new CustomEvent(Ai,mu);a.addEventListener(Ai,u),a.dispatchEvent(x),x.defaultPrevented||(Jb(nv(gu(a)),{select:!0}),document.activeElement===b&&Cn(a))}return()=>{a.removeEventListener(Ai,u),setTimeout(()=>{const x=new CustomEvent(Ri,mu);a.addEventListener(Ri,d),a.dispatchEvent(x),x.defaultPrevented||Cn(b??document.body,{select:!0}),a.removeEventListener(Ri,d),bu.remove(m)},0)}}},[a,u,d,m]);const w=h.useCallback(b=>{if(!n&&!r||m.paused)return;const g=b.key==="Tab"&&!b.altKey&&!b.ctrlKey&&!b.metaKey,x=document.activeElement;if(g&&x){const v=b.currentTarget,[y,E]=Zb(v);y&&E?!b.shiftKey&&x===E?(b.preventDefault(),n&&Cn(y,{select:!0})):b.shiftKey&&x===y&&(b.preventDefault(),n&&Cn(E,{select:!0})):x===v&&b.preventDefault()}},[n,r,m.paused]);return l.jsx(Se.div,{tabIndex:-1,...i,ref:p,onKeyDown:w})});Do.displayName=Xb;function Jb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Cn(r,{select:t}),document.activeElement!==n)return}function Zb(e){const t=gu(e),n=xu(t,e),r=xu(t.reverse(),e);return[n,r]}function gu(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 xu(e,t){for(const n of e)if(!Qb(n,{upTo:t}))return n}function Qb(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 ev(e){return e instanceof HTMLInputElement&&"select"in e}function Cn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&ev(e)&&t&&e.select()}}var bu=tv();function tv(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=vu(e,t),e.unshift(t)},remove(t){var n;e=vu(e,t),(n=e[0])==null||n.resume()}}}function vu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function nv(e){return e.filter(t=>t.tagName!=="A")}var rv="Portal",Lo=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);lt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Ps.createPortal(l.jsx(Se.div,{...r,ref:t}),i):null});Lo.displayName=rv;var _i=0;function Pi(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??wu()),document.body.insertAdjacentElement("beforeend",e[1]??wu()),_i++,()=>{_i===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),_i--}},[])}function wu(){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 tn=function(){return tn=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},tn.apply(this,arguments)};function yu(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function ov(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 $o="right-scroll-bar-position",Fo="width-before-scroll-bar",sv="with-scroll-bars-hidden",iv="--removed-body-scroll-bar-size";function Oi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function av(e,t){var n=C.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 lv=typeof window<"u"?h.useLayoutEffect:h.useEffect,Su=new WeakMap;function cv(e,t){var n=av(null,function(r){return e.forEach(function(o){return Oi(o,r)})});return lv(function(){var r=Su.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Oi(a,null)}),s.forEach(function(a){o.has(a)||Oi(a,i)})}Su.set(n,e)},[e]),n}function uv(e){return e}function dv(e,t){t===void 0&&(t=uv);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 c=function(){var d=i;i=[],d.forEach(s)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return o}function fv(e){e===void 0&&(e={});var t=dv(null);return t.options=tn({async:!0,ssr:!1},e),t}var Cu=function(e){var t=e.sideCar,n=yu(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return h.createElement(r,tn({},n))};Cu.isSideCarExport=!0;function hv(e,t){return e.useMedium(t),Cu}var Tu=fv(),Mi=function(){},zo=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:Mi,onWheelCapture:Mi,onTouchMoveCapture:Mi}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,c=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,w=e.noIsolation,b=e.inert,g=e.allowPinchZoom,x=e.as,v=x===void 0?"div":x,y=e.gapMode,E=yu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=p,T=cv([n,t]),I=tn(tn({},E),o);return h.createElement(h.Fragment,null,d&&h.createElement(S,{sideCar:Tu,removeScrollBar:u,shards:f,noRelative:m,noIsolation:w,inert:b,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:y}),i?h.cloneElement(h.Children.only(a),tn(tn({},I),{ref:T})):h.createElement(v,tn({},I,{className:c,ref:T}),a))});zo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},zo.classNames={fullWidth:Fo,zeroRight:$o};var pv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function mv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=pv();return t&&e.setAttribute("nonce",t),e}function gv(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function xv(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var bv=function(){var e=0,t=null;return{add:function(n){e==0&&(t=mv())&&(gv(t,n),xv(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},vv=function(){var e=bv();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},ku=function(){var e=vv(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},wv={left:0,top:0,right:0,gap:0},Di=function(e){return parseInt(e||"",10)||0},yv=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[Di(n),Di(r),Di(o)]},Sv=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return wv;var t=yv(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])}},Cv=ku(),tr="data-scroll-locked",Tv=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
84
|
+
.`.concat(sv,` {
|
|
85
85
|
overflow: hidden `).concat(r,`;
|
|
86
86
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
87
87
|
}
|
|
@@ -115,19 +115,19 @@ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An err
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
body[`).concat(tr,`] {
|
|
118
|
-
`).concat(
|
|
118
|
+
`).concat(iv,": ").concat(a,`px;
|
|
119
119
|
}
|
|
120
|
-
`)},
|
|
120
|
+
`)},Eu=function(){var e=parseInt(document.body.getAttribute(tr)||"0",10);return isFinite(e)?e:0},kv=function(){h.useEffect(function(){return document.body.setAttribute(tr,(Eu()+1).toString()),function(){var e=Eu()-1;e<=0?document.body.removeAttribute(tr):document.body.setAttribute(tr,e.toString())}},[])},Ev=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;kv();var s=h.useMemo(function(){return Sv(o)},[o]);return h.createElement(Cv,{styles:Tv(s,!t,o,n?"":"!important")})},Li=!1;if(typeof window<"u")try{var Bo=Object.defineProperty({},"passive",{get:function(){return Li=!0,!0}});window.addEventListener("test",Bo,Bo),window.removeEventListener("test",Bo,Bo)}catch{Li=!1}var nr=Li?{passive:!1}:!1,Iv=function(e){return e.tagName==="TEXTAREA"},Iu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Iv(e)&&n[t]==="visible")},Nv=function(e){return Iu(e,"overflowY")},jv=function(e){return Iu(e,"overflowX")},Nu=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=ju(e,r);if(o){var s=Au(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Av=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Rv=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},ju=function(e,t){return e==="v"?Nv(t):jv(t)},Au=function(e,t){return e==="v"?Av(t):Rv(t)},_v=function(e,t){return e==="h"&&t==="rtl"?-1:1},Pv=function(e,t,n,r,o){var s=_v(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,c=t.contains(a),u=!1,d=i>0,f=0,p=0;do{if(!a)break;var m=Au(e,a),w=m[0],b=m[1],g=m[2],x=b-g-s*w;(w||x)&&ju(e,a)&&(f+=x,p+=w);var v=a.parentNode;a=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!c&&a!==document.body||c&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(p)<1)&&(u=!0),u},Ho=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Ru=function(e){return[e.deltaX,e.deltaY]},_u=function(e){return e&&"current"in e?e.current:e},Ov=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Mv=function(e){return`
|
|
121
121
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
122
122
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
123
|
-
`)},
|
|
123
|
+
`)},Dv=0,rr=[];function Lv(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(Dv++)[0],s=h.useState(ku)[0],i=h.useRef(e);h.useEffect(function(){i.current=e},[e]),h.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var b=ov([e.lockRef.current],(e.shards||[]).map(_u),!0).filter(Boolean);return b.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),b.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=h.useCallback(function(b,g){if("touches"in b&&b.touches.length===2||b.type==="wheel"&&b.ctrlKey)return!i.current.allowPinchZoom;var x=Ho(b),v=n.current,y="deltaX"in b?b.deltaX:v[0]-x[0],E="deltaY"in b?b.deltaY:v[1]-x[1],S,T=b.target,I=Math.abs(y)>Math.abs(E)?"h":"v";if("touches"in b&&I==="h"&&T.type==="range")return!1;var N=Nu(I,T);if(!N)return!0;if(N?S=I:(S=I==="v"?"h":"v",N=Nu(I,T)),!N)return!1;if(!r.current&&"changedTouches"in b&&(y||E)&&(r.current=S),!S)return!0;var j=r.current||S;return Pv(j,g,b,j==="h"?y:E)},[]),c=h.useCallback(function(b){var g=b;if(!(!rr.length||rr[rr.length-1]!==s)){var x="deltaY"in g?Ru(g):Ho(g),v=t.current.filter(function(S){return S.name===g.type&&(S.target===g.target||g.target===S.shadowParent)&&Ov(S.delta,x)})[0];if(v&&v.should){g.cancelable&&g.preventDefault();return}if(!v){var y=(i.current.shards||[]).map(_u).filter(Boolean).filter(function(S){return S.contains(g.target)}),E=y.length>0?a(g,y[0]):!i.current.noIsolation;E&&g.cancelable&&g.preventDefault()}}},[]),u=h.useCallback(function(b,g,x,v){var y={name:b,delta:g,target:x,should:v,shadowParent:$v(x)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(E){return E!==y})},1)},[]),d=h.useCallback(function(b){n.current=Ho(b),r.current=void 0},[]),f=h.useCallback(function(b){u(b.type,Ru(b),b.target,a(b,e.lockRef.current))},[]),p=h.useCallback(function(b){u(b.type,Ho(b),b.target,a(b,e.lockRef.current))},[]);h.useEffect(function(){return rr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",c,nr),document.addEventListener("touchmove",c,nr),document.addEventListener("touchstart",d,nr),function(){rr=rr.filter(function(b){return b!==s}),document.removeEventListener("wheel",c,nr),document.removeEventListener("touchmove",c,nr),document.removeEventListener("touchstart",d,nr)}},[]);var m=e.removeScrollBar,w=e.inert;return h.createElement(h.Fragment,null,w?h.createElement(s,{styles:Mv(o)}):null,m?h.createElement(Ev,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function $v(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Fv=hv(Tu,Lv);var Uo=h.forwardRef(function(e,t){return h.createElement(zo,tn({},e,{ref:t,sideCar:Fv}))});Uo.classNames=zo.classNames;var zv=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},or=new WeakMap,Wo=new WeakMap,Vo={},$i=0,Pu=function(e){return e&&(e.host||Pu(e.parentNode))},Bv=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Pu(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})},Hv=function(e,t,n,r){var o=Bv(t,Array.isArray(e)?e:[e]);Vo[n]||(Vo[n]=new WeakMap);var s=Vo[n],i=[],a=new Set,c=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var d=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(p){if(a.has(p))d(p);else try{var m=p.getAttribute(r),w=m!==null&&m!=="false",b=(or.get(p)||0)+1,g=(s.get(p)||0)+1;or.set(p,b),s.set(p,g),i.push(p),b===1&&w&&Wo.set(p,!0),g===1&&p.setAttribute(n,"true"),w||p.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",p,x)}})};return d(t),a.clear(),$i++,function(){i.forEach(function(f){var p=or.get(f)-1,m=s.get(f)-1;or.set(f,p),s.set(f,m),p||(Wo.has(f)||f.removeAttribute(r),Wo.delete(f)),m||f.removeAttribute(n)}),$i--,$i||(or=new WeakMap,or=new WeakMap,Wo=new WeakMap,Vo={})}},Fi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=zv(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Hv(r,o,n,"aria-hidden")):function(){return null}},Ko="Dialog",[Ou,XT]=Vt(Ko),[Uv,qt]=Ou(Ko),Mu=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=h.useRef(null),c=h.useRef(null),[u,d]=wn({prop:r,defaultProp:o??!1,onChange:s,caller:Ko});return l.jsx(Uv,{scope:t,triggerRef:a,contentRef:c,contentId:Kt(),titleId:Kt(),descriptionId:Kt(),open:u,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Mu.displayName=Ko;var Du="DialogTrigger",Lu=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=qt(Du,n),s=Re(t,o.triggerRef);return l.jsx(Se.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Hi(o.open),...r,ref:s,onClick:te(e.onClick,o.onOpenToggle)})});Lu.displayName=Du;var zi="DialogPortal",[Wv,$u]=Ou(zi,{forceMount:void 0}),Fu=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=qt(zi,t);return l.jsx(Wv,{scope:t,forceMount:n,children:h.Children.map(r,i=>l.jsx(Tt,{present:n||s.open,children:l.jsx(Lo,{asChild:!0,container:o,children:i})}))})};Fu.displayName=zi;var qo="DialogOverlay",zu=h.forwardRef((e,t)=>{const n=$u(qo,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=qt(qo,e.__scopeDialog);return s.modal?l.jsx(Tt,{present:r||s.open,children:l.jsx(Kv,{...o,ref:t})}):null});zu.displayName=qo;var Vv=Et.createSlot("DialogOverlay.RemoveScroll"),Kv=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=qt(qo,n);return l.jsx(Uo,{as:Vv,allowPinchZoom:!0,shards:[o.contentRef],children:l.jsx(Se.div,{"data-state":Hi(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),$n="DialogContent",Bu=h.forwardRef((e,t)=>{const n=$u($n,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=qt($n,e.__scopeDialog);return l.jsx(Tt,{present:r||s.open,children:s.modal?l.jsx(qv,{...o,ref:t}):l.jsx(Gv,{...o,ref:t})})});Bu.displayName=$n;var qv=h.forwardRef((e,t)=>{const n=qt($n,e.__scopeDialog),r=h.useRef(null),o=Re(t,n.contentRef,r);return h.useEffect(()=>{const s=r.current;if(s)return Fi(s)},[]),l.jsx(Hu,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:te(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:te(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:te(e.onFocusOutside,s=>s.preventDefault())})}),Gv=h.forwardRef((e,t)=>{const n=qt($n,e.__scopeDialog),r=h.useRef(!1),o=h.useRef(!1);return l.jsx(Hu,{...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 c,u;(c=e.onInteractOutside)==null||c.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()}})}),Hu=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=qt($n,n),c=h.useRef(null),u=Re(t,c);return Pi(),l.jsxs(l.Fragment,{children:[l.jsx(Do,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:l.jsx(Mr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Hi(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),l.jsxs(l.Fragment,{children:[l.jsx(Yv,{titleId:a.titleId}),l.jsx(Jv,{contentRef:c,descriptionId:a.descriptionId})]})]})}),Bi="DialogTitle",Uu=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=qt(Bi,n);return l.jsx(Se.h2,{id:o.titleId,...r,ref:t})});Uu.displayName=Bi;var Wu="DialogDescription",Vu=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=qt(Wu,n);return l.jsx(Se.p,{id:o.descriptionId,...r,ref:t})});Vu.displayName=Wu;var Ku="DialogClose",qu=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=qt(Ku,n);return l.jsx(Se.button,{type:"button",...r,ref:t,onClick:te(e.onClick,()=>o.onOpenChange(!1))})});qu.displayName=Ku;function Hi(e){return e?"open":"closed"}var Gu="DialogTitleWarning",[JT,Yu]=nb(Gu,{contentName:$n,titleName:Bi,docsSlug:"dialog"}),Yv=({titleId:e})=>{const t=Yu(Gu),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
124
124
|
|
|
125
125
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
126
126
|
|
|
127
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return h.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},
|
|
128
|
-
… [truncated ${i.length-o} chars]`}catch{return""}},n=e.filter(r=>r.type==="tool_result");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
|
|
129
|
-
… [truncated ${_.length-Zo} chars]`,[_]),de=C.useMemo(()=>iw(t.createdAt),[t.createdAt]),ne=lw(G,r),_e=C.useCallback(async()=>{const ve=Z?_:G;async function Fe(Ge){try{await navigator.clipboard.writeText(Ge)}catch{try{const P=document.createElement("textarea");P.value=Ge,P.setAttribute("readonly",""),P.style.position="absolute",P.style.left="-9999px",document.body.appendChild(P),P.select(),document.execCommand("copy"),document.body.removeChild(P)}catch(P){throw console.error("Failed to copy:",P),P}}}try{await Fe(ve),E(!0),setTimeout(()=>E(!1),2e3),v==null||v(ve)}catch(Ge){console.error("Failed to copy:",Ge)}},[Z,_,G,v]),Pe=C.useCallback(()=>{if(!b)return;const ve=Z?_:G;b(t.id,ve)},[b,t.id,Z,_,G]),Ue=C.useCallback(()=>{g==null||g(n)},[g,n]),Ee=C.useCallback(async(ve,Fe,Ge)=>{if(!he){ve.preventDefault();return}try{const P=String(Fe.url??""),U=P.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(U){ve.preventDefault();const ue=U[1],be=Fe.name||`file_${ue}`,le=Fe.mimeType||"application/octet-stream";W({id:ue,name:be,mimeType:le}),K(!0);return}if(P.startsWith("data:")){if(ve.preventDefault(),H[Ge])return;D(be=>({...be,[Ge]:!0}));const ue=F({title:"Fetching file...",description:"",open:!0});try{const le=(await Mb(A??void 0)).find(Be=>!Be||typeof Be!="object"||!((Be.filename??"")===(Fe.name??""))?!1:typeof Fe.size=="number"&&typeof Be.size=="number"?Be.size===Fe.size:!0);if(!(le!=null&&le.id))throw new Error("File is not yet available on the server");W({id:le.id,name:Fe.name||le.filename||`file_${le.id}`,mimeType:Fe.mimeType||le.mime_type||"application/octet-stream"}),K(!0),ue.update({id:ue.id,title:"Done",description:void 0})}catch(be){console.error("Failed to fetch server file:",be),ue.update({id:ue.id,title:"Failed",description:String(be)}),F({title:"Failed to fetch file",description:String(be),open:!0})}finally{D(be=>({...be,[Ge]:!1}))}}}catch(P){console.error("File click error:",P)}},[he,H,F,A,D,W,K]),Ae=C.useCallback(()=>{const Fe=L(M?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",$);switch(X){case"user":return l.jsx(se.User,{className:Fe});case"assistant":return l.jsx(se.Bot,{className:Fe});case"tool":return l.jsx(se.Wrench,{className:Fe});default:return l.jsx(se.Bot,{className:Fe})}},[M,$,X]),et=C.useCallback(()=>{const ve="group relative mb-4 flex w-full";switch(X){case"user":return L(ve,"justify-end");case"assistant":case"tool":case"system":return L(ve,"justify-start");default:return ve}},[X]),qe=C.useCallback(()=>{const ve=L("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",M&&"px-3 py-2 text-sm");switch(X){case"user":return L(ve,"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 L(ve,"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 L(ve,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return L(ve,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return L(ve,"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")}},[M,X]),ct=C.useCallback(()=>{if(!(G.trim().length>0||pe.length>0||z.length>0))return l.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[l.jsx(se.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),l.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]});if(t.model==="reflection"){const P=G.trim(),U=Ui(P);if(U&&typeof U=="object")return l.jsx(pw,{data:U})}if(Z&&ee.name==="get_issues"){const P=t.content.find(be=>be.type==="tool_result"),U=(P==null?void 0:P.output)??_,ue=ld(U);if(ue)return l.jsx(mw,{issues:ue})}if(Z&&!I){const P=_.slice(0,80).replace(/\s+/g," ");return l.jsx("div",{className:L("text-xs font-mono opacity-70 flex items-center justify-between gap-2 text-current",M&&"text-[10px]"),children:l.jsxs("span",{className:"truncate max-w-full text-current",children:[P,P.length>=80?"…":""]})})}if(Z&&d){const P=_,U=P.length>f;return l.jsx(Kc,{open:S,onOpenChange:T,children:l.jsxs("div",{className:"font-mono text-sm text-current",children:[l.jsx("pre",{className:L("whitespace-pre-wrap break-words text-current",M&&"text-xs"),children:U&&!S?`${Q.substring(0,f)}...`:Q}),U&&l.jsx(qc,{asChild:!0,children:l.jsx(ze,{variant:"ghost",size:"sm",className:"h-6 text-xs text-current",children:S?l.jsxs(l.Fragment,{children:[l.jsx(se.ChevronUp,{className:"h-3 w-3 mr-1"}),"Show less"]}):l.jsxs(l.Fragment,{children:[l.jsx(se.ChevronDown,{className:"h-3 w-3 mr-1"}),"Show more (",Math.max(P.length-f,0)," chars)"]})})})]})})}if(Z&&I&&!d)return Y&&uw(Y)?l.jsx(Po,{content:Y.trim()}):l.jsx("div",{className:"font-mono text-sm text-current",children:l.jsx("pre",{className:L("whitespace-pre-wrap break-words text-current",M&&"text-xs"),children:Q})});const Fe=pe.length>0&&X!=="tool",Ge=z.length>0&&X!=="tool";return l.jsxs("div",{children:[r?l.jsxs("div",{className:L("relative transition-all duration-200 ease-out",M?"text-xs":"text-sm"),style:{minHeight:80},children:[(()=>{const U=od(X,ne)?Ui(ne):null;if(U!==null)return l.jsx(sd,{data:U});const ue=fw(dw(ne)),be=ne.trim().length===0;return l.jsx(l.Fragment,{children:be?l.jsx("div",{className:"w-full",children:l.jsxs("div",{className:"animate-pulse space-y-2",children:[l.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-3/4"}),l.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-5/6"}),l.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-2/3"})]})}):l.jsx("pre",{className:L("whitespace-pre-wrap break-words font-sans leading-relaxed transition-opacity duration-200",M&&"text-xs"),children:ue})})})(),l.jsx("div",{className:"mt-2",children:l.jsx(cw,{className:L($,M?"text-xs":"text-sm")})})]}):(()=>{const P=G.trim(),ue=od(X,P)?Ui(P):null;if(ue!==null)return l.jsx(sd,{data:ue});if(X==="user"&&p){const be=P;if(be.length>m)return l.jsxs(Kc,{open:j,onOpenChange:O,children:[l.jsx("div",{className:L("text-sm text-[hsl(var(--chat-bubble-user-text))]",M&&"text-xs"),children:j?l.jsx(Po,{content:be,allowHtml:!1}):l.jsxs("pre",{className:L("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",M&&"text-xs"),children:[be.substring(0,m),"..."]})}),l.jsx(qc,{asChild:!0,children:l.jsx(ze,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:j?l.jsxs(l.Fragment,{children:[l.jsx(se.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):l.jsxs(l.Fragment,{children:[l.jsx(se.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",be.length-m," chars)"]})})})]})}return l.jsx(Po,{content:G.trim(),allowHtml:!1})})(),Fe&&l.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:pe.map((P,U)=>{const ue=P,be=typeof ue.width=="number"?ue.width:void 0,le=typeof ue.height=="number"?ue.height:void 0,Be=be&&le&&le>0?`${be} / ${le}`:"4 / 3",at=be&&le&&le>0?Math.max(120,Math.round(le/be*140)):160;return l.jsxs("div",{className:"relative border rounded overflow-hidden bg-gray-100 dark:bg-gray-900/40",style:{aspectRatio:Be,minHeight:at},"data-placeholder-height":at,children:[l.jsx("img",{src:ue.url,alt:ue.alt??"image",loading:"lazy",className:"absolute inset-0 h-full w-full object-contain"}),l.jsxs("div",{className:"absolute top-1 right-1 bg-background/70 rounded px-1 py-0.5 text-[10px] flex items-center gap-1",children:[l.jsx(se.Image,{className:"h-3 w-3"}),l.jsx("span",{children:"image"})]})]},U)})}),Ge&&l.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:z.map((P,U)=>{const ue=P,be=ue.name||"file";return l.jsxs("a",{href:ue.url,download:be,onClick:le=>Ee(le,ue,U),target:"_blank",rel:"noreferrer",className:L("inline-flex items-center gap-2 rounded px-2 py-1 text-xs","bg-gray-100 border border-gray-200 hover:bg-gray-200","dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20","text-current",!he&&"pointer-events-none opacity-60"),title:be,"aria-disabled":!he,children:[l.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-gray-400 dark:bg-gray-500"}),H[U]?l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx(se.Loader,{className:"h-4 w-4 animate-spin"}),l.jsxs("span",{className:"truncate max-w-[140px]",children:[be," (processing)"]})]}):l.jsx("span",{className:"truncate max-w-[180px]",children:be})]},U)})})]})},[Z,G,pe,z,t,ee.name,_,I,d,S,Q,f,Y,r,ne,X,$,M,p,j,m,he,H,Ee]),ut=C.useMemo(()=>aw(t),[t]);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:L(et(),w.container),children:l.jsxs("div",{className:L(qe(),w.content),children:[(a||c||Z)&&l.jsxs("div",{className:L("flex items-center justify-between mb-2 pb-2 border-b border-current/10",M&&"mb-1 pb-1",$,w.header),children:[l.jsxs("div",{className:"flex items-center gap-2",children:[Ae(),c&&ut&&l.jsx("span",{className:L("font-medium",M?"text-xs":"text-sm"),children:ut}),Z&&ee.name&&l.jsxs(zc,{variant:"outline",className:L("text-xs flex items-center gap-1 cursor-pointer",$,"border border-current/40",M&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":I,onKeyDown:ve=>{(ve.key==="Enter"||ve.key===" ")&&(ve.preventDefault(),N(Fe=>!Fe))},onClick:()=>N(ve=>!ve),children:[l.jsx("span",{children:ee.name}),l.jsx("span",{className:"inline-flex items-center",children:I?l.jsx(se.ChevronUp,{className:"h-3 w-3"}):l.jsx(se.ChevronDown,{className:"h-3 w-3"})})]}),Z&&!ee.name&&l.jsx(ze,{variant:"ghost",size:"sm",className:L("h-6 px-1",$,"hover:bg-foreground/10"),onClick:()=>N(ve=>!ve),children:l.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",I?l.jsx(se.ChevronUp,{className:"h-3 w-3"}):l.jsx(se.ChevronDown,{className:"h-3 w-3"})]})})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[a&&l.jsx("span",{className:L("text-xs opacity-60",$,M&&"text-xs"),children:de}),i&&!s&&l.jsxs("div",{className:L("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",w.actions),children:[l.jsx(ze,{variant:"ghost",size:"sm",onClick:_e,className:L("h-6 w-6 p-0 hover:bg-foreground/10",$,M&&"h-5 w-5"),"aria-label":"Copy message",children:l.jsx(se.Copy,{className:L(y?"text-success":$,M?"h-3 w-3":"h-4 w-4")})}),X==="user"&&b&&l.jsx(ze,{variant:"ghost",size:"sm",onClick:Pe,className:L("h-6 w-6 p-0 hover:bg-foreground/10",$,M&&"h-5 w-5"),"aria-label":"Edit message",children:l.jsx(se.Edit,{className:L($,M?"h-3 w-3":"h-4 w-4")})}),X==="assistant"&&g&&l.jsx(ze,{variant:"ghost",size:"sm",onClick:Ue,className:L("h-6 w-6 p-0 hover:bg-foreground/10",$,M&&"h-5 w-5"),"aria-label":"Regenerate response",children:l.jsx(se.RotateCcw,{className:L($,M?"h-3 w-3":"h-4 w-4")})})]})]})]}),l.jsx("div",{className:"relative",children:ct()}),Z&&I&&(ee.toolCallId||ee.name)&&l.jsxs("div",{className:L("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",M&&"text-xs"),children:[ee.name&&l.jsxs("div",{children:["Function: ",ee.name]}),ee.toolCallId&&l.jsxs("div",{children:["Call ID: ",ee.toolCallId]})]}),!(a||c||Z)&&i&&!s&&l.jsxs("div",{className:L("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",w.actions),children:[l.jsx(ze,{variant:"ghost",size:"sm",onClick:_e,className:L("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:l.jsx(se.Copy,{className:L(y?"text-success":"text-current",M?"h-3 w-3":"h-4 w-4")})}),X==="user"&&b&&l.jsx(ze,{variant:"ghost",size:"sm",onClick:Pe,className:L("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:l.jsx(se.Edit,{className:L("text-current",M?"h-3 w-3":"h-4 w-4")})}),X==="assistant"&&g&&l.jsx(ze,{variant:"ghost",size:"sm",onClick:Ue,className:L("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:l.jsx(se.RotateCcw,{className:L("text-current",M?"h-3 w-3":"h-4 w-4")})})]})]})}),oe&&l.jsx(tw,{isOpen:J,onClose:()=>{K(!1),W(null)},fileId:oe.id,fileName:oe.name,mimeType:oe.mimeType})]})},(e,t)=>{var i,a,c,u,d,f,p,m;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&nd(e.message)===nd(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(w=>e[w]===t[w]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((c=e.customStyles)==null?void 0:c.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)&&((p=e.customStyles)==null?void 0:p.header)===((m=t.customStyles)==null?void 0:m.header);return o&&s});function uw(e){return e.includes(`
|
|
130
|
-
`)||e.includes("```")||/[-*] /.test(e)||/#+\s/.test(e)}function
|
|
127
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return h.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Xv="DialogDescriptionWarning",Jv=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Yu(Xv).contentName}}.`;return h.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},Xu=Mu,Zv=Lu,Ju=Fu,Go=zu,Yo=Bu,Fn=Uu,Xo=Vu,Zu=qu;const Qv=Xu,ew=Ju,Qu=h.forwardRef(({className:e,...t},n)=>l.jsx(Go,{ref:n,className:L("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}));Qu.displayName=Go.displayName;const ed=h.forwardRef(({className:e,children:t,...n},r)=>{const o=h.useMemo(()=>{let s=!1;function i(a){h.Children.forEach(a,c=>{if(s||!h.isValidElement(c))return;const u=c.type;if(u===Fn||(u==null?void 0:u.displayName)===Fn.displayName||(u==null?void 0:u.name)==="DialogTitle"){s=!0;return}c.props&&c.props.children&&i(c.props.children)})}return i(t),s},[t]);return l.jsxs(ew,{children:[l.jsx(Qu,{}),l.jsxs(Yo,{ref:r,className:L("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&&l.jsx(Fn,{className:"sr-only",children:"Dialog"}),t,l.jsxs(Zu,{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:[l.jsx(se.X,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});ed.displayName=Yo.displayName;const td=({className:e,...t})=>l.jsx("div",{className:L("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});td.displayName="DialogHeader";const nd=h.forwardRef(({className:e,...t},n)=>l.jsx(Fn,{ref:n,className:L("text-lg font-semibold leading-none tracking-tight",e),...t}));nd.displayName=Fn.displayName;const tw=h.forwardRef(({className:e,...t},n)=>l.jsx(Xo,{ref:n,className:L("text-sm text-muted-foreground",e),...t}));tw.displayName=Xo.displayName;function nw({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=C.useState(!1),[a,c]=C.useState(null),[u,d]=C.useState(null),{toast:f}=Ni(),p=C.useCallback(async()=>{if(n){i(!0),d(null),c(null);try{const x=await cu(n);c(x)}catch(x){console.error("Failed to load file:",x),d(x instanceof Error?x.message:"Failed to load file")}finally{i(!1)}}},[n]);C.useEffect(()=>{e&&n&&p()},[e,n,p]);const m=async()=>{if(n)try{await Mb(n),f({title:"Download started",description:`Downloading ${r}`})}catch(x){console.error("Failed to download file:",x),f({title:"Download failed",description:String(x),variant:"destructive"})}},w=async()=>{if(n)try{const x=await cu(n),v=new Blob([x],{type:o}),y=URL.createObjectURL(v);window.open(y,"_blank"),URL.revokeObjectURL(y)}catch(x){console.error("Failed to open file externally:",x),f({title:"Failed to open file",description:String(x),variant:"destructive"})}},b=()=>s?l.jsxs("div",{className:"flex items-center justify-center py-12",children:[l.jsx(se.Loader,{className:"h-8 w-8 animate-spin mr-3"}),l.jsx("span",{children:"Loading file..."})]}):u?l.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[l.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),l.jsx("p",{className:"text-red-600 mb-4",children:u}),l.jsx(ze,{onClick:p,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?l.jsx("div",{className:"flex justify-center",children:l.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?l.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:l.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?l.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:l.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):l.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[l.jsx(se.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),l.jsx("p",{className:"text-lg font-medium mb-2",children:r}),l.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),g=()=>o.startsWith("image/")?l.jsx(se.Image,{className:"h-5 w-5"}):l.jsx(se.FileText,{className:"h-5 w-5"});return l.jsx(Qv,{open:e,onOpenChange:t,children:l.jsxs(ed,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[l.jsx(td,{children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[g(),l.jsxs("div",{children:[l.jsx(nd,{className:"text-left",children:r}),l.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(ze,{variant:"outline",size:"sm",onClick:w,className:"flex items-center gap-2",children:[l.jsx(se.ExternalLink,{className:"h-4 w-4"}),"External"]}),l.jsxs(ze,{variant:"outline",size:"sm",onClick:m,className:"flex items-center gap-2",children:[l.jsx(se.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),l.jsx("div",{className:"flex-1 overflow-hidden",children:b()})]})})}const Jo="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",Zo=1e5;function rw(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function ow(e){const t=e.find(r=>r.type==="tool_call"),n=e.find(r=>r.type==="tool_result");return{name:t==null?void 0:t.name,toolCallId:(n==null?void 0:n.toolCallId)??(t==null?void 0:t.id)}}function sw(e){const t=(r,o=Zo)=>{try{const s=Dr(r),i=typeof s=="string"?s:JSON.stringify(s??"");return i.length<=o?i:i.slice(0,o)+`
|
|
128
|
+
… [truncated ${i.length-o} chars]`}catch{return""}},n=e.filter(r=>r.type==="tool_result");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 iw(e){const t=e.find(r=>r.type==="tool_result");if(!t)return null;const n=t.output;return typeof n=="string"?n:null}function aw(e){if(!e)return"";try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function lw(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function rd(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_result":return"result";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function cw(e,t){const[n,r]=C.useState(e),o=C.useRef(e),s=C.useRef(null);return C.useEffect(()=>{if(o.current=e,!t){s.current!==null&&(cancelAnimationFrame(s.current),s.current=null),r(e);return}return s.current===null&&(s.current=requestAnimationFrame(()=>{s.current=null,r(o.current)})),()=>{s.current!==null&&(cancelAnimationFrame(s.current),s.current=null)}},[e,t]),n}function uw({className:e}){const[t,n]=C.useState(0);return C.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),l.jsxs("span",{"aria-live":"polite",className:L("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const od=C.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,streamingDebounceMs:o=16,isEditing:s=!1,showActions:i=!0,showTimestamp:a=!0,showAgentName:c=!0,layoutSize:u="desktop",truncateToolMessages:d=!0,toolMessagePreviewLength:f=200,truncateUserMessages:p=!0,userMessagePreviewLength:m=200,customStyles:w={},onEdit:b,onRegenerate:g,onCancelEdit:x,onCopy:v}){const[y,E]=C.useState(!1),[S,T]=C.useState(!1),[I,N]=C.useState(!1),[j,O]=C.useState(!1),{currentThreadId:A}=ho(),{toast:F}=Ni(),[H,D]=C.useState({}),[J,K]=C.useState(!1),[oe,W]=C.useState(null),M=u==="phone"||u==="half-screen",X=t.role,Z=X==="tool",he=!(r&&X!=="user"),$=C.useMemo(()=>{switch(X){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))]"}},[X]),G=C.useMemo(()=>rw(t.content),[t.content]),ee=C.useMemo(()=>ow(t.content),[t.content]),pe=C.useMemo(()=>t.content.filter(ve=>ve.type==="image_url"),[t.content]),z=C.useMemo(()=>t.content.filter(ve=>ve.type==="file"),[t.content]),_=C.useMemo(()=>sw(t.content),[t.content]),Y=C.useMemo(()=>iw(t.content),[t.content]),Q=C.useMemo(()=>_.length<=Zo?_:`${_.slice(0,Zo)}
|
|
129
|
+
… [truncated ${_.length-Zo} chars]`,[_]),de=C.useMemo(()=>aw(t.createdAt),[t.createdAt]),ne=cw(G,r),_e=C.useCallback(async()=>{const ve=Z?_:G;async function Fe(Ge){try{await navigator.clipboard.writeText(Ge)}catch{try{const P=document.createElement("textarea");P.value=Ge,P.setAttribute("readonly",""),P.style.position="absolute",P.style.left="-9999px",document.body.appendChild(P),P.select(),document.execCommand("copy"),document.body.removeChild(P)}catch(P){throw console.error("Failed to copy:",P),P}}}try{await Fe(ve),E(!0),setTimeout(()=>E(!1),2e3),v==null||v(ve)}catch(Ge){console.error("Failed to copy:",Ge)}},[Z,_,G,v]),Pe=C.useCallback(()=>{if(!b)return;const ve=Z?_:G;b(t.id,ve)},[b,t.id,Z,_,G]),Ue=C.useCallback(()=>{g==null||g(n)},[g,n]),Ee=C.useCallback(async(ve,Fe,Ge)=>{if(!he){ve.preventDefault();return}try{const P=String(Fe.url??""),U=P.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(U){ve.preventDefault();const ue=U[1],be=Fe.name||`file_${ue}`,le=Fe.mimeType||"application/octet-stream";W({id:ue,name:be,mimeType:le}),K(!0);return}if(P.startsWith("data:")){if(ve.preventDefault(),H[Ge])return;D(be=>({...be,[Ge]:!0}));const ue=F({title:"Fetching file...",description:"",open:!0});try{const le=(await Db(A??void 0)).find(Be=>!Be||typeof Be!="object"||!((Be.filename??"")===(Fe.name??""))?!1:typeof Fe.size=="number"&&typeof Be.size=="number"?Be.size===Fe.size:!0);if(!(le!=null&&le.id))throw new Error("File is not yet available on the server");W({id:le.id,name:Fe.name||le.filename||`file_${le.id}`,mimeType:Fe.mimeType||le.mime_type||"application/octet-stream"}),K(!0),ue.update({id:ue.id,title:"Done",description:void 0})}catch(be){console.error("Failed to fetch server file:",be),ue.update({id:ue.id,title:"Failed",description:String(be)}),F({title:"Failed to fetch file",description:String(be),open:!0})}finally{D(be=>({...be,[Ge]:!1}))}}}catch(P){console.error("File click error:",P)}},[he,H,F,A,D,W,K]),Ae=C.useCallback(()=>{const Fe=L(M?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",$);switch(X){case"user":return l.jsx(se.User,{className:Fe});case"assistant":return l.jsx(se.Bot,{className:Fe});case"tool":return l.jsx(se.Wrench,{className:Fe});default:return l.jsx(se.Bot,{className:Fe})}},[M,$,X]),et=C.useCallback(()=>{const ve="group relative mb-4 flex w-full";switch(X){case"user":return L(ve,"justify-end");case"assistant":case"tool":case"system":return L(ve,"justify-start");default:return ve}},[X]),qe=C.useCallback(()=>{const ve=L("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",M&&"px-3 py-2 text-sm");switch(X){case"user":return L(ve,"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 L(ve,"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 L(ve,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return L(ve,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return L(ve,"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")}},[M,X]),ct=C.useCallback(()=>{if(!(G.trim().length>0||pe.length>0||z.length>0))return l.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[l.jsx(se.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),l.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]});if(t.model==="reflection"){const P=G.trim(),U=Ui(P);if(U&&typeof U=="object")return l.jsx(mw,{data:U})}if(Z&&ee.name==="get_issues"){const P=t.content.find(be=>be.type==="tool_result"),U=(P==null?void 0:P.output)??_,ue=cd(U);if(ue)return l.jsx(gw,{issues:ue})}if(Z&&!I){const P=_.slice(0,80).replace(/\s+/g," ");return l.jsx("div",{className:L("text-xs font-mono opacity-70 flex items-center justify-between gap-2 text-current",M&&"text-[10px]"),children:l.jsxs("span",{className:"truncate max-w-full text-current",children:[P,P.length>=80?"…":""]})})}if(Z&&d){const P=_,U=P.length>f;return l.jsx(qc,{open:S,onOpenChange:T,children:l.jsxs("div",{className:"font-mono text-sm text-current",children:[l.jsx("pre",{className:L("whitespace-pre-wrap break-words text-current",M&&"text-xs"),children:U&&!S?`${Q.substring(0,f)}...`:Q}),U&&l.jsx(Gc,{asChild:!0,children:l.jsx(ze,{variant:"ghost",size:"sm",className:"h-6 text-xs text-current",children:S?l.jsxs(l.Fragment,{children:[l.jsx(se.ChevronUp,{className:"h-3 w-3 mr-1"}),"Show less"]}):l.jsxs(l.Fragment,{children:[l.jsx(se.ChevronDown,{className:"h-3 w-3 mr-1"}),"Show more (",Math.max(P.length-f,0)," chars)"]})})})]})})}if(Z&&I&&!d)return Y&&dw(Y)?l.jsx(Po,{content:Y.trim()}):l.jsx("div",{className:"font-mono text-sm text-current",children:l.jsx("pre",{className:L("whitespace-pre-wrap break-words text-current",M&&"text-xs"),children:Q})});const Fe=pe.length>0&&X!=="tool",Ge=z.length>0&&X!=="tool";return l.jsxs("div",{children:[r?l.jsxs("div",{className:L("relative transition-all duration-200 ease-out",M?"text-xs":"text-sm"),style:{minHeight:80},children:[(()=>{const U=sd(X,ne)?Ui(ne):null;if(U!==null)return l.jsx(id,{data:U});const ue=hw(fw(ne)),be=ne.trim().length===0;return l.jsx(l.Fragment,{children:be?l.jsx("div",{className:"w-full",children:l.jsxs("div",{className:"animate-pulse space-y-2",children:[l.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-3/4"}),l.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-5/6"}),l.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-2/3"})]})}):l.jsx("pre",{className:L("whitespace-pre-wrap break-words font-sans leading-relaxed transition-opacity duration-200",M&&"text-xs"),children:ue})})})(),l.jsx("div",{className:"mt-2",children:l.jsx(uw,{className:L($,M?"text-xs":"text-sm")})})]}):(()=>{const P=G.trim(),ue=sd(X,P)?Ui(P):null;if(ue!==null)return l.jsx(id,{data:ue});if(X==="user"&&p){const be=P;if(be.length>m)return l.jsxs(qc,{open:j,onOpenChange:O,children:[l.jsx("div",{className:L("text-sm text-[hsl(var(--chat-bubble-user-text))]",M&&"text-xs"),children:j?l.jsx(Po,{content:be,allowHtml:!1}):l.jsxs("pre",{className:L("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",M&&"text-xs"),children:[be.substring(0,m),"..."]})}),l.jsx(Gc,{asChild:!0,children:l.jsx(ze,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:j?l.jsxs(l.Fragment,{children:[l.jsx(se.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):l.jsxs(l.Fragment,{children:[l.jsx(se.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",be.length-m," chars)"]})})})]})}return l.jsx(Po,{content:G.trim(),allowHtml:!1})})(),Fe&&l.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:pe.map((P,U)=>{const ue=P,be=typeof ue.width=="number"?ue.width:void 0,le=typeof ue.height=="number"?ue.height:void 0,Be=be&&le&&le>0?`${be} / ${le}`:"4 / 3",at=be&&le&&le>0?Math.max(120,Math.round(le/be*140)):160;return l.jsxs("div",{className:"relative border rounded overflow-hidden bg-gray-100 dark:bg-gray-900/40",style:{aspectRatio:Be,minHeight:at},"data-placeholder-height":at,children:[l.jsx("img",{src:ue.url,alt:ue.alt??"image",loading:"lazy",className:"absolute inset-0 h-full w-full object-contain"}),l.jsxs("div",{className:"absolute top-1 right-1 bg-background/70 rounded px-1 py-0.5 text-[10px] flex items-center gap-1",children:[l.jsx(se.Image,{className:"h-3 w-3"}),l.jsx("span",{children:"image"})]})]},U)})}),Ge&&l.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:z.map((P,U)=>{const ue=P,be=ue.name||"file";return l.jsxs("a",{href:ue.url,download:be,onClick:le=>Ee(le,ue,U),target:"_blank",rel:"noreferrer",className:L("inline-flex items-center gap-2 rounded px-2 py-1 text-xs","bg-gray-100 border border-gray-200 hover:bg-gray-200","dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20","text-current",!he&&"pointer-events-none opacity-60"),title:be,"aria-disabled":!he,children:[l.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-gray-400 dark:bg-gray-500"}),H[U]?l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx(se.Loader,{className:"h-4 w-4 animate-spin"}),l.jsxs("span",{className:"truncate max-w-[140px]",children:[be," (processing)"]})]}):l.jsx("span",{className:"truncate max-w-[180px]",children:be})]},U)})})]})},[Z,G,pe,z,t,ee.name,_,I,d,S,Q,f,Y,r,ne,X,$,M,p,j,m,he,H,Ee]),ut=C.useMemo(()=>lw(t),[t]);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:L(et(),w.container),children:l.jsxs("div",{className:L(qe(),w.content),children:[(a||c||Z)&&l.jsxs("div",{className:L("flex items-center justify-between mb-2 pb-2 border-b border-current/10",M&&"mb-1 pb-1",$,w.header),children:[l.jsxs("div",{className:"flex items-center gap-2",children:[Ae(),c&&ut&&l.jsx("span",{className:L("font-medium",M?"text-xs":"text-sm"),children:ut}),Z&&ee.name&&l.jsxs(Bc,{variant:"outline",className:L("text-xs flex items-center gap-1 cursor-pointer",$,"border border-current/40",M&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":I,onKeyDown:ve=>{(ve.key==="Enter"||ve.key===" ")&&(ve.preventDefault(),N(Fe=>!Fe))},onClick:()=>N(ve=>!ve),children:[l.jsx("span",{children:ee.name}),l.jsx("span",{className:"inline-flex items-center",children:I?l.jsx(se.ChevronUp,{className:"h-3 w-3"}):l.jsx(se.ChevronDown,{className:"h-3 w-3"})})]}),Z&&!ee.name&&l.jsx(ze,{variant:"ghost",size:"sm",className:L("h-6 px-1",$,"hover:bg-foreground/10"),onClick:()=>N(ve=>!ve),children:l.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",I?l.jsx(se.ChevronUp,{className:"h-3 w-3"}):l.jsx(se.ChevronDown,{className:"h-3 w-3"})]})})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[a&&l.jsx("span",{className:L("text-xs opacity-60",$,M&&"text-xs"),children:de}),i&&!s&&l.jsxs("div",{className:L("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",w.actions),children:[l.jsx(ze,{variant:"ghost",size:"sm",onClick:_e,className:L("h-6 w-6 p-0 hover:bg-foreground/10",$,M&&"h-5 w-5"),"aria-label":"Copy message",children:l.jsx(se.Copy,{className:L(y?"text-success":$,M?"h-3 w-3":"h-4 w-4")})}),X==="user"&&b&&l.jsx(ze,{variant:"ghost",size:"sm",onClick:Pe,className:L("h-6 w-6 p-0 hover:bg-foreground/10",$,M&&"h-5 w-5"),"aria-label":"Edit message",children:l.jsx(se.Edit,{className:L($,M?"h-3 w-3":"h-4 w-4")})}),X==="assistant"&&g&&l.jsx(ze,{variant:"ghost",size:"sm",onClick:Ue,className:L("h-6 w-6 p-0 hover:bg-foreground/10",$,M&&"h-5 w-5"),"aria-label":"Regenerate response",children:l.jsx(se.RotateCcw,{className:L($,M?"h-3 w-3":"h-4 w-4")})})]})]})]}),l.jsx("div",{className:"relative",children:ct()}),Z&&I&&(ee.toolCallId||ee.name)&&l.jsxs("div",{className:L("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",M&&"text-xs"),children:[ee.name&&l.jsxs("div",{children:["Function: ",ee.name]}),ee.toolCallId&&l.jsxs("div",{children:["Call ID: ",ee.toolCallId]})]}),!(a||c||Z)&&i&&!s&&l.jsxs("div",{className:L("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",w.actions),children:[l.jsx(ze,{variant:"ghost",size:"sm",onClick:_e,className:L("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:l.jsx(se.Copy,{className:L(y?"text-success":"text-current",M?"h-3 w-3":"h-4 w-4")})}),X==="user"&&b&&l.jsx(ze,{variant:"ghost",size:"sm",onClick:Pe,className:L("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:l.jsx(se.Edit,{className:L("text-current",M?"h-3 w-3":"h-4 w-4")})}),X==="assistant"&&g&&l.jsx(ze,{variant:"ghost",size:"sm",onClick:Ue,className:L("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:l.jsx(se.RotateCcw,{className:L("text-current",M?"h-3 w-3":"h-4 w-4")})})]})]})}),oe&&l.jsx(nw,{isOpen:J,onClose:()=>{K(!1),W(null)},fileId:oe.id,fileName:oe.name,mimeType:oe.mimeType})]})},(e,t)=>{var i,a,c,u,d,f,p,m;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&rd(e.message)===rd(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(w=>e[w]===t[w]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((c=e.customStyles)==null?void 0:c.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)&&((p=e.customStyles)==null?void 0:p.header)===((m=t.customStyles)==null?void 0:m.header);return o&&s});function dw(e){return e.includes(`
|
|
130
|
+
`)||e.includes("```")||/[-*] /.test(e)||/#+\s/.test(e)}function fw(e){let t=e;try{(t.match(/```/g)||[]).length%2===1&&(t+="\n```"),(t.replace(/```[\s\S]*?```/g,"").match(new RegExp("(?<!`)`(?!`)","g"))||[]).length%2===1&&(t+="`")}catch{}return t}function hw(e){try{const t=[],n=[],r="\0F",o="\0I";let s=e.replace(/```[\s\S]*?```/g,i=>(t.push(i),`${r}${t.length-1}\0`));return s=s.replace(/`[^`]*`/g,i=>(n.push(i),`${o}${n.length-1}\0`)),s=s.replace(/\b([A-Za-z0-9_&\/-]+)\b(\s+\1\b)+/g,"$1").replace(/\b([A-Za-z0-9_&\/-]+\s+[A-Za-z0-9_&\/-]+)\b(\s+\1\b)+/g,"$1"),s=s.replace(/\u0000F(\d+)\u0000/g,(i,a)=>t[+a]??""),s=s.replace(/\u0000I(\d+)\u0000/g,(i,a)=>n[+a]??""),s}catch{return e}}function Ui(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function sd(e,t){const n=t==null?void 0:t.trim();return n?!!(e==="tool"||n.startsWith("```json")||n.length<5e3&&(n.startsWith("{")||n.startsWith("["))):!1}function id({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?l.jsx("div",{className:Jo,children:l.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>l.jsx("li",{children:String(n)},r))})}):l.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:ld(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 l.jsxs("div",{className:Jo,children:[typeof r=="boolean"&&l.jsxs("p",{children:[l.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&l.jsxs("div",{children:[l.jsx("p",{children:l.jsx("strong",{children:"Follow-up queries:"})}),l.jsx("ul",{className:"list-disc pl-5",children:n.map((s,i)=>l.jsx("li",{children:String(s)},i))})]}),t&&t.length>0&&l.jsxs("div",{children:[l.jsx("p",{children:l.jsx("strong",{children:"Facts:"})}),l.jsx("ul",{className:"list-disc pl-5",children:t.map((s,i)=>l.jsx("li",{children:String(s)},i))})]})]});const o=Object.entries(e);return l.jsx("div",{className:Jo,children:l.jsx("dl",{className:"mt-0",children:o.map(([s,i])=>l.jsxs("div",{className:"mb-1",children:[l.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),l.jsx("dd",{className:"inline",children:pw(i)})]},s))})})}return l.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:ld(e)})}function pw(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 l.jsx("code",{className:"text-xs",children:JSON.stringify(Dr(e))})}catch{return String(e)}}function ad(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Dr(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(Dr).filter(r=>r!==void 0);return n.length?n:void 0}if(ad(e))return;const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=Dr(r);o!==void 0&&(t[n]=o)}}return Object.keys(t).length?t:void 0}return e}function ld(e){if(typeof e=="string")return e;if(ad(e))return"";try{const t=Dr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function mw({data:e}){return l.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>l.jsxs("div",{className:"flex",children:[l.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),l.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>l.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function cd(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 cd(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 c=new RegExp(i+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(r);if(!c)continue;const u=c[1],d=/Issue\(([\s\S]*?)\)(?:,|$)/g;let f=null;for(;(f=d.exec(u))!==null;){const p=f[1],m=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(p),w=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(p),b=m?m[2].trim():"",g=w?w[2].trim():"";n[i].push({title:b,description:g})}}return Object.values(n).some(i=>i.length>0)?n:null}function gw({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return l.jsx("div",{className:Jo,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:l.jsxs("div",{className:"mb-4",children:[l.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),l.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>l.jsxs("li",{children:[l.jsx("div",{className:"font-medium",children:o.title}),l.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}`,Wi=C.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:c,onRegenerate:u,onCancelEdit:d,className:f,style:p,emptyMessage:m,followNewMessages:w=!0,isNavigatingCheckpoint:b=!1,onScrollAway:g,onAtBottom:x},v)=>{const y=C.useRef(null),E=C.useRef(null),S=C.useRef(!1),[T,I]=C.useState(!0),N=C.useCallback(A=>{I(A),g&&g(!A),x&&x(A)},[g,x]),j=C.useMemo(()=>{if(a)return async()=>{if(!S.current){S.current=!0;try{await a()}finally{S.current=!1}}}},[a]),O=C.useRef(!1);return C.useEffect(()=>{if(!w||b){O.current!==!1&&(O.current=!1);return}const A=t&&T?"auto":!1;O.current!==A&&(O.current=A)},[t,T,w,b]),e.length===0?l.jsx("div",{className:f,style:p,children:l.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:m||"No messages yet. Start a conversation!"})}):l.jsx("div",{className:f,style:p,children:l.jsx(zx,{ref:A=>{y.current=A},scrollerRef:A=>{E.current=A instanceof HTMLDivElement?A:null},data:e.reverse(),followOutput:O.current,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!0,startReached:()=>{j&&j()},atBottomStateChange:N,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(A,F)=>ud(F,A),itemContent:(A,F)=>{const H=ud(F,A);return l.jsx("div",{className:"mb-4 last:mb-0","data-message-id":H,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:l.jsx(od,{message:F,messageIndex:A,isStreamingMessage:t&&n===F.id,streamingDebounceMs:r,isEditing:i===F.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:c,onRegenerate:()=>u(A),onCancelEdit:d})})}})})});Wi.displayName="MessageList";const Qo=1e4;function xw(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,`
|
|
131
131
|
`).replace(/<p>(.*?)<\/p>/gi,`$1
|
|
132
132
|
|
|
133
133
|
`).replace(/<h([1-6])>(.*?)<\/h[1-6]>/gi,(o,s,i)=>`${"#".repeat(parseInt(s))} ${i}
|
|
@@ -135,4 +135,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
135
135
|
`).replace(/<ul>/gi,"").replace(/<\/ul>/gi,`
|
|
136
136
|
`).replace(/<ol>/gi,"").replace(/<\/ol>/gi,`
|
|
137
137
|
`).replace(/<li>(.*?)<\/li>/gi,`- $1
|
|
138
|
-
`).trim():n.replace(/</g,"<").replace(/>/g,">").trim()}function xw(e,t=Qo){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 bw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),xw(t),gw(t)}function Vi(e){const t=e+"CollectionProvider",[n,r]=Vt(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=b=>{const{scope:g,children:x}=b,v=C.useRef(null),y=C.useRef(new Map).current;return l.jsx(o,{scope:g,itemMap:y,collectionRef:v,children:x})};i.displayName=t;const a=e+"CollectionSlot",c=Et.createSlot(a),u=C.forwardRef((b,g)=>{const{scope:x,children:v}=b,y=s(a,x),E=Re(g,y.collectionRef);return l.jsx(c,{ref:E,children:v})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",p=Et.createSlot(d),m=C.forwardRef((b,g)=>{const{scope:x,children:v,...y}=b,E=C.useRef(null),S=Re(g,E),T=s(d,x);return C.useEffect(()=>(T.itemMap.set(E,{ref:E,...y}),()=>void T.itemMap.delete(E))),l.jsx(p,{[f]:"",ref:S,children:v})});m.displayName=d;function w(b){const g=s(e+"CollectionConsumer",b);return C.useCallback(()=>{const v=g.collectionRef.current;if(!v)return[];const y=Array.from(v.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((T,I)=>y.indexOf(T.ref.current)-y.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:m},w,r]}var vw=h.createContext(void 0);function es(e){const t=h.useContext(vw);return e||t||"ltr"}const ww=["top","right","bottom","left"],Tn=Math.min,At=Math.max,ts=Math.round,ns=Math.floor,nn=e=>({x:e,y:e}),yw={left:"right",right:"left",bottom:"top",top:"bottom"},Sw={start:"end",end:"start"};function Ki(e,t,n){return At(e,Tn(t,n))}function dn(e,t){return typeof e=="function"?e(t):e}function fn(e){return e.split("-")[0]}function sr(e){return e.split("-")[1]}function qi(e){return e==="x"?"y":"x"}function Gi(e){return e==="y"?"height":"width"}const Cw=new Set(["top","bottom"]);function rn(e){return Cw.has(fn(e))?"y":"x"}function Yi(e){return qi(rn(e))}function Tw(e,t,n){n===void 0&&(n=!1);const r=sr(e),o=Yi(e),s=Gi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=rs(i)),[i,rs(i)]}function kw(e){const t=rs(e);return[Xi(e),t,Xi(t)]}function Xi(e){return e.replace(/start|end/g,t=>Sw[t])}const ud=["left","right"],dd=["right","left"],Ew=["top","bottom"],Iw=["bottom","top"];function Nw(e,t,n){switch(e){case"top":case"bottom":return n?t?dd:ud:t?ud:dd;case"left":case"right":return t?Ew:Iw;default:return[]}}function jw(e,t,n,r){const o=sr(e);let s=Nw(fn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Xi)))),s}function rs(e){return e.replace(/left|right|bottom|top/g,t=>yw[t])}function Aw(e){return{top:0,right:0,bottom:0,left:0,...e}}function fd(e){return typeof e!="number"?Aw(e):{top:e,right:e,bottom:e,left:e}}function os(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=rn(t),i=Yi(t),a=Gi(i),c=fn(t),u=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,p=r[a]/2-o[a]/2;let m;switch(c){case"top":m={x:d,y:r.y-o.height};break;case"bottom":m={x:d,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-o.width,y:f};break;default:m={x:r.x,y:r.y}}switch(sr(t)){case"start":m[i]-=p*(n&&u?-1:1);break;case"end":m[i]+=p*(n&&u?-1:1);break}return m}const Rw=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),c=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,c),p=r,m={},w=0;for(let b=0;b<a.length;b++){const{name:g,fn:x}=a[b],{x:v,y,data:E,reset:S}=await x({x:d,y:f,initialPlacement:r,placement:p,strategy:o,middlewareData:m,rects:u,platform:i,elements:{reference:e,floating:t}});d=v??d,f=y??f,m={...m,[g]:{...m[g],...E}},S&&w<=50&&(w++,typeof S=="object"&&(S.placement&&(p=S.placement),S.rects&&(u=S.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:d,y:f}=hd(u,p,c)),b=-1)}return{x:d,y:f,placement:p,strategy:o,middlewareData:m}};async function Lr(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:p=!1,padding:m=0}=dn(t,e),w=fd(m),g=a[p?f==="floating"?"reference":"floating":f],x=os(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:c})),v=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,y=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(y))?await(s.getScale==null?void 0:s.getScale(y))||{x:1,y:1}:{x:1,y:1},S=os(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:y,strategy:c}):v);return{top:(x.top-S.top+w.top)/E.y,bottom:(S.bottom-x.bottom+w.bottom)/E.y,left:(x.left-S.left+w.left)/E.x,right:(S.right-x.right+w.right)/E.x}}const _w=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:c}=t,{element:u,padding:d=0}=dn(e,t)||{};if(u==null)return{};const f=fd(d),p={x:n,y:r},m=Yi(o),w=Gi(m),b=await i.getDimensions(u),g=m==="y",x=g?"top":"left",v=g?"bottom":"right",y=g?"clientHeight":"clientWidth",E=s.reference[w]+s.reference[m]-p[m]-s.floating[w],S=p[m]-s.reference[m],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let I=T?T[y]:0;(!I||!await(i.isElement==null?void 0:i.isElement(T)))&&(I=a.floating[y]||s.floating[w]);const N=E/2-S/2,j=I/2-b[w]/2-1,O=Tn(f[x],j),A=Tn(f[v],j),F=O,H=I-b[w]-A,D=I/2-b[w]/2+N,J=Ki(F,D,H),K=!c.arrow&&sr(o)!=null&&D!==J&&s.reference[w]/2-(D<F?O:A)-b[w]/2<0,oe=K?D<F?D-F:D-H:0;return{[m]:p[m]+oe,data:{[m]:J,centerOffset:D-J-oe,...K&&{alignmentOffset:oe}},reset:K}}}),Pw=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:c,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:b=!0,...g}=dn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=fn(o),v=rn(a),y=fn(a)===a,E=await(c.isRTL==null?void 0:c.isRTL(u.floating)),S=p||(y||!b?[rs(a)]:kw(a)),T=w!=="none";!p&&T&&S.push(...jw(a,b,w,E));const I=[a,...S],N=await Lr(t,g),j=[];let O=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&j.push(N[x]),f){const D=Tw(o,i,E);j.push(N[D[0]],N[D[1]])}if(O=[...O,{placement:o,overflows:j}],!j.every(D=>D<=0)){var A,F;const D=(((A=s.flip)==null?void 0:A.index)||0)+1,J=I[D];if(J&&(!(f==="alignment"?v!==rn(J):!1)||O.every(W=>rn(W.placement)===v?W.overflows[0]>0:!0)))return{data:{index:D,overflows:O},reset:{placement:J}};let K=(F=O.filter(oe=>oe.overflows[0]<=0).sort((oe,W)=>oe.overflows[1]-W.overflows[1])[0])==null?void 0:F.placement;if(!K)switch(m){case"bestFit":{var H;const oe=(H=O.filter(W=>{if(T){const M=rn(W.placement);return M===v||M==="y"}return!0}).map(W=>[W.placement,W.overflows.filter(M=>M>0).reduce((M,X)=>M+X,0)]).sort((W,M)=>W[1]-M[1])[0])==null?void 0:H[0];oe&&(K=oe);break}case"initialPlacement":K=a;break}if(o!==K)return{reset:{placement:K}}}return{}}}};function pd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function md(e){return ww.some(t=>e[t]>=0)}const Ow=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=dn(e,t);switch(r){case"referenceHidden":{const s=await Lr(t,{...o,elementContext:"reference"}),i=pd(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:md(i)}}}case"escaped":{const s=await Lr(t,{...o,altBoundary:!0}),i=pd(s,n.floating);return{data:{escapedOffsets:i,escaped:md(i)}}}default:return{}}}}},gd=new Set(["left","top"]);async function Mw(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=fn(n),a=sr(n),c=rn(n)==="y",u=gd.has(i)?-1:1,d=s&&c?-1:1,f=dn(t,e);let{mainAxis:p,crossAxis:m,alignmentAxis:w}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof w=="number"&&(m=a==="end"?w*-1:w),c?{x:m*d,y:p*u}:{x:p*u,y:m*d}}const Dw=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,c=await Mw(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:i}}}}},Lw=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:v}=g;return{x,y:v}}},...c}=dn(e,t),u={x:n,y:r},d=await Lr(t,c),f=rn(fn(o)),p=qi(f);let m=u[p],w=u[f];if(s){const g=p==="y"?"top":"left",x=p==="y"?"bottom":"right",v=m+d[g],y=m-d[x];m=Ki(v,m,y)}if(i){const g=f==="y"?"top":"left",x=f==="y"?"bottom":"right",v=w+d[g],y=w-d[x];w=Ki(v,w,y)}const b=a.fn({...t,[p]:m,[f]:w});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[p]:s,[f]:i}}}}}},$w=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:c=!0,crossAxis:u=!0}=dn(e,t),d={x:n,y:r},f=rn(o),p=qi(f);let m=d[p],w=d[f];const b=dn(a,t),g=typeof b=="number"?{mainAxis:b,crossAxis:0}:{mainAxis:0,crossAxis:0,...b};if(c){const y=p==="y"?"height":"width",E=s.reference[p]-s.floating[y]+g.mainAxis,S=s.reference[p]+s.reference[y]-g.mainAxis;m<E?m=E:m>S&&(m=S)}if(u){var x,v;const y=p==="y"?"width":"height",E=gd.has(fn(o)),S=s.reference[f]-s.floating[y]+(E&&((x=i.offset)==null?void 0:x[f])||0)+(E?0:g.crossAxis),T=s.reference[f]+s.reference[y]+(E?0:((v=i.offset)==null?void 0:v[f])||0)-(E?g.crossAxis:0);w<S?w=S:w>T&&(w=T)}return{[p]:m,[f]:w}}}},Fw=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:c=()=>{},...u}=dn(e,t),d=await Lr(t,u),f=fn(o),p=sr(o),m=rn(o)==="y",{width:w,height:b}=s.floating;let g,x;f==="top"||f==="bottom"?(g=f,x=p===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=f,g=p==="end"?"top":"bottom");const v=b-d.top-d.bottom,y=w-d.left-d.right,E=Tn(b-d[g],v),S=Tn(w-d[x],y),T=!t.middlewareData.shift;let I=E,N=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=v),T&&!p){const O=At(d.left,0),A=At(d.right,0),F=At(d.top,0),H=At(d.bottom,0);m?N=w-2*(O!==0||A!==0?O+A:At(d.left,d.right)):I=b-2*(F!==0||H!==0?F+H:At(d.top,d.bottom))}await c({...t,availableWidth:N,availableHeight:I});const j=await i.getDimensions(a.floating);return w!==j.width||b!==j.height?{reset:{rects:!0}}:{}}}};function ss(){return typeof window<"u"}function ir(e){return xd(e)?(e.nodeName||"").toLowerCase():"#document"}function Rt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function on(e){var t;return(t=(xd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function xd(e){return ss()?e instanceof Node||e instanceof Rt(e).Node:!1}function Gt(e){return ss()?e instanceof Element||e instanceof Rt(e).Element:!1}function sn(e){return ss()?e instanceof HTMLElement||e instanceof Rt(e).HTMLElement:!1}function bd(e){return!ss()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Rt(e).ShadowRoot}const zw=new Set(["inline","contents"]);function $r(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Yt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!zw.has(o)}const Bw=new Set(["table","td","th"]);function Hw(e){return Bw.has(ir(e))}const Uw=[":popover-open",":modal"];function is(e){return Uw.some(t=>{try{return e.matches(t)}catch{return!1}})}const Ww=["transform","translate","scale","rotate","perspective"],Vw=["transform","translate","scale","rotate","perspective","filter"],Kw=["paint","layout","strict","content"];function Ji(e){const t=Zi(),n=Gt(e)?Yt(e):e;return Ww.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)||Vw.some(r=>(n.willChange||"").includes(r))||Kw.some(r=>(n.contain||"").includes(r))}function qw(e){let t=kn(e);for(;sn(t)&&!ar(t);){if(Ji(t))return t;if(is(t))return null;t=kn(t)}return null}function Zi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Gw=new Set(["html","body","#document"]);function ar(e){return Gw.has(ir(e))}function Yt(e){return Rt(e).getComputedStyle(e)}function as(e){return Gt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function kn(e){if(ir(e)==="html")return e;const t=e.assignedSlot||e.parentNode||bd(e)&&e.host||on(e);return bd(t)?t.host:t}function vd(e){const t=kn(e);return ar(t)?e.ownerDocument?e.ownerDocument.body:e.body:sn(t)&&$r(t)?t:vd(t)}function Fr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=vd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Rt(o);if(s){const a=Qi(i);return t.concat(i,i.visualViewport||[],$r(o)?o:[],a&&n?Fr(a):[])}return t.concat(o,Fr(o,[],n))}function Qi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function wd(e){const t=Yt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=sn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=ts(n)!==s||ts(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ea(e){return Gt(e)?e:e.contextElement}function lr(e){const t=ea(e);if(!sn(t))return nn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=wd(t);let i=(s?ts(n.width):n.width)/r,a=(s?ts(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Yw=nn(0);function yd(e){const t=Rt(e);return!Zi()||!t.visualViewport?Yw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Xw(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Rt(e)?!1:t}function zn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ea(e);let i=nn(1);t&&(r?Gt(r)&&(i=lr(r)):i=lr(e));const a=Xw(s,n,r)?yd(s):nn(0);let c=(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 p=Rt(s),m=r&&Gt(r)?Rt(r):r;let w=p,b=Qi(w);for(;b&&r&&m!==w;){const g=lr(b),x=b.getBoundingClientRect(),v=Yt(b),y=x.left+(b.clientLeft+parseFloat(v.paddingLeft))*g.x,E=x.top+(b.clientTop+parseFloat(v.paddingTop))*g.y;c*=g.x,u*=g.y,d*=g.x,f*=g.y,c+=y,u+=E,w=Rt(b),b=Qi(w)}}return os({width:d,height:f,x:c,y:u})}function ta(e,t){const n=as(e).scrollLeft;return t?t.left+n:zn(on(e)).left+n}function Sd(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:ta(e,r)),s=r.top+t.scrollTop;return{x:o,y:s}}function Jw(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=on(r),a=t?is(t.floating):!1;if(r===i||a&&s)return n;let c={scrollLeft:0,scrollTop:0},u=nn(1);const d=nn(0),f=sn(r);if((f||!f&&!s)&&((ir(r)!=="body"||$r(i))&&(c=as(r)),sn(r))){const m=zn(r);u=lr(r),d.x=m.x+r.clientLeft,d.y=m.y+r.clientTop}const p=i&&!f&&!s?Sd(i,c,!0):nn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+p.x,y:n.y*u.y-c.scrollTop*u.y+d.y+p.y}}function Zw(e){return Array.from(e.getClientRects())}function Qw(e){const t=on(e),n=as(e),r=e.ownerDocument.body,o=At(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=At(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ta(e);const a=-n.scrollTop;return Yt(r).direction==="rtl"&&(i+=At(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function ey(e,t){const n=Rt(e),r=on(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,c=0;if(o){s=o.width,i=o.height;const u=Zi();(!u||u&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}return{width:s,height:i,x:a,y:c}}const ty=new Set(["absolute","fixed"]);function ny(e,t){const n=zn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=sn(e)?lr(e):nn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,c=o*s.x,u=r*s.y;return{width:i,height:a,x:c,y:u}}function Cd(e,t,n){let r;if(t==="viewport")r=ey(e,n);else if(t==="document")r=Qw(on(e));else if(Gt(t))r=ny(t,n);else{const o=yd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return os(r)}function Td(e,t){const n=kn(e);return n===t||!Gt(n)||ar(n)?!1:Yt(n).position==="fixed"||Td(n,t)}function ry(e,t){const n=t.get(e);if(n)return n;let r=Fr(e,[],!1).filter(a=>Gt(a)&&ir(a)!=="body"),o=null;const s=Yt(e).position==="fixed";let i=s?kn(e):e;for(;Gt(i)&&!ar(i);){const a=Yt(i),c=Ji(i);!c&&a.position==="fixed"&&(o=null),(s?!c&&!o:!c&&a.position==="static"&&!!o&&ty.has(o.position)||$r(i)&&!c&&Td(e,i))?r=r.filter(d=>d!==i):o=a,i=kn(i)}return t.set(e,r),r}function oy(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?is(t)?[]:ry(t,this._c):[].concat(n),r],a=i[0],c=i.reduce((u,d)=>{const f=Cd(t,d,o);return u.top=At(f.top,u.top),u.right=Tn(f.right,u.right),u.bottom=Tn(f.bottom,u.bottom),u.left=At(f.left,u.left),u},Cd(t,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function sy(e){const{width:t,height:n}=wd(e);return{width:t,height:n}}function iy(e,t,n){const r=sn(t),o=on(t),s=n==="fixed",i=zn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const c=nn(0);function u(){c.x=ta(o)}if(r||!r&&!s)if((ir(t)!=="body"||$r(o))&&(a=as(t)),r){const m=zn(t,!0,s,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?Sd(o,a):nn(0),f=i.left+a.scrollLeft-c.x-d.x,p=i.top+a.scrollTop-c.y-d.y;return{x:f,y:p,width:i.width,height:i.height}}function na(e){return Yt(e).position==="static"}function kd(e,t){if(!sn(e)||Yt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return on(e)===n&&(n=n.ownerDocument.body),n}function Ed(e,t){const n=Rt(e);if(is(e))return n;if(!sn(e)){let o=kn(e);for(;o&&!ar(o);){if(Gt(o)&&!na(o))return o;o=kn(o)}return n}let r=kd(e,t);for(;r&&Hw(r)&&na(r);)r=kd(r,t);return r&&ar(r)&&na(r)&&!Ji(r)?n:r||qw(e)||n}const ay=async function(e){const t=this.getOffsetParent||Ed,n=this.getDimensions,r=await n(e.floating);return{reference:iy(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function ly(e){return Yt(e).direction==="rtl"}const cy={convertOffsetParentRelativeRectToViewportRelativeRect:Jw,getDocumentElement:on,getClippingRect:oy,getOffsetParent:Ed,getElementRects:ay,getClientRects:Zw,getDimensions:sy,getScale:lr,isElement:Gt,isRTL:ly};function Id(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function uy(e,t){let n=null,r;const o=on(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:p,height:m}=u;if(a||t(),!p||!m)return;const w=ns(f),b=ns(o.clientWidth-(d+p)),g=ns(o.clientHeight-(f+m)),x=ns(d),y={rootMargin:-w+"px "+-b+"px "+-g+"px "+-x+"px",threshold:At(0,Tn(1,c))||1};let E=!0;function S(T){const I=T[0].intersectionRatio;if(I!==c){if(!E)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!Id(u,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(S,{...y,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,y)}n.observe(e)}return i(!0),s}function dy(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:c=!1}=r,u=ea(e),d=o||s?[...u?Fr(u):[],...Fr(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const f=u&&a?uy(u,n):null;let p=-1,m=null;i&&(m=new ResizeObserver(x=>{let[v]=x;v&&v.target===u&&m&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var y;(y=m)==null||y.observe(t)})),n()}),u&&!c&&m.observe(u),m.observe(t));let w,b=c?zn(e):null;c&&g();function g(){const x=zn(e);b&&!Id(b,x)&&n(),b=x,w=requestAnimationFrame(g)}return n(),()=>{var x;d.forEach(v=>{o&&v.removeEventListener("scroll",n),s&&v.removeEventListener("resize",n)}),f==null||f(),(x=m)==null||x.disconnect(),m=null,c&&cancelAnimationFrame(w)}}const fy=Dw,hy=Lw,py=Pw,my=Fw,gy=Ow,Nd=_w,xy=$w,by=(e,t,n)=>{const r=new Map,o={platform:cy,...n},s={...o.platform,_c:r};return Rw(e,t,{...o,platform:s})};var vy=typeof document<"u",wy=function(){},ls=vy?C.useLayoutEffect:wy;function cs(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(!cs(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)&&!cs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function jd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ad(e,t){const n=jd(e);return Math.round(t*n)/n}function ra(e){const t=h.useRef(e);return ls(()=>{t.current=e}),t}function yy(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:c,open:u}=e,[d,f]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=h.useState(r);cs(p,r)||m(r);const[w,b]=h.useState(null),[g,x]=h.useState(null),v=h.useCallback(W=>{W!==T.current&&(T.current=W,b(W))},[]),y=h.useCallback(W=>{W!==I.current&&(I.current=W,x(W))},[]),E=s||w,S=i||g,T=h.useRef(null),I=h.useRef(null),N=h.useRef(d),j=c!=null,O=ra(c),A=ra(o),F=ra(u),H=h.useCallback(()=>{if(!T.current||!I.current)return;const W={placement:t,strategy:n,middleware:p};A.current&&(W.platform=A.current),by(T.current,I.current,W).then(M=>{const X={...M,isPositioned:F.current!==!1};D.current&&!cs(N.current,X)&&(N.current=X,eo.flushSync(()=>{f(X)}))})},[p,t,n,A,F]);ls(()=>{u===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,f(W=>({...W,isPositioned:!1})))},[u]);const D=h.useRef(!1);ls(()=>(D.current=!0,()=>{D.current=!1}),[]),ls(()=>{if(E&&(T.current=E),S&&(I.current=S),E&&S){if(O.current)return O.current(E,S,H);H()}},[E,S,H,O,j]);const J=h.useMemo(()=>({reference:T,floating:I,setReference:v,setFloating:y}),[v,y]),K=h.useMemo(()=>({reference:E,floating:S}),[E,S]),oe=h.useMemo(()=>{const W={position:n,left:0,top:0};if(!K.floating)return W;const M=Ad(K.floating,d.x),X=Ad(K.floating,d.y);return a?{...W,transform:"translate("+M+"px, "+X+"px)",...jd(K.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:M,top:X}},[n,a,K.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:H,refs:J,elements:K,floatingStyles:oe}),[d,H,J,K,oe])}const Sy=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?Nd({element:r.current,padding:o}).fn(n):{}:r?Nd({element:r,padding:o}).fn(n):{}}}},Cy=(e,t)=>({...fy(e),options:[e,t]}),Ty=(e,t)=>({...hy(e),options:[e,t]}),ky=(e,t)=>({...xy(e),options:[e,t]}),Ey=(e,t)=>({...py(e),options:[e,t]}),Iy=(e,t)=>({...my(e),options:[e,t]}),Ny=(e,t)=>({...gy(e),options:[e,t]}),jy=(e,t)=>({...Sy(e),options:[e,t]});var Ay="Arrow",Rd=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return l.jsx(Se.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:l.jsx("polygon",{points:"0,0 30,0 15,10"})})});Rd.displayName=Ay;var Ry=Rd;function _d(e){const[t,n]=h.useState(void 0);return lt(()=>{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 c=s.borderBoxSize,u=Array.isArray(c)?c[0]:c;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 oa="Popper",[Pd,cr]=Vt(oa),[_y,Od]=Pd(oa),Md=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return l.jsx(_y,{scope:t,anchor:r,onAnchorChange:o,children:n})};Md.displayName=oa;var Dd="PopperAnchor",Ld=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Od(Dd,n),i=h.useRef(null),a=Re(t,i),c=h.useRef(null);return h.useEffect(()=>{const u=c.current;c.current=(r==null?void 0:r.current)||i.current,u!==c.current&&s.onAnchorChange(c.current)}),r?null:l.jsx(Se.div,{...o,ref:a})});Ld.displayName=Dd;var sa="PopperContent",[Py,Oy]=Pd(sa),$d=h.forwardRef((e,t)=>{var z,_,Y,Q,de,ne;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:w,...b}=e,g=Od(sa,n),[x,v]=h.useState(null),y=Re(t,_e=>v(_e)),[E,S]=h.useState(null),T=_d(E),I=(T==null?void 0:T.width)??0,N=(T==null?void 0:T.height)??0,j=r+(s!=="center"?"-"+s:""),O=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},A=Array.isArray(u)?u:[u],F=A.length>0,H={padding:O,boundary:A.filter(Dy),altBoundary:F},{refs:D,floatingStyles:J,placement:K,isPositioned:oe,middlewareData:W}=yy({strategy:"fixed",placement:j,whileElementsMounted:(..._e)=>dy(..._e,{animationFrame:m==="always"}),elements:{reference:g.anchor},middleware:[Cy({mainAxis:o+N,alignmentAxis:i}),c&&Ty({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?ky():void 0,...H}),c&&Ey({...H}),Iy({...H,apply:({elements:_e,rects:Pe,availableWidth:Ue,availableHeight:Ee})=>{const{width:Ae,height:et}=Pe.reference,qe=_e.floating.style;qe.setProperty("--radix-popper-available-width",`${Ue}px`),qe.setProperty("--radix-popper-available-height",`${Ee}px`),qe.setProperty("--radix-popper-anchor-width",`${Ae}px`),qe.setProperty("--radix-popper-anchor-height",`${et}px`)}}),E&&jy({element:E,padding:a}),Ly({arrowWidth:I,arrowHeight:N}),p&&Ny({strategy:"referenceHidden",...H})]}),[M,X]=Bd(K),Z=dt(w);lt(()=>{oe&&(Z==null||Z())},[oe,Z]);const he=(z=W.arrow)==null?void 0:z.x,$=(_=W.arrow)==null?void 0:_.y,G=((Y=W.arrow)==null?void 0:Y.centerOffset)!==0,[ee,pe]=h.useState();return lt(()=>{x&&pe(window.getComputedStyle(x).zIndex)},[x]),l.jsx("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...J,transform:oe?J.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ee,"--radix-popper-transform-origin":[(Q=W.transformOrigin)==null?void 0:Q.x,(de=W.transformOrigin)==null?void 0:de.y].join(" "),...((ne=W.hide)==null?void 0:ne.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:l.jsx(Py,{scope:n,placedSide:M,onArrowChange:S,arrowX:he,arrowY:$,shouldHideArrow:G,children:l.jsx(Se.div,{"data-side":M,"data-align":X,...b,ref:y,style:{...b.style,animation:oe?void 0:"none"}})})})});$d.displayName=sa;var Fd="PopperArrow",My={top:"bottom",right:"left",bottom:"top",left:"right"},zd=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Oy(Fd,r),i=My[s.placedSide];return l.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:l.jsx(Ry,{...o,ref:n,style:{...o.style,display:"block"}})})});zd.displayName=Fd;function Dy(e){return e!==null}var Ly=e=>({name:"transformOrigin",options:e,fn(t){var g,x,v;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,d]=Bd(n),f={start:"0%",center:"50%",end:"100%"}[d],p=(((x=o.arrow)==null?void 0:x.x)??0)+a/2,m=(((v=o.arrow)==null?void 0:v.y)??0)+c/2;let w="",b="";return u==="bottom"?(w=i?f:`${p}px`,b=`${-c}px`):u==="top"?(w=i?f:`${p}px`,b=`${r.floating.height+c}px`):u==="right"?(w=`${-c}px`,b=i?f:`${m}px`):u==="left"&&(w=`${r.floating.width+c}px`,b=i?f:`${m}px`),{data:{x:w,y:b}}}});function Bd(e){const[t,n="center"]=e.split("-");return[t,n]}var ia=Md,aa=Ld,la=$d,ca=zd,ua="rovingFocusGroup.onEntryFocus",$y={bubbles:!1,cancelable:!0},zr="RovingFocusGroup",[da,Hd,Fy]=Vi(zr),[zy,Ud]=Vt(zr,[Fy]),[By,Hy]=zy(zr),Wd=h.forwardRef((e,t)=>l.jsx(da.Provider,{scope:e.__scopeRovingFocusGroup,children:l.jsx(da.Slot,{scope:e.__scopeRovingFocusGroup,children:l.jsx(Uy,{...e,ref:t})})}));Wd.displayName=zr;var Uy=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,p=h.useRef(null),m=Re(t,p),w=es(s),[b,g]=wn({prop:i,defaultProp:a??null,onChange:c,caller:zr}),[x,v]=h.useState(!1),y=dt(u),E=Hd(n),S=h.useRef(!1),[T,I]=h.useState(0);return h.useEffect(()=>{const N=p.current;if(N)return N.addEventListener(ua,y),()=>N.removeEventListener(ua,y)},[y]),l.jsx(By,{scope:n,orientation:r,dir:w,loop:o,currentTabStopId:b,onItemFocus:h.useCallback(N=>g(N),[g]),onItemShiftTab:h.useCallback(()=>v(!0),[]),onFocusableItemAdd:h.useCallback(()=>I(N=>N+1),[]),onFocusableItemRemove:h.useCallback(()=>I(N=>N-1),[]),children:l.jsx(Se.div,{tabIndex:x||T===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:te(e.onMouseDown,()=>{S.current=!0}),onFocus:te(e.onFocus,N=>{const j=!S.current;if(N.target===N.currentTarget&&j&&!x){const O=new CustomEvent(ua,$y);if(N.currentTarget.dispatchEvent(O),!O.defaultPrevented){const A=E().filter(K=>K.focusable),F=A.find(K=>K.active),H=A.find(K=>K.id===b),J=[F,H,...A].filter(Boolean).map(K=>K.ref.current);qd(J,d)}}S.current=!1}),onBlur:te(e.onBlur,()=>v(!1))})})}),Vd="RovingFocusGroupItem",Kd=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,c=Kt(),u=s||c,d=Hy(Vd,n),f=d.currentTabStopId===u,p=Hd(n),{onFocusableItemAdd:m,onFocusableItemRemove:w,currentTabStopId:b}=d;return h.useEffect(()=>{if(r)return m(),()=>w()},[r,m,w]),l.jsx(da.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:l.jsx(Se.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:te(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:te(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:te(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=Ky(g,d.orientation,d.dir);if(x!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let y=p().filter(E=>E.focusable).map(E=>E.ref.current);if(x==="last")y.reverse();else if(x==="prev"||x==="next"){x==="prev"&&y.reverse();const E=y.indexOf(g.currentTarget);y=d.loop?qy(y,E+1):y.slice(E+1)}setTimeout(()=>qd(y))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:b!=null}):i})})});Kd.displayName=Vd;var Wy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Vy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ky(e,t,n){const r=Vy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Wy[r]}function qd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function qy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Gy=Wd,Yy=Kd,fa=["Enter"," "],Xy=["ArrowDown","PageUp","Home"],Gd=["ArrowUp","PageDown","End"],Jy=[...Xy,...Gd],Zy={ltr:[...fa,"ArrowRight"],rtl:[...fa,"ArrowLeft"]},Qy={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Br="Menu",[Hr,e0,t0]=Vi(Br),[Bn,Yd]=Vt(Br,[t0,cr,Ud]),us=cr(),Xd=Ud(),[n0,Hn]=Bn(Br),[r0,Ur]=Bn(Br),Jd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=us(t),[c,u]=h.useState(null),d=h.useRef(!1),f=dt(s),p=es(o);return h.useEffect(()=>{const m=()=>{d.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>d.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),l.jsx(ia,{...a,children:l.jsx(n0,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:u,children:l.jsx(r0,{scope:t,onClose:h.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:i,children:r})})})};Jd.displayName=Br;var o0="MenuAnchor",ha=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=us(n);return l.jsx(aa,{...o,...r,ref:t})});ha.displayName=o0;var pa="MenuPortal",[s0,Zd]=Bn(pa,{forceMount:void 0}),Qd=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Hn(pa,t);return l.jsx(s0,{scope:t,forceMount:n,children:l.jsx(Tt,{present:n||s.open,children:l.jsx(Lo,{asChild:!0,container:o,children:r})})})};Qd.displayName=pa;var $t="MenuContent",[i0,ma]=Bn($t),ef=h.forwardRef((e,t)=>{const n=Zd($t,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Hn($t,e.__scopeMenu),i=Ur($t,e.__scopeMenu);return l.jsx(Hr.Provider,{scope:e.__scopeMenu,children:l.jsx(Tt,{present:r||s.open,children:l.jsx(Hr.Slot,{scope:e.__scopeMenu,children:i.modal?l.jsx(a0,{...o,ref:t}):l.jsx(l0,{...o,ref:t})})})})}),a0=h.forwardRef((e,t)=>{const n=Hn($t,e.__scopeMenu),r=h.useRef(null),o=Re(t,r);return h.useEffect(()=>{const s=r.current;if(s)return Fi(s)},[]),l.jsx(ga,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:te(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),l0=h.forwardRef((e,t)=>{const n=Hn($t,e.__scopeMenu);return l.jsx(ga,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),c0=Et.createSlot("MenuContent.ScrollLock"),ga=h.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,disableOutsideScroll:w,...b}=e,g=Hn($t,n),x=Ur($t,n),v=us(n),y=Xd(n),E=e0(n),[S,T]=h.useState(null),I=h.useRef(null),N=Re(t,I,g.onContentChange),j=h.useRef(0),O=h.useRef(""),A=h.useRef(0),F=h.useRef(null),H=h.useRef("right"),D=h.useRef(0),J=w?Uo:h.Fragment,K=w?{as:c0,allowPinchZoom:!0}:void 0,oe=M=>{var z,_;const X=O.current+M,Z=E().filter(Y=>!Y.disabled),he=document.activeElement,$=(z=Z.find(Y=>Y.ref.current===he))==null?void 0:z.textValue,G=Z.map(Y=>Y.textValue),ee=y0(G,X,$),pe=(_=Z.find(Y=>Y.textValue===ee))==null?void 0:_.ref.current;(function Y(Q){O.current=Q,window.clearTimeout(j.current),Q!==""&&(j.current=window.setTimeout(()=>Y(""),1e3))})(X),pe&&setTimeout(()=>pe.focus())};h.useEffect(()=>()=>window.clearTimeout(j.current),[]),Pi();const W=h.useCallback(M=>{var Z,he;return H.current===((Z=F.current)==null?void 0:Z.side)&&C0(M,(he=F.current)==null?void 0:he.area)},[]);return l.jsx(i0,{scope:n,searchRef:O,onItemEnter:h.useCallback(M=>{W(M)&&M.preventDefault()},[W]),onItemLeave:h.useCallback(M=>{var X;W(M)||((X=I.current)==null||X.focus(),T(null))},[W]),onTriggerLeave:h.useCallback(M=>{W(M)&&M.preventDefault()},[W]),pointerGraceTimerRef:A,onPointerGraceIntentChange:h.useCallback(M=>{F.current=M},[]),children:l.jsx(J,{...K,children:l.jsx(Do,{asChild:!0,trapped:o,onMountAutoFocus:te(s,M=>{var X;M.preventDefault(),(X=I.current)==null||X.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:l.jsx(Mr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,children:l.jsx(Gy,{asChild:!0,...y,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:T,onEntryFocus:te(c,M=>{x.isUsingKeyboardRef.current||M.preventDefault()}),preventScrollOnEntryFocus:!0,children:l.jsx(la,{role:"menu","aria-orientation":"vertical","data-state":bf(g.open),"data-radix-menu-content":"",dir:x.dir,...v,...b,ref:N,style:{outline:"none",...b.style},onKeyDown:te(b.onKeyDown,M=>{const Z=M.target.closest("[data-radix-menu-content]")===M.currentTarget,he=M.ctrlKey||M.altKey||M.metaKey,$=M.key.length===1;Z&&(M.key==="Tab"&&M.preventDefault(),!he&&$&&oe(M.key));const G=I.current;if(M.target!==G||!Jy.includes(M.key))return;M.preventDefault();const pe=E().filter(z=>!z.disabled).map(z=>z.ref.current);Gd.includes(M.key)&&pe.reverse(),v0(pe)}),onBlur:te(e.onBlur,M=>{M.currentTarget.contains(M.target)||(window.clearTimeout(j.current),O.current="")}),onPointerMove:te(e.onPointerMove,Vr(M=>{const X=M.target,Z=D.current!==M.clientX;if(M.currentTarget.contains(X)&&Z){const he=M.clientX>D.current?"right":"left";H.current=he,D.current=M.clientX}}))})})})})})})});ef.displayName=$t;var u0="MenuGroup",xa=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(Se.div,{role:"group",...r,ref:t})});xa.displayName=u0;var d0="MenuLabel",tf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(Se.div,{...r,ref:t})});tf.displayName=d0;var ds="MenuItem",nf="menu.itemSelect",fs=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=Ur(ds,e.__scopeMenu),a=ma(ds,e.__scopeMenu),c=Re(t,s),u=h.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const p=new CustomEvent(nf,{bubbles:!0,cancelable:!0});f.addEventListener(nf,m=>r==null?void 0:r(m),{once:!0}),Hc(f,p),p.defaultPrevented?u.current=!1:i.onClose()}};return l.jsx(rf,{...o,ref:c,disabled:n,onClick:te(e.onClick,d),onPointerDown:f=>{var p;(p=e.onPointerDown)==null||p.call(e,f),u.current=!0},onPointerUp:te(e.onPointerUp,f=>{var p;u.current||(p=f.currentTarget)==null||p.click()}),onKeyDown:te(e.onKeyDown,f=>{const p=a.searchRef.current!=="";n||p&&f.key===" "||fa.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});fs.displayName=ds;var rf=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ma(ds,n),a=Xd(n),c=h.useRef(null),u=Re(t,c),[d,f]=h.useState(!1),[p,m]=h.useState("");return h.useEffect(()=>{const w=c.current;w&&m((w.textContent??"").trim())},[s.children]),l.jsx(Hr.ItemSlot,{scope:n,disabled:r,textValue:o??p,children:l.jsx(Yy,{asChild:!0,...a,focusable:!r,children:l.jsx(Se.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:te(e.onPointerMove,Vr(w=>{r?i.onItemLeave(w):(i.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:te(e.onPointerLeave,Vr(w=>i.onItemLeave(w))),onFocus:te(e.onFocus,()=>f(!0)),onBlur:te(e.onBlur,()=>f(!1))})})})}),f0="MenuCheckboxItem",of=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return l.jsx(uf,{scope:e.__scopeMenu,checked:n,children:l.jsx(fs,{role:"menuitemcheckbox","aria-checked":hs(n)?"mixed":n,...o,ref:t,"data-state":va(n),onSelect:te(o.onSelect,()=>r==null?void 0:r(hs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});of.displayName=f0;var sf="MenuRadioGroup",[h0,p0]=Bn(sf,{value:void 0,onValueChange:()=>{}}),af=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=dt(r);return l.jsx(h0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:l.jsx(xa,{...o,ref:t})})});af.displayName=sf;var lf="MenuRadioItem",cf=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=p0(lf,e.__scopeMenu),s=n===o.value;return l.jsx(uf,{scope:e.__scopeMenu,checked:s,children:l.jsx(fs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":va(s),onSelect:te(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});cf.displayName=lf;var ba="MenuItemIndicator",[uf,m0]=Bn(ba,{checked:!1}),df=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=m0(ba,n);return l.jsx(Tt,{present:r||hs(s.checked)||s.checked===!0,children:l.jsx(Se.span,{...o,ref:t,"data-state":va(s.checked)})})});df.displayName=ba;var g0="MenuSeparator",ff=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(Se.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});ff.displayName=g0;var x0="MenuArrow",hf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=us(n);return l.jsx(ca,{...o,...r,ref:t})});hf.displayName=x0;var b0="MenuSub",[JT,pf]=Bn(b0),Wr="MenuSubTrigger",mf=h.forwardRef((e,t)=>{const n=Hn(Wr,e.__scopeMenu),r=Ur(Wr,e.__scopeMenu),o=pf(Wr,e.__scopeMenu),s=ma(Wr,e.__scopeMenu),i=h.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:c}=s,u={__scopeMenu:e.__scopeMenu},d=h.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return h.useEffect(()=>d,[d]),h.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),c(null)}},[a,c]),l.jsx(ha,{asChild:!0,...u,children:l.jsx(rf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":bf(n.open),...e,ref:wi(t,o.onTriggerChange),onClick:f=>{var p;(p=e.onClick)==null||p.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:te(e.onPointerMove,Vr(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:te(e.onPointerLeave,Vr(f=>{var m,w;d();const p=(m=n.content)==null?void 0:m.getBoundingClientRect();if(p){const b=(w=n.content)==null?void 0:w.dataset.side,g=b==="right",x=g?-5:5,v=p[g?"left":"right"],y=p[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+x,y:f.clientY},{x:v,y:p.top},{x:y,y:p.top},{x:y,y:p.bottom},{x:v,y:p.bottom}],side:b}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:te(e.onKeyDown,f=>{var m;const p=s.searchRef.current!=="";e.disabled||p&&f.key===" "||Zy[r.dir].includes(f.key)&&(n.onOpenChange(!0),(m=n.content)==null||m.focus(),f.preventDefault())})})})});mf.displayName=Wr;var gf="MenuSubContent",xf=h.forwardRef((e,t)=>{const n=Zd($t,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Hn($t,e.__scopeMenu),i=Ur($t,e.__scopeMenu),a=pf(gf,e.__scopeMenu),c=h.useRef(null),u=Re(t,c);return l.jsx(Hr.Provider,{scope:e.__scopeMenu,children:l.jsx(Tt,{present:r||s.open,children:l.jsx(Hr.Slot,{scope:e.__scopeMenu,children:l.jsx(ga,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=c.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:te(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:te(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:te(e.onKeyDown,d=>{var m;const f=d.currentTarget.contains(d.target),p=Qy[i.dir].includes(d.key);f&&p&&(s.onOpenChange(!1),(m=a.trigger)==null||m.focus(),d.preventDefault())})})})})})});xf.displayName=gf;function bf(e){return e?"open":"closed"}function hs(e){return e==="indeterminate"}function va(e){return hs(e)?"indeterminate":e?"checked":"unchecked"}function v0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function w0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function y0(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=w0(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function S0(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],c=t[i],u=a.x,d=a.y,f=c.x,p=c.y;d>r!=p>r&&n<(f-u)*(r-d)/(p-d)+u&&(o=!o)}return o}function C0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return S0(n,t)}function Vr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var T0=Jd,k0=ha,E0=Qd,I0=ef,N0=xa,j0=tf,A0=fs,R0=of,_0=af,P0=cf,O0=df,M0=ff,D0=hf,L0=mf,$0=xf,ps="DropdownMenu",[F0,ZT]=Vt(ps,[Yd]),vt=Yd(),[z0,vf]=F0(ps),wf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,c=vt(t),u=h.useRef(null),[d,f]=wn({prop:o,defaultProp:s??!1,onChange:i,caller:ps});return l.jsx(z0,{scope:t,triggerId:Kt(),triggerRef:u,contentId:Kt(),open:d,onOpenChange:f,onOpenToggle:h.useCallback(()=>f(p=>!p),[f]),modal:a,children:l.jsx(T0,{...c,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};wf.displayName=ps;var yf="DropdownMenuTrigger",Sf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=vf(yf,n),i=vt(n);return l.jsx(k0,{asChild:!0,...i,children:l.jsx(Se.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:wi(t,s.triggerRef),onPointerDown:te(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:te(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Sf.displayName=yf;var B0="DropdownMenuPortal",Cf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=vt(t);return l.jsx(E0,{...r,...n})};Cf.displayName=B0;var Tf="DropdownMenuContent",kf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vf(Tf,n),s=vt(n),i=h.useRef(!1);return l.jsx(I0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:te(e.onCloseAutoFocus,a=>{var c;i.current||(c=o.triggerRef.current)==null||c.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:te(e.onInteractOutside,a=>{const c=a.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,d=c.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)"}})});kf.displayName=Tf;var H0="DropdownMenuGroup",U0=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(N0,{...o,...r,ref:t})});U0.displayName=H0;var W0="DropdownMenuLabel",Ef=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(j0,{...o,...r,ref:t})});Ef.displayName=W0;var V0="DropdownMenuItem",If=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(A0,{...o,...r,ref:t})});If.displayName=V0;var K0="DropdownMenuCheckboxItem",Nf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(R0,{...o,...r,ref:t})});Nf.displayName=K0;var q0="DropdownMenuRadioGroup",G0=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(_0,{...o,...r,ref:t})});G0.displayName=q0;var Y0="DropdownMenuRadioItem",jf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(P0,{...o,...r,ref:t})});jf.displayName=Y0;var X0="DropdownMenuItemIndicator",Af=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(O0,{...o,...r,ref:t})});Af.displayName=X0;var J0="DropdownMenuSeparator",Rf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(M0,{...o,...r,ref:t})});Rf.displayName=J0;var Z0="DropdownMenuArrow",Q0=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(D0,{...o,...r,ref:t})});Q0.displayName=Z0;var eS="DropdownMenuSubTrigger",_f=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(L0,{...o,...r,ref:t})});_f.displayName=eS;var tS="DropdownMenuSubContent",Pf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx($0,{...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)"}})});Pf.displayName=tS;var nS=wf,rS=Sf,oS=Cf,Of=kf,Mf=Ef,Df=If,Lf=Nf,$f=jf,Ff=Af,zf=Rf,Bf=_f,Hf=Pf;const sS=nS,iS=rS,aS=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>l.jsxs(Bf,{ref:o,className:L("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,l.jsx(se.ChevronRight,{className:"ml-auto h-4 w-4"})]}));aS.displayName=Bf.displayName;const lS=h.forwardRef(({className:e,...t},n)=>l.jsx(Hf,{ref:n,className:L("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}));lS.displayName=Hf.displayName;const Uf=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>l.jsx(oS,{children:l.jsx(Of,{ref:r,sideOffset:t,className:L("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})}));Uf.displayName=Of.displayName;const wa=h.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(Df,{ref:r,className:L("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=Df.displayName;const cS=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>l.jsxs(Lf,{ref:o,className:L("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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Ff,{children:l.jsx(se.Check,{className:"h-4 w-4"})})}),t]}));cS.displayName=Lf.displayName;const uS=h.forwardRef(({className:e,children:t,...n},r)=>l.jsxs($f,{ref:r,className:L("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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Ff,{children:l.jsx(se.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));uS.displayName=$f.displayName;const dS=h.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(Mf,{ref:r,className:L("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));dS.displayName=Mf.displayName;const fS=h.forwardRef(({className:e,...t},n)=>l.jsx(zf,{ref:n,className:L("-mx-1 my-1 h-px bg-muted",e),...t}));fS.displayName=zf.displayName;function Kr({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:c=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:p,onError:m}){const{currentThreadId:w,messages:b,isStreaming:g,streamingAssistantId:x,error:v,send:y,stop:E,lastCheckpointId:S,lastCheckpointNs:T,listCheckpoints:I,navigateToCheckpoint:N,returnToLatest:j,hasMoreHistory:O,isLoadingHistory:A,loadOlderMessages:F,api:H}=ho(),[D,J]=C.useState(null),[K,oe]=C.useState(""),[W,M]=C.useState(null),[X,Z]=C.useState([]),[he,$]=C.useState(!1),[G,ee]=C.useState(null),[pe,z]=C.useState(null),[_,Y]=C.useState(!1),[Q,de]=C.useState(null),[ne,_e]=C.useState([]),[Pe,Ue]=C.useState(null),[Ee,Ae]=C.useState(null),[et,qe]=C.useState(!1),ct=C.useRef(null),ut=C.useRef(null),ve=C.useRef(null),[Fe,Ge]=C.useState("desktop");C.useEffect(()=>{const re=()=>{const me=window.innerWidth;Ge(me<640?"phone":me<1024?"tablet":"desktop")};return re(),window.addEventListener("resize",re),()=>window.removeEventListener("resize",re)},[]),C.useEffect(()=>{let re=!1;if(!w){_e([]),Ue(null),Ae(null),ve.current=null;return}const me={threadId:w,checkpointId:S??null,checkpointNs:T??null},De=ve.current;if(!(De&&De.threadId===me.threadId&&De.checkpointId===me.checkpointId&&De.checkpointNs===me.checkpointNs))return I(w).then(Xe=>{var Zr;if(re)return;const ln=((Xe==null?void 0:Xe.checkpoints)??[]).slice().sort((pn,Qr)=>new Date(Qr.createdAt).getTime()-new Date(pn.createdAt).getTime());_e(ln);const cn=Pe,Xr=cn&&ln.some(pn=>pn.checkpointId===cn)?cn:((Zr=ln[0])==null?void 0:Zr.checkpointId)??null;let Jr=null;if(Xr){const pn=ln.find(Qr=>Qr.checkpointId===Xr);Jr=(pn==null?void 0:pn.checkpointNs)??null}Ue(Xr),Ae(Jr),ve.current=me}).catch(Xe=>{console.error("ChatInterface - listCheckpoints error:",Xe),re||(_e([]),ve.current=null)}),()=>{re=!0}},[w,S,T,Pe,I]),C.useEffect(()=>{S&&(Ue(S),Ae(T??null))},[S,T]);const P=C.useCallback(async()=>{if(!(!O||A))try{await F()}catch(re){console.warn("loadOlderMessages failed",re)}},[O,A,F]);C.useEffect(()=>{(async()=>{try{const me=await H.getAgent("default");de(me.uiDefaultMessage||null)}catch(me){console.warn("Failed to fetch default message:",me),de(null)}})()},[H]),C.useEffect(()=>{v&&!_&&(m==null||m(v))},[v,_,m]);const U=re=>{if(re.length>Qo)return`Message too long (${re.length}/${Qo} characters)`;try{return bw(re),null}catch(me){return(me==null?void 0:me.message)||"Invalid message"}},ue=async re=>{const me=re.trim();if(!(!me&&X.length===0)){if(me){const De=U(me);if(De){M(De);return}}try{await y(me||"",{checkpointId:Pe??S??void 0,checkpointNs:Ee??T??void 0,payloadExtras:D?{edit:!0,originalMessageId:D}:void 0,attachments:X}),f==null||f(me),M(null),Z([]),J(null),oe("")}catch(De){const Xe=(De==null?void 0:De.message)||"Failed to send message";M(Xe),m==null||m(Xe)}}},be=C.useCallback((re,me)=>{u&&(J(re),oe(me),M(null))},[u]),le=C.useCallback(()=>{J(null),oe(""),M(null)},[]),Be=C.useCallback((re,me)=>{be(re,me)},[be]),at=C.useCallback(re=>{const me=De=>{const Xe=De.content||[],ln=Xe.filter(cn=>cn.type==="text").map(cn=>cn.text).join("");if(ln)return ln;try{return JSON.stringify(Xe,null,2)}catch{return String(Xe)}};for(let De=re-1;De>=0;De--)if(b[De].role==="user"){const Xe=me(b[De]);Xe&&y(Xe,{checkpointId:Pe??S??void 0,checkpointNs:Ee??T??void 0});break}},[b,y,Pe,Ee,S,T]),hn=re=>{const me=Array.from(re.target.files||[]);Z(De=>[...De,...me])},xt=re=>Z(me=>me.filter((De,Xe)=>re!==Xe)),_t=async re=>{const me=(re.target.files||[])[0];if(me){ee(null),z(null),$(!0);try{await y("",{checkpointId:Pe??S??void 0,checkpointNs:Ee??T??void 0,attachments:[me]});const De=`Uploaded ${me.name} - processing through chat stream`;z(De)}catch(De){const Xe=De instanceof Error?De.message:"Failed to upload Excel file";console.error("Excel upload failed",De),ee(Xe),m==null||m(Xe)}finally{$(!1),re.target.value=""}}},ft=re=>{if(!re)return"Unknown";const me=Date.parse(re);return Number.isNaN(me)?re:new Date(me).toLocaleString()},Pt=async re=>{if(w){qe(!0);try{if(!re){await j(),Ue(null),Ae(null);return}const me=ne.find(Xe=>Xe.checkpointId===re),De=(me==null?void 0:me.checkpointNs)??null;await N(re,De),Ue(re),Ae(De)}finally{qe(!1)}}},jn=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,Kn=`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||""}`,qn=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return l.jsxs("div",{className:jn,children:[!!v&&!_&&l.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:[l.jsx("span",{children:v}),l.jsx(ze,{variant:"ghost",size:"sm",onClick:()=>Y(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:l.jsx(se.X,{size:16})})]}),w&&ne.length>0&&l.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:[l.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),l.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:re=>{const me=re.target.value||null;Pt(me)},children:[l.jsx("option",{value:"",children:"Latest"}),ne.map(re=>l.jsxs("option",{value:re.checkpointId,children:[ft(re.createdAt),re.preview?` — ${re.preview.slice(0,40)}`:""]},re.checkpointId))]})]}),l.jsx(Wi,{className:Kn,style:r?{maxHeight:r}:void 0,messages:b,isStreaming:g,streamingAssistantId:x,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Fe,enableMessageEditing:u,editingMessageId:D,onStartReached:()=>{P()},onEdit:Be,onRegenerate:at,onCancelEdit:le,emptyMessage:Q??void 0,isNavigatingCheckpoint:et}),l.jsxs("div",{className:qn,children:[D&&l.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(se.Edit3,{size:16,className:"text-blue-600"}),l.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),l.jsx(ze,{variant:"ghost",size:"sm",onClick:le,className:"text-blue-600 hover:bg-blue-100",children:l.jsx(se.X,{size:16})})]})}),(a||c)&&l.jsxs("div",{className:"mb-3 space-y-3",children:[a&&l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:ct,type:"file",multiple:!0,onChange:re=>hn(re),className:"hidden"}),X.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2",children:X.map((re,me)=>l.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:[l.jsx(se.Paperclip,{size:14}),l.jsx("span",{className:"truncate max-w-[150px]",children:re.name}),l.jsx(ze,{variant:"ghost",size:"sm",onClick:()=>xt(me),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 ${re.name}`,children:l.jsx(se.X,{size:12})})]},me))})]}),c&&l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:ut,type:"file",accept:".xls,.xlsx,.xlsm",onChange:_t,className:"hidden"}),he&&l.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[l.jsx(se.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),pe&&!he&&l.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:pe}),G&&!he&&l.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:G})]})]}),W&&l.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:W}),l.jsxs("div",{className:"flex items-end gap-2",children:[(a||c)&&l.jsxs(sS,{children:[l.jsx(iS,{asChild:!0,children:l.jsx(ze,{type:"button",size:"icon",variant:"outline",disabled:g,title:"More input actions",className:d.moreButton||"",children:l.jsx(se.Plus,{size:16})})}),l.jsxs(Uf,{align:"start",sideOffset:6,className:"w-52",children:[a&&l.jsxs(wa,{onClick:()=>{var re;return(re=ct.current)==null?void 0:re.click()},className:"cursor-pointer",children:[l.jsx(se.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),c&&l.jsxs(wa,{onClick:()=>{var re;he||(re=ut.current)==null||re.click()},className:`cursor-pointer ${he?"opacity-60 pointer-events-none":""}`,children:[l.jsx(se.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),l.jsx("div",{className:"flex-1",children:l.jsx(jg,{initialValue:K,editingMessageId:D,placeholder:D?"Edit your message...":t,isStreaming:g,disabled:!1,maxLength:Qo,onSend:ue,onCancelEdit:le,onStop:E,allowEmptySend:X.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${D?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${W?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const qr=h.forwardRef(({className:e,type:t,...n},r)=>l.jsx("input",{type:t,className:L("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}));qr.displayName="Input";function ya(e,[t,n]){return Math.min(n,Math.max(t,e))}function hS(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Sa="ScrollArea",[Wf,QT]=Vt(Sa),[pS,Ft]=Wf(Sa),Vf=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,c]=h.useState(null),[u,d]=h.useState(null),[f,p]=h.useState(null),[m,w]=h.useState(null),[b,g]=h.useState(null),[x,v]=h.useState(0),[y,E]=h.useState(0),[S,T]=h.useState(!1),[I,N]=h.useState(!1),j=Re(t,A=>c(A)),O=es(o);return l.jsx(pS,{scope:n,type:r,dir:O,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:p,scrollbarX:m,onScrollbarXChange:w,scrollbarXEnabled:S,onScrollbarXEnabledChange:T,scrollbarY:b,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:N,onCornerWidthChange:v,onCornerHeightChange:E,children:l.jsx(Se.div,{dir:O,...i,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":y+"px",...e.style}})})});Vf.displayName=Sa;var Kf="ScrollAreaViewport",qf=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Ft(Kf,n),a=h.useRef(null),c=Re(t,a,i.onViewportChange);return l.jsxs(l.Fragment,{children:[l.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}),l.jsx(Se.div,{"data-radix-scroll-area-viewport":"",...s,ref:c,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:l.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});qf.displayName=Kf;var an="ScrollAreaScrollbar",Ca=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ft(an,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return h.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?l.jsx(mS,{...r,ref:t,forceMount:n}):o.type==="scroll"?l.jsx(gS,{...r,ref:t,forceMount:n}):o.type==="auto"?l.jsx(Gf,{...r,ref:t,forceMount:n}):o.type==="always"?l.jsx(Ta,{...r,ref:t}):null});Ca.displayName=an;var mS=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ft(an,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let c=0;if(a){const u=()=>{window.clearTimeout(c),i(!0)},d=()=>{c=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),l.jsx(Tt,{present:n||s,children:l.jsx(Gf,{"data-state":s?"visible":"hidden",...r,ref:t})})}),gS=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ft(an,e.__scopeScrollArea),s=e.orientation==="horizontal",i=bs(()=>c("SCROLL_END"),100),[a,c]=hS("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 h.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,c]),h.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const p=()=>{const m=u[d];f!==m&&(c("SCROLL"),i()),f=m};return u.addEventListener("scroll",p),()=>u.removeEventListener("scroll",p)}},[o.viewport,s,c,i]),l.jsx(Tt,{present:n||a!=="hidden",children:l.jsx(Ta,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:te(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:te(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),Gf=h.forwardRef((e,t)=>{const n=Ft(an,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",c=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 ur(n.viewport,c),ur(n.content,c),l.jsx(Tt,{present:r||s,children:l.jsx(Ta,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Ta=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Ft(an,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,c]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=Qf(a.viewport,a.content),d={...r,sizes:a,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:p=>s.current=p,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:p=>i.current=p};function f(p,m){return SS(p,i.current,a,m)}return n==="horizontal"?l.jsx(xS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollLeft,m=eh(p,a,o.dir);s.current.style.transform=`translate3d(${m}px, 0, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollLeft=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollLeft=f(p,o.dir))}}):n==="vertical"?l.jsx(bS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollTop,m=eh(p,a);s.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollTop=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollTop=f(p))}}):null}),xS=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Ft(an,e.__scopeScrollArea),[i,a]=h.useState(),c=h.useRef(null),u=Re(t,c,s.onScrollbarXChange);return h.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(Xf,{"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":xs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const p=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(p),nh(p,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:gs(i.paddingLeft),paddingEnd:gs(i.paddingRight)}})}})}),bS=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Ft(an,e.__scopeScrollArea),[i,a]=h.useState(),c=h.useRef(null),u=Re(t,c,s.onScrollbarYChange);return h.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(Xf,{"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":xs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const p=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(p),nh(p,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:gs(i.paddingTop),paddingEnd:gs(i.paddingBottom)}})}})}),[vS,Yf]=Wf(an),Xf=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:f,...p}=e,m=Ft(an,n),[w,b]=h.useState(null),g=Re(t,j=>b(j)),x=h.useRef(null),v=h.useRef(""),y=m.viewport,E=r.content-r.viewport,S=dt(d),T=dt(c),I=bs(f,10);function N(j){if(x.current){const O=j.clientX-x.current.left,A=j.clientY-x.current.top;u({x:O,y:A})}}return h.useEffect(()=>{const j=O=>{const A=O.target;(w==null?void 0:w.contains(A))&&S(O,E)};return document.addEventListener("wheel",j,{passive:!1}),()=>document.removeEventListener("wheel",j,{passive:!1})},[y,w,E,S]),h.useEffect(T,[r,T]),ur(w,I),ur(m.content,I),l.jsx(vS,{scope:n,scrollbar:w,hasThumb:o,onThumbChange:dt(s),onThumbPointerUp:dt(i),onThumbPositionChange:T,onThumbPointerDown:dt(a),children:l.jsx(Se.div,{...p,ref:g,style:{position:"absolute",...p.style},onPointerDown:te(e.onPointerDown,j=>{j.button===0&&(j.target.setPointerCapture(j.pointerId),x.current=w.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),N(j))}),onPointerMove:te(e.onPointerMove,N),onPointerUp:te(e.onPointerUp,j=>{const O=j.target;O.hasPointerCapture(j.pointerId)&&O.releasePointerCapture(j.pointerId),document.body.style.webkitUserSelect=v.current,m.viewport&&(m.viewport.style.scrollBehavior=""),x.current=null})})})}),ms="ScrollAreaThumb",Jf=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Yf(ms,e.__scopeScrollArea);return l.jsx(Tt,{present:n||o.hasThumb,children:l.jsx(wS,{ref:t,...r})})}),wS=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Ft(ms,n),i=Yf(ms,n),{onThumbPositionChange:a}=i,c=Re(t,f=>i.onThumbChange(f)),u=h.useRef(void 0),d=bs(()=>{u.current&&(u.current(),u.current=void 0)},100);return h.useEffect(()=>{const f=s.viewport;if(f){const p=()=>{if(d(),!u.current){const m=CS(f,a);u.current=m,a()}};return a(),f.addEventListener("scroll",p),()=>f.removeEventListener("scroll",p)}},[s.viewport,d,a]),l.jsx(Se.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:te(e.onPointerDownCapture,f=>{const m=f.target.getBoundingClientRect(),w=f.clientX-m.left,b=f.clientY-m.top;i.onThumbPointerDown({x:w,y:b})}),onPointerUp:te(e.onPointerUp,i.onThumbPointerUp)})});Jf.displayName=ms;var ka="ScrollAreaCorner",Zf=h.forwardRef((e,t)=>{const n=Ft(ka,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?l.jsx(yS,{...e,ref:t}):null});Zf.displayName=ka;var yS=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Ft(ka,n),[s,i]=h.useState(0),[a,c]=h.useState(0),u=!!(s&&a);return ur(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),c(d)}),ur(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?l.jsx(Se.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 gs(e){return e?parseInt(e,10):0}function Qf(e,t){const n=e/t;return isNaN(n)?0:n}function xs(e){const t=Qf(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function SS(e,t,n,r="ltr"){const o=xs(n),s=o/2,i=t||s,a=o-i,c=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 th([c,u],f)(e)}function eh(e,t,n="ltr"){const r=xs(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,c=n==="ltr"?[0,i]:[i*-1,0],u=ya(e,c);return th([0,i],[0,a])(u)}function th(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function nh(e,t){return e>0&&e<t}var CS=(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=dt(e),r=h.useRef(0);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),h.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function ur(e,t){const n=dt(t);lt(()=>{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 rh=Vf,TS=qf,kS=Zf;const oh=h.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(rh,{ref:r,className:L("relative overflow-hidden",e),...n,children:[l.jsx(TS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),l.jsx(sh,{}),l.jsx(kS,{})]}));oh.displayName=rh.displayName;const sh=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>l.jsx(Ca,{ref:r,orientation:t,className:L("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:l.jsx(Jf,{className:"relative flex-1 rounded-full bg-border"})}));sh.displayName=Ca.displayName;function vs({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:c,onThreadCreate:u,onThreadDelete:d}){const{loadThread:f,threads:p,refreshThreads:m,currentThreadId:w,createThread:b,deleteThread:g,renameThread:x}=ho(),[v,y]=C.useState(p??[]),[E,S]=C.useState(!1),[T,I]=C.useState(null),[N,j]=C.useState(null),[O,A]=C.useState(""),[F,H]=C.useState(!1);C.useEffect(()=>{y(p??[])},[p]);const D=async $=>{try{await f($),a==null||a($),c==null||c($)}catch(G){console.error("Failed to select thread:",G)}},J=async()=>{try{H(!0);const $=await b();u==null||u($),a==null||a($)}catch($){console.error("Failed to create thread:",$)}finally{H(!1)}},K=async($,G)=>{if(G.stopPropagation(),!!confirm("Delete this thread?"))try{await g($),d==null||d($)}catch(ee){console.error("Failed to delete thread:",ee)}},oe=($,G)=>{G.stopPropagation(),j($.threadId),A($.title||`Thread ${$.threadId.slice(0,8)}`)},W=async $=>{if(O.trim())try{await x($,O.trim()),j(null),A("")}catch(G){console.error("Failed to update title:",G)}},M=()=>{j(null),A("")},X=($,G)=>{$.key==="Enter"?W(G):$.key==="Escape"&&M()},Z=$=>{if(!$)return"";try{const G=new Date($),pe=new Date().getTime()-G.getTime(),z=Math.floor(pe/(1e3*60*60*24));return z===0?G.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):z===1?"Yesterday":z<7?`${z} days ago`:G.toLocaleDateString()}catch{return""}},he=$=>$.title||`Thread ${$.threadId.slice(0,8)}`;return l.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&l.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:l.jsx(ze,{onClick:J,disabled:F||E,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:F?"Creating...":"New Chat",children:l.jsx(se.MessageSquarePlus,{size:20})})}),l.jsx(oh,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:l.jsx("div",{className:"p-2 space-y-1 pb-4",children:E?l.jsx("div",{className:"text-center py-8 text-slate-400",children:"Loading…"}):v.length===0?l.jsxs("div",{className:"text-center py-8 text-slate-400",children:[l.jsx(se.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),l.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):v.slice().sort(($,G)=>new Date(G.updatedAt||G.createdAt||"").getTime()-new Date($.updatedAt||$.createdAt||"").getTime()).map($=>l.jsxs("div",{onClick:()=>D($.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??w)===$.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:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("div",{className:"flex-1 min-w-0",children:N===$.threadId?l.jsxs("div",{className:"flex items-center gap-2",onClick:G=>G.stopPropagation(),children:[l.jsx(qr,{value:O,onChange:G=>A(G.target.value),onKeyDown:G=>X(G,$.threadId),className:"h-6 text-sm",autoFocus:!0}),l.jsx(ze,{variant:"ghost",size:"sm",onClick:()=>W($.threadId),className:"h-6 w-6 p-0",children:l.jsx(se.Check,{size:12})}),l.jsx(ze,{variant:"ghost",size:"sm",onClick:M,className:"h-6 w-6 p-0",children:l.jsx(se.X,{size:12})})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:he($)}),l.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[l.jsx(se.Calendar,{size:10}),l.jsx("span",{children:Z($.updatedAt||$.createdAt)})]})]})}),l.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&N!==$.threadId&&l.jsx(ze,{variant:"ghost",size:"sm",onClick:G=>oe($,G),className:"h-6 w-6 p-0",title:"Edit title",children:l.jsx(se.Edit3,{size:12})}),n&&l.jsx(ze,{variant:"ghost",size:"sm",onClick:G=>K($.threadId,G),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:l.jsx(se.Trash2,{size:12})})]})]}),i===$.threadId&&l.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},$.threadId))})})]})}const ih=C.createContext(null);function ES({children:e,basePath:t="/chat"}){const n=C.useMemo(()=>t?t==="/"?"":t.endsWith("/")?t.slice(0,-1):t:"/chat",[t]),r={basePath:n,buildThreadPath:o=>`${n}/${o}`,buildBasePath:()=>n};return l.jsx(ih.Provider,{value:r,children:e})}function IS(){const e=C.useContext(ih);return e||{basePath:"/chat",buildThreadPath:t=>`/chat/${t}`,buildBasePath:()=>"/chat"}}const Ea=768;function NS(){const[e,t]=h.useState(void 0);return h.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Ea-1}px)`),r=()=>{t(window.innerWidth<Ea)};return n.addEventListener("change",r),t(window.innerWidth<Ea),()=>n.removeEventListener("change",r)},[]),!!e}var jS="Separator",ah="horizontal",AS=["horizontal","vertical"],lh=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=ah,...o}=e,s=RS(r)?r:ah,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return l.jsx(Se.div,{"data-orientation":s,...a,...o,ref:t})});lh.displayName=jS;function RS(e){return AS.includes(e)}var ch=lh;const Ia=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>l.jsx(ch,{ref:o,decorative:n,orientation:t,className:L("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Ia.displayName=ch.displayName;const uh=Yu,_S=Jv,PS=Xu,dh=h.forwardRef(({className:e,...t},n)=>l.jsx(Go,{className:L("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}));dh.displayName=Go.displayName;const OS=mr.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"}}),Na=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>l.jsxs(PS,{children:[l.jsx(dh,{}),l.jsxs(Yo,{ref:o,className:L(OS({side:e}),t),...r,children:[n,l.jsxs(Ju,{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:[l.jsx(se.X,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Na.displayName=Yo.displayName;const fh=({className:e,...t})=>l.jsx("div",{className:L("flex flex-col space-y-2 text-center sm:text-left",e),...t});fh.displayName="SheetHeader";const hh=h.forwardRef(({className:e,...t},n)=>l.jsx(Fn,{ref:n,className:L("text-lg font-semibold text-foreground",e),...t}));hh.displayName=Fn.displayName;const ph=h.forwardRef(({className:e,...t},n)=>l.jsx(Xo,{ref:n,className:L("text-sm text-muted-foreground",e),...t}));ph.displayName=Xo.displayName;function mh({className:e,...t}){return l.jsx("div",{className:L("animate-pulse rounded-md bg-muted",e),...t})}var gh=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),MS="VisuallyHidden",xh=h.forwardRef((e,t)=>l.jsx(Se.span,{...e,ref:t,style:{...gh,...e.style}}));xh.displayName=MS;var DS=xh,[ws,ek]=Vt("Tooltip",[cr]),ys=cr(),bh="TooltipProvider",LS=700,ja="tooltip.open",[$S,Aa]=ws(bh),vh=e=>{const{__scopeTooltip:t,delayDuration:n=LS,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),c=h.useRef(0);return h.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),l.jsx($S,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(c.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(u=>{a.current=u},[]),disableHoverableContent:o,children:s})};vh.displayName=bh;var Gr="Tooltip",[FS,Ss]=ws(Gr),wh=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,c=Aa(Gr,e.__scopeTooltip),u=ys(t),[d,f]=h.useState(null),p=Kt(),m=h.useRef(0),w=i??c.disableHoverableContent,b=a??c.delayDuration,g=h.useRef(!1),[x,v]=wn({prop:r,defaultProp:o??!1,onChange:I=>{I?(c.onOpen(),document.dispatchEvent(new CustomEvent(ja))):c.onClose(),s==null||s(I)},caller:Gr}),y=h.useMemo(()=>x?g.current?"delayed-open":"instant-open":"closed",[x]),E=h.useCallback(()=>{window.clearTimeout(m.current),m.current=0,g.current=!1,v(!0)},[v]),S=h.useCallback(()=>{window.clearTimeout(m.current),m.current=0,v(!1)},[v]),T=h.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{g.current=!0,v(!0),m.current=0},b)},[b,v]);return h.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),l.jsx(ia,{...u,children:l.jsx(FS,{scope:t,contentId:p,open:x,stateAttribute:y,trigger:d,onTriggerChange:f,onTriggerEnter:h.useCallback(()=>{c.isOpenDelayedRef.current?T():E()},[c.isOpenDelayedRef,T,E]),onTriggerLeave:h.useCallback(()=>{w?S():(window.clearTimeout(m.current),m.current=0)},[S,w]),onOpen:E,onClose:S,disableHoverableContent:w,children:n})})};wh.displayName=Gr;var Ra="TooltipTrigger",yh=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Ss(Ra,n),s=Aa(Ra,n),i=ys(n),a=h.useRef(null),c=Re(t,a,o.onTriggerChange),u=h.useRef(!1),d=h.useRef(!1),f=h.useCallback(()=>u.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),l.jsx(aa,{asChild:!0,...i,children:l.jsx(Se.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,onPointerMove:te(e.onPointerMove,p=>{p.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:te(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:te(e.onPointerDown,()=>{o.open&&o.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:te(e.onFocus,()=>{u.current||o.onOpen()}),onBlur:te(e.onBlur,o.onClose),onClick:te(e.onClick,o.onClose)})})});yh.displayName=Ra;var zS="TooltipPortal",[tk,BS]=ws(zS,{forceMount:void 0}),dr="TooltipContent",Sh=h.forwardRef((e,t)=>{const n=BS(dr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=Ss(dr,e.__scopeTooltip);return l.jsx(Tt,{present:r||i.open,children:i.disableHoverableContent?l.jsx(Ch,{side:o,...s,ref:t}):l.jsx(HS,{side:o,...s,ref:t})})}),HS=h.forwardRef((e,t)=>{const n=Ss(dr,e.__scopeTooltip),r=Aa(dr,e.__scopeTooltip),o=h.useRef(null),s=Re(t,o),[i,a]=h.useState(null),{trigger:c,onClose:u}=n,d=o.current,{onPointerInTransitChange:f}=r,p=h.useCallback(()=>{a(null),f(!1)},[f]),m=h.useCallback((w,b)=>{const g=w.currentTarget,x={x:w.clientX,y:w.clientY},v=qS(x,g.getBoundingClientRect()),y=GS(x,v),E=YS(b.getBoundingClientRect()),S=JS([...y,...E]);a(S),f(!0)},[f]);return h.useEffect(()=>()=>p(),[p]),h.useEffect(()=>{if(c&&d){const w=g=>m(g,d),b=g=>m(g,c);return c.addEventListener("pointerleave",w),d.addEventListener("pointerleave",b),()=>{c.removeEventListener("pointerleave",w),d.removeEventListener("pointerleave",b)}}},[c,d,m,p]),h.useEffect(()=>{if(i){const w=b=>{const g=b.target,x={x:b.clientX,y:b.clientY},v=(c==null?void 0:c.contains(g))||(d==null?void 0:d.contains(g)),y=!XS(x,i);v?p():y&&(p(),u())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[c,d,i,u,p]),l.jsx(Ch,{...e,ref:s})}),[US,WS]=ws(Gr,{isInside:!1}),VS=Et.createSlottable("TooltipContent"),Ch=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,c=Ss(dr,n),u=ys(n),{onClose:d}=c;return h.useEffect(()=>(document.addEventListener(ja,d),()=>document.removeEventListener(ja,d)),[d]),h.useEffect(()=>{if(c.trigger){const f=p=>{const m=p.target;m!=null&&m.contains(c.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,d]),l.jsx(Mr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:l.jsxs(la,{"data-state":c.stateAttribute,...u,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[l.jsx(VS,{children:r}),l.jsx(US,{scope:n,isInside:!0,children:l.jsx(DS,{id:c.contentId,role:"tooltip",children:o||r})})]})})});Sh.displayName=dr;var Th="TooltipArrow",KS=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ys(n);return WS(Th,n).isInside?null:l.jsx(ca,{...o,...r,ref:t})});KS.displayName=Th;function qS(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function GS(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function YS(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function XS(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],c=t[i],u=a.x,d=a.y,f=c.x,p=c.y;d>r!=p>r&&n<(f-u)*(r-d)/(p-d)+u&&(o=!o)}return o}function JS(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),ZS(t)}function ZS(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var QS=vh,eC=wh,tC=yh,kh=Sh;const nC=QS,rC=eC,oC=tC,Eh=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>l.jsx(kh,{ref:r,sideOffset:t,className:L("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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}));Eh.displayName=kh.displayName;const sC="sidebar:state",iC=60*60*24*7,aC="16rem",lC="18rem",cC="3rem",uC="b",Ih=h.createContext(null);function Cs(){const e=h.useContext(Ih);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Nh=h.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:o,children:s,...i},a)=>{const c=NS(),[u,d]=h.useState(!1),[f,p]=h.useState(e),m=t??f,w=h.useCallback(v=>{const y=typeof v=="function"?v(m):v;n?n(y):p(y),document.cookie=`${sC}=${y}; path=/; max-age=${iC}`},[n,m]),b=h.useCallback(()=>c?d(v=>!v):w(v=>!v),[c,w,d]);h.useEffect(()=>{const v=y=>{y.key===uC&&(y.metaKey||y.ctrlKey)&&(y.preventDefault(),b())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[b]);const g=m?"expanded":"collapsed",x=h.useMemo(()=>({state:g,open:m,setOpen:w,isMobile:c,openMobile:u,setOpenMobile:d,toggleSidebar:b}),[g,m,w,c,u,d,b]);return l.jsx(Ih.Provider,{value:x,children:l.jsx(nC,{delayDuration:0,children:l.jsx("div",{style:{"--sidebar-width":aC,"--sidebar-width-icon":cC,...o},className:L("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",r),ref:a,...i,children:s})})})});Nh.displayName="SidebarProvider";const jh=h.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:o,...s},i)=>{const{isMobile:a,state:c,openMobile:u,setOpenMobile:d}=Cs();return n==="none"?l.jsx("div",{className:L("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:i,...s,children:o}):a?l.jsx(uh,{open:u,onOpenChange:d,...s,children:l.jsx(Na,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":lC},side:e,children:l.jsx("div",{className:"flex h-full w-full flex-col",children:o})})}):l.jsxs("div",{ref:i,className:"group peer hidden md:block text-sidebar-foreground","data-state":c,"data-collapsible":c==="collapsed"?n:"","data-variant":t,"data-side":e,children:[l.jsx("div",{className:L("duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),l.jsx("div",{className:L("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex",e==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...s,children:l.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow",children:o})})]})});jh.displayName="Sidebar";const Ah=h.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:o}=Cs();return l.jsxs(ze,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:L("h-7 w-7",e),onClick:s=>{t==null||t(s),o()},...n,children:[l.jsx(se.PanelLeft,{}),l.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Ah.displayName="SidebarTrigger";const dC=h.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=Cs();return l.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:L("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})});dC.displayName="SidebarRail";const Rh=h.forwardRef(({className:e,...t},n)=>l.jsx("main",{ref:n,className:L("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",e),...t}));Rh.displayName="SidebarInset";const fC=h.forwardRef(({className:e,...t},n)=>l.jsx(qr,{ref:n,"data-sidebar":"input",className:L("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));fC.displayName="SidebarInput";const _h=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"header",className:L("flex flex-col gap-2 p-2",e),...t}));_h.displayName="SidebarHeader";const hC=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"footer",className:L("flex flex-col gap-2 p-2",e),...t}));hC.displayName="SidebarFooter";const pC=h.forwardRef(({className:e,...t},n)=>l.jsx(Ia,{ref:n,"data-sidebar":"separator",className:L("mx-2 w-auto bg-sidebar-border",e),...t}));pC.displayName="SidebarSeparator";const Ph=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"content",className:L("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Ph.displayName="SidebarContent";const Oh=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"group",className:L("relative flex w-full min-w-0 flex-col p-2",e),...t}));Oh.displayName="SidebarGroup";const Mh=h.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?Et.Slot:"div";return l.jsx(o,{ref:r,"data-sidebar":"group-label",className:L("duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...n})});Mh.displayName="SidebarGroupLabel";const mC=h.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?Et.Slot:"button";return l.jsx(o,{ref:r,"data-sidebar":"group-action",className:L("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",e),...n})});mC.displayName="SidebarGroupAction";const Dh=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"group-content",className:L("w-full text-sm",e),...t}));Dh.displayName="SidebarGroupContent";const Lh=h.forwardRef(({className:e,...t},n)=>l.jsx("ul",{ref:n,"data-sidebar":"menu",className:L("flex w-full min-w-0 flex-col gap-1",e),...t}));Lh.displayName="SidebarMenu";const $h=h.forwardRef(({className:e,...t},n)=>l.jsx("li",{ref:n,"data-sidebar":"menu-item",className:L("group/menu-item relative",e),...t}));$h.displayName="SidebarMenuItem";const gC=mr.cva("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),Fh=h.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:o,className:s,...i},a)=>{const c=e?Et.Slot:"button",{isMobile:u,state:d}=Cs(),f=l.jsx(c,{ref:a,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:L(gC({variant:n,size:r}),s),...i});return o?(typeof o=="string"&&(o={children:o}),l.jsxs(rC,{children:[l.jsx(oC,{asChild:!0,children:f}),l.jsx(Eh,{side:"right",align:"center",hidden:d!=="collapsed"||u,...o})]})):f});Fh.displayName="SidebarMenuButton";const xC=h.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},o)=>{const s=t?Et.Slot:"button";return l.jsx(s,{ref:o,"data-sidebar":"menu-action",className:L("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",n&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",e),...r})});xC.displayName="SidebarMenuAction";const bC=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:L("absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...t}));bC.displayName="SidebarMenuBadge";const vC=h.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const o=h.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return l.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:L("rounded-md h-8 flex gap-2 px-2 items-center",e),...n,children:[t&&l.jsx(mh,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),l.jsx(mh,{className:"h-4 flex-1 max-w-[--skeleton-width]","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":o}})]})});vC.displayName="SidebarMenuSkeleton";const wC=h.forwardRef(({className:e,...t},n)=>l.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:L("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),...t}));wC.displayName="SidebarMenuSub";const yC=h.forwardRef(({...e},t)=>l.jsx("li",{ref:t,...e}));yC.displayName="SidebarMenuSubItem";const SC=h.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...o},s)=>{const i=e?Et.Slot:"a";return l.jsx(i,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:L("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",t==="sm"&&"text-xs",t==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",r),...o})});SC.displayName="SidebarMenuSubButton";function CC({header:e,sidebarTitle:t="Threads",showThreads:n=!0,className:r="",sidebarClassName:o="",chatClassName:s="",...i}){return l.jsx(Cr,{...i,children:l.jsxs(Nh,{className:`w-full ${r}`,children:[l.jsxs(jh,{className:`border-r ${o}`,children:[l.jsx(_h,{children:l.jsx(Lh,{children:l.jsx($h,{children:l.jsx(Fh,{asChild:!0,size:"lg",children:l.jsx("span",{className:"font-semibold",children:t})})})})}),l.jsx(Ph,{children:n&&l.jsxs(Oh,{children:[l.jsx(Mh,{children:"Conversations"}),l.jsx(Dh,{children:l.jsx("div",{className:"px-2 py-1",children:l.jsx(vs,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-[calc(100vh-12rem)]"})})})]})})]}),l.jsxs(Rh,{children:[l.jsxs("header",{className:"h-14 border-b bg-background/60 backdrop-blur flex items-center gap-2 px-4",children:[l.jsx(Ah,{}),l.jsx("div",{className:"flex-1"}),e]}),l.jsx("main",{className:`flex-1 min-h-0 overflow-hidden ${s}`,children:l.jsx(Kr,{})})]})]})})}function fr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function TC(e){if(typeof e!="string")return;const t=e.trim();if(t)return t.replace(/\/+$/g,"")}function zh(){const e=[fr("__API_BASE_URL__"),fr("__CHAT_API_BASE_URL__"),fr("__CHAT_API_URL__")];for(const t of e){const n=TC(t);if(n)return n}}function Bh(){const e=[fr("__API_AUTH_TOKEN__"),fr("__CHAT_API_KEY__"),fr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Hh(){const e={},t=zh(),n=Bh();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Uh(){const e=Hh(),t=mn.getAuthToken(),n=zh();return{apiBaseUrl:e.baseUrl||mn.baseUrl||n||"http://localhost:8000",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 Wh="chat-settings";function kC(){try{const e=localStorage.getItem(Wh);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function EC(e){try{localStorage.setItem(Wh,JSON.stringify(e)),e.apiKey&&mn.setAuthToken(e.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function IC(){const e=Uh(),t=kC(),n=mn.getAuthToken();return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:mn.baseUrl||t.apiBaseUrl||e.apiBaseUrl}}function NC(e){e.apiKey&&mn.setAuthToken(e.apiKey),EC(e)}var jC="Label",Vh=h.forwardRef((e,t)=>l.jsx(Se.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())}}));Vh.displayName=jC;var Kh=Vh;const AC=mr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),zt=h.forwardRef(({className:e,...t},n)=>l.jsx(Kh,{ref:n,className:L(AC(),e),...t}));zt.displayName=Kh.displayName;function qh(e){const t=h.useRef({value:e,previous:e});return h.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Ts="Switch",[RC,nk]=Vt(Ts),[_C,PC]=RC(Ts),Gh=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:c="on",onCheckedChange:u,form:d,...f}=e,[p,m]=h.useState(null),w=Re(t,y=>m(y)),b=h.useRef(!1),g=p?d||!!p.closest("form"):!0,[x,v]=wn({prop:o,defaultProp:s??!1,onChange:u,caller:Ts});return l.jsxs(_C,{scope:n,checked:x,disabled:a,children:[l.jsx(Se.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":Zh(x),"data-disabled":a?"":void 0,disabled:a,value:c,...f,ref:w,onClick:te(e.onClick,y=>{v(E=>!E),g&&(b.current=y.isPropagationStopped(),b.current||y.stopPropagation())})}),g&&l.jsx(Jh,{control:p,bubbles:!b.current,name:r,value:c,checked:x,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Gh.displayName=Ts;var Yh="SwitchThumb",Xh=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=PC(Yh,n);return l.jsx(Se.span,{"data-state":Zh(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Xh.displayName=Yh;var OC="SwitchBubbleInput",Jh=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=Re(i,s),c=qh(n),u=_d(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==n&&m){const w=new Event("click",{bubbles:r});m.call(d,n),d.dispatchEvent(w)}},[c,n,r]),l.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}})});Jh.displayName=OC;function Zh(e){return e?"checked":"unchecked"}var Qh=Gh,MC=Xh;const En=h.forwardRef(({className:e,...t},n)=>l.jsx(Qh,{className:L("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:l.jsx(MC,{className:L("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")})}));En.displayName=Qh.displayName;var DC=[" ","Enter","ArrowUp","ArrowDown"],LC=[" ","Enter"],Un="Select",[ks,Es,$C]=Vi(Un),[hr,rk]=Vt(Un,[$C,cr]),Is=cr(),[FC,In]=hr(Un),[zC,BC]=hr(Un),ep=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:c,dir:u,name:d,autoComplete:f,disabled:p,required:m,form:w}=e,b=Is(t),[g,x]=h.useState(null),[v,y]=h.useState(null),[E,S]=h.useState(!1),T=es(u),[I,N]=wn({prop:r,defaultProp:o??!1,onChange:s,caller:Un}),[j,O]=wn({prop:i,defaultProp:a,onChange:c,caller:Un}),A=h.useRef(null),F=g?w||!!g.closest("form"):!0,[H,D]=h.useState(new Set),J=Array.from(H).map(K=>K.props.value).join(";");return l.jsx(ia,{...b,children:l.jsxs(FC,{required:m,scope:t,trigger:g,onTriggerChange:x,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:E,onValueNodeHasChildrenChange:S,contentId:Kt(),value:j,onValueChange:O,open:I,onOpenChange:N,dir:T,triggerPointerDownPosRef:A,disabled:p,children:[l.jsx(ks.Provider,{scope:t,children:l.jsx(zC,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(K=>{D(oe=>new Set(oe).add(K))},[]),onNativeOptionRemove:h.useCallback(K=>{D(oe=>{const W=new Set(oe);return W.delete(K),W})},[]),children:n})}),F?l.jsxs(Tp,{"aria-hidden":!0,required:m,tabIndex:-1,name:d,autoComplete:f,value:j,onChange:K=>O(K.target.value),disabled:p,form:w,children:[j===void 0?l.jsx("option",{value:""}):null,Array.from(H)]},J):null]})})};ep.displayName=Un;var tp="SelectTrigger",np=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Is(n),i=In(tp,n),a=i.disabled||r,c=Re(t,i.onTriggerChange),u=Es(n),d=h.useRef("touch"),[f,p,m]=Ep(b=>{const g=u().filter(y=>!y.disabled),x=g.find(y=>y.value===i.value),v=Ip(g,b,x);v!==void 0&&i.onValueChange(v.value)}),w=b=>{a||(i.onOpenChange(!0),m()),b&&(i.triggerPointerDownPosRef.current={x:Math.round(b.pageX),y:Math.round(b.pageY)})};return l.jsx(aa,{asChild:!0,...s,children:l.jsx(Se.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":kp(i.value)?"":void 0,...o,ref:c,onClick:te(o.onClick,b=>{b.currentTarget.focus(),d.current!=="mouse"&&w(b)}),onPointerDown:te(o.onPointerDown,b=>{d.current=b.pointerType;const g=b.target;g.hasPointerCapture(b.pointerId)&&g.releasePointerCapture(b.pointerId),b.button===0&&b.ctrlKey===!1&&b.pointerType==="mouse"&&(w(b),b.preventDefault())}),onKeyDown:te(o.onKeyDown,b=>{const g=f.current!=="";!(b.ctrlKey||b.altKey||b.metaKey)&&b.key.length===1&&p(b.key),!(g&&b.key===" ")&&DC.includes(b.key)&&(w(),b.preventDefault())})})})});np.displayName=tp;var rp="SelectValue",op=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,c=In(rp,n),{onValueNodeHasChildrenChange:u}=c,d=s!==void 0,f=Re(t,c.onValueNodeChange);return lt(()=>{u(d)},[u,d]),l.jsx(Se.span,{...a,ref:f,style:{pointerEvents:"none"},children:kp(c.value)?l.jsx(l.Fragment,{children:i}):s})});op.displayName=rp;var HC="SelectIcon",sp=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return l.jsx(Se.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});sp.displayName=HC;var UC="SelectPortal",ip=e=>l.jsx(Lo,{asChild:!0,...e});ip.displayName=UC;var Wn="SelectContent",ap=h.forwardRef((e,t)=>{const n=In(Wn,e.__scopeSelect),[r,o]=h.useState();if(lt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?eo.createPortal(l.jsx(lp,{scope:e.__scopeSelect,children:l.jsx(ks.Slot,{scope:e.__scopeSelect,children:l.jsx("div",{children:e.children})})}),s):null}return l.jsx(cp,{...e,ref:t})});ap.displayName=Wn;var Xt=10,[lp,Nn]=hr(Wn),WC="SelectContentImpl",VC=Et.createSlot("SelectContent.RemoveScroll"),cp=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:w,hideWhenDetached:b,avoidCollisions:g,...x}=e,v=In(Wn,n),[y,E]=h.useState(null),[S,T]=h.useState(null),I=Re(t,z=>E(z)),[N,j]=h.useState(null),[O,A]=h.useState(null),F=Es(n),[H,D]=h.useState(!1),J=h.useRef(!1);h.useEffect(()=>{if(y)return Fi(y)},[y]),Pi();const K=h.useCallback(z=>{const[_,...Y]=F().map(ne=>ne.ref.current),[Q]=Y.slice(-1),de=document.activeElement;for(const ne of z)if(ne===de||(ne==null||ne.scrollIntoView({block:"nearest"}),ne===_&&S&&(S.scrollTop=0),ne===Q&&S&&(S.scrollTop=S.scrollHeight),ne==null||ne.focus(),document.activeElement!==de))return},[F,S]),oe=h.useCallback(()=>K([N,y]),[K,N,y]);h.useEffect(()=>{H&&oe()},[H,oe]);const{onOpenChange:W,triggerPointerDownPosRef:M}=v;h.useEffect(()=>{if(y){let z={x:0,y:0};const _=Q=>{var de,ne;z={x:Math.abs(Math.round(Q.pageX)-(((de=M.current)==null?void 0:de.x)??0)),y:Math.abs(Math.round(Q.pageY)-(((ne=M.current)==null?void 0:ne.y)??0))}},Y=Q=>{z.x<=10&&z.y<=10?Q.preventDefault():y.contains(Q.target)||W(!1),document.removeEventListener("pointermove",_),M.current=null};return M.current!==null&&(document.addEventListener("pointermove",_),document.addEventListener("pointerup",Y,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",Y,{capture:!0})}}},[y,W,M]),h.useEffect(()=>{const z=()=>W(!1);return window.addEventListener("blur",z),window.addEventListener("resize",z),()=>{window.removeEventListener("blur",z),window.removeEventListener("resize",z)}},[W]);const[X,Z]=Ep(z=>{const _=F().filter(de=>!de.disabled),Y=_.find(de=>de.ref.current===document.activeElement),Q=Ip(_,z,Y);Q&&setTimeout(()=>Q.ref.current.focus())}),he=h.useCallback((z,_,Y)=>{const Q=!J.current&&!Y;(v.value!==void 0&&v.value===_||Q)&&(j(z),Q&&(J.current=!0))},[v.value]),$=h.useCallback(()=>y==null?void 0:y.focus(),[y]),G=h.useCallback((z,_,Y)=>{const Q=!J.current&&!Y;(v.value!==void 0&&v.value===_||Q)&&A(z)},[v.value]),ee=r==="popper"?_a:up,pe=ee===_a?{side:a,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:w,hideWhenDetached:b,avoidCollisions:g}:{};return l.jsx(lp,{scope:n,content:y,viewport:S,onViewportChange:T,itemRefCallback:he,selectedItem:N,onItemLeave:$,itemTextRefCallback:G,focusSelectedItem:oe,selectedItemText:O,position:r,isPositioned:H,searchRef:X,children:l.jsx(Uo,{as:VC,allowPinchZoom:!0,children:l.jsx(Do,{asChild:!0,trapped:v.open,onMountAutoFocus:z=>{z.preventDefault()},onUnmountAutoFocus:te(o,z=>{var _;(_=v.trigger)==null||_.focus({preventScroll:!0}),z.preventDefault()}),children:l.jsx(Mr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:z=>z.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:l.jsx(ee,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:z=>z.preventDefault(),...x,...pe,onPlaced:()=>D(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:te(x.onKeyDown,z=>{const _=z.ctrlKey||z.altKey||z.metaKey;if(z.key==="Tab"&&z.preventDefault(),!_&&z.key.length===1&&Z(z.key),["ArrowUp","ArrowDown","Home","End"].includes(z.key)){let Q=F().filter(de=>!de.disabled).map(de=>de.ref.current);if(["ArrowUp","End"].includes(z.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes(z.key)){const de=z.target,ne=Q.indexOf(de);Q=Q.slice(ne+1)}setTimeout(()=>K(Q)),z.preventDefault()}})})})})})})});cp.displayName=WC;var KC="SelectItemAlignedPosition",up=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=In(Wn,n),i=Nn(Wn,n),[a,c]=h.useState(null),[u,d]=h.useState(null),f=Re(t,I=>d(I)),p=Es(n),m=h.useRef(!1),w=h.useRef(!0),{viewport:b,selectedItem:g,selectedItemText:x,focusSelectedItem:v}=i,y=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&b&&g&&x){const I=s.trigger.getBoundingClientRect(),N=u.getBoundingClientRect(),j=s.valueNode.getBoundingClientRect(),O=x.getBoundingClientRect();if(s.dir!=="rtl"){const de=O.left-N.left,ne=j.left-de,_e=I.left-ne,Pe=I.width+_e,Ue=Math.max(Pe,N.width),Ee=window.innerWidth-Xt,Ae=ya(ne,[Xt,Math.max(Xt,Ee-Ue)]);a.style.minWidth=Pe+"px",a.style.left=Ae+"px"}else{const de=N.right-O.right,ne=window.innerWidth-j.right-de,_e=window.innerWidth-I.right-ne,Pe=I.width+_e,Ue=Math.max(Pe,N.width),Ee=window.innerWidth-Xt,Ae=ya(ne,[Xt,Math.max(Xt,Ee-Ue)]);a.style.minWidth=Pe+"px",a.style.right=Ae+"px"}const A=p(),F=window.innerHeight-Xt*2,H=b.scrollHeight,D=window.getComputedStyle(u),J=parseInt(D.borderTopWidth,10),K=parseInt(D.paddingTop,10),oe=parseInt(D.borderBottomWidth,10),W=parseInt(D.paddingBottom,10),M=J+K+H+W+oe,X=Math.min(g.offsetHeight*5,M),Z=window.getComputedStyle(b),he=parseInt(Z.paddingTop,10),$=parseInt(Z.paddingBottom,10),G=I.top+I.height/2-Xt,ee=F-G,pe=g.offsetHeight/2,z=g.offsetTop+pe,_=J+K+z,Y=M-_;if(_<=G){const de=A.length>0&&g===A[A.length-1].ref.current;a.style.bottom="0px";const ne=u.clientHeight-b.offsetTop-b.offsetHeight,_e=Math.max(ee,pe+(de?$:0)+ne+oe),Pe=_+_e;a.style.height=Pe+"px"}else{const de=A.length>0&&g===A[0].ref.current;a.style.top="0px";const _e=Math.max(G,J+b.offsetTop+(de?he:0)+pe)+Y;a.style.height=_e+"px",b.scrollTop=_-G+b.offsetTop}a.style.margin=`${Xt}px 0`,a.style.minHeight=X+"px",a.style.maxHeight=F+"px",r==null||r(),requestAnimationFrame(()=>m.current=!0)}},[p,s.trigger,s.valueNode,a,u,b,g,x,s.dir,r]);lt(()=>y(),[y]);const[E,S]=h.useState();lt(()=>{u&&S(window.getComputedStyle(u).zIndex)},[u]);const T=h.useCallback(I=>{I&&w.current===!0&&(y(),v==null||v(),w.current=!1)},[y,v]);return l.jsx(GC,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:m,onScrollButtonChange:T,children:l.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:l.jsx(Se.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});up.displayName=KC;var qC="SelectPopperPosition",_a=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Xt,...s}=e,i=Is(n);return l.jsx(la,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});_a.displayName=qC;var[GC,Pa]=hr(Wn,{}),Oa="SelectViewport",dp=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Nn(Oa,n),i=Pa(Oa,n),a=Re(t,s.onViewportChange),c=h.useRef(0);return l.jsxs(l.Fragment,{children:[l.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}),l.jsx(ks.Slot,{scope:n,children:l.jsx(Se.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:te(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:p}=i;if(p!=null&&p.current&&f){const m=Math.abs(c.current-d.scrollTop);if(m>0){const w=window.innerHeight-Xt*2,b=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),x=Math.max(b,g);if(x<w){const v=x+m,y=Math.min(w,v),E=v-y;f.style.height=y+"px",f.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}c.current=d.scrollTop})})})]})});dp.displayName=Oa;var fp="SelectGroup",[YC,XC]=hr(fp),JC=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Kt();return l.jsx(YC,{scope:n,id:o,children:l.jsx(Se.div,{role:"group","aria-labelledby":o,...r,ref:t})})});JC.displayName=fp;var hp="SelectLabel",pp=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=XC(hp,n);return l.jsx(Se.div,{id:o.id,...r,ref:t})});pp.displayName=hp;var Ns="SelectItem",[ZC,mp]=hr(Ns),gp=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=In(Ns,n),c=Nn(Ns,n),u=a.value===r,[d,f]=h.useState(s??""),[p,m]=h.useState(!1),w=Re(t,v=>{var y;return(y=c.itemRefCallback)==null?void 0:y.call(c,v,r,o)}),b=Kt(),g=h.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 l.jsx(ZC,{scope:n,value:r,disabled:o,textId:b,isSelected:u,onItemTextChange:h.useCallback(v=>{f(y=>y||((v==null?void 0:v.textContent)??"").trim())},[]),children:l.jsx(ks.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:l.jsx(Se.div,{role:"option","aria-labelledby":b,"data-highlighted":p?"":void 0,"aria-selected":u&&p,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:w,onFocus:te(i.onFocus,()=>m(!0)),onBlur:te(i.onBlur,()=>m(!1)),onClick:te(i.onClick,()=>{g.current!=="mouse"&&x()}),onPointerUp:te(i.onPointerUp,()=>{g.current==="mouse"&&x()}),onPointerDown:te(i.onPointerDown,v=>{g.current=v.pointerType}),onPointerMove:te(i.onPointerMove,v=>{var y;g.current=v.pointerType,o?(y=c.onItemLeave)==null||y.call(c):g.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:te(i.onPointerLeave,v=>{var y;v.currentTarget===document.activeElement&&((y=c.onItemLeave)==null||y.call(c))}),onKeyDown:te(i.onKeyDown,v=>{var E;((E=c.searchRef)==null?void 0:E.current)!==""&&v.key===" "||(LC.includes(v.key)&&x(),v.key===" "&&v.preventDefault())})})})})});gp.displayName=Ns;var Yr="SelectItemText",xp=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=In(Yr,n),a=Nn(Yr,n),c=mp(Yr,n),u=BC(Yr,n),[d,f]=h.useState(null),p=Re(t,x=>f(x),c.onItemTextChange,x=>{var v;return(v=a.itemTextRefCallback)==null?void 0:v.call(a,x,c.value,c.disabled)}),m=d==null?void 0:d.textContent,w=h.useMemo(()=>l.jsx("option",{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:b,onNativeOptionRemove:g}=u;return lt(()=>(b(w),()=>g(w)),[b,g,w]),l.jsxs(l.Fragment,{children:[l.jsx(Se.span,{id:c.textId,...s,ref:p}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?eo.createPortal(s.children,i.valueNode):null]})});xp.displayName=Yr;var bp="SelectItemIndicator",vp=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return mp(bp,n).isSelected?l.jsx(Se.span,{"aria-hidden":!0,...r,ref:t}):null});vp.displayName=bp;var Ma="SelectScrollUpButton",wp=h.forwardRef((e,t)=>{const n=Nn(Ma,e.__scopeSelect),r=Pa(Ma,e.__scopeSelect),[o,s]=h.useState(!1),i=Re(t,r.onScrollButtonChange);return lt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollTop>0;s(u)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?l.jsx(Sp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop-c.offsetHeight)}}):null});wp.displayName=Ma;var Da="SelectScrollDownButton",yp=h.forwardRef((e,t)=>{const n=Nn(Da,e.__scopeSelect),r=Pa(Da,e.__scopeSelect),[o,s]=h.useState(!1),i=Re(t,r.onScrollButtonChange);return lt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollHeight-c.clientHeight,d=Math.ceil(c.scrollTop)<u;s(d)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?l.jsx(Sp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop+c.offsetHeight)}}):null});yp.displayName=Da;var Sp=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Nn("SelectScrollButton",n),i=h.useRef(null),a=Es(n),c=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>c(),[c]),lt(()=>{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]),l.jsx(Se.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:te(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:te(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:te(o.onPointerLeave,()=>{c()})})}),QC="SelectSeparator",Cp=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return l.jsx(Se.div,{"aria-hidden":!0,...r,ref:t})});Cp.displayName=QC;var La="SelectArrow",eT=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Is(n),s=In(La,n),i=Nn(La,n);return s.open&&i.position==="popper"?l.jsx(ca,{...o,...r,ref:t}):null});eT.displayName=La;var tT="SelectBubbleInput",Tp=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=Re(r,o),i=qh(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),l.jsx(Se.select,{...n,style:{...gh,...n.style},ref:s,defaultValue:t})});Tp.displayName=tT;function kp(e){return e===""||e===void 0}function Ep(e){const t=dt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function c(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>c(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Ip(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=nT(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function nT(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var rT=ep,Np=np,oT=op,sT=sp,iT=ip,jp=ap,aT=dp,Ap=pp,Rp=gp,lT=xp,cT=vp,_p=wp,Pp=yp,Op=Cp;const Mp=rT,Dp=oT,$a=h.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Np,{ref:r,className:L("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,l.jsx(sT,{asChild:!0,children:l.jsx(se.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));$a.displayName=Np.displayName;const Lp=h.forwardRef(({className:e,...t},n)=>l.jsx(_p,{ref:n,className:L("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(se.ChevronUp,{className:"h-4 w-4"})}));Lp.displayName=_p.displayName;const $p=h.forwardRef(({className:e,...t},n)=>l.jsx(Pp,{ref:n,className:L("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(se.ChevronDown,{className:"h-4 w-4"})}));$p.displayName=Pp.displayName;const Fa=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>l.jsx(iT,{children:l.jsxs(jp,{ref:o,className:L("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:[l.jsx(Lp,{}),l.jsx(aT,{className:L("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),l.jsx($p,{})]})}));Fa.displayName=jp.displayName;const uT=h.forwardRef(({className:e,...t},n)=>l.jsx(Ap,{ref:n,className:L("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));uT.displayName=Ap.displayName;const Vn=h.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Rp,{ref:r,className:L("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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(cT,{children:l.jsx(se.Check,{className:"h-4 w-4"})})}),l.jsx(lT,{children:t})]}));Vn.displayName=Rp.displayName;const dT=h.forwardRef(({className:e,...t},n)=>l.jsx(Op,{ref:n,className:L("-mx-1 my-1 h-px bg-muted",e),...t}));dT.displayName=Op.displayName;const js=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:L("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));js.displayName="Card";const As=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:L("flex flex-col space-y-1.5 p-6",e),...t}));As.displayName="CardHeader";const Rs=h.forwardRef(({className:e,...t},n)=>l.jsx("h3",{ref:n,className:L("text-2xl font-semibold leading-none tracking-tight",e),...t}));Rs.displayName="CardTitle";const fT=h.forwardRef(({className:e,...t},n)=>l.jsx("p",{ref:n,className:L("text-sm text-muted-foreground",e),...t}));fT.displayName="CardDescription";const _s=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:L("p-6 pt-0",e),...t}));_s.displayName="CardContent";const hT=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:L("flex items-center p-6 pt-0",e),...t}));hT.displayName="CardFooter";const pT={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 mT({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=C.useState(!1),[s,i]=C.useState(!1),[a,c]=C.useState(e),[u,d]=C.useState(!1),{toast:f}=Ni();C.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),C.useEffect(()=>{c(e)},[e]);const p=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},m=()=>{c(pT),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},w=()=>{c(e),d(!1),o(!1)},b=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 l.jsxs(uh,{open:r,onOpenChange:o,children:[l.jsx(_S,{asChild:!0,children:l.jsxs(ze,{variant:"outline",size:"sm",className:n,children:[l.jsx(se.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&l.jsx(zc,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),l.jsxs(Na,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[l.jsxs(fh,{children:[l.jsx(hh,{children:"Chat Settings"}),l.jsx(ph,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),l.jsxs("div",{className:"space-y-6 py-6",children:[l.jsxs(js,{children:[l.jsx(As,{className:"pb-3",children:l.jsxs(Rs,{className:"text-lg flex items-center gap-2",children:[l.jsx(se.Server,{className:"h-5 w-5"}),"API Configuration"]})}),l.jsxs(_s,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(zt,{htmlFor:"api-url",children:"API Base URL"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(qr,{id:"api-url",value:a.api.baseUrl,onChange:g=>c(x=>({...x,api:{...x.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),l.jsx(ze,{variant:"outline",onClick:b,children:"Test"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(zt,{htmlFor:"enable-auth",children:"Enable Authentication"}),l.jsx(En,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>c(x=>({...x,api:{...x.api,enableAuth:g}}))})]}),a.api.enableAuth&&l.jsxs("div",{className:"space-y-2",children:[l.jsx(zt,{htmlFor:"auth-token",children:"Authentication Token"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(qr,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>c(x=>({...x,api:{...x.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),l.jsx(ze,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?l.jsx(se.EyeOff,{className:"h-4 w-4"}):l.jsx(se.Eye,{className:"h-4 w-4"})})]})]})]})]}),l.jsxs(js,{children:[l.jsx(As,{className:"pb-3",children:l.jsxs(Rs,{className:"text-lg flex items-center gap-2",children:[l.jsx(se.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),l.jsxs(_s,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(zt,{htmlFor:"layout",children:"Layout Style"}),l.jsxs(Mp,{value:a.ui.layout,onValueChange:g=>c(x=>({...x,ui:{...x.ui,layout:g}})),children:[l.jsx($a,{children:l.jsx(Dp,{})}),l.jsxs(Fa,{children:[l.jsx(Vn,{value:"sidebar",children:"Sidebar Layout"}),l.jsx(Vn,{value:"fullscreen",children:"Fullscreen"}),l.jsx(Vn,{value:"tabs",children:"Tabbed Interface"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(zt,{htmlFor:"theme",children:"Theme"}),l.jsxs(Mp,{value:a.ui.theme,onValueChange:g=>c(x=>({...x,ui:{...x.ui,theme:g}})),children:[l.jsx($a,{children:l.jsx(Dp,{})}),l.jsxs(Fa,{children:[l.jsx(Vn,{value:"light",children:"Light"}),l.jsx(Vn,{value:"dark",children:"Dark"}),l.jsx(Vn,{value:"system",children:"System"})]})]})]}),l.jsx(Ia,{}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(zt,{htmlFor:"show-timestamps",children:"Show Timestamps"}),l.jsx(En,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,showTimestamps:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(zt,{htmlFor:"show-agent-names",children:"Show Agent Names"}),l.jsx(En,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,showAgentNames:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(zt,{htmlFor:"compact-messages",children:"Compact Messages"}),l.jsx(En,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,compactMessages:g}}))})]})]})]})]}),l.jsxs(js,{children:[l.jsx(As,{className:"pb-3",children:l.jsxs(Rs,{className:"text-lg flex items-center gap-2",children:[l.jsx(se.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),l.jsxs(_s,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(zt,{htmlFor:"auto-save",children:"Auto-save Conversations"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),l.jsx(En,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,autoSave:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(zt,{htmlFor:"enable-streaming",children:"Enable Streaming"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),l.jsx(En,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,enableStreaming:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(zt,{htmlFor:"typing-indicator",children:"Typing Indicator"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),l.jsx(En,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,showTypingIndicator:g}}))})]})]})]})]}),l.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[l.jsxs(ze,{variant:"outline",onClick:m,children:[l.jsx(se.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(ze,{variant:"outline",onClick:w,children:"Cancel"}),l.jsxs(ze,{onClick:p,disabled:!u,children:[l.jsx(se.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function gT({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"}),c=C.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?l.jsx(Cr,{...s,onThreadChange:c,children:l.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:l.jsx(Kr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?l.jsx(Cr,{...s,onThreadChange:c,children:l.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:l.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&l.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:l.jsx(vs,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),l.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:l.jsx(Kr,{onError:s.onError,enableFileUpload:!0})})]})})}):l.jsx(Cr,{...s,onThreadChange:c,children:l.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&l.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:l.jsx(vs,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),l.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:l.jsx(Kr,{onError:s.onError,enableFileUpload:!0})})]})})}Te.ChatApi=Ml,Te.ChatInterface=Kr,Te.ChatMainLayout=CC,Te.ChatProvider=Cr,Te.ChatRoutingProvider=ES,Te.ChatSettings=mT,Te.MarkdownContent=Po,Te.MessageComponent=rd,Te.MessageList=Wi,Te.ThreadManager=vs,Te.applySettings=NC,Te.chatApiClient=mn,Te.default=gT,Te.del=Ol,Te.get=It,Te.getChatToken=Al,Te.getCurrentSettings=IC,Te.getDefaultApiConfig=Hh,Te.getDefaultChatSettings=Uh,Te.onChatTokenChanged=Rl,Te.post=_l,Te.put=Pl,Te.setChatToken=Gs,Te.useChat=ho,Te.useChatRouting=IS,Te.useChatStream=Dl,Te.useMessagesReducer=Ll,Object.defineProperties(Te,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
138
|
+
`).trim():n.replace(/</g,"<").replace(/>/g,">").trim()}function bw(e,t=Qo){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 vw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),bw(t),xw(t)}function Vi(e){const t=e+"CollectionProvider",[n,r]=Vt(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=b=>{const{scope:g,children:x}=b,v=C.useRef(null),y=C.useRef(new Map).current;return l.jsx(o,{scope:g,itemMap:y,collectionRef:v,children:x})};i.displayName=t;const a=e+"CollectionSlot",c=Et.createSlot(a),u=C.forwardRef((b,g)=>{const{scope:x,children:v}=b,y=s(a,x),E=Re(g,y.collectionRef);return l.jsx(c,{ref:E,children:v})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",p=Et.createSlot(d),m=C.forwardRef((b,g)=>{const{scope:x,children:v,...y}=b,E=C.useRef(null),S=Re(g,E),T=s(d,x);return C.useEffect(()=>(T.itemMap.set(E,{ref:E,...y}),()=>void T.itemMap.delete(E))),l.jsx(p,{[f]:"",ref:S,children:v})});m.displayName=d;function w(b){const g=s(e+"CollectionConsumer",b);return C.useCallback(()=>{const v=g.collectionRef.current;if(!v)return[];const y=Array.from(v.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((T,I)=>y.indexOf(T.ref.current)-y.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:m},w,r]}var ww=h.createContext(void 0);function es(e){const t=h.useContext(ww);return e||t||"ltr"}const yw=["top","right","bottom","left"],Tn=Math.min,At=Math.max,ts=Math.round,ns=Math.floor,nn=e=>({x:e,y:e}),Sw={left:"right",right:"left",bottom:"top",top:"bottom"},Cw={start:"end",end:"start"};function Ki(e,t,n){return At(e,Tn(t,n))}function dn(e,t){return typeof e=="function"?e(t):e}function fn(e){return e.split("-")[0]}function sr(e){return e.split("-")[1]}function qi(e){return e==="x"?"y":"x"}function Gi(e){return e==="y"?"height":"width"}const Tw=new Set(["top","bottom"]);function rn(e){return Tw.has(fn(e))?"y":"x"}function Yi(e){return qi(rn(e))}function kw(e,t,n){n===void 0&&(n=!1);const r=sr(e),o=Yi(e),s=Gi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=rs(i)),[i,rs(i)]}function Ew(e){const t=rs(e);return[Xi(e),t,Xi(t)]}function Xi(e){return e.replace(/start|end/g,t=>Cw[t])}const dd=["left","right"],fd=["right","left"],Iw=["top","bottom"],Nw=["bottom","top"];function jw(e,t,n){switch(e){case"top":case"bottom":return n?t?fd:dd:t?dd:fd;case"left":case"right":return t?Iw:Nw;default:return[]}}function Aw(e,t,n,r){const o=sr(e);let s=jw(fn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Xi)))),s}function rs(e){return e.replace(/left|right|bottom|top/g,t=>Sw[t])}function Rw(e){return{top:0,right:0,bottom:0,left:0,...e}}function hd(e){return typeof e!="number"?Rw(e):{top:e,right:e,bottom:e,left:e}}function os(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 pd(e,t,n){let{reference:r,floating:o}=e;const s=rn(t),i=Yi(t),a=Gi(i),c=fn(t),u=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,p=r[a]/2-o[a]/2;let m;switch(c){case"top":m={x:d,y:r.y-o.height};break;case"bottom":m={x:d,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-o.width,y:f};break;default:m={x:r.x,y:r.y}}switch(sr(t)){case"start":m[i]-=p*(n&&u?-1:1);break;case"end":m[i]+=p*(n&&u?-1:1);break}return m}const _w=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=pd(u,r,c),p=r,m={},w=0;for(let b=0;b<a.length;b++){const{name:g,fn:x}=a[b],{x:v,y,data:E,reset:S}=await x({x:d,y:f,initialPlacement:r,placement:p,strategy:o,middlewareData:m,rects:u,platform:i,elements:{reference:e,floating:t}});d=v??d,f=y??f,m={...m,[g]:{...m[g],...E}},S&&w<=50&&(w++,typeof S=="object"&&(S.placement&&(p=S.placement),S.rects&&(u=S.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:d,y:f}=pd(u,p,c)),b=-1)}return{x:d,y:f,placement:p,strategy:o,middlewareData:m}};async function Lr(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:p=!1,padding:m=0}=dn(t,e),w=hd(m),g=a[p?f==="floating"?"reference":"floating":f],x=os(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:c})),v=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,y=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(y))?await(s.getScale==null?void 0:s.getScale(y))||{x:1,y:1}:{x:1,y:1},S=os(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:y,strategy:c}):v);return{top:(x.top-S.top+w.top)/E.y,bottom:(S.bottom-x.bottom+w.bottom)/E.y,left:(x.left-S.left+w.left)/E.x,right:(S.right-x.right+w.right)/E.x}}const Pw=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:c}=t,{element:u,padding:d=0}=dn(e,t)||{};if(u==null)return{};const f=hd(d),p={x:n,y:r},m=Yi(o),w=Gi(m),b=await i.getDimensions(u),g=m==="y",x=g?"top":"left",v=g?"bottom":"right",y=g?"clientHeight":"clientWidth",E=s.reference[w]+s.reference[m]-p[m]-s.floating[w],S=p[m]-s.reference[m],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let I=T?T[y]:0;(!I||!await(i.isElement==null?void 0:i.isElement(T)))&&(I=a.floating[y]||s.floating[w]);const N=E/2-S/2,j=I/2-b[w]/2-1,O=Tn(f[x],j),A=Tn(f[v],j),F=O,H=I-b[w]-A,D=I/2-b[w]/2+N,J=Ki(F,D,H),K=!c.arrow&&sr(o)!=null&&D!==J&&s.reference[w]/2-(D<F?O:A)-b[w]/2<0,oe=K?D<F?D-F:D-H:0;return{[m]:p[m]+oe,data:{[m]:J,centerOffset:D-J-oe,...K&&{alignmentOffset:oe}},reset:K}}}),Ow=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:c,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:b=!0,...g}=dn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=fn(o),v=rn(a),y=fn(a)===a,E=await(c.isRTL==null?void 0:c.isRTL(u.floating)),S=p||(y||!b?[rs(a)]:Ew(a)),T=w!=="none";!p&&T&&S.push(...Aw(a,b,w,E));const I=[a,...S],N=await Lr(t,g),j=[];let O=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&j.push(N[x]),f){const D=kw(o,i,E);j.push(N[D[0]],N[D[1]])}if(O=[...O,{placement:o,overflows:j}],!j.every(D=>D<=0)){var A,F;const D=(((A=s.flip)==null?void 0:A.index)||0)+1,J=I[D];if(J&&(!(f==="alignment"?v!==rn(J):!1)||O.every(W=>rn(W.placement)===v?W.overflows[0]>0:!0)))return{data:{index:D,overflows:O},reset:{placement:J}};let K=(F=O.filter(oe=>oe.overflows[0]<=0).sort((oe,W)=>oe.overflows[1]-W.overflows[1])[0])==null?void 0:F.placement;if(!K)switch(m){case"bestFit":{var H;const oe=(H=O.filter(W=>{if(T){const M=rn(W.placement);return M===v||M==="y"}return!0}).map(W=>[W.placement,W.overflows.filter(M=>M>0).reduce((M,X)=>M+X,0)]).sort((W,M)=>W[1]-M[1])[0])==null?void 0:H[0];oe&&(K=oe);break}case"initialPlacement":K=a;break}if(o!==K)return{reset:{placement:K}}}return{}}}};function md(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function gd(e){return yw.some(t=>e[t]>=0)}const Mw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=dn(e,t);switch(r){case"referenceHidden":{const s=await Lr(t,{...o,elementContext:"reference"}),i=md(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:gd(i)}}}case"escaped":{const s=await Lr(t,{...o,altBoundary:!0}),i=md(s,n.floating);return{data:{escapedOffsets:i,escaped:gd(i)}}}default:return{}}}}},xd=new Set(["left","top"]);async function Dw(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=fn(n),a=sr(n),c=rn(n)==="y",u=xd.has(i)?-1:1,d=s&&c?-1:1,f=dn(t,e);let{mainAxis:p,crossAxis:m,alignmentAxis:w}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof w=="number"&&(m=a==="end"?w*-1:w),c?{x:m*d,y:p*u}:{x:p*u,y:m*d}}const Lw=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,c=await Dw(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:i}}}}},$w=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:v}=g;return{x,y:v}}},...c}=dn(e,t),u={x:n,y:r},d=await Lr(t,c),f=rn(fn(o)),p=qi(f);let m=u[p],w=u[f];if(s){const g=p==="y"?"top":"left",x=p==="y"?"bottom":"right",v=m+d[g],y=m-d[x];m=Ki(v,m,y)}if(i){const g=f==="y"?"top":"left",x=f==="y"?"bottom":"right",v=w+d[g],y=w-d[x];w=Ki(v,w,y)}const b=a.fn({...t,[p]:m,[f]:w});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[p]:s,[f]:i}}}}}},Fw=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:c=!0,crossAxis:u=!0}=dn(e,t),d={x:n,y:r},f=rn(o),p=qi(f);let m=d[p],w=d[f];const b=dn(a,t),g=typeof b=="number"?{mainAxis:b,crossAxis:0}:{mainAxis:0,crossAxis:0,...b};if(c){const y=p==="y"?"height":"width",E=s.reference[p]-s.floating[y]+g.mainAxis,S=s.reference[p]+s.reference[y]-g.mainAxis;m<E?m=E:m>S&&(m=S)}if(u){var x,v;const y=p==="y"?"width":"height",E=xd.has(fn(o)),S=s.reference[f]-s.floating[y]+(E&&((x=i.offset)==null?void 0:x[f])||0)+(E?0:g.crossAxis),T=s.reference[f]+s.reference[y]+(E?0:((v=i.offset)==null?void 0:v[f])||0)-(E?g.crossAxis:0);w<S?w=S:w>T&&(w=T)}return{[p]:m,[f]:w}}}},zw=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:c=()=>{},...u}=dn(e,t),d=await Lr(t,u),f=fn(o),p=sr(o),m=rn(o)==="y",{width:w,height:b}=s.floating;let g,x;f==="top"||f==="bottom"?(g=f,x=p===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=f,g=p==="end"?"top":"bottom");const v=b-d.top-d.bottom,y=w-d.left-d.right,E=Tn(b-d[g],v),S=Tn(w-d[x],y),T=!t.middlewareData.shift;let I=E,N=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=v),T&&!p){const O=At(d.left,0),A=At(d.right,0),F=At(d.top,0),H=At(d.bottom,0);m?N=w-2*(O!==0||A!==0?O+A:At(d.left,d.right)):I=b-2*(F!==0||H!==0?F+H:At(d.top,d.bottom))}await c({...t,availableWidth:N,availableHeight:I});const j=await i.getDimensions(a.floating);return w!==j.width||b!==j.height?{reset:{rects:!0}}:{}}}};function ss(){return typeof window<"u"}function ir(e){return bd(e)?(e.nodeName||"").toLowerCase():"#document"}function Rt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function on(e){var t;return(t=(bd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function bd(e){return ss()?e instanceof Node||e instanceof Rt(e).Node:!1}function Gt(e){return ss()?e instanceof Element||e instanceof Rt(e).Element:!1}function sn(e){return ss()?e instanceof HTMLElement||e instanceof Rt(e).HTMLElement:!1}function vd(e){return!ss()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Rt(e).ShadowRoot}const Bw=new Set(["inline","contents"]);function $r(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Yt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Bw.has(o)}const Hw=new Set(["table","td","th"]);function Uw(e){return Hw.has(ir(e))}const Ww=[":popover-open",":modal"];function is(e){return Ww.some(t=>{try{return e.matches(t)}catch{return!1}})}const Vw=["transform","translate","scale","rotate","perspective"],Kw=["transform","translate","scale","rotate","perspective","filter"],qw=["paint","layout","strict","content"];function Ji(e){const t=Zi(),n=Gt(e)?Yt(e):e;return Vw.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)||Kw.some(r=>(n.willChange||"").includes(r))||qw.some(r=>(n.contain||"").includes(r))}function Gw(e){let t=kn(e);for(;sn(t)&&!ar(t);){if(Ji(t))return t;if(is(t))return null;t=kn(t)}return null}function Zi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Yw=new Set(["html","body","#document"]);function ar(e){return Yw.has(ir(e))}function Yt(e){return Rt(e).getComputedStyle(e)}function as(e){return Gt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function kn(e){if(ir(e)==="html")return e;const t=e.assignedSlot||e.parentNode||vd(e)&&e.host||on(e);return vd(t)?t.host:t}function wd(e){const t=kn(e);return ar(t)?e.ownerDocument?e.ownerDocument.body:e.body:sn(t)&&$r(t)?t:wd(t)}function Fr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=wd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Rt(o);if(s){const a=Qi(i);return t.concat(i,i.visualViewport||[],$r(o)?o:[],a&&n?Fr(a):[])}return t.concat(o,Fr(o,[],n))}function Qi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function yd(e){const t=Yt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=sn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=ts(n)!==s||ts(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ea(e){return Gt(e)?e:e.contextElement}function lr(e){const t=ea(e);if(!sn(t))return nn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=yd(t);let i=(s?ts(n.width):n.width)/r,a=(s?ts(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Xw=nn(0);function Sd(e){const t=Rt(e);return!Zi()||!t.visualViewport?Xw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Jw(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Rt(e)?!1:t}function zn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ea(e);let i=nn(1);t&&(r?Gt(r)&&(i=lr(r)):i=lr(e));const a=Jw(s,n,r)?Sd(s):nn(0);let c=(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 p=Rt(s),m=r&&Gt(r)?Rt(r):r;let w=p,b=Qi(w);for(;b&&r&&m!==w;){const g=lr(b),x=b.getBoundingClientRect(),v=Yt(b),y=x.left+(b.clientLeft+parseFloat(v.paddingLeft))*g.x,E=x.top+(b.clientTop+parseFloat(v.paddingTop))*g.y;c*=g.x,u*=g.y,d*=g.x,f*=g.y,c+=y,u+=E,w=Rt(b),b=Qi(w)}}return os({width:d,height:f,x:c,y:u})}function ta(e,t){const n=as(e).scrollLeft;return t?t.left+n:zn(on(e)).left+n}function Cd(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:ta(e,r)),s=r.top+t.scrollTop;return{x:o,y:s}}function Zw(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=on(r),a=t?is(t.floating):!1;if(r===i||a&&s)return n;let c={scrollLeft:0,scrollTop:0},u=nn(1);const d=nn(0),f=sn(r);if((f||!f&&!s)&&((ir(r)!=="body"||$r(i))&&(c=as(r)),sn(r))){const m=zn(r);u=lr(r),d.x=m.x+r.clientLeft,d.y=m.y+r.clientTop}const p=i&&!f&&!s?Cd(i,c,!0):nn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+p.x,y:n.y*u.y-c.scrollTop*u.y+d.y+p.y}}function Qw(e){return Array.from(e.getClientRects())}function ey(e){const t=on(e),n=as(e),r=e.ownerDocument.body,o=At(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=At(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ta(e);const a=-n.scrollTop;return Yt(r).direction==="rtl"&&(i+=At(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function ty(e,t){const n=Rt(e),r=on(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,c=0;if(o){s=o.width,i=o.height;const u=Zi();(!u||u&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}return{width:s,height:i,x:a,y:c}}const ny=new Set(["absolute","fixed"]);function ry(e,t){const n=zn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=sn(e)?lr(e):nn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,c=o*s.x,u=r*s.y;return{width:i,height:a,x:c,y:u}}function Td(e,t,n){let r;if(t==="viewport")r=ty(e,n);else if(t==="document")r=ey(on(e));else if(Gt(t))r=ry(t,n);else{const o=Sd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return os(r)}function kd(e,t){const n=kn(e);return n===t||!Gt(n)||ar(n)?!1:Yt(n).position==="fixed"||kd(n,t)}function oy(e,t){const n=t.get(e);if(n)return n;let r=Fr(e,[],!1).filter(a=>Gt(a)&&ir(a)!=="body"),o=null;const s=Yt(e).position==="fixed";let i=s?kn(e):e;for(;Gt(i)&&!ar(i);){const a=Yt(i),c=Ji(i);!c&&a.position==="fixed"&&(o=null),(s?!c&&!o:!c&&a.position==="static"&&!!o&&ny.has(o.position)||$r(i)&&!c&&kd(e,i))?r=r.filter(d=>d!==i):o=a,i=kn(i)}return t.set(e,r),r}function sy(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?is(t)?[]:oy(t,this._c):[].concat(n),r],a=i[0],c=i.reduce((u,d)=>{const f=Td(t,d,o);return u.top=At(f.top,u.top),u.right=Tn(f.right,u.right),u.bottom=Tn(f.bottom,u.bottom),u.left=At(f.left,u.left),u},Td(t,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function iy(e){const{width:t,height:n}=yd(e);return{width:t,height:n}}function ay(e,t,n){const r=sn(t),o=on(t),s=n==="fixed",i=zn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const c=nn(0);function u(){c.x=ta(o)}if(r||!r&&!s)if((ir(t)!=="body"||$r(o))&&(a=as(t)),r){const m=zn(t,!0,s,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?Cd(o,a):nn(0),f=i.left+a.scrollLeft-c.x-d.x,p=i.top+a.scrollTop-c.y-d.y;return{x:f,y:p,width:i.width,height:i.height}}function na(e){return Yt(e).position==="static"}function Ed(e,t){if(!sn(e)||Yt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return on(e)===n&&(n=n.ownerDocument.body),n}function Id(e,t){const n=Rt(e);if(is(e))return n;if(!sn(e)){let o=kn(e);for(;o&&!ar(o);){if(Gt(o)&&!na(o))return o;o=kn(o)}return n}let r=Ed(e,t);for(;r&&Uw(r)&&na(r);)r=Ed(r,t);return r&&ar(r)&&na(r)&&!Ji(r)?n:r||Gw(e)||n}const ly=async function(e){const t=this.getOffsetParent||Id,n=this.getDimensions,r=await n(e.floating);return{reference:ay(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function cy(e){return Yt(e).direction==="rtl"}const uy={convertOffsetParentRelativeRectToViewportRelativeRect:Zw,getDocumentElement:on,getClippingRect:sy,getOffsetParent:Id,getElementRects:ly,getClientRects:Qw,getDimensions:iy,getScale:lr,isElement:Gt,isRTL:cy};function Nd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function dy(e,t){let n=null,r;const o=on(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:p,height:m}=u;if(a||t(),!p||!m)return;const w=ns(f),b=ns(o.clientWidth-(d+p)),g=ns(o.clientHeight-(f+m)),x=ns(d),y={rootMargin:-w+"px "+-b+"px "+-g+"px "+-x+"px",threshold:At(0,Tn(1,c))||1};let E=!0;function S(T){const I=T[0].intersectionRatio;if(I!==c){if(!E)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!Nd(u,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(S,{...y,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,y)}n.observe(e)}return i(!0),s}function fy(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:c=!1}=r,u=ea(e),d=o||s?[...u?Fr(u):[],...Fr(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const f=u&&a?dy(u,n):null;let p=-1,m=null;i&&(m=new ResizeObserver(x=>{let[v]=x;v&&v.target===u&&m&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var y;(y=m)==null||y.observe(t)})),n()}),u&&!c&&m.observe(u),m.observe(t));let w,b=c?zn(e):null;c&&g();function g(){const x=zn(e);b&&!Nd(b,x)&&n(),b=x,w=requestAnimationFrame(g)}return n(),()=>{var x;d.forEach(v=>{o&&v.removeEventListener("scroll",n),s&&v.removeEventListener("resize",n)}),f==null||f(),(x=m)==null||x.disconnect(),m=null,c&&cancelAnimationFrame(w)}}const hy=Lw,py=$w,my=Ow,gy=zw,xy=Mw,jd=Pw,by=Fw,vy=(e,t,n)=>{const r=new Map,o={platform:uy,...n},s={...o.platform,_c:r};return _w(e,t,{...o,platform:s})};var wy=typeof document<"u",yy=function(){},ls=wy?C.useLayoutEffect:yy;function cs(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(!cs(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)&&!cs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Ad(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Rd(e,t){const n=Ad(e);return Math.round(t*n)/n}function ra(e){const t=h.useRef(e);return ls(()=>{t.current=e}),t}function Sy(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:c,open:u}=e,[d,f]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=h.useState(r);cs(p,r)||m(r);const[w,b]=h.useState(null),[g,x]=h.useState(null),v=h.useCallback(W=>{W!==T.current&&(T.current=W,b(W))},[]),y=h.useCallback(W=>{W!==I.current&&(I.current=W,x(W))},[]),E=s||w,S=i||g,T=h.useRef(null),I=h.useRef(null),N=h.useRef(d),j=c!=null,O=ra(c),A=ra(o),F=ra(u),H=h.useCallback(()=>{if(!T.current||!I.current)return;const W={placement:t,strategy:n,middleware:p};A.current&&(W.platform=A.current),vy(T.current,I.current,W).then(M=>{const X={...M,isPositioned:F.current!==!1};D.current&&!cs(N.current,X)&&(N.current=X,eo.flushSync(()=>{f(X)}))})},[p,t,n,A,F]);ls(()=>{u===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,f(W=>({...W,isPositioned:!1})))},[u]);const D=h.useRef(!1);ls(()=>(D.current=!0,()=>{D.current=!1}),[]),ls(()=>{if(E&&(T.current=E),S&&(I.current=S),E&&S){if(O.current)return O.current(E,S,H);H()}},[E,S,H,O,j]);const J=h.useMemo(()=>({reference:T,floating:I,setReference:v,setFloating:y}),[v,y]),K=h.useMemo(()=>({reference:E,floating:S}),[E,S]),oe=h.useMemo(()=>{const W={position:n,left:0,top:0};if(!K.floating)return W;const M=Rd(K.floating,d.x),X=Rd(K.floating,d.y);return a?{...W,transform:"translate("+M+"px, "+X+"px)",...Ad(K.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:M,top:X}},[n,a,K.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:H,refs:J,elements:K,floatingStyles:oe}),[d,H,J,K,oe])}const Cy=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?jd({element:r.current,padding:o}).fn(n):{}:r?jd({element:r,padding:o}).fn(n):{}}}},Ty=(e,t)=>({...hy(e),options:[e,t]}),ky=(e,t)=>({...py(e),options:[e,t]}),Ey=(e,t)=>({...by(e),options:[e,t]}),Iy=(e,t)=>({...my(e),options:[e,t]}),Ny=(e,t)=>({...gy(e),options:[e,t]}),jy=(e,t)=>({...xy(e),options:[e,t]}),Ay=(e,t)=>({...Cy(e),options:[e,t]});var Ry="Arrow",_d=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return l.jsx(Se.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:l.jsx("polygon",{points:"0,0 30,0 15,10"})})});_d.displayName=Ry;var _y=_d;function Pd(e){const[t,n]=h.useState(void 0);return lt(()=>{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 c=s.borderBoxSize,u=Array.isArray(c)?c[0]:c;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 oa="Popper",[Od,cr]=Vt(oa),[Py,Md]=Od(oa),Dd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return l.jsx(Py,{scope:t,anchor:r,onAnchorChange:o,children:n})};Dd.displayName=oa;var Ld="PopperAnchor",$d=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Md(Ld,n),i=h.useRef(null),a=Re(t,i),c=h.useRef(null);return h.useEffect(()=>{const u=c.current;c.current=(r==null?void 0:r.current)||i.current,u!==c.current&&s.onAnchorChange(c.current)}),r?null:l.jsx(Se.div,{...o,ref:a})});$d.displayName=Ld;var sa="PopperContent",[Oy,My]=Od(sa),Fd=h.forwardRef((e,t)=>{var z,_,Y,Q,de,ne;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:w,...b}=e,g=Md(sa,n),[x,v]=h.useState(null),y=Re(t,_e=>v(_e)),[E,S]=h.useState(null),T=Pd(E),I=(T==null?void 0:T.width)??0,N=(T==null?void 0:T.height)??0,j=r+(s!=="center"?"-"+s:""),O=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},A=Array.isArray(u)?u:[u],F=A.length>0,H={padding:O,boundary:A.filter(Ly),altBoundary:F},{refs:D,floatingStyles:J,placement:K,isPositioned:oe,middlewareData:W}=Sy({strategy:"fixed",placement:j,whileElementsMounted:(..._e)=>fy(..._e,{animationFrame:m==="always"}),elements:{reference:g.anchor},middleware:[Ty({mainAxis:o+N,alignmentAxis:i}),c&&ky({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Ey():void 0,...H}),c&&Iy({...H}),Ny({...H,apply:({elements:_e,rects:Pe,availableWidth:Ue,availableHeight:Ee})=>{const{width:Ae,height:et}=Pe.reference,qe=_e.floating.style;qe.setProperty("--radix-popper-available-width",`${Ue}px`),qe.setProperty("--radix-popper-available-height",`${Ee}px`),qe.setProperty("--radix-popper-anchor-width",`${Ae}px`),qe.setProperty("--radix-popper-anchor-height",`${et}px`)}}),E&&Ay({element:E,padding:a}),$y({arrowWidth:I,arrowHeight:N}),p&&jy({strategy:"referenceHidden",...H})]}),[M,X]=Hd(K),Z=dt(w);lt(()=>{oe&&(Z==null||Z())},[oe,Z]);const he=(z=W.arrow)==null?void 0:z.x,$=(_=W.arrow)==null?void 0:_.y,G=((Y=W.arrow)==null?void 0:Y.centerOffset)!==0,[ee,pe]=h.useState();return lt(()=>{x&&pe(window.getComputedStyle(x).zIndex)},[x]),l.jsx("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...J,transform:oe?J.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ee,"--radix-popper-transform-origin":[(Q=W.transformOrigin)==null?void 0:Q.x,(de=W.transformOrigin)==null?void 0:de.y].join(" "),...((ne=W.hide)==null?void 0:ne.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:l.jsx(Oy,{scope:n,placedSide:M,onArrowChange:S,arrowX:he,arrowY:$,shouldHideArrow:G,children:l.jsx(Se.div,{"data-side":M,"data-align":X,...b,ref:y,style:{...b.style,animation:oe?void 0:"none"}})})})});Fd.displayName=sa;var zd="PopperArrow",Dy={top:"bottom",right:"left",bottom:"top",left:"right"},Bd=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=My(zd,r),i=Dy[s.placedSide];return l.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:l.jsx(_y,{...o,ref:n,style:{...o.style,display:"block"}})})});Bd.displayName=zd;function Ly(e){return e!==null}var $y=e=>({name:"transformOrigin",options:e,fn(t){var g,x,v;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,d]=Hd(n),f={start:"0%",center:"50%",end:"100%"}[d],p=(((x=o.arrow)==null?void 0:x.x)??0)+a/2,m=(((v=o.arrow)==null?void 0:v.y)??0)+c/2;let w="",b="";return u==="bottom"?(w=i?f:`${p}px`,b=`${-c}px`):u==="top"?(w=i?f:`${p}px`,b=`${r.floating.height+c}px`):u==="right"?(w=`${-c}px`,b=i?f:`${m}px`):u==="left"&&(w=`${r.floating.width+c}px`,b=i?f:`${m}px`),{data:{x:w,y:b}}}});function Hd(e){const[t,n="center"]=e.split("-");return[t,n]}var ia=Dd,aa=$d,la=Fd,ca=Bd,ua="rovingFocusGroup.onEntryFocus",Fy={bubbles:!1,cancelable:!0},zr="RovingFocusGroup",[da,Ud,zy]=Vi(zr),[By,Wd]=Vt(zr,[zy]),[Hy,Uy]=By(zr),Vd=h.forwardRef((e,t)=>l.jsx(da.Provider,{scope:e.__scopeRovingFocusGroup,children:l.jsx(da.Slot,{scope:e.__scopeRovingFocusGroup,children:l.jsx(Wy,{...e,ref:t})})}));Vd.displayName=zr;var Wy=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,p=h.useRef(null),m=Re(t,p),w=es(s),[b,g]=wn({prop:i,defaultProp:a??null,onChange:c,caller:zr}),[x,v]=h.useState(!1),y=dt(u),E=Ud(n),S=h.useRef(!1),[T,I]=h.useState(0);return h.useEffect(()=>{const N=p.current;if(N)return N.addEventListener(ua,y),()=>N.removeEventListener(ua,y)},[y]),l.jsx(Hy,{scope:n,orientation:r,dir:w,loop:o,currentTabStopId:b,onItemFocus:h.useCallback(N=>g(N),[g]),onItemShiftTab:h.useCallback(()=>v(!0),[]),onFocusableItemAdd:h.useCallback(()=>I(N=>N+1),[]),onFocusableItemRemove:h.useCallback(()=>I(N=>N-1),[]),children:l.jsx(Se.div,{tabIndex:x||T===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:te(e.onMouseDown,()=>{S.current=!0}),onFocus:te(e.onFocus,N=>{const j=!S.current;if(N.target===N.currentTarget&&j&&!x){const O=new CustomEvent(ua,Fy);if(N.currentTarget.dispatchEvent(O),!O.defaultPrevented){const A=E().filter(K=>K.focusable),F=A.find(K=>K.active),H=A.find(K=>K.id===b),J=[F,H,...A].filter(Boolean).map(K=>K.ref.current);Gd(J,d)}}S.current=!1}),onBlur:te(e.onBlur,()=>v(!1))})})}),Kd="RovingFocusGroupItem",qd=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,c=Kt(),u=s||c,d=Uy(Kd,n),f=d.currentTabStopId===u,p=Ud(n),{onFocusableItemAdd:m,onFocusableItemRemove:w,currentTabStopId:b}=d;return h.useEffect(()=>{if(r)return m(),()=>w()},[r,m,w]),l.jsx(da.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:l.jsx(Se.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:te(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:te(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:te(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=qy(g,d.orientation,d.dir);if(x!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let y=p().filter(E=>E.focusable).map(E=>E.ref.current);if(x==="last")y.reverse();else if(x==="prev"||x==="next"){x==="prev"&&y.reverse();const E=y.indexOf(g.currentTarget);y=d.loop?Gy(y,E+1):y.slice(E+1)}setTimeout(()=>Gd(y))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:b!=null}):i})})});qd.displayName=Kd;var Vy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ky(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function qy(e,t,n){const r=Ky(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Vy[r]}function Gd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Gy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Yy=Vd,Xy=qd,fa=["Enter"," "],Jy=["ArrowDown","PageUp","Home"],Yd=["ArrowUp","PageDown","End"],Zy=[...Jy,...Yd],Qy={ltr:[...fa,"ArrowRight"],rtl:[...fa,"ArrowLeft"]},e0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Br="Menu",[Hr,t0,n0]=Vi(Br),[Bn,Xd]=Vt(Br,[n0,cr,Wd]),us=cr(),Jd=Wd(),[r0,Hn]=Bn(Br),[o0,Ur]=Bn(Br),Zd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=us(t),[c,u]=h.useState(null),d=h.useRef(!1),f=dt(s),p=es(o);return h.useEffect(()=>{const m=()=>{d.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>d.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),l.jsx(ia,{...a,children:l.jsx(r0,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:u,children:l.jsx(o0,{scope:t,onClose:h.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:i,children:r})})})};Zd.displayName=Br;var s0="MenuAnchor",ha=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=us(n);return l.jsx(aa,{...o,...r,ref:t})});ha.displayName=s0;var pa="MenuPortal",[i0,Qd]=Bn(pa,{forceMount:void 0}),ef=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Hn(pa,t);return l.jsx(i0,{scope:t,forceMount:n,children:l.jsx(Tt,{present:n||s.open,children:l.jsx(Lo,{asChild:!0,container:o,children:r})})})};ef.displayName=pa;var $t="MenuContent",[a0,ma]=Bn($t),tf=h.forwardRef((e,t)=>{const n=Qd($t,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Hn($t,e.__scopeMenu),i=Ur($t,e.__scopeMenu);return l.jsx(Hr.Provider,{scope:e.__scopeMenu,children:l.jsx(Tt,{present:r||s.open,children:l.jsx(Hr.Slot,{scope:e.__scopeMenu,children:i.modal?l.jsx(l0,{...o,ref:t}):l.jsx(c0,{...o,ref:t})})})})}),l0=h.forwardRef((e,t)=>{const n=Hn($t,e.__scopeMenu),r=h.useRef(null),o=Re(t,r);return h.useEffect(()=>{const s=r.current;if(s)return Fi(s)},[]),l.jsx(ga,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:te(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),c0=h.forwardRef((e,t)=>{const n=Hn($t,e.__scopeMenu);return l.jsx(ga,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),u0=Et.createSlot("MenuContent.ScrollLock"),ga=h.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,disableOutsideScroll:w,...b}=e,g=Hn($t,n),x=Ur($t,n),v=us(n),y=Jd(n),E=t0(n),[S,T]=h.useState(null),I=h.useRef(null),N=Re(t,I,g.onContentChange),j=h.useRef(0),O=h.useRef(""),A=h.useRef(0),F=h.useRef(null),H=h.useRef("right"),D=h.useRef(0),J=w?Uo:h.Fragment,K=w?{as:u0,allowPinchZoom:!0}:void 0,oe=M=>{var z,_;const X=O.current+M,Z=E().filter(Y=>!Y.disabled),he=document.activeElement,$=(z=Z.find(Y=>Y.ref.current===he))==null?void 0:z.textValue,G=Z.map(Y=>Y.textValue),ee=S0(G,X,$),pe=(_=Z.find(Y=>Y.textValue===ee))==null?void 0:_.ref.current;(function Y(Q){O.current=Q,window.clearTimeout(j.current),Q!==""&&(j.current=window.setTimeout(()=>Y(""),1e3))})(X),pe&&setTimeout(()=>pe.focus())};h.useEffect(()=>()=>window.clearTimeout(j.current),[]),Pi();const W=h.useCallback(M=>{var Z,he;return H.current===((Z=F.current)==null?void 0:Z.side)&&T0(M,(he=F.current)==null?void 0:he.area)},[]);return l.jsx(a0,{scope:n,searchRef:O,onItemEnter:h.useCallback(M=>{W(M)&&M.preventDefault()},[W]),onItemLeave:h.useCallback(M=>{var X;W(M)||((X=I.current)==null||X.focus(),T(null))},[W]),onTriggerLeave:h.useCallback(M=>{W(M)&&M.preventDefault()},[W]),pointerGraceTimerRef:A,onPointerGraceIntentChange:h.useCallback(M=>{F.current=M},[]),children:l.jsx(J,{...K,children:l.jsx(Do,{asChild:!0,trapped:o,onMountAutoFocus:te(s,M=>{var X;M.preventDefault(),(X=I.current)==null||X.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:l.jsx(Mr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,children:l.jsx(Yy,{asChild:!0,...y,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:T,onEntryFocus:te(c,M=>{x.isUsingKeyboardRef.current||M.preventDefault()}),preventScrollOnEntryFocus:!0,children:l.jsx(la,{role:"menu","aria-orientation":"vertical","data-state":vf(g.open),"data-radix-menu-content":"",dir:x.dir,...v,...b,ref:N,style:{outline:"none",...b.style},onKeyDown:te(b.onKeyDown,M=>{const Z=M.target.closest("[data-radix-menu-content]")===M.currentTarget,he=M.ctrlKey||M.altKey||M.metaKey,$=M.key.length===1;Z&&(M.key==="Tab"&&M.preventDefault(),!he&&$&&oe(M.key));const G=I.current;if(M.target!==G||!Zy.includes(M.key))return;M.preventDefault();const pe=E().filter(z=>!z.disabled).map(z=>z.ref.current);Yd.includes(M.key)&&pe.reverse(),w0(pe)}),onBlur:te(e.onBlur,M=>{M.currentTarget.contains(M.target)||(window.clearTimeout(j.current),O.current="")}),onPointerMove:te(e.onPointerMove,Vr(M=>{const X=M.target,Z=D.current!==M.clientX;if(M.currentTarget.contains(X)&&Z){const he=M.clientX>D.current?"right":"left";H.current=he,D.current=M.clientX}}))})})})})})})});tf.displayName=$t;var d0="MenuGroup",xa=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(Se.div,{role:"group",...r,ref:t})});xa.displayName=d0;var f0="MenuLabel",nf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(Se.div,{...r,ref:t})});nf.displayName=f0;var ds="MenuItem",rf="menu.itemSelect",fs=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=Ur(ds,e.__scopeMenu),a=ma(ds,e.__scopeMenu),c=Re(t,s),u=h.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const p=new CustomEvent(rf,{bubbles:!0,cancelable:!0});f.addEventListener(rf,m=>r==null?void 0:r(m),{once:!0}),Uc(f,p),p.defaultPrevented?u.current=!1:i.onClose()}};return l.jsx(of,{...o,ref:c,disabled:n,onClick:te(e.onClick,d),onPointerDown:f=>{var p;(p=e.onPointerDown)==null||p.call(e,f),u.current=!0},onPointerUp:te(e.onPointerUp,f=>{var p;u.current||(p=f.currentTarget)==null||p.click()}),onKeyDown:te(e.onKeyDown,f=>{const p=a.searchRef.current!=="";n||p&&f.key===" "||fa.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});fs.displayName=ds;var of=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ma(ds,n),a=Jd(n),c=h.useRef(null),u=Re(t,c),[d,f]=h.useState(!1),[p,m]=h.useState("");return h.useEffect(()=>{const w=c.current;w&&m((w.textContent??"").trim())},[s.children]),l.jsx(Hr.ItemSlot,{scope:n,disabled:r,textValue:o??p,children:l.jsx(Xy,{asChild:!0,...a,focusable:!r,children:l.jsx(Se.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:te(e.onPointerMove,Vr(w=>{r?i.onItemLeave(w):(i.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:te(e.onPointerLeave,Vr(w=>i.onItemLeave(w))),onFocus:te(e.onFocus,()=>f(!0)),onBlur:te(e.onBlur,()=>f(!1))})})})}),h0="MenuCheckboxItem",sf=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return l.jsx(df,{scope:e.__scopeMenu,checked:n,children:l.jsx(fs,{role:"menuitemcheckbox","aria-checked":hs(n)?"mixed":n,...o,ref:t,"data-state":va(n),onSelect:te(o.onSelect,()=>r==null?void 0:r(hs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});sf.displayName=h0;var af="MenuRadioGroup",[p0,m0]=Bn(af,{value:void 0,onValueChange:()=>{}}),lf=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=dt(r);return l.jsx(p0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:l.jsx(xa,{...o,ref:t})})});lf.displayName=af;var cf="MenuRadioItem",uf=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=m0(cf,e.__scopeMenu),s=n===o.value;return l.jsx(df,{scope:e.__scopeMenu,checked:s,children:l.jsx(fs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":va(s),onSelect:te(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});uf.displayName=cf;var ba="MenuItemIndicator",[df,g0]=Bn(ba,{checked:!1}),ff=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=g0(ba,n);return l.jsx(Tt,{present:r||hs(s.checked)||s.checked===!0,children:l.jsx(Se.span,{...o,ref:t,"data-state":va(s.checked)})})});ff.displayName=ba;var x0="MenuSeparator",hf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(Se.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});hf.displayName=x0;var b0="MenuArrow",pf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=us(n);return l.jsx(ca,{...o,...r,ref:t})});pf.displayName=b0;var v0="MenuSub",[ZT,mf]=Bn(v0),Wr="MenuSubTrigger",gf=h.forwardRef((e,t)=>{const n=Hn(Wr,e.__scopeMenu),r=Ur(Wr,e.__scopeMenu),o=mf(Wr,e.__scopeMenu),s=ma(Wr,e.__scopeMenu),i=h.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:c}=s,u={__scopeMenu:e.__scopeMenu},d=h.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return h.useEffect(()=>d,[d]),h.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),c(null)}},[a,c]),l.jsx(ha,{asChild:!0,...u,children:l.jsx(of,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":vf(n.open),...e,ref:wi(t,o.onTriggerChange),onClick:f=>{var p;(p=e.onClick)==null||p.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:te(e.onPointerMove,Vr(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:te(e.onPointerLeave,Vr(f=>{var m,w;d();const p=(m=n.content)==null?void 0:m.getBoundingClientRect();if(p){const b=(w=n.content)==null?void 0:w.dataset.side,g=b==="right",x=g?-5:5,v=p[g?"left":"right"],y=p[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+x,y:f.clientY},{x:v,y:p.top},{x:y,y:p.top},{x:y,y:p.bottom},{x:v,y:p.bottom}],side:b}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:te(e.onKeyDown,f=>{var m;const p=s.searchRef.current!=="";e.disabled||p&&f.key===" "||Qy[r.dir].includes(f.key)&&(n.onOpenChange(!0),(m=n.content)==null||m.focus(),f.preventDefault())})})})});gf.displayName=Wr;var xf="MenuSubContent",bf=h.forwardRef((e,t)=>{const n=Qd($t,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Hn($t,e.__scopeMenu),i=Ur($t,e.__scopeMenu),a=mf(xf,e.__scopeMenu),c=h.useRef(null),u=Re(t,c);return l.jsx(Hr.Provider,{scope:e.__scopeMenu,children:l.jsx(Tt,{present:r||s.open,children:l.jsx(Hr.Slot,{scope:e.__scopeMenu,children:l.jsx(ga,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=c.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:te(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:te(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:te(e.onKeyDown,d=>{var m;const f=d.currentTarget.contains(d.target),p=e0[i.dir].includes(d.key);f&&p&&(s.onOpenChange(!1),(m=a.trigger)==null||m.focus(),d.preventDefault())})})})})})});bf.displayName=xf;function vf(e){return e?"open":"closed"}function hs(e){return e==="indeterminate"}function va(e){return hs(e)?"indeterminate":e?"checked":"unchecked"}function w0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function y0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function S0(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=y0(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function C0(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],c=t[i],u=a.x,d=a.y,f=c.x,p=c.y;d>r!=p>r&&n<(f-u)*(r-d)/(p-d)+u&&(o=!o)}return o}function T0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return C0(n,t)}function Vr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var k0=Zd,E0=ha,I0=ef,N0=tf,j0=xa,A0=nf,R0=fs,_0=sf,P0=lf,O0=uf,M0=ff,D0=hf,L0=pf,$0=gf,F0=bf,ps="DropdownMenu",[z0,QT]=Vt(ps,[Xd]),vt=Xd(),[B0,wf]=z0(ps),yf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,c=vt(t),u=h.useRef(null),[d,f]=wn({prop:o,defaultProp:s??!1,onChange:i,caller:ps});return l.jsx(B0,{scope:t,triggerId:Kt(),triggerRef:u,contentId:Kt(),open:d,onOpenChange:f,onOpenToggle:h.useCallback(()=>f(p=>!p),[f]),modal:a,children:l.jsx(k0,{...c,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};yf.displayName=ps;var Sf="DropdownMenuTrigger",Cf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=wf(Sf,n),i=vt(n);return l.jsx(E0,{asChild:!0,...i,children:l.jsx(Se.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:wi(t,s.triggerRef),onPointerDown:te(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:te(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Cf.displayName=Sf;var H0="DropdownMenuPortal",Tf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=vt(t);return l.jsx(I0,{...r,...n})};Tf.displayName=H0;var kf="DropdownMenuContent",Ef=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=wf(kf,n),s=vt(n),i=h.useRef(!1);return l.jsx(N0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:te(e.onCloseAutoFocus,a=>{var c;i.current||(c=o.triggerRef.current)==null||c.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:te(e.onInteractOutside,a=>{const c=a.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,d=c.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)"}})});Ef.displayName=kf;var U0="DropdownMenuGroup",W0=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(j0,{...o,...r,ref:t})});W0.displayName=U0;var V0="DropdownMenuLabel",If=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(A0,{...o,...r,ref:t})});If.displayName=V0;var K0="DropdownMenuItem",Nf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(R0,{...o,...r,ref:t})});Nf.displayName=K0;var q0="DropdownMenuCheckboxItem",jf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(_0,{...o,...r,ref:t})});jf.displayName=q0;var G0="DropdownMenuRadioGroup",Y0=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(P0,{...o,...r,ref:t})});Y0.displayName=G0;var X0="DropdownMenuRadioItem",Af=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(O0,{...o,...r,ref:t})});Af.displayName=X0;var J0="DropdownMenuItemIndicator",Rf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(M0,{...o,...r,ref:t})});Rf.displayName=J0;var Z0="DropdownMenuSeparator",_f=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(D0,{...o,...r,ref:t})});_f.displayName=Z0;var Q0="DropdownMenuArrow",eS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(L0,{...o,...r,ref:t})});eS.displayName=Q0;var tS="DropdownMenuSubTrigger",Pf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx($0,{...o,...r,ref:t})});Pf.displayName=tS;var nS="DropdownMenuSubContent",Of=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vt(n);return l.jsx(F0,{...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)"}})});Of.displayName=nS;var rS=yf,oS=Cf,sS=Tf,Mf=Ef,Df=If,Lf=Nf,$f=jf,Ff=Af,zf=Rf,Bf=_f,Hf=Pf,Uf=Of;const iS=rS,aS=oS,lS=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>l.jsxs(Hf,{ref:o,className:L("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,l.jsx(se.ChevronRight,{className:"ml-auto h-4 w-4"})]}));lS.displayName=Hf.displayName;const cS=h.forwardRef(({className:e,...t},n)=>l.jsx(Uf,{ref:n,className:L("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}));cS.displayName=Uf.displayName;const Wf=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>l.jsx(sS,{children:l.jsx(Mf,{ref:r,sideOffset:t,className:L("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})}));Wf.displayName=Mf.displayName;const wa=h.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(Lf,{ref:r,className:L("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=Lf.displayName;const uS=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>l.jsxs($f,{ref:o,className:L("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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(zf,{children:l.jsx(se.Check,{className:"h-4 w-4"})})}),t]}));uS.displayName=$f.displayName;const dS=h.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Ff,{ref:r,className:L("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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(zf,{children:l.jsx(se.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));dS.displayName=Ff.displayName;const fS=h.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(Df,{ref:r,className:L("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));fS.displayName=Df.displayName;const hS=h.forwardRef(({className:e,...t},n)=>l.jsx(Bf,{ref:n,className:L("-mx-1 my-1 h-px bg-muted",e),...t}));hS.displayName=Bf.displayName;function Kr({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:c=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:p,onError:m}){const{currentThreadId:w,messages:b,isStreaming:g,streamingAssistantId:x,error:v,send:y,stop:E,lastCheckpointId:S,lastCheckpointNs:T,listCheckpoints:I,navigateToCheckpoint:N,returnToLatest:j,hasMoreHistory:O,isLoadingHistory:A,loadOlderMessages:F,api:H}=ho(),[D,J]=C.useState(null),[K,oe]=C.useState(""),[W,M]=C.useState(null),[X,Z]=C.useState([]),[he,$]=C.useState(!1),[G,ee]=C.useState(null),[pe,z]=C.useState(null),[_,Y]=C.useState(!1),[Q,de]=C.useState(null),[ne,_e]=C.useState([]),[Pe,Ue]=C.useState(null),[Ee,Ae]=C.useState(null),[et,qe]=C.useState(!1),ct=C.useRef(null),ut=C.useRef(null),ve=C.useRef(null),[Fe,Ge]=C.useState("desktop");C.useEffect(()=>{const re=()=>{const me=window.innerWidth;Ge(me<640?"phone":me<1024?"tablet":"desktop")};return re(),window.addEventListener("resize",re),()=>window.removeEventListener("resize",re)},[]),C.useEffect(()=>{let re=!1;if(!w){_e([]),Ue(null),Ae(null),ve.current=null;return}const me={threadId:w,checkpointId:S??null,checkpointNs:T??null},De=ve.current;if(!(De&&De.threadId===me.threadId&&De.checkpointId===me.checkpointId&&De.checkpointNs===me.checkpointNs))return I(w).then(Xe=>{var Zr;if(re)return;const ln=((Xe==null?void 0:Xe.checkpoints)??[]).slice().sort((pn,Qr)=>new Date(Qr.createdAt).getTime()-new Date(pn.createdAt).getTime());_e(ln);const cn=Pe,Xr=cn&&ln.some(pn=>pn.checkpointId===cn)?cn:((Zr=ln[0])==null?void 0:Zr.checkpointId)??null;let Jr=null;if(Xr){const pn=ln.find(Qr=>Qr.checkpointId===Xr);Jr=(pn==null?void 0:pn.checkpointNs)??null}Ue(Xr),Ae(Jr),ve.current=me}).catch(Xe=>{console.error("ChatInterface - listCheckpoints error:",Xe),re||(_e([]),ve.current=null)}),()=>{re=!0}},[w,S,T,Pe,I]),C.useEffect(()=>{S&&(Ue(S),Ae(T??null))},[S,T]);const P=C.useCallback(async()=>{if(!(!O||A))try{await F()}catch(re){console.warn("loadOlderMessages failed",re)}},[O,A,F]);C.useEffect(()=>{(async()=>{try{const me=await H.getAgent("default");de(me.uiDefaultMessage||null)}catch(me){console.warn("Failed to fetch default message:",me),de(null)}})()},[H]),C.useEffect(()=>{v&&!_&&(m==null||m(v))},[v,_,m]);const U=re=>{if(re.length>Qo)return`Message too long (${re.length}/${Qo} characters)`;try{return vw(re),null}catch(me){return(me==null?void 0:me.message)||"Invalid message"}},ue=async re=>{const me=re.trim();if(!(!me&&X.length===0)){if(me){const De=U(me);if(De){M(De);return}}try{await y(me||"",{checkpointId:Pe??S??void 0,checkpointNs:Ee??T??void 0,payloadExtras:D?{edit:!0,originalMessageId:D}:void 0,attachments:X}),f==null||f(me),M(null),Z([]),J(null),oe("")}catch(De){const Xe=(De==null?void 0:De.message)||"Failed to send message";M(Xe),m==null||m(Xe)}}},be=C.useCallback((re,me)=>{u&&(J(re),oe(me),M(null))},[u]),le=C.useCallback(()=>{J(null),oe(""),M(null)},[]),Be=C.useCallback((re,me)=>{be(re,me)},[be]),at=C.useCallback(re=>{const me=De=>{const Xe=De.content||[],ln=Xe.filter(cn=>cn.type==="text").map(cn=>cn.text).join("");if(ln)return ln;try{return JSON.stringify(Xe,null,2)}catch{return String(Xe)}};for(let De=re-1;De>=0;De--)if(b[De].role==="user"){const Xe=me(b[De]);Xe&&y(Xe,{checkpointId:Pe??S??void 0,checkpointNs:Ee??T??void 0});break}},[b,y,Pe,Ee,S,T]),hn=re=>{const me=Array.from(re.target.files||[]);Z(De=>[...De,...me])},xt=re=>Z(me=>me.filter((De,Xe)=>re!==Xe)),_t=async re=>{const me=(re.target.files||[])[0];if(me){ee(null),z(null),$(!0);try{await y("",{checkpointId:Pe??S??void 0,checkpointNs:Ee??T??void 0,attachments:[me]});const De=`Uploaded ${me.name} - processing through chat stream`;z(De)}catch(De){const Xe=De instanceof Error?De.message:"Failed to upload Excel file";console.error("Excel upload failed",De),ee(Xe),m==null||m(Xe)}finally{$(!1),re.target.value=""}}},ft=re=>{if(!re)return"Unknown";const me=Date.parse(re);return Number.isNaN(me)?re:new Date(me).toLocaleString()},Pt=async re=>{if(w){qe(!0);try{if(!re){await j(),Ue(null),Ae(null);return}const me=ne.find(Xe=>Xe.checkpointId===re),De=(me==null?void 0:me.checkpointNs)??null;await N(re,De),Ue(re),Ae(De)}finally{qe(!1)}}},jn=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,Kn=`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||""}`,qn=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return l.jsxs("div",{className:jn,children:[!!v&&!_&&l.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:[l.jsx("span",{children:v}),l.jsx(ze,{variant:"ghost",size:"sm",onClick:()=>Y(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:l.jsx(se.X,{size:16})})]}),w&&ne.length>0&&l.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:[l.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),l.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:re=>{const me=re.target.value||null;Pt(me)},children:[l.jsx("option",{value:"",children:"Latest"}),ne.map(re=>l.jsxs("option",{value:re.checkpointId,children:[ft(re.createdAt),re.preview?` — ${re.preview.slice(0,40)}`:""]},re.checkpointId))]})]}),l.jsx(Wi,{className:Kn,style:r?{maxHeight:r}:void 0,messages:b,isStreaming:g,streamingAssistantId:x,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Fe,enableMessageEditing:u,editingMessageId:D,onStartReached:()=>{P()},onEdit:Be,onRegenerate:at,onCancelEdit:le,emptyMessage:Q??void 0,isNavigatingCheckpoint:et}),l.jsxs("div",{className:qn,children:[D&&l.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(se.Edit3,{size:16,className:"text-blue-600"}),l.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),l.jsx(ze,{variant:"ghost",size:"sm",onClick:le,className:"text-blue-600 hover:bg-blue-100",children:l.jsx(se.X,{size:16})})]})}),(a||c)&&l.jsxs("div",{className:"mb-3 space-y-3",children:[a&&l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:ct,type:"file",multiple:!0,onChange:re=>hn(re),className:"hidden"}),X.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2",children:X.map((re,me)=>l.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:[l.jsx(se.Paperclip,{size:14}),l.jsx("span",{className:"truncate max-w-[150px]",children:re.name}),l.jsx(ze,{variant:"ghost",size:"sm",onClick:()=>xt(me),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 ${re.name}`,children:l.jsx(se.X,{size:12})})]},me))})]}),c&&l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:ut,type:"file",accept:".xls,.xlsx,.xlsm",onChange:_t,className:"hidden"}),he&&l.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[l.jsx(se.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),pe&&!he&&l.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:pe}),G&&!he&&l.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:G})]})]}),W&&l.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:W}),l.jsxs("div",{className:"flex items-end gap-2",children:[(a||c)&&l.jsxs(iS,{children:[l.jsx(aS,{asChild:!0,children:l.jsx(ze,{type:"button",size:"icon",variant:"outline",disabled:g,title:"More input actions",className:d.moreButton||"",children:l.jsx(se.Plus,{size:16})})}),l.jsxs(Wf,{align:"start",sideOffset:6,className:"w-52",children:[a&&l.jsxs(wa,{onClick:()=>{var re;return(re=ct.current)==null?void 0:re.click()},className:"cursor-pointer",children:[l.jsx(se.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),c&&l.jsxs(wa,{onClick:()=>{var re;he||(re=ut.current)==null||re.click()},className:`cursor-pointer ${he?"opacity-60 pointer-events-none":""}`,children:[l.jsx(se.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),l.jsx("div",{className:"flex-1",children:l.jsx(Ag,{initialValue:K,editingMessageId:D,placeholder:D?"Edit your message...":t,isStreaming:g,disabled:!1,maxLength:Qo,onSend:ue,onCancelEdit:le,onStop:E,allowEmptySend:X.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${D?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${W?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const qr=h.forwardRef(({className:e,type:t,...n},r)=>l.jsx("input",{type:t,className:L("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}));qr.displayName="Input";function ya(e,[t,n]){return Math.min(n,Math.max(t,e))}function pS(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Sa="ScrollArea",[Vf,ek]=Vt(Sa),[mS,Ft]=Vf(Sa),Kf=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,c]=h.useState(null),[u,d]=h.useState(null),[f,p]=h.useState(null),[m,w]=h.useState(null),[b,g]=h.useState(null),[x,v]=h.useState(0),[y,E]=h.useState(0),[S,T]=h.useState(!1),[I,N]=h.useState(!1),j=Re(t,A=>c(A)),O=es(o);return l.jsx(mS,{scope:n,type:r,dir:O,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:p,scrollbarX:m,onScrollbarXChange:w,scrollbarXEnabled:S,onScrollbarXEnabledChange:T,scrollbarY:b,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:N,onCornerWidthChange:v,onCornerHeightChange:E,children:l.jsx(Se.div,{dir:O,...i,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":y+"px",...e.style}})})});Kf.displayName=Sa;var qf="ScrollAreaViewport",Gf=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Ft(qf,n),a=h.useRef(null),c=Re(t,a,i.onViewportChange);return l.jsxs(l.Fragment,{children:[l.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}),l.jsx(Se.div,{"data-radix-scroll-area-viewport":"",...s,ref:c,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:l.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Gf.displayName=qf;var an="ScrollAreaScrollbar",Ca=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ft(an,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return h.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?l.jsx(gS,{...r,ref:t,forceMount:n}):o.type==="scroll"?l.jsx(xS,{...r,ref:t,forceMount:n}):o.type==="auto"?l.jsx(Yf,{...r,ref:t,forceMount:n}):o.type==="always"?l.jsx(Ta,{...r,ref:t}):null});Ca.displayName=an;var gS=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ft(an,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let c=0;if(a){const u=()=>{window.clearTimeout(c),i(!0)},d=()=>{c=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),l.jsx(Tt,{present:n||s,children:l.jsx(Yf,{"data-state":s?"visible":"hidden",...r,ref:t})})}),xS=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ft(an,e.__scopeScrollArea),s=e.orientation==="horizontal",i=bs(()=>c("SCROLL_END"),100),[a,c]=pS("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 h.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,c]),h.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const p=()=>{const m=u[d];f!==m&&(c("SCROLL"),i()),f=m};return u.addEventListener("scroll",p),()=>u.removeEventListener("scroll",p)}},[o.viewport,s,c,i]),l.jsx(Tt,{present:n||a!=="hidden",children:l.jsx(Ta,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:te(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:te(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),Yf=h.forwardRef((e,t)=>{const n=Ft(an,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",c=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 ur(n.viewport,c),ur(n.content,c),l.jsx(Tt,{present:r||s,children:l.jsx(Ta,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Ta=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Ft(an,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,c]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=eh(a.viewport,a.content),d={...r,sizes:a,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:p=>s.current=p,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:p=>i.current=p};function f(p,m){return CS(p,i.current,a,m)}return n==="horizontal"?l.jsx(bS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollLeft,m=th(p,a,o.dir);s.current.style.transform=`translate3d(${m}px, 0, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollLeft=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollLeft=f(p,o.dir))}}):n==="vertical"?l.jsx(vS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollTop,m=th(p,a);s.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollTop=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollTop=f(p))}}):null}),bS=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Ft(an,e.__scopeScrollArea),[i,a]=h.useState(),c=h.useRef(null),u=Re(t,c,s.onScrollbarXChange);return h.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(Jf,{"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":xs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const p=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(p),rh(p,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:gs(i.paddingLeft),paddingEnd:gs(i.paddingRight)}})}})}),vS=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Ft(an,e.__scopeScrollArea),[i,a]=h.useState(),c=h.useRef(null),u=Re(t,c,s.onScrollbarYChange);return h.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(Jf,{"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":xs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const p=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(p),rh(p,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:gs(i.paddingTop),paddingEnd:gs(i.paddingBottom)}})}})}),[wS,Xf]=Vf(an),Jf=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:f,...p}=e,m=Ft(an,n),[w,b]=h.useState(null),g=Re(t,j=>b(j)),x=h.useRef(null),v=h.useRef(""),y=m.viewport,E=r.content-r.viewport,S=dt(d),T=dt(c),I=bs(f,10);function N(j){if(x.current){const O=j.clientX-x.current.left,A=j.clientY-x.current.top;u({x:O,y:A})}}return h.useEffect(()=>{const j=O=>{const A=O.target;(w==null?void 0:w.contains(A))&&S(O,E)};return document.addEventListener("wheel",j,{passive:!1}),()=>document.removeEventListener("wheel",j,{passive:!1})},[y,w,E,S]),h.useEffect(T,[r,T]),ur(w,I),ur(m.content,I),l.jsx(wS,{scope:n,scrollbar:w,hasThumb:o,onThumbChange:dt(s),onThumbPointerUp:dt(i),onThumbPositionChange:T,onThumbPointerDown:dt(a),children:l.jsx(Se.div,{...p,ref:g,style:{position:"absolute",...p.style},onPointerDown:te(e.onPointerDown,j=>{j.button===0&&(j.target.setPointerCapture(j.pointerId),x.current=w.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),N(j))}),onPointerMove:te(e.onPointerMove,N),onPointerUp:te(e.onPointerUp,j=>{const O=j.target;O.hasPointerCapture(j.pointerId)&&O.releasePointerCapture(j.pointerId),document.body.style.webkitUserSelect=v.current,m.viewport&&(m.viewport.style.scrollBehavior=""),x.current=null})})})}),ms="ScrollAreaThumb",Zf=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Xf(ms,e.__scopeScrollArea);return l.jsx(Tt,{present:n||o.hasThumb,children:l.jsx(yS,{ref:t,...r})})}),yS=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Ft(ms,n),i=Xf(ms,n),{onThumbPositionChange:a}=i,c=Re(t,f=>i.onThumbChange(f)),u=h.useRef(void 0),d=bs(()=>{u.current&&(u.current(),u.current=void 0)},100);return h.useEffect(()=>{const f=s.viewport;if(f){const p=()=>{if(d(),!u.current){const m=TS(f,a);u.current=m,a()}};return a(),f.addEventListener("scroll",p),()=>f.removeEventListener("scroll",p)}},[s.viewport,d,a]),l.jsx(Se.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:te(e.onPointerDownCapture,f=>{const m=f.target.getBoundingClientRect(),w=f.clientX-m.left,b=f.clientY-m.top;i.onThumbPointerDown({x:w,y:b})}),onPointerUp:te(e.onPointerUp,i.onThumbPointerUp)})});Zf.displayName=ms;var ka="ScrollAreaCorner",Qf=h.forwardRef((e,t)=>{const n=Ft(ka,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?l.jsx(SS,{...e,ref:t}):null});Qf.displayName=ka;var SS=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Ft(ka,n),[s,i]=h.useState(0),[a,c]=h.useState(0),u=!!(s&&a);return ur(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),c(d)}),ur(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?l.jsx(Se.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 gs(e){return e?parseInt(e,10):0}function eh(e,t){const n=e/t;return isNaN(n)?0:n}function xs(e){const t=eh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function CS(e,t,n,r="ltr"){const o=xs(n),s=o/2,i=t||s,a=o-i,c=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 nh([c,u],f)(e)}function th(e,t,n="ltr"){const r=xs(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,c=n==="ltr"?[0,i]:[i*-1,0],u=ya(e,c);return nh([0,i],[0,a])(u)}function nh(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 rh(e,t){return e>0&&e<t}var TS=(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=dt(e),r=h.useRef(0);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),h.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function ur(e,t){const n=dt(t);lt(()=>{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 oh=Kf,kS=Gf,ES=Qf;const sh=h.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(oh,{ref:r,className:L("relative overflow-hidden",e),...n,children:[l.jsx(kS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),l.jsx(ih,{}),l.jsx(ES,{})]}));sh.displayName=oh.displayName;const ih=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>l.jsx(Ca,{ref:r,orientation:t,className:L("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:l.jsx(Zf,{className:"relative flex-1 rounded-full bg-border"})}));ih.displayName=Ca.displayName;function vs({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:c,onThreadCreate:u,onThreadDelete:d}){const{loadThread:f,threads:p,refreshThreads:m,currentThreadId:w,createThread:b,deleteThread:g,renameThread:x}=ho(),[v,y]=C.useState(p??[]),[E,S]=C.useState(!1),[T,I]=C.useState(null),[N,j]=C.useState(null),[O,A]=C.useState(""),[F,H]=C.useState(!1);C.useEffect(()=>{y(p??[])},[p]);const D=async $=>{try{await f($),a==null||a($),c==null||c($)}catch(G){console.error("Failed to select thread:",G)}},J=async()=>{try{H(!0);const $=await b();u==null||u($),a==null||a($)}catch($){console.error("Failed to create thread:",$)}finally{H(!1)}},K=async($,G)=>{if(G.stopPropagation(),!!confirm("Delete this thread?"))try{await g($),d==null||d($)}catch(ee){console.error("Failed to delete thread:",ee)}},oe=($,G)=>{G.stopPropagation(),j($.threadId),A($.title||`Thread ${$.threadId.slice(0,8)}`)},W=async $=>{if(O.trim())try{await x($,O.trim()),j(null),A("")}catch(G){console.error("Failed to update title:",G)}},M=()=>{j(null),A("")},X=($,G)=>{$.key==="Enter"?W(G):$.key==="Escape"&&M()},Z=$=>{if(!$)return"";try{const G=new Date($),pe=new Date().getTime()-G.getTime(),z=Math.floor(pe/(1e3*60*60*24));return z===0?G.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):z===1?"Yesterday":z<7?`${z} days ago`:G.toLocaleDateString()}catch{return""}},he=$=>$.title||`Thread ${$.threadId.slice(0,8)}`;return l.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&l.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:l.jsx(ze,{onClick:J,disabled:F||E,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:F?"Creating...":"New Chat",children:l.jsx(se.MessageSquarePlus,{size:20})})}),l.jsx(sh,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:l.jsx("div",{className:"p-2 space-y-1 pb-4",children:E?l.jsx("div",{className:"text-center py-8 text-slate-400",children:"Loading…"}):v.length===0?l.jsxs("div",{className:"text-center py-8 text-slate-400",children:[l.jsx(se.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),l.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):v.slice().sort(($,G)=>new Date(G.updatedAt||G.createdAt||"").getTime()-new Date($.updatedAt||$.createdAt||"").getTime()).map($=>l.jsxs("div",{onClick:()=>D($.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??w)===$.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:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("div",{className:"flex-1 min-w-0",children:N===$.threadId?l.jsxs("div",{className:"flex items-center gap-2",onClick:G=>G.stopPropagation(),children:[l.jsx(qr,{value:O,onChange:G=>A(G.target.value),onKeyDown:G=>X(G,$.threadId),className:"h-6 text-sm",autoFocus:!0}),l.jsx(ze,{variant:"ghost",size:"sm",onClick:()=>W($.threadId),className:"h-6 w-6 p-0",children:l.jsx(se.Check,{size:12})}),l.jsx(ze,{variant:"ghost",size:"sm",onClick:M,className:"h-6 w-6 p-0",children:l.jsx(se.X,{size:12})})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:he($)}),l.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[l.jsx(se.Calendar,{size:10}),l.jsx("span",{children:Z($.updatedAt||$.createdAt)})]})]})}),l.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&N!==$.threadId&&l.jsx(ze,{variant:"ghost",size:"sm",onClick:G=>oe($,G),className:"h-6 w-6 p-0",title:"Edit title",children:l.jsx(se.Edit3,{size:12})}),n&&l.jsx(ze,{variant:"ghost",size:"sm",onClick:G=>K($.threadId,G),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:l.jsx(se.Trash2,{size:12})})]})]}),i===$.threadId&&l.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},$.threadId))})})]})}const ah=C.createContext(null);function IS({children:e,basePath:t="/chat"}){const n=C.useMemo(()=>t?t==="/"?"":t.endsWith("/")?t.slice(0,-1):t:"/chat",[t]),r={basePath:n,buildThreadPath:o=>`${n}/${o}`,buildBasePath:()=>n};return l.jsx(ah.Provider,{value:r,children:e})}function NS(){const e=C.useContext(ah);return e||{basePath:"/chat",buildThreadPath:t=>`/chat/${t}`,buildBasePath:()=>"/chat"}}const Ea=768;function jS(){const[e,t]=h.useState(void 0);return h.useEffect(()=>{const n=window.matchMedia(`(max-width: ${Ea-1}px)`),r=()=>{t(window.innerWidth<Ea)};return n.addEventListener("change",r),t(window.innerWidth<Ea),()=>n.removeEventListener("change",r)},[]),!!e}var AS="Separator",lh="horizontal",RS=["horizontal","vertical"],ch=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=lh,...o}=e,s=_S(r)?r:lh,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return l.jsx(Se.div,{"data-orientation":s,...a,...o,ref:t})});ch.displayName=AS;function _S(e){return RS.includes(e)}var uh=ch;const Ia=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>l.jsx(uh,{ref:o,decorative:n,orientation:t,className:L("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Ia.displayName=uh.displayName;const dh=Xu,PS=Zv,OS=Ju,fh=h.forwardRef(({className:e,...t},n)=>l.jsx(Go,{className:L("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}));fh.displayName=Go.displayName;const MS=mr.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"}}),Na=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>l.jsxs(OS,{children:[l.jsx(fh,{}),l.jsxs(Yo,{ref:o,className:L(MS({side:e}),t),...r,children:[n,l.jsxs(Zu,{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:[l.jsx(se.X,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Na.displayName=Yo.displayName;const hh=({className:e,...t})=>l.jsx("div",{className:L("flex flex-col space-y-2 text-center sm:text-left",e),...t});hh.displayName="SheetHeader";const ph=h.forwardRef(({className:e,...t},n)=>l.jsx(Fn,{ref:n,className:L("text-lg font-semibold text-foreground",e),...t}));ph.displayName=Fn.displayName;const mh=h.forwardRef(({className:e,...t},n)=>l.jsx(Xo,{ref:n,className:L("text-sm text-muted-foreground",e),...t}));mh.displayName=Xo.displayName;function gh({className:e,...t}){return l.jsx("div",{className:L("animate-pulse rounded-md bg-muted",e),...t})}var xh=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"}),DS="VisuallyHidden",bh=h.forwardRef((e,t)=>l.jsx(Se.span,{...e,ref:t,style:{...xh,...e.style}}));bh.displayName=DS;var LS=bh,[ws,tk]=Vt("Tooltip",[cr]),ys=cr(),vh="TooltipProvider",$S=700,ja="tooltip.open",[FS,Aa]=ws(vh),wh=e=>{const{__scopeTooltip:t,delayDuration:n=$S,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),c=h.useRef(0);return h.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),l.jsx(FS,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(c.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(u=>{a.current=u},[]),disableHoverableContent:o,children:s})};wh.displayName=vh;var Gr="Tooltip",[zS,Ss]=ws(Gr),yh=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,c=Aa(Gr,e.__scopeTooltip),u=ys(t),[d,f]=h.useState(null),p=Kt(),m=h.useRef(0),w=i??c.disableHoverableContent,b=a??c.delayDuration,g=h.useRef(!1),[x,v]=wn({prop:r,defaultProp:o??!1,onChange:I=>{I?(c.onOpen(),document.dispatchEvent(new CustomEvent(ja))):c.onClose(),s==null||s(I)},caller:Gr}),y=h.useMemo(()=>x?g.current?"delayed-open":"instant-open":"closed",[x]),E=h.useCallback(()=>{window.clearTimeout(m.current),m.current=0,g.current=!1,v(!0)},[v]),S=h.useCallback(()=>{window.clearTimeout(m.current),m.current=0,v(!1)},[v]),T=h.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{g.current=!0,v(!0),m.current=0},b)},[b,v]);return h.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),l.jsx(ia,{...u,children:l.jsx(zS,{scope:t,contentId:p,open:x,stateAttribute:y,trigger:d,onTriggerChange:f,onTriggerEnter:h.useCallback(()=>{c.isOpenDelayedRef.current?T():E()},[c.isOpenDelayedRef,T,E]),onTriggerLeave:h.useCallback(()=>{w?S():(window.clearTimeout(m.current),m.current=0)},[S,w]),onOpen:E,onClose:S,disableHoverableContent:w,children:n})})};yh.displayName=Gr;var Ra="TooltipTrigger",Sh=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Ss(Ra,n),s=Aa(Ra,n),i=ys(n),a=h.useRef(null),c=Re(t,a,o.onTriggerChange),u=h.useRef(!1),d=h.useRef(!1),f=h.useCallback(()=>u.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),l.jsx(aa,{asChild:!0,...i,children:l.jsx(Se.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,onPointerMove:te(e.onPointerMove,p=>{p.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:te(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:te(e.onPointerDown,()=>{o.open&&o.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:te(e.onFocus,()=>{u.current||o.onOpen()}),onBlur:te(e.onBlur,o.onClose),onClick:te(e.onClick,o.onClose)})})});Sh.displayName=Ra;var BS="TooltipPortal",[nk,HS]=ws(BS,{forceMount:void 0}),dr="TooltipContent",Ch=h.forwardRef((e,t)=>{const n=HS(dr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=Ss(dr,e.__scopeTooltip);return l.jsx(Tt,{present:r||i.open,children:i.disableHoverableContent?l.jsx(Th,{side:o,...s,ref:t}):l.jsx(US,{side:o,...s,ref:t})})}),US=h.forwardRef((e,t)=>{const n=Ss(dr,e.__scopeTooltip),r=Aa(dr,e.__scopeTooltip),o=h.useRef(null),s=Re(t,o),[i,a]=h.useState(null),{trigger:c,onClose:u}=n,d=o.current,{onPointerInTransitChange:f}=r,p=h.useCallback(()=>{a(null),f(!1)},[f]),m=h.useCallback((w,b)=>{const g=w.currentTarget,x={x:w.clientX,y:w.clientY},v=GS(x,g.getBoundingClientRect()),y=YS(x,v),E=XS(b.getBoundingClientRect()),S=ZS([...y,...E]);a(S),f(!0)},[f]);return h.useEffect(()=>()=>p(),[p]),h.useEffect(()=>{if(c&&d){const w=g=>m(g,d),b=g=>m(g,c);return c.addEventListener("pointerleave",w),d.addEventListener("pointerleave",b),()=>{c.removeEventListener("pointerleave",w),d.removeEventListener("pointerleave",b)}}},[c,d,m,p]),h.useEffect(()=>{if(i){const w=b=>{const g=b.target,x={x:b.clientX,y:b.clientY},v=(c==null?void 0:c.contains(g))||(d==null?void 0:d.contains(g)),y=!JS(x,i);v?p():y&&(p(),u())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[c,d,i,u,p]),l.jsx(Th,{...e,ref:s})}),[WS,VS]=ws(Gr,{isInside:!1}),KS=Et.createSlottable("TooltipContent"),Th=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,c=Ss(dr,n),u=ys(n),{onClose:d}=c;return h.useEffect(()=>(document.addEventListener(ja,d),()=>document.removeEventListener(ja,d)),[d]),h.useEffect(()=>{if(c.trigger){const f=p=>{const m=p.target;m!=null&&m.contains(c.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,d]),l.jsx(Mr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:l.jsxs(la,{"data-state":c.stateAttribute,...u,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[l.jsx(KS,{children:r}),l.jsx(WS,{scope:n,isInside:!0,children:l.jsx(LS,{id:c.contentId,role:"tooltip",children:o||r})})]})})});Ch.displayName=dr;var kh="TooltipArrow",qS=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ys(n);return VS(kh,n).isInside?null:l.jsx(ca,{...o,...r,ref:t})});qS.displayName=kh;function GS(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function YS(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function XS(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function JS(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],c=t[i],u=a.x,d=a.y,f=c.x,p=c.y;d>r!=p>r&&n<(f-u)*(r-d)/(p-d)+u&&(o=!o)}return o}function ZS(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),QS(t)}function QS(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var eC=wh,tC=yh,nC=Sh,Eh=Ch;const rC=eC,oC=tC,sC=nC,Ih=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>l.jsx(Eh,{ref:r,sideOffset:t,className:L("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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}));Ih.displayName=Eh.displayName;const iC="sidebar:state",aC=60*60*24*7,lC="16rem",cC="18rem",uC="3rem",dC="b",Nh=h.createContext(null);function Cs(){const e=h.useContext(Nh);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const jh=h.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:o,children:s,...i},a)=>{const c=jS(),[u,d]=h.useState(!1),[f,p]=h.useState(e),m=t??f,w=h.useCallback(v=>{const y=typeof v=="function"?v(m):v;n?n(y):p(y),document.cookie=`${iC}=${y}; path=/; max-age=${aC}`},[n,m]),b=h.useCallback(()=>c?d(v=>!v):w(v=>!v),[c,w,d]);h.useEffect(()=>{const v=y=>{y.key===dC&&(y.metaKey||y.ctrlKey)&&(y.preventDefault(),b())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[b]);const g=m?"expanded":"collapsed",x=h.useMemo(()=>({state:g,open:m,setOpen:w,isMobile:c,openMobile:u,setOpenMobile:d,toggleSidebar:b}),[g,m,w,c,u,d,b]);return l.jsx(Nh.Provider,{value:x,children:l.jsx(rC,{delayDuration:0,children:l.jsx("div",{style:{"--sidebar-width":lC,"--sidebar-width-icon":uC,...o},className:L("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",r),ref:a,...i,children:s})})})});jh.displayName="SidebarProvider";const Ah=h.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:o,...s},i)=>{const{isMobile:a,state:c,openMobile:u,setOpenMobile:d}=Cs();return n==="none"?l.jsx("div",{className:L("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:i,...s,children:o}):a?l.jsx(dh,{open:u,onOpenChange:d,...s,children:l.jsx(Na,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":cC},side:e,children:l.jsx("div",{className:"flex h-full w-full flex-col",children:o})})}):l.jsxs("div",{ref:i,className:"group peer hidden md:block text-sidebar-foreground","data-state":c,"data-collapsible":c==="collapsed"?n:"","data-variant":t,"data-side":e,children:[l.jsx("div",{className:L("duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),l.jsx("div",{className:L("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex",e==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...s,children:l.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow",children:o})})]})});Ah.displayName="Sidebar";const Rh=h.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:o}=Cs();return l.jsxs(ze,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:L("h-7 w-7",e),onClick:s=>{t==null||t(s),o()},...n,children:[l.jsx(se.PanelLeft,{}),l.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Rh.displayName="SidebarTrigger";const fC=h.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=Cs();return l.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:L("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})});fC.displayName="SidebarRail";const _h=h.forwardRef(({className:e,...t},n)=>l.jsx("main",{ref:n,className:L("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",e),...t}));_h.displayName="SidebarInset";const hC=h.forwardRef(({className:e,...t},n)=>l.jsx(qr,{ref:n,"data-sidebar":"input",className:L("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));hC.displayName="SidebarInput";const Ph=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"header",className:L("flex flex-col gap-2 p-2",e),...t}));Ph.displayName="SidebarHeader";const pC=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"footer",className:L("flex flex-col gap-2 p-2",e),...t}));pC.displayName="SidebarFooter";const mC=h.forwardRef(({className:e,...t},n)=>l.jsx(Ia,{ref:n,"data-sidebar":"separator",className:L("mx-2 w-auto bg-sidebar-border",e),...t}));mC.displayName="SidebarSeparator";const Oh=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"content",className:L("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Oh.displayName="SidebarContent";const Mh=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"group",className:L("relative flex w-full min-w-0 flex-col p-2",e),...t}));Mh.displayName="SidebarGroup";const Dh=h.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?Et.Slot:"div";return l.jsx(o,{ref:r,"data-sidebar":"group-label",className:L("duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...n})});Dh.displayName="SidebarGroupLabel";const gC=h.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?Et.Slot:"button";return l.jsx(o,{ref:r,"data-sidebar":"group-action",className:L("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",e),...n})});gC.displayName="SidebarGroupAction";const Lh=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"group-content",className:L("w-full text-sm",e),...t}));Lh.displayName="SidebarGroupContent";const $h=h.forwardRef(({className:e,...t},n)=>l.jsx("ul",{ref:n,"data-sidebar":"menu",className:L("flex w-full min-w-0 flex-col gap-1",e),...t}));$h.displayName="SidebarMenu";const Fh=h.forwardRef(({className:e,...t},n)=>l.jsx("li",{ref:n,"data-sidebar":"menu-item",className:L("group/menu-item relative",e),...t}));Fh.displayName="SidebarMenuItem";const xC=mr.cva("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),zh=h.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:o,className:s,...i},a)=>{const c=e?Et.Slot:"button",{isMobile:u,state:d}=Cs(),f=l.jsx(c,{ref:a,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:L(xC({variant:n,size:r}),s),...i});return o?(typeof o=="string"&&(o={children:o}),l.jsxs(oC,{children:[l.jsx(sC,{asChild:!0,children:f}),l.jsx(Ih,{side:"right",align:"center",hidden:d!=="collapsed"||u,...o})]})):f});zh.displayName="SidebarMenuButton";const bC=h.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},o)=>{const s=t?Et.Slot:"button";return l.jsx(s,{ref:o,"data-sidebar":"menu-action",className:L("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",n&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",e),...r})});bC.displayName="SidebarMenuAction";const vC=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:L("absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...t}));vC.displayName="SidebarMenuBadge";const wC=h.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const o=h.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return l.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:L("rounded-md h-8 flex gap-2 px-2 items-center",e),...n,children:[t&&l.jsx(gh,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),l.jsx(gh,{className:"h-4 flex-1 max-w-[--skeleton-width]","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":o}})]})});wC.displayName="SidebarMenuSkeleton";const yC=h.forwardRef(({className:e,...t},n)=>l.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:L("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),...t}));yC.displayName="SidebarMenuSub";const SC=h.forwardRef(({...e},t)=>l.jsx("li",{ref:t,...e}));SC.displayName="SidebarMenuSubItem";const CC=h.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...o},s)=>{const i=e?Et.Slot:"a";return l.jsx(i,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:L("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",t==="sm"&&"text-xs",t==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",r),...o})});CC.displayName="SidebarMenuSubButton";function TC({header:e,sidebarTitle:t="Threads",showThreads:n=!0,className:r="",sidebarClassName:o="",chatClassName:s="",...i}){return l.jsx(Cr,{...i,children:l.jsxs(jh,{className:`w-full ${r}`,children:[l.jsxs(Ah,{className:`border-r ${o}`,children:[l.jsx(Ph,{children:l.jsx($h,{children:l.jsx(Fh,{children:l.jsx(zh,{asChild:!0,size:"lg",children:l.jsx("span",{className:"font-semibold",children:t})})})})}),l.jsx(Oh,{children:n&&l.jsxs(Mh,{children:[l.jsx(Dh,{children:"Conversations"}),l.jsx(Lh,{children:l.jsx("div",{className:"px-2 py-1",children:l.jsx(vs,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-[calc(100vh-12rem)]"})})})]})})]}),l.jsxs(_h,{children:[l.jsxs("header",{className:"h-14 border-b bg-background/60 backdrop-blur flex items-center gap-2 px-4",children:[l.jsx(Rh,{}),l.jsx("div",{className:"flex-1"}),e]}),l.jsx("main",{className:`flex-1 min-h-0 overflow-hidden ${s}`,children:l.jsx(Kr,{})})]})]})})}function fr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function kC(e){if(typeof e!="string")return;const t=e.trim();if(t)return t.replace(/\/+$/g,"")}function Bh(){const e=[fr("__API_BASE_URL__"),fr("__CHAT_API_BASE_URL__"),fr("__CHAT_API_URL__")];for(const t of e){const n=kC(t);if(n)return n}}function Hh(){const e=[fr("__API_AUTH_TOKEN__"),fr("__CHAT_API_KEY__"),fr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Uh(){const e={},t=Bh(),n=Hh();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Wh(){const e=Uh(),t=mn.getAuthToken(),n=Bh();return{apiBaseUrl:e.baseUrl||mn.baseUrl||n||"http://localhost:8000",apiKey:t||e.apiKey||Hh()||"",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 EC(){try{const e=localStorage.getItem(Vh);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function IC(e){try{localStorage.setItem(Vh,JSON.stringify(e)),e.apiKey&&mn.setAuthToken(e.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function NC(){const e=Wh(),t=EC(),n=mn.getAuthToken();return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:mn.baseUrl||t.apiBaseUrl||e.apiBaseUrl}}function jC(e){e.apiKey&&mn.setAuthToken(e.apiKey),IC(e)}var AC="Label",Kh=h.forwardRef((e,t)=>l.jsx(Se.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())}}));Kh.displayName=AC;var qh=Kh;const RC=mr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),zt=h.forwardRef(({className:e,...t},n)=>l.jsx(qh,{ref:n,className:L(RC(),e),...t}));zt.displayName=qh.displayName;function Gh(e){const t=h.useRef({value:e,previous:e});return h.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Ts="Switch",[_C,rk]=Vt(Ts),[PC,OC]=_C(Ts),Yh=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:c="on",onCheckedChange:u,form:d,...f}=e,[p,m]=h.useState(null),w=Re(t,y=>m(y)),b=h.useRef(!1),g=p?d||!!p.closest("form"):!0,[x,v]=wn({prop:o,defaultProp:s??!1,onChange:u,caller:Ts});return l.jsxs(PC,{scope:n,checked:x,disabled:a,children:[l.jsx(Se.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":Qh(x),"data-disabled":a?"":void 0,disabled:a,value:c,...f,ref:w,onClick:te(e.onClick,y=>{v(E=>!E),g&&(b.current=y.isPropagationStopped(),b.current||y.stopPropagation())})}),g&&l.jsx(Zh,{control:p,bubbles:!b.current,name:r,value:c,checked:x,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Yh.displayName=Ts;var Xh="SwitchThumb",Jh=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=OC(Xh,n);return l.jsx(Se.span,{"data-state":Qh(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Jh.displayName=Xh;var MC="SwitchBubbleInput",Zh=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=Re(i,s),c=Gh(n),u=Pd(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==n&&m){const w=new Event("click",{bubbles:r});m.call(d,n),d.dispatchEvent(w)}},[c,n,r]),l.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=MC;function Qh(e){return e?"checked":"unchecked"}var ep=Yh,DC=Jh;const En=h.forwardRef(({className:e,...t},n)=>l.jsx(ep,{className:L("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:l.jsx(DC,{className:L("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")})}));En.displayName=ep.displayName;var LC=[" ","Enter","ArrowUp","ArrowDown"],$C=[" ","Enter"],Un="Select",[ks,Es,FC]=Vi(Un),[hr,ok]=Vt(Un,[FC,cr]),Is=cr(),[zC,In]=hr(Un),[BC,HC]=hr(Un),tp=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:c,dir:u,name:d,autoComplete:f,disabled:p,required:m,form:w}=e,b=Is(t),[g,x]=h.useState(null),[v,y]=h.useState(null),[E,S]=h.useState(!1),T=es(u),[I,N]=wn({prop:r,defaultProp:o??!1,onChange:s,caller:Un}),[j,O]=wn({prop:i,defaultProp:a,onChange:c,caller:Un}),A=h.useRef(null),F=g?w||!!g.closest("form"):!0,[H,D]=h.useState(new Set),J=Array.from(H).map(K=>K.props.value).join(";");return l.jsx(ia,{...b,children:l.jsxs(zC,{required:m,scope:t,trigger:g,onTriggerChange:x,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:E,onValueNodeHasChildrenChange:S,contentId:Kt(),value:j,onValueChange:O,open:I,onOpenChange:N,dir:T,triggerPointerDownPosRef:A,disabled:p,children:[l.jsx(ks.Provider,{scope:t,children:l.jsx(BC,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(K=>{D(oe=>new Set(oe).add(K))},[]),onNativeOptionRemove:h.useCallback(K=>{D(oe=>{const W=new Set(oe);return W.delete(K),W})},[]),children:n})}),F?l.jsxs(kp,{"aria-hidden":!0,required:m,tabIndex:-1,name:d,autoComplete:f,value:j,onChange:K=>O(K.target.value),disabled:p,form:w,children:[j===void 0?l.jsx("option",{value:""}):null,Array.from(H)]},J):null]})})};tp.displayName=Un;var np="SelectTrigger",rp=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Is(n),i=In(np,n),a=i.disabled||r,c=Re(t,i.onTriggerChange),u=Es(n),d=h.useRef("touch"),[f,p,m]=Ip(b=>{const g=u().filter(y=>!y.disabled),x=g.find(y=>y.value===i.value),v=Np(g,b,x);v!==void 0&&i.onValueChange(v.value)}),w=b=>{a||(i.onOpenChange(!0),m()),b&&(i.triggerPointerDownPosRef.current={x:Math.round(b.pageX),y:Math.round(b.pageY)})};return l.jsx(aa,{asChild:!0,...s,children:l.jsx(Se.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:c,onClick:te(o.onClick,b=>{b.currentTarget.focus(),d.current!=="mouse"&&w(b)}),onPointerDown:te(o.onPointerDown,b=>{d.current=b.pointerType;const g=b.target;g.hasPointerCapture(b.pointerId)&&g.releasePointerCapture(b.pointerId),b.button===0&&b.ctrlKey===!1&&b.pointerType==="mouse"&&(w(b),b.preventDefault())}),onKeyDown:te(o.onKeyDown,b=>{const g=f.current!=="";!(b.ctrlKey||b.altKey||b.metaKey)&&b.key.length===1&&p(b.key),!(g&&b.key===" ")&&LC.includes(b.key)&&(w(),b.preventDefault())})})})});rp.displayName=np;var op="SelectValue",sp=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,c=In(op,n),{onValueNodeHasChildrenChange:u}=c,d=s!==void 0,f=Re(t,c.onValueNodeChange);return lt(()=>{u(d)},[u,d]),l.jsx(Se.span,{...a,ref:f,style:{pointerEvents:"none"},children:Ep(c.value)?l.jsx(l.Fragment,{children:i}):s})});sp.displayName=op;var UC="SelectIcon",ip=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return l.jsx(Se.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});ip.displayName=UC;var WC="SelectPortal",ap=e=>l.jsx(Lo,{asChild:!0,...e});ap.displayName=WC;var Wn="SelectContent",lp=h.forwardRef((e,t)=>{const n=In(Wn,e.__scopeSelect),[r,o]=h.useState();if(lt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?eo.createPortal(l.jsx(cp,{scope:e.__scopeSelect,children:l.jsx(ks.Slot,{scope:e.__scopeSelect,children:l.jsx("div",{children:e.children})})}),s):null}return l.jsx(up,{...e,ref:t})});lp.displayName=Wn;var Xt=10,[cp,Nn]=hr(Wn),VC="SelectContentImpl",KC=Et.createSlot("SelectContent.RemoveScroll"),up=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:w,hideWhenDetached:b,avoidCollisions:g,...x}=e,v=In(Wn,n),[y,E]=h.useState(null),[S,T]=h.useState(null),I=Re(t,z=>E(z)),[N,j]=h.useState(null),[O,A]=h.useState(null),F=Es(n),[H,D]=h.useState(!1),J=h.useRef(!1);h.useEffect(()=>{if(y)return Fi(y)},[y]),Pi();const K=h.useCallback(z=>{const[_,...Y]=F().map(ne=>ne.ref.current),[Q]=Y.slice(-1),de=document.activeElement;for(const ne of z)if(ne===de||(ne==null||ne.scrollIntoView({block:"nearest"}),ne===_&&S&&(S.scrollTop=0),ne===Q&&S&&(S.scrollTop=S.scrollHeight),ne==null||ne.focus(),document.activeElement!==de))return},[F,S]),oe=h.useCallback(()=>K([N,y]),[K,N,y]);h.useEffect(()=>{H&&oe()},[H,oe]);const{onOpenChange:W,triggerPointerDownPosRef:M}=v;h.useEffect(()=>{if(y){let z={x:0,y:0};const _=Q=>{var de,ne;z={x:Math.abs(Math.round(Q.pageX)-(((de=M.current)==null?void 0:de.x)??0)),y:Math.abs(Math.round(Q.pageY)-(((ne=M.current)==null?void 0:ne.y)??0))}},Y=Q=>{z.x<=10&&z.y<=10?Q.preventDefault():y.contains(Q.target)||W(!1),document.removeEventListener("pointermove",_),M.current=null};return M.current!==null&&(document.addEventListener("pointermove",_),document.addEventListener("pointerup",Y,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",Y,{capture:!0})}}},[y,W,M]),h.useEffect(()=>{const z=()=>W(!1);return window.addEventListener("blur",z),window.addEventListener("resize",z),()=>{window.removeEventListener("blur",z),window.removeEventListener("resize",z)}},[W]);const[X,Z]=Ip(z=>{const _=F().filter(de=>!de.disabled),Y=_.find(de=>de.ref.current===document.activeElement),Q=Np(_,z,Y);Q&&setTimeout(()=>Q.ref.current.focus())}),he=h.useCallback((z,_,Y)=>{const Q=!J.current&&!Y;(v.value!==void 0&&v.value===_||Q)&&(j(z),Q&&(J.current=!0))},[v.value]),$=h.useCallback(()=>y==null?void 0:y.focus(),[y]),G=h.useCallback((z,_,Y)=>{const Q=!J.current&&!Y;(v.value!==void 0&&v.value===_||Q)&&A(z)},[v.value]),ee=r==="popper"?_a:dp,pe=ee===_a?{side:a,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:w,hideWhenDetached:b,avoidCollisions:g}:{};return l.jsx(cp,{scope:n,content:y,viewport:S,onViewportChange:T,itemRefCallback:he,selectedItem:N,onItemLeave:$,itemTextRefCallback:G,focusSelectedItem:oe,selectedItemText:O,position:r,isPositioned:H,searchRef:X,children:l.jsx(Uo,{as:KC,allowPinchZoom:!0,children:l.jsx(Do,{asChild:!0,trapped:v.open,onMountAutoFocus:z=>{z.preventDefault()},onUnmountAutoFocus:te(o,z=>{var _;(_=v.trigger)==null||_.focus({preventScroll:!0}),z.preventDefault()}),children:l.jsx(Mr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:z=>z.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:l.jsx(ee,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:z=>z.preventDefault(),...x,...pe,onPlaced:()=>D(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:te(x.onKeyDown,z=>{const _=z.ctrlKey||z.altKey||z.metaKey;if(z.key==="Tab"&&z.preventDefault(),!_&&z.key.length===1&&Z(z.key),["ArrowUp","ArrowDown","Home","End"].includes(z.key)){let Q=F().filter(de=>!de.disabled).map(de=>de.ref.current);if(["ArrowUp","End"].includes(z.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes(z.key)){const de=z.target,ne=Q.indexOf(de);Q=Q.slice(ne+1)}setTimeout(()=>K(Q)),z.preventDefault()}})})})})})})});up.displayName=VC;var qC="SelectItemAlignedPosition",dp=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=In(Wn,n),i=Nn(Wn,n),[a,c]=h.useState(null),[u,d]=h.useState(null),f=Re(t,I=>d(I)),p=Es(n),m=h.useRef(!1),w=h.useRef(!0),{viewport:b,selectedItem:g,selectedItemText:x,focusSelectedItem:v}=i,y=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&b&&g&&x){const I=s.trigger.getBoundingClientRect(),N=u.getBoundingClientRect(),j=s.valueNode.getBoundingClientRect(),O=x.getBoundingClientRect();if(s.dir!=="rtl"){const de=O.left-N.left,ne=j.left-de,_e=I.left-ne,Pe=I.width+_e,Ue=Math.max(Pe,N.width),Ee=window.innerWidth-Xt,Ae=ya(ne,[Xt,Math.max(Xt,Ee-Ue)]);a.style.minWidth=Pe+"px",a.style.left=Ae+"px"}else{const de=N.right-O.right,ne=window.innerWidth-j.right-de,_e=window.innerWidth-I.right-ne,Pe=I.width+_e,Ue=Math.max(Pe,N.width),Ee=window.innerWidth-Xt,Ae=ya(ne,[Xt,Math.max(Xt,Ee-Ue)]);a.style.minWidth=Pe+"px",a.style.right=Ae+"px"}const A=p(),F=window.innerHeight-Xt*2,H=b.scrollHeight,D=window.getComputedStyle(u),J=parseInt(D.borderTopWidth,10),K=parseInt(D.paddingTop,10),oe=parseInt(D.borderBottomWidth,10),W=parseInt(D.paddingBottom,10),M=J+K+H+W+oe,X=Math.min(g.offsetHeight*5,M),Z=window.getComputedStyle(b),he=parseInt(Z.paddingTop,10),$=parseInt(Z.paddingBottom,10),G=I.top+I.height/2-Xt,ee=F-G,pe=g.offsetHeight/2,z=g.offsetTop+pe,_=J+K+z,Y=M-_;if(_<=G){const de=A.length>0&&g===A[A.length-1].ref.current;a.style.bottom="0px";const ne=u.clientHeight-b.offsetTop-b.offsetHeight,_e=Math.max(ee,pe+(de?$:0)+ne+oe),Pe=_+_e;a.style.height=Pe+"px"}else{const de=A.length>0&&g===A[0].ref.current;a.style.top="0px";const _e=Math.max(G,J+b.offsetTop+(de?he:0)+pe)+Y;a.style.height=_e+"px",b.scrollTop=_-G+b.offsetTop}a.style.margin=`${Xt}px 0`,a.style.minHeight=X+"px",a.style.maxHeight=F+"px",r==null||r(),requestAnimationFrame(()=>m.current=!0)}},[p,s.trigger,s.valueNode,a,u,b,g,x,s.dir,r]);lt(()=>y(),[y]);const[E,S]=h.useState();lt(()=>{u&&S(window.getComputedStyle(u).zIndex)},[u]);const T=h.useCallback(I=>{I&&w.current===!0&&(y(),v==null||v(),w.current=!1)},[y,v]);return l.jsx(YC,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:m,onScrollButtonChange:T,children:l.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:l.jsx(Se.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});dp.displayName=qC;var GC="SelectPopperPosition",_a=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Xt,...s}=e,i=Is(n);return l.jsx(la,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});_a.displayName=GC;var[YC,Pa]=hr(Wn,{}),Oa="SelectViewport",fp=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Nn(Oa,n),i=Pa(Oa,n),a=Re(t,s.onViewportChange),c=h.useRef(0);return l.jsxs(l.Fragment,{children:[l.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}),l.jsx(ks.Slot,{scope:n,children:l.jsx(Se.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:te(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:p}=i;if(p!=null&&p.current&&f){const m=Math.abs(c.current-d.scrollTop);if(m>0){const w=window.innerHeight-Xt*2,b=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),x=Math.max(b,g);if(x<w){const v=x+m,y=Math.min(w,v),E=v-y;f.style.height=y+"px",f.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}c.current=d.scrollTop})})})]})});fp.displayName=Oa;var hp="SelectGroup",[XC,JC]=hr(hp),ZC=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Kt();return l.jsx(XC,{scope:n,id:o,children:l.jsx(Se.div,{role:"group","aria-labelledby":o,...r,ref:t})})});ZC.displayName=hp;var pp="SelectLabel",mp=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=JC(pp,n);return l.jsx(Se.div,{id:o.id,...r,ref:t})});mp.displayName=pp;var Ns="SelectItem",[QC,gp]=hr(Ns),xp=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=In(Ns,n),c=Nn(Ns,n),u=a.value===r,[d,f]=h.useState(s??""),[p,m]=h.useState(!1),w=Re(t,v=>{var y;return(y=c.itemRefCallback)==null?void 0:y.call(c,v,r,o)}),b=Kt(),g=h.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 l.jsx(QC,{scope:n,value:r,disabled:o,textId:b,isSelected:u,onItemTextChange:h.useCallback(v=>{f(y=>y||((v==null?void 0:v.textContent)??"").trim())},[]),children:l.jsx(ks.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:l.jsx(Se.div,{role:"option","aria-labelledby":b,"data-highlighted":p?"":void 0,"aria-selected":u&&p,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:w,onFocus:te(i.onFocus,()=>m(!0)),onBlur:te(i.onBlur,()=>m(!1)),onClick:te(i.onClick,()=>{g.current!=="mouse"&&x()}),onPointerUp:te(i.onPointerUp,()=>{g.current==="mouse"&&x()}),onPointerDown:te(i.onPointerDown,v=>{g.current=v.pointerType}),onPointerMove:te(i.onPointerMove,v=>{var y;g.current=v.pointerType,o?(y=c.onItemLeave)==null||y.call(c):g.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:te(i.onPointerLeave,v=>{var y;v.currentTarget===document.activeElement&&((y=c.onItemLeave)==null||y.call(c))}),onKeyDown:te(i.onKeyDown,v=>{var E;((E=c.searchRef)==null?void 0:E.current)!==""&&v.key===" "||($C.includes(v.key)&&x(),v.key===" "&&v.preventDefault())})})})})});xp.displayName=Ns;var Yr="SelectItemText",bp=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=In(Yr,n),a=Nn(Yr,n),c=gp(Yr,n),u=HC(Yr,n),[d,f]=h.useState(null),p=Re(t,x=>f(x),c.onItemTextChange,x=>{var v;return(v=a.itemTextRefCallback)==null?void 0:v.call(a,x,c.value,c.disabled)}),m=d==null?void 0:d.textContent,w=h.useMemo(()=>l.jsx("option",{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:b,onNativeOptionRemove:g}=u;return lt(()=>(b(w),()=>g(w)),[b,g,w]),l.jsxs(l.Fragment,{children:[l.jsx(Se.span,{id:c.textId,...s,ref:p}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?eo.createPortal(s.children,i.valueNode):null]})});bp.displayName=Yr;var vp="SelectItemIndicator",wp=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return gp(vp,n).isSelected?l.jsx(Se.span,{"aria-hidden":!0,...r,ref:t}):null});wp.displayName=vp;var Ma="SelectScrollUpButton",yp=h.forwardRef((e,t)=>{const n=Nn(Ma,e.__scopeSelect),r=Pa(Ma,e.__scopeSelect),[o,s]=h.useState(!1),i=Re(t,r.onScrollButtonChange);return lt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollTop>0;s(u)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?l.jsx(Cp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop-c.offsetHeight)}}):null});yp.displayName=Ma;var Da="SelectScrollDownButton",Sp=h.forwardRef((e,t)=>{const n=Nn(Da,e.__scopeSelect),r=Pa(Da,e.__scopeSelect),[o,s]=h.useState(!1),i=Re(t,r.onScrollButtonChange);return lt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollHeight-c.clientHeight,d=Math.ceil(c.scrollTop)<u;s(d)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?l.jsx(Cp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop+c.offsetHeight)}}):null});Sp.displayName=Da;var Cp=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Nn("SelectScrollButton",n),i=h.useRef(null),a=Es(n),c=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>c(),[c]),lt(()=>{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]),l.jsx(Se.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:te(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:te(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:te(o.onPointerLeave,()=>{c()})})}),eT="SelectSeparator",Tp=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return l.jsx(Se.div,{"aria-hidden":!0,...r,ref:t})});Tp.displayName=eT;var La="SelectArrow",tT=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Is(n),s=In(La,n),i=Nn(La,n);return s.open&&i.position==="popper"?l.jsx(ca,{...o,...r,ref:t}):null});tT.displayName=La;var nT="SelectBubbleInput",kp=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=Re(r,o),i=Gh(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),l.jsx(Se.select,{...n,style:{...xh,...n.style},ref:s,defaultValue:t})});kp.displayName=nT;function Ep(e){return e===""||e===void 0}function Ip(e){const t=dt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function c(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>c(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Np(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=rT(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function rT(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var oT=tp,jp=rp,sT=sp,iT=ip,aT=ap,Ap=lp,lT=fp,Rp=mp,_p=xp,cT=bp,uT=wp,Pp=yp,Op=Sp,Mp=Tp;const Dp=oT,Lp=sT,$a=h.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(jp,{ref:r,className:L("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,l.jsx(iT,{asChild:!0,children:l.jsx(se.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));$a.displayName=jp.displayName;const $p=h.forwardRef(({className:e,...t},n)=>l.jsx(Pp,{ref:n,className:L("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(se.ChevronUp,{className:"h-4 w-4"})}));$p.displayName=Pp.displayName;const Fp=h.forwardRef(({className:e,...t},n)=>l.jsx(Op,{ref:n,className:L("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(se.ChevronDown,{className:"h-4 w-4"})}));Fp.displayName=Op.displayName;const Fa=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>l.jsx(aT,{children:l.jsxs(Ap,{ref:o,className:L("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:[l.jsx($p,{}),l.jsx(lT,{className:L("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),l.jsx(Fp,{})]})}));Fa.displayName=Ap.displayName;const dT=h.forwardRef(({className:e,...t},n)=>l.jsx(Rp,{ref:n,className:L("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));dT.displayName=Rp.displayName;const Vn=h.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(_p,{ref:r,className:L("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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(uT,{children:l.jsx(se.Check,{className:"h-4 w-4"})})}),l.jsx(cT,{children:t})]}));Vn.displayName=_p.displayName;const fT=h.forwardRef(({className:e,...t},n)=>l.jsx(Mp,{ref:n,className:L("-mx-1 my-1 h-px bg-muted",e),...t}));fT.displayName=Mp.displayName;const js=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:L("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));js.displayName="Card";const As=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:L("flex flex-col space-y-1.5 p-6",e),...t}));As.displayName="CardHeader";const Rs=h.forwardRef(({className:e,...t},n)=>l.jsx("h3",{ref:n,className:L("text-2xl font-semibold leading-none tracking-tight",e),...t}));Rs.displayName="CardTitle";const hT=h.forwardRef(({className:e,...t},n)=>l.jsx("p",{ref:n,className:L("text-sm text-muted-foreground",e),...t}));hT.displayName="CardDescription";const _s=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:L("p-6 pt-0",e),...t}));_s.displayName="CardContent";const pT=h.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:L("flex items-center p-6 pt-0",e),...t}));pT.displayName="CardFooter";const mT={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 gT({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=C.useState(!1),[s,i]=C.useState(!1),[a,c]=C.useState(e),[u,d]=C.useState(!1),{toast:f}=Ni();C.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),C.useEffect(()=>{c(e)},[e]);const p=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},m=()=>{c(mT),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},w=()=>{c(e),d(!1),o(!1)},b=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 l.jsxs(dh,{open:r,onOpenChange:o,children:[l.jsx(PS,{asChild:!0,children:l.jsxs(ze,{variant:"outline",size:"sm",className:n,children:[l.jsx(se.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&l.jsx(Bc,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),l.jsxs(Na,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[l.jsxs(hh,{children:[l.jsx(ph,{children:"Chat Settings"}),l.jsx(mh,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),l.jsxs("div",{className:"space-y-6 py-6",children:[l.jsxs(js,{children:[l.jsx(As,{className:"pb-3",children:l.jsxs(Rs,{className:"text-lg flex items-center gap-2",children:[l.jsx(se.Server,{className:"h-5 w-5"}),"API Configuration"]})}),l.jsxs(_s,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(zt,{htmlFor:"api-url",children:"API Base URL"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(qr,{id:"api-url",value:a.api.baseUrl,onChange:g=>c(x=>({...x,api:{...x.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),l.jsx(ze,{variant:"outline",onClick:b,children:"Test"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(zt,{htmlFor:"enable-auth",children:"Enable Authentication"}),l.jsx(En,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>c(x=>({...x,api:{...x.api,enableAuth:g}}))})]}),a.api.enableAuth&&l.jsxs("div",{className:"space-y-2",children:[l.jsx(zt,{htmlFor:"auth-token",children:"Authentication Token"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(qr,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>c(x=>({...x,api:{...x.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),l.jsx(ze,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?l.jsx(se.EyeOff,{className:"h-4 w-4"}):l.jsx(se.Eye,{className:"h-4 w-4"})})]})]})]})]}),l.jsxs(js,{children:[l.jsx(As,{className:"pb-3",children:l.jsxs(Rs,{className:"text-lg flex items-center gap-2",children:[l.jsx(se.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),l.jsxs(_s,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(zt,{htmlFor:"layout",children:"Layout Style"}),l.jsxs(Dp,{value:a.ui.layout,onValueChange:g=>c(x=>({...x,ui:{...x.ui,layout:g}})),children:[l.jsx($a,{children:l.jsx(Lp,{})}),l.jsxs(Fa,{children:[l.jsx(Vn,{value:"sidebar",children:"Sidebar Layout"}),l.jsx(Vn,{value:"fullscreen",children:"Fullscreen"}),l.jsx(Vn,{value:"tabs",children:"Tabbed Interface"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(zt,{htmlFor:"theme",children:"Theme"}),l.jsxs(Dp,{value:a.ui.theme,onValueChange:g=>c(x=>({...x,ui:{...x.ui,theme:g}})),children:[l.jsx($a,{children:l.jsx(Lp,{})}),l.jsxs(Fa,{children:[l.jsx(Vn,{value:"light",children:"Light"}),l.jsx(Vn,{value:"dark",children:"Dark"}),l.jsx(Vn,{value:"system",children:"System"})]})]})]}),l.jsx(Ia,{}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(zt,{htmlFor:"show-timestamps",children:"Show Timestamps"}),l.jsx(En,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,showTimestamps:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(zt,{htmlFor:"show-agent-names",children:"Show Agent Names"}),l.jsx(En,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,showAgentNames:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(zt,{htmlFor:"compact-messages",children:"Compact Messages"}),l.jsx(En,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,compactMessages:g}}))})]})]})]})]}),l.jsxs(js,{children:[l.jsx(As,{className:"pb-3",children:l.jsxs(Rs,{className:"text-lg flex items-center gap-2",children:[l.jsx(se.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),l.jsxs(_s,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(zt,{htmlFor:"auto-save",children:"Auto-save Conversations"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),l.jsx(En,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,autoSave:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(zt,{htmlFor:"enable-streaming",children:"Enable Streaming"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),l.jsx(En,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,enableStreaming:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(zt,{htmlFor:"typing-indicator",children:"Typing Indicator"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),l.jsx(En,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,showTypingIndicator:g}}))})]})]})]})]}),l.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[l.jsxs(ze,{variant:"outline",onClick:m,children:[l.jsx(se.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(ze,{variant:"outline",onClick:w,children:"Cancel"}),l.jsxs(ze,{onClick:p,disabled:!u,children:[l.jsx(se.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function xT({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"}),c=C.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?l.jsx(Cr,{...s,onThreadChange:c,children:l.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:l.jsx(Kr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?l.jsx(Cr,{...s,onThreadChange:c,children:l.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:l.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&l.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:l.jsx(vs,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),l.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:l.jsx(Kr,{onError:s.onError,enableFileUpload:!0})})]})})}):l.jsx(Cr,{...s,onThreadChange:c,children:l.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&l.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:l.jsx(vs,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),l.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:l.jsx(Kr,{onError:s.onError,enableFileUpload:!0})})]})})}Te.ChatApi=Ml,Te.ChatInterface=Kr,Te.ChatMainLayout=TC,Te.ChatProvider=Cr,Te.ChatRoutingProvider=IS,Te.ChatSettings=gT,Te.MarkdownContent=Po,Te.MessageComponent=od,Te.MessageList=Wi,Te.ThreadManager=vs,Te.applySettings=jC,Te.chatApiClient=mn,Te.default=xT,Te.del=Ol,Te.get=It,Te.getChatToken=Al,Te.getCurrentSettings=NC,Te.getDefaultApiConfig=Uh,Te.getDefaultChatSettings=Wh,Te.onChatTokenChanged=Rl,Te.post=_l,Te.put=Pl,Te.setChatToken=Gs,Te.useChat=ho,Te.useChatRouting=NS,Te.useChatStream=Dl,Te.useMessagesReducer=Ll,Object.defineProperties(Te,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|